Plugin Directory

Changeset 995564


Ignore:
Timestamp:
09/23/2014 05:41:58 PM (11 years ago)
Author:
tjsantilo
Message:

Fixed polling in social-polling.php;

Updated CSS for vote count - now floats to left;

Altered jquery to redirect to comment field after displaying vote count.

Location:
because/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • because/trunk/README.txt

    r992786 r995564  
    77Tested up to: 4.0
    88<<<<<<< .mine
    9 Stable tag: 1.3.0
     9Stable tag: 1.3.1
    1010=======
    11 Stable tag: 1.3.0
     11Stable tag: 1.3.1
    1212>>>>>>> .r969865
    1313License: GPLv2 or later
  • because/trunk/public/assets/css/public.css

    r992786 r995564  
    207207.sp_comment-list .comment_controls{
    208208    font-size:.8em;
     209    float:left;
     210    margin-right:10px;
    209211   
    210212}
     
    389391{
    390392    border-bottom: 1px solid #ccc;
     393    min-height: 90px;
    391394}
    392395
     
    396399    margin:0;
    397400    padding:0;
    398     max-height:25px;
    399     max-width:25px;
     401    height:auto;
     402    width:25px;
    400403}
    401404
  • because/trunk/public/assets/js/public.js

    r953144 r995564  
    5252
    5353               
     54        var $comment_box_offset = $('#respond').offset().top + 'px';
     55
     56        setTimeout(function() {
     57  $("html, body").animate({ scrollTop: $comment_box_offset  }, 450);
     58}, 2000);
     59       
    5460
    5561               
     
    5763                //console.log(data+ajaxurl);
    5864
    59                
     65   
    6066
    6167            }//success
     
    6874
    6975    })//$(document).on('click', 'button.answer_divs', function(){
    70 
    7176   
    7277
     
    167172                $('#answer_2_wrapper .poll_results').html($answer2_html);
    168173
    169                 $('#social_polling_see_results_wrapper').html('<button class="joindiscussion">Join the discussion below</button>');
     174                $('#social_polling_see_results_wrapper').html('');
    170175
    171176               
  • because/trunk/social-polling.php

    r992786 r995564  
    3434
    3535<<<<<<< .mine
    36  * Version:           1.3.0
     36 * Version:           1.3.1
    3737=======
    38  * Version:           1.3.0
     38 * Version:           1.3.1
    3939>>>>>>> .r969865
    4040
     
    9090require_once( plugin_dir_path( __FILE__ ) . 'public/includes/class-sp_comments.php' );
    9191
    92 /*
    93 
    94  * Register hooks that are fired when the plugin is activated or deactivated.
    95 
    96  * When the plugin is deleted, the uninstall.php file is loaded.
    97 
    98  *
    99 
    100  * @TODO:
    101 
    102  *
    103 
    104  * - replace Social_Polling with the name of the class defined in
    105 
    106  *   `class-social-polling.php`
    107 
    108  */
     92
    10993
    11094// SETTINGS
     
    11397define('BECAUSE_ADMIN_SECRET_TOKEN_NAME', 'secretToken');
    11498define('BECAUSE_ADMIN_SECRET_TOKEN_VALUE', 'X-Secret-Token');
     99
     100
     101/*
     102
     103 * Register hooks that are fired when the plugin is activated or deactivated.
     104
     105 * When the plugin is deleted, the uninstall.php file is loaded.
     106
     107 *
     108
     109 * @TODO:
     110
     111 *
     112
     113 * - replace Social_Polling with the name of the class defined in
     114
     115 *   `class-social-polling.php`
     116
     117 */
     118
    115119register_activation_hook( __FILE__, 'because_plugin_activate' );
     120register_deactivation_hook( __FILE__, 'because_plugin_deactivate' );
     121
     122
     123/* executes the static activate functions from the social_polling and spComments classes to create new tables */
     124register_activation_hook( __FILE__, array( 'Social_Polling', 'activate' ) );
     125register_deactivation_hook( __FILE__, array( 'Social_Polling', 'deactivate' ) );
     126register_activation_hook( __FILE__, array( 'spComments', 'activate' ) );
     127register_deactivation_hook( __FILE__, array( 'spComments', 'deactivate' ) );
     128
     129
    116130function because_plugin_activate(){
    117 because_old_activation();
    118  $data = get_wp_data();
    119  $data['isActivation'] = '1';
    120  send_statistic_data($data);
    121 }
    122 register_deactivation_hook( __FILE__, 'because_plugin_deactivate' );
     131    because_old_activation();
     132    $data = get_wp_data();
     133    $data['isActivation'] = '1';
     134    send_statistic_data($data);
     135}
     136
    123137function because_plugin_deactivate()
    124138{
    125  $data = get_wp_data();
    126  $data['isActivation'] = '0';
    127  send_statistic_data($data);}
     139    $data = get_wp_data();
     140    $data['isActivation'] = '0';
     141    send_statistic_data($data);
     142}
     143
    128144function get_wp_data(){
    129  $site_url = get_site_url();
    130  $site_name = get_bloginfo('name');
    131  $site_ip_addr = get_ip();
    132  $data_arr = array(
    133  'siteIpAddress' => $site_ip_addr,
    134  'siteName' => $site_name,
    135  'siteUrl' => $site_url
    136  );
    137  return $data_arr;
    138 }
     145    $site_url = get_site_url();
     146    $site_name = get_bloginfo('name');
     147    $site_ip_addr = get_ip();
     148    $data_arr = array(
     149        'siteIpAddress' => $site_ip_addr,
     150        'siteName' => $site_name,
     151        'siteUrl' => $site_url
     152    );
     153    return $data_arr;
     154}
     155
     156
    139157function send_statistic_data($data)
    140158{
    141  try {
    142  $ch = curl_init();
    143  curl_setopt($ch, CURLOPT_URL, BECAUSE_ADMIN_SERVER_URL);
    144  curl_setopt($ch, CURLOPT_POST, 1);
    145 $header = array(BECAUSE_ADMIN_SECRET_TOKEN_NAME.': ' .
    146 BECAUSE_ADMIN_SECRET_TOKEN_VALUE);
    147  curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    148  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    149  curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
    150  $response = curl_exec ($ch);
    151  $error = curl_error($ch);
    152  curl_close ($ch);
    153  }catch (Exception $error) {
    154  $this->debug(__METHOD__, 'CURL error: ' . $error);
    155  return $response;
    156  }
    157 }
    158 
    159 function get_ip()
    160 {
    161 
    162  if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
    163  $ip = getenv("HTTP_CLIENT_IP");
    164 else if (getenv("HTTP_X_FORWARDED_FOR") &&
    165 strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
    166  $ip = getenv("HTTP_X_FORWARDED_FOR");
    167  else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
    168  $ip = getenv("REMOTE_ADDR");
    169 else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] &&
    170 strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
    171  $ip = $_SERVER['REMOTE_ADDR'];
    172  else
    173  $ip = "unknown";
    174  return($ip);
     159    try {
     160        $ch = curl_init();
     161        curl_setopt($ch, CURLOPT_URL, BECAUSE_ADMIN_SERVER_URL);
     162        curl_setopt($ch, CURLOPT_POST, 1);
     163        $header = array(BECAUSE_ADMIN_SECRET_TOKEN_NAME.': ' .
     164        BECAUSE_ADMIN_SECRET_TOKEN_VALUE);
     165        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
     166        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     167        curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
     168        $response = curl_exec ($ch);
     169        $error = curl_error($ch);
     170        curl_close ($ch);
     171    }
     172    catch (Exception $error) {
     173        $this->debug(__METHOD__, 'CURL error: ' . $error);
     174        return $response;
     175    }
     176}
     177
     178function get_ip(){
     179    if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
     180        $ip = getenv("HTTP_CLIENT_IP");
     181    else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
     182        $ip = getenv("HTTP_X_FORWARDED_FOR");
     183    else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
     184        $ip = getenv("REMOTE_ADDR");
     185    else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
     186        $ip = $_SERVER['REMOTE_ADDR'];
     187    else
     188        $ip = "unknown";
     189    return($ip);
    175190}
    176191
    177192
    178193function because_old_activation(){
    179 ob_start();
    180 //Site Name
    181 $site_name = urlencode(get_option ('blogname'));
    182 //Site Url
    183 $site_url =  urlencode(get_option ('siteurl'));
    184 //Site Description
    185 $site_description =  urlencode(get_option('blogdescription')); 
    186 // Get cURL resource
    187 $curl = curl_init();
    188 // Set some options - we are passing in a useragent too here
    189 curl_setopt_array($curl, array(
    190    CURLOPT_RETURNTRANSFER => 1,
    191    CURLOPT_URL => 'http://www.teambecause.com/pluginactivated.php?sitename='.$site_name.'&site_url='.$site_url.'&site_description='.$site_description,
    192    CURLOPT_USERAGENT => 'Codular Sample cURL Request'
    193 ));
    194 // Send the request & save response to $resp
    195 $resp = curl_exec($curl);
    196 // Close request to clear up some resources
    197 curl_close($curl); 
    198 //exit;
    199 ob_end_clean();
    200 }
     194    ob_start();
     195    //Site Name
     196    $site_name = urlencode(get_option ('blogname'));
     197    //Site Url
     198    $site_url =  urlencode(get_option ('siteurl'));
     199    //Site Description
     200    $site_description =  urlencode(get_option('blogdescription')); 
     201    // Get cURL resource
     202    $curl = curl_init();
     203    // Set some options - we are passing in a useragent too here
     204    curl_setopt_array($curl, array(
     205        CURLOPT_RETURNTRANSFER => 1,
     206        CURLOPT_URL => 'http://www.teambecause.com/pluginactivated.php?sitename='.$site_name.'&site_url='.$site_url.'&site_description='.$site_description,
     207        CURLOPT_USERAGENT => 'Codular Sample cURL Request'
     208    ));
     209    // Send the request & save response to $resp
     210    $resp = curl_exec($curl);
     211    // Close request to clear up some resources
     212    curl_close($curl); 
     213    //exit;
     214    ob_end_clean();
     215}
     216
     217
     218
     219
     220
    201221
    202222/*
Note: See TracChangeset for help on using the changeset viewer.