Plugin Directory

Changeset 1076529


Ignore:
Timestamp:
01/27/2015 08:25:26 AM (11 years ago)
Author:
jakob42
Message:

added version 2.0.0, still not stable

Location:
reaction-buttons
Files:
2 added
3 edited
4 copied

Legend:

Unmodified
Added
Removed
  • reaction-buttons/tags/2.0.0/reaction_buttons.css

    r1076493 r1076529  
    3737    clear: both;
    3838    padding: 0;
    39     width: 100%;
     39    width: 90%;
    4040}
    4141div.reaction_buttons ul.graph li.reaction_button {
     
    4747    padding-left: 10px;
    4848    text-align: left;
     49    display: block;
    4950
    5051    background: #4ecdc4;
     
    6970        padding: 0;
    7071        width: 18%;
     72        display: inline-block;
    7173    }
    72     div.reaction_buttons ul.graph li.reaction_button > div {
     74    div.reaction_buttons ul.graph li.reaction_button span.button_name {
    7375        bottom: -4em;
    7476        position: absolute;
     77    }
     78    div.reaction_buttons ul.graph li.reaction_button span.braces {
     79        display: none;
     80    }
     81    div.reaction_buttons ul.graph li.reaction_button span.count_number {
     82        bottom: 3px;
     83        position: absolute;
     84        font-size: 2em;
     85        font-weight: bold;
    7586    }
    7687}
  • reaction-buttons/tags/2.0.0/reaction_buttons.php

    r1076493 r1076529  
    6161    $use_percentages = get_option("reaction_buttons_percentages", false);
    6262    $use_percentages_precision = get_option("reaction_buttons_percentages_precision", 1);
    63     $show_graphs = get_option("reaction_buttons_graphs", true) && $use_percentages; // todo
     63    $show_graphs = get_option("reaction_buttons_graphs", false);
    6464    $show_after_votes = get_option("reaction_buttons_show_after_votes");
    6565
     
    105105
    106106    // get overall count for this post for the percentage view
    107     if($use_percentages){
     107    if($use_percentages || $show_graphs){
    108108        $count_all = 0;
    109109        foreach($buttons as $button_id => $button){
     
    119119        $voted = array_key_exists($button_id, $cookie) && $cookie[$button_id];
    120120
    121         if($use_percentages){
     121        if($use_percentages || $show_graphs){
    122122            if(empty($count_all)){
    123                 $count = number_format(0, $use_percentages_precision) . "%";;
     123                $percentage = number_format(0, $use_percentages_precision) . "%";;
    124124            }
    125125            else{
    126                 $count = number_format(100*$count/$count_all, $use_percentages_precision) . "%";
    127             }
    128         }
    129 
    130         $html .= $show_graphs?"<li style='height: $count'":"<li ";
     126                $percentage = number_format(100*$count/$count_all, $use_percentages_precision) . "%";
     127            }
     128        }
     129        if($use_percentages){
     130            $count = $percentage;
     131        }
     132
     133        $html .= $show_graphs?"<li style='height: $percentage'":"<li ";
    131134        $html .= "class='reaction_button reaction_button_" . $button_id;
    132135
     
    146149        $html .= "<span class='button_name'>" . $button . "</span>";
    147150        if(!$show_after_votes || $already_voted_other){
    148             $html .= "&nbsp;<span class='count'>(<span class='count_number'>" . $count . "</span>)</span>";
    149         }
    150         else{
    151             $html .= "&nbsp;<span class='count' style='display: none;'>(<span class='count_number'>" . $count . "</span>)</span>";
     151            $html .= "&nbsp;<span class='braces'>(</span><span class='count_number'>" . $count . "</span><span class='braces'>)</span>";
     152        }
     153        else{
     154            $html .= "&nbsp;<span class='braces' style='display: none;'>(<span class='count_number'></span><span class='braces' style='display: none;'>)</span>";
    152155        }
    153156        $html .= "</div></li>";
     
    243246    }
    244247
     248    if ( $force or !( get_option('reaction_buttons_percentages')) ) {
     249        update_option('reaction_buttons_percentages', false);
     250    }
     251
     252    if ( $force or !( get_option('reaction_buttons_percentages_precision')) ) {
     253        update_option('reaction_buttons_percentages_precision', 0);
     254    }
     255
     256    if ( $force or !( get_option('reaction_buttons_graphs')) ) {
     257        update_option('reaction_buttons_graphs', false);
     258    }
     259
    245260    if ( $force or !( get_option('reaction_buttons_show_after_votes')) ) {
    246261        update_option('reaction_buttons_show_after_votes', false);
     
    251266    }
    252267
    253         if ( $force or !( get_option('reaction_buttons_use_as_counter')) ) {
     268    if ( $force or !( get_option('reaction_buttons_use_as_counter')) ) {
    254269        update_option('reaction_buttons_use_as_counter', false);
    255270    }
     
    480495                            }
    481496                        }
     497                        else if(show_after_votes){
     498                            var i;
     499                            var b;
     500                            for(i = 0; i < buttons.length; ++i){
     501                                b = buttons[i];
     502                                jQuery("#reaction_buttons_post" + post_id + " .reaction_button_" + b + " .count_number").html(data['counts'][b]);
     503                            }
     504                        }
    482505                        else{
    483506                            jQuery("#reaction_buttons_post" + post_id + " .reaction_button_" + button + " .count_number").html(data['count']);
     
    489512                            jQuery("#reaction_buttons_post" + post_id + " .reaction_button_" + button).addClass('voted');
    490513                        }
    491                         if(show_after_votes){
    492                             jQuery("#reaction_buttons_post" + post_id + " .reaction_button .count").removeAttr('style');
     514                        if(show_after_votes){
     515                            jQuery("#reaction_buttons_post" + post_id + " .reaction_button .braces").removeAttr('style');
    493516                        }
    494517                    }
     
    537560    $use_percentages = get_option("reaction_buttons_percentages", false);
    538561    $use_percentages_precision = get_option("reaction_buttons_percentages_precision", 1);
     562    $show_after_votes = get_option("reaction_buttons_show_after_votes");
    539563
    540564    // get all the buttons, stripped of whitespaces
     
    588612    }
    589613
     614    if($show_after_votes){
     615        foreach($buttons as $button){
     616            $result['counts'][$button] = intval(get_post_meta($post_id, "_reaction_buttons_" . $button, true));
     617
     618        }
     619    }
    590620
    591621    $result['count'] = $current;
     
    688718
    689719        // save the different settings (boolean, text, array of bool)
    690         foreach ( array('activate', 'usecss', 'usecookies', 'only_one_vote', 'use_as_counter', 'show_after_votes', 'clear_supported_caches', 'percentages') as $val ) {
     720        foreach ( array('activate', 'usecss', 'usecookies', 'only_one_vote', 'use_as_counter', 'show_after_votes', 'clear_supported_caches', 'percentages', 'graphs') as $val ) {
    691721            if ( isset($_POST[$val]) && $_POST[$val] )
    692722                update_option('reaction_buttons_'.$val,true);
     
    843873                        <input type="checkbox" name="percentages" <?php checked( get_option('reaction_buttons_percentages')); ?> /> <?php _e("Show percentages instead of the number of votes", "reaction_buttons"); ?><br />
    844874                        <input type="number" min="0" max="9" name="percentages_precision" value="<?php echo get_option('reaction_buttons_percentages_precision', 1); ?>" /> <?php _e("Number of decimal points for the percentages", "reaction_buttons"); ?>
     875                    </td>
     876                </tr>
     877                <tr>
     878                    <th scope="row" valign="top">
     879                        <?php _e("Show graphs:", "reaction_buttons"); ?>
     880                    </th>
     881                    <td>
     882                    <input type="checkbox" name="graphs" <?php checked( get_option('reaction_buttons_graphs')); ?> />
     883                        <?php _e("Show the results as clickable graphs instead of buttons. Beware, this feature might need massive css changes to look remotely good. I included an example that worked fine on my test blog, but I suspect it'll need adaptation.", "reaction_buttons"); ?><br />
    845884                    </td>
    846885                </tr>
  • reaction-buttons/tags/2.0.0/readme.txt

    r1065133 r1076529  
    3535
    3636= My reaction buttons don't update =
    37 * Do you use any special characters like exclamation marks in your button names?
    3837* Is your PHP installation new enough? Reaction buttons require at least PHP 5.2.
    3938* Do you use a cache plugin? When the page is cached as soon as you reload the page your vote isn't shown anymore until the cache is cleared. See below.
     39* (This shouldn't apply since version 2.0.0 anymore.) Do you use any special characters like exclamation marks in your button names?
    4040
    4141= I want to deactivate reaction buttons in certain situations =
     
    61611. Shows a german default installation with Reaction Buttons and some clicks on them.
    62622. Shows the sidebar widget with some dummy data.
     633. The graph feature.
     644. The graph feature on a small screen.
     65
     66== Restrictions ==
     67* When using plugins to cache the pages, the buttons won't be up to date. They will increment through the javascript, but when the page reloads the old count will show again, until the cache is deleted. Check the FAQ on possibilities how to change that.
     68
     69== Upgrade Notice ==
     70= 2.0.0 =
     71* This upgrade changes how the reaction data is saved and will convert automatically. But [saving your wordpress database](http://codex.wordpress.org/WordPress_Backups) just in case is never a bad idea, especially if you want to go back to the old system.
    6372
    6473== Changelog ==
     74= 2.0.0 =
     75* changed the way buttons are saved. They are simply numbered now, so there shouldn't be any problems with special characters. The plugin should automatically convert your reaction counts on the first run to the new system.
     76* New graph feature, display the votes as a graph instead of buttons. This will possibly look bad and need css updates to match your blogs style.
     77
    6578= 1.8.2 =
    6679* bump for new wordpress version
     
    189202* First public release.
    190203
    191 == Restrictions ==
    192 * There cannot be spaces in html classes, so the plugin wouldn't work if there would be buttons named "great article" *and* "great___article", because it converts the spaces into three underscores.
    193 * Also the addon (at least the ajax part) doesn't work with certain special chars like exclamation marks.
    194 * When using plugins to cache the pages, the buttons won't be up to date. They will increment through the javascript, but when the page reloads the old count will show again, until the cache is deleted. Check the FAQ on possibilities how to change that.
  • reaction-buttons/trunk/reaction_buttons.css

    r1076493 r1076529  
    3737    clear: both;
    3838    padding: 0;
    39     width: 100%;
     39    width: 90%;
    4040}
    4141div.reaction_buttons ul.graph li.reaction_button {
     
    4747    padding-left: 10px;
    4848    text-align: left;
     49    display: block;
    4950
    5051    background: #4ecdc4;
     
    6970        padding: 0;
    7071        width: 18%;
     72        display: inline-block;
    7173    }
    72     div.reaction_buttons ul.graph li.reaction_button > div {
     74    div.reaction_buttons ul.graph li.reaction_button span.button_name {
    7375        bottom: -4em;
    7476        position: absolute;
     77    }
     78    div.reaction_buttons ul.graph li.reaction_button span.braces {
     79        display: none;
     80    }
     81    div.reaction_buttons ul.graph li.reaction_button span.count_number {
     82        bottom: 3px;
     83        position: absolute;
     84        font-size: 2em;
     85        font-weight: bold;
    7586    }
    7687}
  • reaction-buttons/trunk/reaction_buttons.php

    r1076493 r1076529  
    6161    $use_percentages = get_option("reaction_buttons_percentages", false);
    6262    $use_percentages_precision = get_option("reaction_buttons_percentages_precision", 1);
    63     $show_graphs = get_option("reaction_buttons_graphs", true) && $use_percentages; // todo
     63    $show_graphs = get_option("reaction_buttons_graphs", false);
    6464    $show_after_votes = get_option("reaction_buttons_show_after_votes");
    6565
     
    105105
    106106    // get overall count for this post for the percentage view
    107     if($use_percentages){
     107    if($use_percentages || $show_graphs){
    108108        $count_all = 0;
    109109        foreach($buttons as $button_id => $button){
     
    119119        $voted = array_key_exists($button_id, $cookie) && $cookie[$button_id];
    120120
    121         if($use_percentages){
     121        if($use_percentages || $show_graphs){
    122122            if(empty($count_all)){
    123                 $count = number_format(0, $use_percentages_precision) . "%";;
     123                $percentage = number_format(0, $use_percentages_precision) . "%";;
    124124            }
    125125            else{
    126                 $count = number_format(100*$count/$count_all, $use_percentages_precision) . "%";
    127             }
    128         }
    129 
    130         $html .= $show_graphs?"<li style='height: $count'":"<li ";
     126                $percentage = number_format(100*$count/$count_all, $use_percentages_precision) . "%";
     127            }
     128        }
     129        if($use_percentages){
     130            $count = $percentage;
     131        }
     132
     133        $html .= $show_graphs?"<li style='height: $percentage'":"<li ";
    131134        $html .= "class='reaction_button reaction_button_" . $button_id;
    132135
     
    146149        $html .= "<span class='button_name'>" . $button . "</span>";
    147150        if(!$show_after_votes || $already_voted_other){
    148             $html .= "&nbsp;<span class='count'>(<span class='count_number'>" . $count . "</span>)</span>";
    149         }
    150         else{
    151             $html .= "&nbsp;<span class='count' style='display: none;'>(<span class='count_number'>" . $count . "</span>)</span>";
     151            $html .= "&nbsp;<span class='braces'>(</span><span class='count_number'>" . $count . "</span><span class='braces'>)</span>";
     152        }
     153        else{
     154            $html .= "&nbsp;<span class='braces' style='display: none;'>(<span class='count_number'></span><span class='braces' style='display: none;'>)</span>";
    152155        }
    153156        $html .= "</div></li>";
     
    243246    }
    244247
     248    if ( $force or !( get_option('reaction_buttons_percentages')) ) {
     249        update_option('reaction_buttons_percentages', false);
     250    }
     251
     252    if ( $force or !( get_option('reaction_buttons_percentages_precision')) ) {
     253        update_option('reaction_buttons_percentages_precision', 0);
     254    }
     255
     256    if ( $force or !( get_option('reaction_buttons_graphs')) ) {
     257        update_option('reaction_buttons_graphs', false);
     258    }
     259
    245260    if ( $force or !( get_option('reaction_buttons_show_after_votes')) ) {
    246261        update_option('reaction_buttons_show_after_votes', false);
     
    251266    }
    252267
    253         if ( $force or !( get_option('reaction_buttons_use_as_counter')) ) {
     268    if ( $force or !( get_option('reaction_buttons_use_as_counter')) ) {
    254269        update_option('reaction_buttons_use_as_counter', false);
    255270    }
     
    480495                            }
    481496                        }
     497                        else if(show_after_votes){
     498                            var i;
     499                            var b;
     500                            for(i = 0; i < buttons.length; ++i){
     501                                b = buttons[i];
     502                                jQuery("#reaction_buttons_post" + post_id + " .reaction_button_" + b + " .count_number").html(data['counts'][b]);
     503                            }
     504                        }
    482505                        else{
    483506                            jQuery("#reaction_buttons_post" + post_id + " .reaction_button_" + button + " .count_number").html(data['count']);
     
    489512                            jQuery("#reaction_buttons_post" + post_id + " .reaction_button_" + button).addClass('voted');
    490513                        }
    491                         if(show_after_votes){
    492                             jQuery("#reaction_buttons_post" + post_id + " .reaction_button .count").removeAttr('style');
     514                        if(show_after_votes){
     515                            jQuery("#reaction_buttons_post" + post_id + " .reaction_button .braces").removeAttr('style');
    493516                        }
    494517                    }
     
    537560    $use_percentages = get_option("reaction_buttons_percentages", false);
    538561    $use_percentages_precision = get_option("reaction_buttons_percentages_precision", 1);
     562    $show_after_votes = get_option("reaction_buttons_show_after_votes");
    539563
    540564    // get all the buttons, stripped of whitespaces
     
    588612    }
    589613
     614    if($show_after_votes){
     615        foreach($buttons as $button){
     616            $result['counts'][$button] = intval(get_post_meta($post_id, "_reaction_buttons_" . $button, true));
     617
     618        }
     619    }
    590620
    591621    $result['count'] = $current;
     
    688718
    689719        // save the different settings (boolean, text, array of bool)
    690         foreach ( array('activate', 'usecss', 'usecookies', 'only_one_vote', 'use_as_counter', 'show_after_votes', 'clear_supported_caches', 'percentages') as $val ) {
     720        foreach ( array('activate', 'usecss', 'usecookies', 'only_one_vote', 'use_as_counter', 'show_after_votes', 'clear_supported_caches', 'percentages', 'graphs') as $val ) {
    691721            if ( isset($_POST[$val]) && $_POST[$val] )
    692722                update_option('reaction_buttons_'.$val,true);
     
    843873                        <input type="checkbox" name="percentages" <?php checked( get_option('reaction_buttons_percentages')); ?> /> <?php _e("Show percentages instead of the number of votes", "reaction_buttons"); ?><br />
    844874                        <input type="number" min="0" max="9" name="percentages_precision" value="<?php echo get_option('reaction_buttons_percentages_precision', 1); ?>" /> <?php _e("Number of decimal points for the percentages", "reaction_buttons"); ?>
     875                    </td>
     876                </tr>
     877                <tr>
     878                    <th scope="row" valign="top">
     879                        <?php _e("Show graphs:", "reaction_buttons"); ?>
     880                    </th>
     881                    <td>
     882                    <input type="checkbox" name="graphs" <?php checked( get_option('reaction_buttons_graphs')); ?> />
     883                        <?php _e("Show the results as clickable graphs instead of buttons. Beware, this feature might need massive css changes to look remotely good. I included an example that worked fine on my test blog, but I suspect it'll need adaptation.", "reaction_buttons"); ?><br />
    845884                    </td>
    846885                </tr>
  • reaction-buttons/trunk/readme.txt

    r1065133 r1076529  
    3535
    3636= My reaction buttons don't update =
    37 * Do you use any special characters like exclamation marks in your button names?
    3837* Is your PHP installation new enough? Reaction buttons require at least PHP 5.2.
    3938* Do you use a cache plugin? When the page is cached as soon as you reload the page your vote isn't shown anymore until the cache is cleared. See below.
     39* (This shouldn't apply since version 2.0.0 anymore.) Do you use any special characters like exclamation marks in your button names?
    4040
    4141= I want to deactivate reaction buttons in certain situations =
     
    61611. Shows a german default installation with Reaction Buttons and some clicks on them.
    62622. Shows the sidebar widget with some dummy data.
     633. The graph feature.
     644. The graph feature on a small screen.
     65
     66== Restrictions ==
     67* When using plugins to cache the pages, the buttons won't be up to date. They will increment through the javascript, but when the page reloads the old count will show again, until the cache is deleted. Check the FAQ on possibilities how to change that.
     68
     69== Upgrade Notice ==
     70= 2.0.0 =
     71* This upgrade changes how the reaction data is saved and will convert automatically. But [saving your wordpress database](http://codex.wordpress.org/WordPress_Backups) just in case is never a bad idea, especially if you want to go back to the old system.
    6372
    6473== Changelog ==
     74= 2.0.0 =
     75* changed the way buttons are saved. They are simply numbered now, so there shouldn't be any problems with special characters. The plugin should automatically convert your reaction counts on the first run to the new system.
     76* New graph feature, display the votes as a graph instead of buttons. This will possibly look bad and need css updates to match your blogs style.
     77
    6578= 1.8.2 =
    6679* bump for new wordpress version
     
    189202* First public release.
    190203
    191 == Restrictions ==
    192 * There cannot be spaces in html classes, so the plugin wouldn't work if there would be buttons named "great article" *and* "great___article", because it converts the spaces into three underscores.
    193 * Also the addon (at least the ajax part) doesn't work with certain special chars like exclamation marks.
    194 * When using plugins to cache the pages, the buttons won't be up to date. They will increment through the javascript, but when the page reloads the old count will show again, until the cache is deleted. Check the FAQ on possibilities how to change that.
Note: See TracChangeset for help on using the changeset viewer.