Changeset 1522922
- Timestamp:
- 10/27/2016 07:56:22 AM (9 years ago)
- Location:
- generalstats/trunk
- Files:
-
- 2 edited
-
generalstats.php (modified) (10 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
generalstats/trunk/generalstats.php
r1410813 r1522922 6 6 Description: Counts the number of users, categories, posts, comments, pages, links, tags, link-categories, words in posts, words in comments and words in pages. 7 7 Author: Dr. Bernhard Riedl 8 Version: 3.3 28 Version: 3.33 9 9 Author URI: http://www.bernhard-riedl.com/ 10 10 */ … … 424 424 425 425 add_action('save_post', array($this, 'save_post_force_cache_refresh'), 10, 2); 426 427 /* 428 posts 429 */ 430 431 add_action('after_delete_post', array($this, 'force_post_cache_refresh')); 432 add_action('trashed_post', array($this, 'force_post_cache_refresh')); 433 add_action('untrashed_post', array($this, 'force_post_cache_refresh')); 434 435 /* 436 pages 437 */ 438 439 add_action('after_delete_post', array($this, 'force_page_cache_refresh')); 440 add_action('trashed_post', array($this, 'force_page_cache_refresh')); 441 add_action('untrashed_post', array($this, 'force_page_cache_refresh')); 426 add_action('transition_post_status', array($this, 'transition_post_status_force_cache_refresh'), 10, 3); 427 428 /* 429 posts & pages 430 for sites with 431 trash days = 0 432 */ 433 434 if (!EMPTY_TRASH_DAYS) { 435 add_action('after_delete_post', array($this, 'force_post_cache_refresh')); 436 add_action('after_delete_post', array($this, 'force_page_cache_refresh')); 437 } 442 438 443 439 /* … … 445 441 */ 446 442 447 add_action('comment_post', array($this, 'comment_status_force_cache_refresh'), 10, 2); 448 add_action('edit_comment', array($this, 'force_comment_cache_refresh')); 449 450 /* 451 deleted/trashed comment can be realized 452 by using wp_set_comment_status 453 */ 454 455 add_action('wp_set_comment_status', array($this, 'force_comment_cache_refresh')); 456 457 /* 458 special hooks for trashing/untrashing 459 all comments of a certain post 460 */ 461 462 add_action('trashed_post_comments', array($this, 'force_comment_cache_refresh')); 463 add_action('untrashed_post_comments', array($this, 'force_comment_cache_refresh')); 443 add_action('comment_post', array($this, 'comment_post_force_cache_refresh'), 10, 2); 444 add_action('edit_comment', array($this, 'edit_comment_force_cache_refresh')); 445 add_action('transition_comment_status', array($this, 'transition_comment_status_force_cache_refresh'), 10, 3); 464 446 465 447 /* … … 1730 1712 1731 1713 function head_meta() { 1732 echo("<meta name=\"".$this->get_nicename()."\" content=\"3.3 2\"/>\n");1714 echo("<meta name=\"".$this->get_nicename()."\" content=\"3.33\"/>\n"); 1733 1715 } 1734 1716 … … 2841 2823 2842 2824 /* 2843 check comment-status before force cache refresh 2844 */ 2845 2846 function comment_status_force_cache_refresh($id=-1, $status=false) { 2847 if ($status==1 || $status===false) 2848 $this->force_comment_cache_refresh(); 2849 } 2850 2851 /* 2852 check post-status and 2853 visibility before force cache refresh 2825 check post-status 2826 before force cache refresh 2854 2827 */ 2855 2828 2856 2829 function save_post_force_cache_refresh($id=-1, $post=false) { 2857 2858 2830 if (is_object($post)) { 2859 2831 … … 2863 2835 2864 2836 if (wp_is_post_autosave($post)>0) 2837 return; 2838 2839 /* 2840 check if post is published 2841 */ 2842 2843 if ($post->post_status!='publish') 2865 2844 return; 2866 2845 … … 2881 2860 /* 2882 2861 we didn't receive an object 2883 and could check for post details 2862 so we couldn't check 2863 for post details 2884 2864 => refresh post and page caches 2885 2865 */ … … 2887 2867 $this->force_post_cache_refresh(); 2888 2868 $this->force_page_cache_refresh(); 2869 } 2870 2871 /* 2872 check post-status 2873 before force cache refresh 2874 */ 2875 2876 function transition_post_status_force_cache_refresh($new_status, $old_status, $post) { 2877 if (is_object($post)) { 2878 2879 /* 2880 here we handle only transitions 2881 from non-publish to publish 2882 and vice versa 2883 */ 2884 2885 if (($old_status=='publish' && $new_status=='publish') || ($old_status!='publish' && $new_status!='publish')) 2886 return; 2887 2888 if ($post->post_type=='post') { 2889 $this->force_post_cache_refresh(); 2890 return; 2891 } 2892 else if ($post->post_type=='page') { 2893 $this->force_page_cache_refresh(); 2894 return; 2895 } 2896 } 2897 2898 /* 2899 we didn't receive an object 2900 so we couldn't check 2901 for post details 2902 => refresh post and page caches 2903 */ 2904 2905 $this->force_post_cache_refresh(); 2906 $this->force_page_cache_refresh(); 2907 } 2908 2909 /* 2910 check comment-status 2911 before force cache refresh 2912 */ 2913 2914 function edit_comment_force_cache_refresh($comment_ID) { 2915 2916 /* 2917 check if comment is approved 2918 */ 2919 2920 if (wp_get_comment_status($comment_ID)!='approved') 2921 return; 2922 2923 $this->force_comment_cache_refresh(); 2924 } 2925 2926 /* 2927 check comment-status 2928 before force cache refresh 2929 */ 2930 2931 function comment_post_force_cache_refresh($id=-1, $status=false) { 2932 if ($status==1 || $status===false) 2933 $this->force_comment_cache_refresh(); 2934 } 2935 2936 /* 2937 check comment-status 2938 before force cache refresh 2939 */ 2940 2941 function transition_comment_status_force_cache_refresh($new_status, $old_status, $comment) { 2942 2943 /* 2944 here we handle only transitions 2945 from non-approved to approved 2946 and vice versa 2947 */ 2948 2949 if (($old_status=='approved' && $new_status=='approved') || ($old_status!='approved' && $new_status!='approved')) 2950 return; 2951 2952 $this->force_comment_cache_refresh(); 2889 2953 } 2890 2954 … … 2939 3003 2940 3004 function force_term_cache_refresh($term=null, $tt_id=-1, $taxonomy='') { 2941 2942 3005 if ($taxonomy=='category') 2943 3006 $this->force_category_cache_refresh(); … … 3012 3075 if (array_key_exists($stat, $this->stats_selected)) 3013 3076 set_transient($this->get_prefix(false), '', -1); 3077 3078 /* 3079 triggers custom action on 3080 specific stat 3081 */ 3082 3083 do_action($this->get_prefix().'force_cache_refresh_stat', $stat); 3014 3084 } 3015 3085 } 3086 3087 /* 3088 triggers custom action on 3089 stats array 3090 */ 3091 3092 do_action($this->get_prefix().'force_cache_refresh_stats', $stats); 3016 3093 } 3017 3094 -
generalstats/trunk/readme.txt
r1410813 r1522922 17 17 * possible to integrate in "Right Now" box or to display as widget on the dashboard 18 18 * high performing with caching technology and customizable memory usage 19 * cache-purge mechanism via actions (triggers) for other plugins 19 20 * optional Ajax refresh with jQuery 20 21 * fully compatible with [https/SSL/TLS-sites](https://codex.wordpress.org/Administration_Over_SSL) … … 75 76 With GeneralStats 2.00 and higher you can use a function-call to display individual stat(-blocks) on different positions on your page. 76 77 77 Parameters can either be passed [as an array or a URL query type string (e.g. "display=0&format=0")](https://codex.wordpress.org/Function_Reference/wp_parse_args). Please note that WordPress parses all arguments as strings, thus booleans have to be 0 or 1 if used in query type strings whereas for arrays [real booleans](https:// php.net/manual/en/language.types.boolean.php) should be used. Furthermore you have to use the prefix `stats_` to select different stats in a query_string. - For example: `stat_0=Community&stat_12=Pages Word-Count`.78 Parameters can either be passed [as an array or a URL query type string (e.g. "display=0&format=0")](https://codex.wordpress.org/Function_Reference/wp_parse_args). Please note that WordPress parses all arguments as strings, thus booleans have to be 0 or 1 if used in query type strings whereas for arrays [real booleans](https://secure.php.net/manual/en/language.types.boolean.php) should be used. Furthermore you have to use the prefix `stats_` to select different stats in a query_string. - For example: `stat_0=Community&stat_12=Pages Word-Count`. 78 79 79 80 **`function $generalstats->count($params=array())`** … … 208 209 Receives an array which is used for the mail-stats-function call to `$generalstats->output($params)`. `display` and `use_container` will automatically be set to false. 209 210 211 **Available Actions:** 212 213 `generalstats_force_cache_refresh_stat` 214 215 Gets triggered by GeneralStats' forced cache refresh; receives a stat-id as parameter. 216 217 `generalstats_force_cache_refresh_stats` 218 219 Gets triggered by GeneralStats' forced cache refresh; receives an array with stat-ids as parameter. 220 210 221 == Screenshots == 211 222 … … 229 240 230 241 == Changelog == 242 243 = 3.33 = 244 245 * added two actions to equip other plugins with a cache purging mechanism 246 * improved forced cache purging of posts, pages & comments 247 * SSLified further links 231 248 232 249 = 3.32 =
Note: See TracChangeset
for help on using the changeset viewer.