Plugin Directory

Changeset 821261


Ignore:
Timestamp:
12/13/2013 05:51:25 PM (12 years ago)
Author:
fd
Message:

Changed to meta-box. Tested in 3.8

Location:
word-statistics-plugin/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • word-statistics-plugin/trunk/fdwordstats.php

    r79046 r821261  
    66Author: John Watson
    77Author URI: http://flagrantdisregard.com/
    8 Version: 1.2
     8Version: 1.3
    99*/
    1010
     
    302302*/
    303303
     304function wordstats_add_meta_box() {
     305    add_meta_box('wordstats', 'Writing analysis', 'wordstats_meta_box', 'post');
     306    add_meta_box('wordstats', 'Writing analysis', 'wordstats_meta_box', 'page');
     307}
     308
    304309// Draw the readability statistics for the post
    305310// being edited and the help rollovers.
    306 function wordstats_draw_admin_footer() {
     311function wordstats_meta_box() {
    307312    global $wpdb;
    308313    global $post;
     
    310315
    311316    if ($post->post_content != '') {
    312         $stat = new WordStats;
     317        $stat = new WordStats();
    313318        $stat->set_text($post->post_content);
    314         $template = '';
    315         if (version_compare($wp_version, "2.7", ">=")) {
    316             $template = '<div id="wordstats">'
    317                 .'<span>Sentences: %d</span> '
    318                 .'<span title="Score indicates number of years of education required for comprehension.">Fog: %2.1f</span> '
    319                 .'<span title="Score indicates number of years of education required for comprehension.">Kincaid: %2.1f</span> '
    320                 .'<span title="Readability score between 0 (worst) and 100 (best).">Flesch: %3.0f</span> '
    321                 .'</div>';
    322             $pluginHTML = sprintf($template,
    323                     $stat->get_sentences(),
    324                     $stat->get_fog(),
    325                     $stat->get_flesch_kincaid(),
    326                     $stat->get_flesch()
    327                 );
    328             printf('<script language="javascript" type="text/javascript">
    329                     var div = document.getElementById("post-status-info");
    330                     if (div != undefined) {
    331                         div.innerHTML = div.innerHTML + \'%s\';
    332                     }
    333                     </script>', str_replace("'", "\'", $pluginHTML)
    334                 );
    335         } else {
    336             $template = '<div id="wordstats">'
    337                 .'<span>Words:</strong> %d</span> '
    338                 .'<span>Sentences: %d</span> '
    339                 .'<span title="Score indicates number of years of education required for comprehension.">Fog: %2.1f</span> '
    340                 .'<span title="Score indicates number of years of education required for comprehension.">Kincaid: %2.1f</span> '
    341                 .'<span title="Readability score between 0 (worst) and 100 (best).">Flesch: %3.0f</span> '
    342                 .'</div>';
    343             $pluginHTML = sprintf($template,
    344                     $stat->get_words(),
    345                     $stat->get_sentences(),
    346                     $stat->get_fog(),
    347                     $stat->get_flesch_kincaid(),
    348                     $stat->get_flesch()
    349                 );
    350             printf('<script language="javascript" type="text/javascript">
    351                     var div = document.getElementById("titlediv");
    352                     if (div != undefined) {
    353                         div.innerHTML = \'%s\' + div.innerHTML;
    354                     }
    355                     </script>', str_replace("'", "\'", $pluginHTML)
    356                 );
    357         }
    358     }
    359 }
    360 
    361 // Inject some CSS into the header for displaying
    362 // the readability stats of the post being edited.
    363 function wordstats_draw_admin_header() {
    364     echo '
    365     <style type="text/css">
    366     #wordstats span {
    367         padding-right: 15px;
    368     }
    369     </style>
    370     ';
     319        $template =
     320            '<table width="100%%"><tr>'
     321            .'<td align="left" width="35%%">Sentences<br>%d</td> '
     322            .'<td align="left" width="20%%" title="Score indicates number of years of education required for comprehension.">Fog<br>%2.1f</td> '
     323            .'<td align="left" width="25%%" title="Score indicates number of years of education required for comprehension.">Kincaid<br>%2.1f</td> '
     324            .'<td align="left" width="20%%" title="Readability score between 0 (worst) and 100 (best).">Flesch<br>%3.0f</td> '
     325            .'</tr></table>';
     326        printf($template,
     327            $stat->get_sentences(),
     328            $stat->get_fog(),
     329            $stat->get_flesch_kincaid(),
     330            $stat->get_flesch()
     331        );
     332    }
    371333}
    372334
     
    452414==================================================
    453415*/
    454 add_action('admin_head', 'wordstats_draw_admin_header');
    455 add_action('admin_footer', 'wordstats_draw_admin_footer');
    456 ?>
     416add_action('add_meta_boxes', 'wordstats_add_meta_box');
  • word-statistics-plugin/trunk/readme.txt

    r634071 r821261  
    33Donate link: http://flagrantdisregard.com/wordstats/
    44Tags: posts, writing, editing, readability, analysis, word count, sentence count, statistics
    5 Requires at least: 2.0
    6 Tested up to: 3.4.2
     5Requires at least: 3.0
     6Tested up to: 3.8
    77Stable tag: trunk
    88
     
    4949== Changelog ==
    5050
    51 = 1.2 =
    52 * This is a placeholder for the next release.
     51= 1.3 =
     52* Moved information into a meta box titled "Writing analysis"
     53* Requires version 3.0 or higher
Note: See TracChangeset for help on using the changeset viewer.