~clint-fewbar/charms/oneiric/omgubuntu-wp/trunk

« back to all changes in this revision

Viewing changes to files/wordpress/wp-content/plugins/popular-posts-plugin/popular-posts-admin.php

  • Committer: Marco Ceppi
  • Date: 2012-03-19 14:27:51 UTC
  • Revision ID: marco@ceppi.net-20120319142751-xvn4zfl0rq99r00p
First revision of OMG charm

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
// Admin stuff for Popular Posts Plugin, Version 2.6.2.0
 
4
 
 
5
function popular_posts_option_menu() {
 
6
        add_options_page(__('Popular Posts Options', 'popular_posts_plugin'), __('Popular Posts', 'popular_posts_plugin'), 8, 'popular-posts-plugin', 'popular_posts_options_page');
 
7
}
 
8
 
 
9
add_action('admin_menu', 'popular_posts_option_menu', 1);
 
10
 
 
11
function popular_posts_options_page(){
 
12
        echo '<div class="wrap"><h2>';
 
13
        _e('Popular Posts ', 'popular_posts_plugin'); 
 
14
        echo '<a href="http://rmarsh.com/plugins/post-options/" style="font-size: 0.8em;">';
 
15
        _e('help and instructions'); 
 
16
        echo '</a></h2></div>';
 
17
        if (!PopularPosts::check_post_plugin_library(__('<h1>Please install the <a href="http://downloads.wordpress.org/plugin/post-plugin-library.zip">Post Plugin Library</a> plugin.</h1>'))) return;
 
18
        $m = new admin_subpages();
 
19
        $m->add_subpage('General', 'general', 'popular_posts_general_options_subpage');
 
20
        $m->add_subpage('Output', 'output', 'popular_posts_output_options_subpage');
 
21
        $m->add_subpage('Filter', 'filter', 'popular_posts_filter_options_subpage');
 
22
        $m->add_subpage('Placement', 'placement', 'popular_posts_placement_options_subpage');
 
23
        $m->add_subpage('Other', 'other', 'popular_posts_other_options_subpage');
 
24
        $m->add_subpage('Report a Bug', 'bug', 'popular_posts_bug_subpage');
 
25
        $m->add_subpage('Remove this Plugin', 'remove', 'popular_posts_remove_subpage');
 
26
        $m->display();
 
27
        add_action('in_admin_footer', 'popular_posts_admin_footer');
 
28
}
 
29
 
 
30
function popular_posts_admin_footer() {
 
31
        ppl_admin_footer(str_replace('-admin', '', __FILE__), "popular-posts");
 
32
}
 
33
 
 
34
function popular_posts_general_options_subpage(){
 
35
        global $wpdb, $wp_version;
 
36
        $options = get_option('popular-posts');
 
37
        if (isset($_POST['update_options'])) {
 
38
                check_admin_referer('popular-posts-update-options'); 
 
39
                if (defined('POC_CACHE_4')) poc_cache_flush();
 
40
                // Fill up the options with the values chosen...
 
41
                $options = ppl_options_from_post($options, array('limit', 'skip', 'show_private', 'show_pages', 'show_attachments', 'status', 'age', 'omit_current_post', 'match_cat', 'match_tags', 'match_author'));
 
42
                update_option('popular-posts', $options);
 
43
                // Show a message to say we've done something
 
44
                echo '<div class="updated fade"><p>' . __('Options saved', 'popular_posts_plugin') . '</p></div>';
 
45
        } 
 
46
        //now we drop into html to display the option page form
 
47
        ?>
 
48
                <div class="wrap">
 
49
                <h2><?php _e('General Settings', 'popular_posts_plugin'); ?></h2>
 
50
                <form method="post" action="">
 
51
                <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save General Settings', 'popular_posts_plugin') ?>" /></div>
 
52
                <table class="optiontable form-table">
 
53
                        <?php 
 
54
                                ppl_display_limit($options['limit']); 
 
55
                                ppl_display_skip($options['skip']); 
 
56
                                ppl_display_show_private($options['show_private']); 
 
57
                                ppl_display_show_pages($options['show_pages']); 
 
58
                                ppl_display_show_attachments($options['show_attachments']); 
 
59
                                ppl_display_status($options['status']);
 
60
                                ppl_display_age($options['age']);
 
61
                                ppl_display_omit_current_post($options['omit_current_post']); 
 
62
                                ppl_display_match_cat($options['match_cat']); 
 
63
                                ppl_display_match_tags($options['match_tags']); 
 
64
                                ppl_display_match_author($options['match_author']); 
 
65
                        ?>
 
66
                </table>
 
67
                <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save General Settings', 'popular_posts_plugin') ?>" /></div>
 
68
                <?php if (function_exists('wp_nonce_field')) wp_nonce_field('popular-posts-update-options'); ?>
 
69
                </form>  
 
70
        </div>
 
71
        <?php   
 
72
}
 
73
 
 
74
function popular_posts_output_options_subpage(){
 
75
        global $wpdb, $wp_version;
 
76
        $options = get_option('popular-posts');
 
77
        if (isset($_POST['update_options'])) {
 
78
                check_admin_referer('popular-posts-update-options'); 
 
79
                if (defined('POC_CACHE_4')) poc_cache_flush();
 
80
                // Fill up the options with the values chosen...
 
81
                $options = ppl_options_from_post($options, array('output_template', 'prefix', 'suffix', 'none_text', 'no_text', 'divider', 'sort', 'group_template'));
 
82
                update_option('popular-posts', $options);
 
83
                // Show a message to say we've done something
 
84
                echo '<div class="updated fade"><p>' . __('Options saved', 'popular_posts_plugin') . '</p></div>';
 
85
        } 
 
86
        //now we drop into html to display the option page form
 
87
        ?>
 
88
                <div class="wrap">
 
89
                <h2><?php _e('Output Settings', 'popular_posts_plugin'); ?></h2>
 
90
                <form method="post" action="">
 
91
                <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Output Settings', 'popular_posts_plugin') ?>" /></div>
 
92
                <table class="optiontable form-table">
 
93
                        <tr>
 
94
                        <td>
 
95
                        <table>
 
96
                        <?php 
 
97
                                ppl_display_output_template($options['output_template']); 
 
98
                                ppl_display_prefix($options['prefix']); 
 
99
                                ppl_display_suffix($options['suffix']); 
 
100
                                ppl_display_none_text($options['none_text']); 
 
101
                                ppl_display_no_text($options['no_text']); 
 
102
                                ppl_display_divider($options['divider']); 
 
103
                                ppl_display_sort($options['sort']);
 
104
                                ppl_display_group_template($options['group_template']); 
 
105
                        ?>
 
106
                        </table>
 
107
                        </td>
 
108
                        <td>
 
109
                        <?php ppl_display_available_tags('popular-posts'); ?>
 
110
                        </td></tr>
 
111
                </table>
 
112
                <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Output Settings', 'popular_posts_plugin') ?>" /></div>
 
113
                <?php if (function_exists('wp_nonce_field')) wp_nonce_field('popular-posts-update-options'); ?>
 
114
                </form>  
 
115
        </div>
 
116
        <?php   
 
117
}
 
118
 
 
119
function popular_posts_filter_options_subpage(){
 
120
        global $wpdb, $wp_version;
 
121
        $options = get_option('popular-posts');
 
122
        if (isset($_POST['update_options'])) {
 
123
                check_admin_referer('popular-posts-update-options'); 
 
124
                if (defined('POC_CACHE_4')) poc_cache_flush();
 
125
                // Fill up the options with the values chosen...
 
126
                $options = ppl_options_from_post($options, array('excluded_posts', 'included_posts', 'excluded_authors', 'included_authors', 'excluded_cats', 'included_cats', 'tag_str', 'custom'));
 
127
                update_option('popular-posts', $options);
 
128
                // Show a message to say we've done something
 
129
                echo '<div class="updated fade"><p>' . __('Options saved', 'popular_posts_plugin') . '</p></div>';
 
130
        } 
 
131
        //now we drop into html to display the option page form
 
132
        ?>
 
133
                <div class="wrap">
 
134
                <h2><?php _e('Filter Settings', 'popular_posts_plugin'); ?></h2>
 
135
                <form method="post" action="">
 
136
                <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Filter Settings', 'popular_posts_plugin') ?>" /></div>
 
137
                <table class="optiontable form-table">
 
138
                        <?php 
 
139
                                ppl_display_excluded_posts($options['excluded_posts']); 
 
140
                                ppl_display_included_posts($options['included_posts']); 
 
141
                                ppl_display_authors($options['excluded_authors'], $options['included_authors']); 
 
142
                                ppl_display_cats($options['excluded_cats'], $options['included_cats']); 
 
143
                                ppl_display_tag_str($options['tag_str']); 
 
144
                                ppl_display_custom($options['custom']); 
 
145
                        ?>
 
146
                </table>
 
147
                <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Filter Settings', 'popular_posts_plugin') ?>" /></div>
 
148
                <?php if (function_exists('wp_nonce_field')) wp_nonce_field('popular-posts-update-options'); ?>
 
149
                </form>  
 
150
        </div>
 
151
        <?php   
 
152
}
 
153
 
 
154
function popular_posts_placement_options_subpage(){
 
155
        global $wpdb, $wp_version;
 
156
        $options = get_option('popular-posts');
 
157
        if (isset($_POST['update_options'])) {
 
158
                check_admin_referer('popular-posts-update-options'); 
 
159
                if (defined('POC_CACHE_4')) poc_cache_flush();
 
160
                // Fill up the options with the values chosen...
 
161
                $options = ppl_options_from_post($options, array('content_filter', 'widget_parameters', 'widget_condition', 'feed_on', 'feed_priority', 'feed_parameters', 'append_on', 'append_priority', 'append_parameters', 'append_condition'));
 
162
                update_option('popular-posts', $options);
 
163
                // Show a message to say we've done something
 
164
                echo '<div class="updated fade"><p>' . __('Options saved', 'popular_posts') . '</p></div>';
 
165
        } 
 
166
        //now we drop into html to display the option page form
 
167
        ?>
 
168
                <div class="wrap">
 
169
                <h2><?php _e('Placement Settings', 'popular_posts'); ?></h2>
 
170
                <form method="post" action="">
 
171
                <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Placement Settings', 'popular_posts') ?>" /></div>
 
172
                <table class="optiontable form-table">
 
173
                        <?php 
 
174
                                ppl_display_append($options); 
 
175
                                ppl_display_feed($options); 
 
176
                                ppl_display_widget($options); 
 
177
                                ppl_display_content_filter($options['content_filter']);
 
178
                        ?>
 
179
                </table>
 
180
                <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Placement Settings', 'popular_posts') ?>" /></div>
 
181
                <?php if (function_exists('wp_nonce_field')) wp_nonce_field('popular-posts-update-options'); ?>
 
182
                </form>  
 
183
        </div>
 
184
        <?php   
 
185
}
 
186
function pvc_options_page(){
 
187
        global $wpdb;
 
188
        // we only reset the counter if both the button is pressed AND the box checked
 
189
        if (isset($_POST['reset_count']) && isset($_POST['reset_check']) && 'true' === $_POST['reset_check']) {
 
190
                popular_posts_reset();
 
191
        }
 
192
        // This bit stores any updated values when the Update button has been pressed
 
193
        if (isset($_POST['update_options'])) {
 
194
                // Fill up the options array as necessary
 
195
                $options['exclude_users'] = $_POST['exclude_users'];
 
196
                $options['count_single'] = $_POST['count_single'];
 
197
                $options['count_page'] = $_POST['count_page'];
 
198
                $options['count_home'] = $_POST['count_home'];
 
199
                $options['count_archive'] = $_POST['count_archive'];
 
200
                $options['count_category'] = $_POST['count_category'];
 
201
                $options['count_search'] = $_POST['count_search'];
 
202
                $options['count_feed'] = $_POST['count_feed'];
 
203
                // store the option values under the plugin filename
 
204
                update_option(PVC_OPTION, $options);
 
205
                // Show a message to say we've done something
 
206
                echo '<div class="updated"><p>' . __('Options saved') . '</p></div>';
 
207
        } else {
 
208
                // If we are just displaying the page we first load up the options array
 
209
                $options = get_option(PVC_OPTION);
 
210
        }
 
211
        //now we drop into html to display the option page form
 
212
        ?>
 
213
                <div class="wrap">
 
214
                <h2><?php _e('Post View Counter Options'); ?></h2>
 
215
                <form method="post" action="">
 
216
                <fieldset class="options">
 
217
                <table class="optiontable">
 
218
                        <tr valign="top">
 
219
                                <th scope="row"><?php _e('Exclude views by logged-in users?') ?></th>
 
220
                                <td>
 
221
                                <select name="exclude_users" id="exclude_users">
 
222
                                <option <?php if($options['exclude_users'] == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
 
223
                                <option <?php if($options['exclude_users'] == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
 
224
                                </select> 
 
225
                                </td>
 
226
                        </tr>
 
227
                        <tr valign="top">
 
228
                                <th scope="row"><?php _e('Count home page views?'); ?></th>
 
229
                                <td><input type="checkbox" name="count_home" value="true" <?php $ischecked = ($options['count_home']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
230
                        </tr>
 
231
                        <tr valign="top">
 
232
                                <th scope="row"><?php _e('Count single page views?'); ?></th>
 
233
                                <td><input type="checkbox" name="count_single" value="true" <?php $ischecked = ($options['count_single']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
234
                        </tr>
 
235
                        <tr valign="top">
 
236
                                <th scope="row"><?php _e('Count feed page views?'); ?></th>
 
237
                                <td><input type="checkbox" name="count_feed" value="true" <?php $ischecked = ($options['count_feed']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
238
                        </tr>
 
239
                        <tr valign="top">
 
240
                                <th scope="row"><?php _e('Count archive page views?'); ?></th>
 
241
                                <td><input type="checkbox" name="count_archive" value="true" <?php $ischecked = ($options['count_archive']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
242
                        </tr>
 
243
                        <tr valign="top">
 
244
                                <th scope="row"><?php _e('Count category page views?'); ?></th>
 
245
                                <td><input type="checkbox" name="count_category" value="true" <?php $ischecked = ($options['count_category']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
246
                        </tr>
 
247
                        <tr valign="top">
 
248
                                <th scope="row"><?php _e('Count search page views?'); ?></th>
 
249
                                <td><input type="checkbox" name="count_search" value="true" <?php $ischecked = ($options['count_search']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
250
                        </tr>
 
251
                        <tr valign="top">
 
252
                                <th scope="row"><?php _e('Count static page views?'); ?></th>
 
253
                                <td><input type="checkbox" name="count_page" value="true" <?php $ischecked = ($options['count_page']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
254
                        </tr>
 
255
                </table>
 
256
                </fieldset>
 
257
                <div class="submit"><input type="submit" name="update_options" value="<?php _e('Update') ?>"  style="font-weight:bold;" /></div>
 
258
                <p><?php _e('If you wish, you can start counting from scratch by checking the box and pressing the button below which will set all the view counts to zero.') ?></p>
 
259
                <div class="submit">    
 
260
                <input type="checkbox" name="reset_check" value="true" />
 
261
                <?php _e('Check the box to show you really want to reset the counters...'); ?>
 
262
                <input type="submit" name="reset_count" value="<?php _e('Reset') ?>" style="font-weight:bold;" />
 
263
                </div>          
 
264
                </form>                 
 
265
        </div>
 
266
        <?php   
 
267
}
 
268
 
 
269
 
 
270
function popular_posts_other_options_subpage(){
 
271
        global $wpdb, $wp_version;
 
272
        $options = get_option('popular-posts');
 
273
        if (isset($_POST['reset_count']) && isset($_POST['reset_check']) && 'true' === $_POST['reset_check']) {
 
274
                popular_posts_reset();
 
275
        }
 
276
        if (isset($_POST['update_options'])) {
 
277
                check_admin_referer('popular-posts-update-options'); 
 
278
                if (defined('POC_CACHE_4')) poc_cache_flush();
 
279
                // Fill up the options with the values chosen...
 
280
                $options = ppl_options_from_post($options, array('stripcodes', 'exclude_users', 'count_single', 'count_page', 'count_home', 'count_archive', 'count_category', 'count_search', 'count_feed'));
 
281
                update_option('popular-posts', $options);
 
282
                // Show a message to say we've done something
 
283
                echo '<div class="updated fade"><p>' . __('Options saved', 'popular_posts_plugin') . '</p></div>';
 
284
        } 
 
285
        //now we drop into html to display the option page form
 
286
        ?>
 
287
                <div class="wrap">
 
288
                <h2><?php _e('Other Settings', 'popular_posts_plugin'); ?></h2>
 
289
                <form method="post" action="">
 
290
                <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Other Settings', 'popular_posts_plugin') ?>" /></div>
 
291
                <table class="optiontable form-table">
 
292
                        <?php 
 
293
                                ppl_display_stripcodes($options['stripcodes']); 
 
294
                        ?>
 
295
                        <tr valign="top">
 
296
                                <th scope="row"><?php _e('Exclude views by logged-in users?') ?></th>
 
297
                                <td>
 
298
                                <select name="exclude_users" id="exclude_users">
 
299
                                <option <?php if($options['exclude_users'] == 'false') { echo 'selected="selected"'; } ?> value="false">No</option>
 
300
                                <option <?php if($options['exclude_users'] == 'true') { echo 'selected="selected"'; } ?> value="true">Yes</option>
 
301
                                </select> 
 
302
                                </td>
 
303
                        </tr>
 
304
                        <tr valign="top">
 
305
                                <th scope="row"><?php _e('Count home page views?'); ?></th>
 
306
                                <td><input type="checkbox" name="count_home" value="true" <?php $ischecked = ($options['count_home']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
307
                        </tr>
 
308
                        <tr valign="top">
 
309
                                <th scope="row"><?php _e('Count single page views?'); ?></th>
 
310
                                <td><input type="checkbox" name="count_single" value="true" <?php $ischecked = ($options['count_single']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
311
                        </tr>
 
312
                        <tr valign="top">
 
313
                                <th scope="row"><?php _e('Count feed page views?'); ?></th>
 
314
                                <td><input type="checkbox" name="count_feed" value="true" <?php $ischecked = ($options['count_feed']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
315
                        </tr>
 
316
                        <tr valign="top">
 
317
                                <th scope="row"><?php _e('Count archive page views?'); ?></th>
 
318
                                <td><input type="checkbox" name="count_archive" value="true" <?php $ischecked = ($options['count_archive']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
319
                        </tr>
 
320
                        <tr valign="top">
 
321
                                <th scope="row"><?php _e('Count category page views?'); ?></th>
 
322
                                <td><input type="checkbox" name="count_category" value="true" <?php $ischecked = ($options['count_category']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
323
                        </tr>
 
324
                        <tr valign="top">
 
325
                                <th scope="row"><?php _e('Count search page views?'); ?></th>
 
326
                                <td><input type="checkbox" name="count_search" value="true" <?php $ischecked = ($options['count_search']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
327
                        </tr>
 
328
                        <tr valign="top">
 
329
                                <th scope="row"><?php _e('Count static page views?'); ?></th>
 
330
                                <td><input type="checkbox" name="count_page" value="true" <?php $ischecked = ($options['count_page']) ? 'checked="checked"' : ''; echo $ischecked ?> /></td>
 
331
                        </tr>
 
332
                </table>
 
333
                <div class="submit"><input type="submit" name="update_options" value="<?php _e('Save Other Settings', 'popular_posts_plugin') ?>" /></div>
 
334
                <?php if (function_exists('wp_nonce_field')) wp_nonce_field('popular-posts-update-options'); ?>
 
335
                </form>  
 
336
        </div>
 
337
        <?php   
 
338
}
 
339
 
 
340
function popular_posts_bug_subpage(){
 
341
        ppl_bug_form('popular-posts'); 
 
342
}
 
343
 
 
344
function popular_posts_remove_subpage(){
 
345
        ppl_plugin_eradicate_form(str_replace('-admin', '', __FILE__)); 
 
346
}       
 
347
 
 
348
function popular_posts_install() {
 
349
        $options = get_option('popular-posts');
 
350
        // check each of the option values and, if empty, assign a default (doing it this long way
 
351
        // lets us retain old values and add new options in later versions)
 
352
        if (!isset($options['exclude_users'])) $options['exclude_users'] = 'true';
 
353
        if (!isset($options['count_home'])) $options['count_home'] = 'false';
 
354
        if (!isset($options['count_feed'])) $options['count_feed'] = 'false';
 
355
        if (!isset($options['count_single'])) $options['count_single'] = 'true';
 
356
        if (!isset($options['count_archive'])) $options['count_archive'] = 'false';
 
357
        if (!isset($options['count_category'])) $options['count_category'] = 'false';
 
358
        if (!isset($options['count_page'])) $options['count_page'] = 'true';
 
359
        if (!isset($options['count_search'])) $options['count_search'] = 'false';
 
360
        
 
361
        if (!isset($options['widget_condition'])) $options['widget_condition'] = '';
 
362
        if (!isset($options['widget_parameters'])) $options['widget_parameters'] = '';
 
363
        if (!isset($options['feed_on'])) $options['feed_on'] = 'false';
 
364
        if (!isset($options['feed_priority'])) $options['feed_priority'] = '10';
 
365
        if (!isset($options['feed_parameters'])) $options['feed_parameters'] = 'prefix=<strong>'.__('Popular Posts', 'popular-posts').':</strong><ul class="popular-posts">&suffix=</ul>';
 
366
        if (!isset($options['append_on'])) $options['append_on'] = 'false';
 
367
        if (!isset($options['append_priority'])) $options['append_priority'] = '10';
 
368
        if (!isset($options['append_parameters'])) $options['append_parameters'] = 'prefix=<h3>'.__('Popular Posts', 'popular-posts').':</h3><ul class="popular-posts">&suffix=</ul>';
 
369
        if (!isset($options['append_condition'])) $options['append_condition'] = 'is_single()';
 
370
        if (!isset($options['limit'])) $options['limit'] = 5;
 
371
        if (!isset($options['skip'])) $options['skip'] = 0;
 
372
        if (!isset($options['age'])) {$options['age']['direction'] = 'none'; $options['age']['length'] = '0'; $options['age']['duration'] = 'month';}
 
373
        if (!isset($options['divider'])) $options['divider'] = '';
 
374
        if (!isset($options['omit_current_post'])) $options['omit_current_post'] = 'false';
 
375
        if (!isset($options['show_private'])) $options['show_private'] = 'false';
 
376
        if (!isset($options['show_pages'])) $options['show_pages'] = 'false';
 
377
        if (!isset($options['show_attachments'])) $options['show_attachments'] = 'false';
 
378
        // show_static is now show_pages
 
379
        if ( isset($options['show_static'])) {$options['show_pages'] = $options['show_static']; unset($options['show_static']);};
 
380
        if (!isset($options['none_text'])) $options['none_text'] = __('None Found', 'popular_posts_plugin');
 
381
        if (!isset($options['no_text'])) $options['no_text'] = 'false';
 
382
        if (!isset($options['tag_str'])) $options['tag_str'] = '';
 
383
        if (!isset($options['excluded_cats'])) $options['excluded_cats'] = '';
 
384
        // the '9999' flag is now obsolete
 
385
        if ($options['excluded_cats'] === '9999') $options['excluded_cats'] = '';
 
386
        if (!isset($options['included_cats'])) $options['included_cats'] = '';
 
387
        if ($options['included_cats'] === '9999') $options['included_cats'] = '';
 
388
        if (!isset($options['excluded_authors'])) $options['excluded_authors'] = '';
 
389
        if ($options['excluded_authors'] === '9999') $options['excluded_authors'] = '';
 
390
        if (!isset($options['included_authors'])) $options['included_authors'] = '';
 
391
        if ($options['included_authors'] === '9999') $options['included_authors'] = '';
 
392
        if (!isset($options['included_posts'])) $options['included_posts'] = '';
 
393
        if (!isset($options['excluded_posts'])) $options['excluded_posts'] = '';
 
394
        if ($options['excluded_posts'] === '9999') $options['excluded_posts'] = '';
 
395
        if (!isset($options['stripcodes'])) $options['stripcodes'] = array(array());
 
396
        if (!isset($options['prefix'])) $options['prefix'] = '<ul>';
 
397
        if (!isset($options['suffix'])) $options['suffix'] = '</ul>';
 
398
        if (!isset($options['output_template'])) $options['output_template'] = '<li>{link}</li>';
 
399
        if (!isset($options['match_cat'])) $options['match_cat'] = 'false';
 
400
        if (!isset($options['match_tags'])) $options['match_tags'] = 'false';
 
401
        if (!isset($options['match_author'])) $options['match_author'] = 'false';
 
402
        if (!isset($options['content_filter'])) $options['content_filter'] = 'false';
 
403
        if (!isset($options['custom'])) {$options['custom']['key'] = ''; $options['custom']['op'] = '='; $options['custom']['value'] = '';}
 
404
        if (!isset($options['sort'])) {$options['sort']['by1'] = ''; $options['sort']['order1'] = SORT_ASC; $options['sort']['case1'] = 'false';$options['sort']['by2'] = ''; $options['sort']['order2'] = SORT_ASC; $options['sort']['case2'] = 'false';}
 
405
        if (!isset($options['status'])) {$options['status']['publish'] = 'true'; $options['status']['private'] = 'false'; $options['status']['draft'] = 'false'; $options['status']['future'] = 'false';}
 
406
        if (!isset($options['group_template'])) $options['group_template'] = '';
 
407
        if (!isset($options['date_modified'])) $options['date_modified'] = 'false';
 
408
        update_option('popular-posts', $options);
 
409
}
 
410
 
 
411
if (!function_exists('ppl_plugin_basename')) {
 
412
        if ( !defined('WP_PLUGIN_DIR') ) define( 'WP_PLUGIN_DIR', ABSPATH . 'wp-content/plugins' ); 
 
413
        function ppl_plugin_basename($file) {
 
414
                $file = str_replace('\\','/',$file); // sanitize for Win32 installs
 
415
                $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
 
416
                $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
 
417
                $plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash
 
418
                $file = preg_replace('|^' . preg_quote($plugin_dir, '|') . '/|','',$file); // get relative path from plugins dir
 
419
                return $file;
 
420
        }
 
421
}
 
422
 
 
423
add_action('activate_'.str_replace('-admin', '', ppl_plugin_basename(__FILE__)), 'popular_posts_install');
 
424
 
 
425
?>
 
 
b'\\ No newline at end of file'