WP Hide Post - Version 1.1.0

Version Description

Download this release

Release Info

Developer rmahfoud
Plugin Icon wp plugin WP Hide Post
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.4 to 1.1.0

Files changed (4) hide show
  1. admin.php +298 -0
  2. readme.txt +3 -2
  3. upgrade.php +89 -0
  4. wp-hide-post.php +6 -333
admin.php ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* Copyright 2009 Robert Mahfoud (email : robert.mahfoud@gmail.com)
3
+
4
+ This program is free software; you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation; either version 2 of the License, or
7
+ (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+ */
18
+
19
+ /**
20
+ * Hook to watch for the activation of 'WP low Profiler', and forbid it...
21
+ * @return unknown_type
22
+ */
23
+ function wphp_activate_lowprofiler() {
24
+ wphp_log("called: wphp_activate_lowprofiler");
25
+ require_once(dirname(__FILE__).'/upgrade.php');
26
+ wphp_migrate_db(); // in case any tables were created, clean them up
27
+ wphp_remove_wp_low_profiler(); // remove the files of the plugin
28
+
29
+ $msgbox = __("'WP low Profiler' has been deprecated and replaced by 'WP Hide Post' which you already have active! Activation failed and plugin files cleaned up.", 'wp-hide-post');
30
+ $err1_sorry = __("Cannot install 'WP low Profiler' because of a conflict. Sorry for this inconvenience.", 'wp-hide-post');
31
+ $err2_cleanup = __("The downloaded files were cleaned-up and no further action is required.", 'wp-hide-post');
32
+ $err3_return = __("Return to plugins page...", 'wp-hide-post');
33
+ $return_url = admin_url('plugins.php');
34
+
35
+ $html = <<<HTML
36
+ ${err1_sorry}<br />${err2_cleanup}<br /><a href="${$return_url}">${err3_return}</a>
37
+ <script language="javascript">window.alert("${msgbox}");</script>
38
+ HTML;
39
+ // show the error page with the message...
40
+ wp_die($html, 'WP low Profiler Activation Not Allowed', array( 'response' => '200') );
41
+ }
42
+ add_action('activate_wp-low-profiler/wp-low-profiler.php', 'wphp_activate_lowprofiler' );
43
+
44
+ /**
45
+ * @param $action_links
46
+ * @param $plugin
47
+ * @return unknown_type
48
+ */
49
+ function plugin_install_action_links_wp_lowprofiler($action_links, $plugin) {
50
+ wphp_log("called: plugin_install_action_links_wp_lowprofiler");
51
+ if( $plugin['name'] == 'WP low Profiler' ) {
52
+ $alt = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&amp;plugin=wp-hide-post&amp;TB_iframe=true&amp;width=600&amp;height=800') . '" class="thickbox onclick" title="WP Hide Post">' . __('Check "WP Hide Post"') . '</a>';
53
+ $action_links = array(
54
+ __('Deprecated'),
55
+ $alt);
56
+ }
57
+ return $action_links;
58
+ }
59
+ add_filter('plugin_install_action_links', 'plugin_install_action_links_wp_lowprofiler', 10, 2);
60
+
61
+ /**
62
+ *
63
+ * @param $id
64
+ * @param $lp_flag
65
+ * @param $lp_value
66
+ * @return unknown_type
67
+ */
68
+ function wphp_update_visibility($id, $lp_flag, $lp_value) {
69
+ wphp_log("called: wphp_update_visibility");
70
+ global $wpdb;
71
+ $item_type = get_post_type($id);
72
+ if( ($item_type == 'post' && !$lp_value) || ($item_type == 'page' && ( ($lp_flag == '_wplp_page_flags' && $lp_value == 'none') || ($lp_flag == '_wplp_page_search' && !$lp_value) ) ) ) {
73
+ wphp_unset_low_profile($item_type, $id, $lp_flag);
74
+ } else {
75
+ wphp_set_low_profile($item_type, $id, $lp_flag, $lp_value);
76
+ }
77
+ }
78
+
79
+ /**
80
+ *
81
+ * @param $item_type
82
+ * @param $id
83
+ * @param $lp_flag
84
+ * @return unknown_type
85
+ */
86
+ function wphp_unset_low_profile($item_type, $id, $lp_flag) {
87
+ wphp_log("called: wphp_unset_low_profile");
88
+ global $wpdb;
89
+ // Delete the flag from the database table
90
+ $wpdb->query("DELETE FROM ".WPHP_TABLE_NAME." WHERE post_id = $id AND meta_key = '$lp_flag'");
91
+ }
92
+
93
+ /**
94
+ *
95
+ * @param $item_type
96
+ * @param $id
97
+ * @param $lp_flag
98
+ * @param $lp_value
99
+ * @return unknown_type
100
+ */
101
+ function wphp_set_low_profile($item_type, $id, $lp_flag, $lp_value) {
102
+ wphp_log("called: wphp_set_low_profile");
103
+ global $wpdb;
104
+ // Ensure No Duplicates!
105
+ $check = $wpdb->get_var("SELECT count(*) FROM ".WPHP_TABLE_NAME." WHERE post_id = $id AND meta_key='$lp_flag'");
106
+ error_log("Check: $check");
107
+ if(!$check) {
108
+ $wpdb->query("INSERT INTO ".WPHP_TABLE_NAME."(post_id, meta_key, meta_value) VALUES($id, '$lp_flag', '$lp_value')");
109
+ } elseif( $item_type == 'page' && $lp_flag == "_wplp_page_flags" ) {
110
+ $wpdb->query("UPDATE ".WPHP_TABLE_NAME." set meta_value = '$lp_value' WHERE post_id = $id and meta_key = '$lp_flag'");
111
+ }
112
+ }
113
+
114
+ /**
115
+ *
116
+ * @return unknown_type
117
+ */
118
+ function wphp_add_post_edit_meta_box() {
119
+ wphp_log("called: wphp_add_post_edit_meta_box");
120
+ add_meta_box('hidepostdivpost', __('Post Visibility', 'wp-hide-post'), 'wphp_metabox_post_edit', 'post', 'side');
121
+ add_meta_box('hidepostdivpage', __('Page Visibility', 'wp-hide-post'), 'wphp_metabox_page_edit', 'page', 'side');
122
+ }
123
+ add_action('admin_menu', 'wphp_add_post_edit_meta_box');
124
+
125
+ /**
126
+ *
127
+ * @return unknown_type
128
+ */
129
+ function wphp_metabox_post_edit() {
130
+ wphp_log("called: wphp_metabox_post_edit");
131
+ global $wpdb;
132
+
133
+ $id = isset($_GET['post']) ? intval($_GET['post']) : 0;
134
+
135
+ $wplp_post_front = 0;
136
+ $wplp_post_category = 0;
137
+ $wplp_post_tag = 0;
138
+ $wplp_post_author = 0;
139
+ $wplp_post_archive = 0;
140
+ $wplp_post_search = 0;
141
+ $wplp_post_feed = 0;
142
+
143
+ if($id > 0) {
144
+ $flags = $wpdb->get_results("SELECT meta_key from ".WPHP_TABLE_NAME." where post_id = $id and meta_key like '_wplp_%'", ARRAY_N);
145
+ if( $flags ) {
146
+ foreach($flags as $flag_array) {
147
+ $flag = $flag_array[0];
148
+ // remove the leading _
149
+ $flag = substr($flag, 1, strlen($flag)-1);
150
+ ${$flag} = 1;
151
+ }
152
+ }
153
+ }
154
+ ?>
155
+ <label for="wplp_post_front" class="selectit"><input type="checkbox" id="wplp_post_front" name="wplp_post_front" value="1"<?php checked($wplp_post_front, 1); ?>/>&nbsp;<?php _e('Hide on the front page.', 'wp-hide-post'); ?></label>
156
+ <input type="hidden" name="old_wplp_post_front" value="<?php echo $wplp_post_front; ?>"/>
157
+ <br />
158
+ <label for="wplp_post_category" class="selectit"><input type="checkbox" id="wplp_post_category" name="wplp_post_category" value="1"<?php checked($wplp_post_category, 1); ?>/>&nbsp;<?php _e('Hide on category pages.', 'wp-hide-post'); ?></label>
159
+ <input type="hidden" name="old_wplp_post_category" value="<?php echo $wplp_post_category; ?>"/>
160
+ <br />
161
+ <label for="wplp_post_tag" class="selectit"><input type="checkbox" id="wplp_post_tag" name="wplp_post_tag" value="1"<?php checked($wplp_post_tag, 1); ?>/>&nbsp;<?php _e('Hide on tag pages.', 'wp-hide-post'); ?></label>
162
+ <input type="hidden" name="old_wplp_post_tag" value="<?php echo $wplp_post_tag; ?>"/>
163
+ <br />
164
+ <label for="wplp_post_author" class="selectit"><input type="checkbox" id="wplp_post_author" name="wplp_post_author" value="1"<?php checked($wplp_post_author, 1); ?>/>&nbsp;<?php _e('Hide on author pages.', 'wp-hide-post'); ?></label>
165
+ <input type="hidden" name="old_wplp_post_author" value="<?php echo $wplp_post_author; ?>"/>
166
+ <br />
167
+ <label for="wplp_post_archive" class="selectit"><input type="checkbox" id="wplp_post_archive" name="wplp_post_archive" value="1"<?php checked($wplp_post_archive, 1); ?>/>&nbsp;<?php _e('Hide in date archives (month, day, year, etc...)', 'wp-hide-post'); ?></label>
168
+ <input type="hidden" name="old_wplp_post_archive" value="<?php echo $wplp_post_archive; ?>"/>
169
+ <br />
170
+ <label for="wplp_post_search" class="selectit"><input type="checkbox" id="wplp_post_search" name="wplp_post_search" value="1"<?php checked($wplp_post_search, 1); ?>/>&nbsp;<?php _e('Hide in search results.', 'wp-hide-post'); ?></label>
171
+ <input type="hidden" name="old_wplp_post_search" value="<?php echo $wplp_post_search; ?>"/>
172
+ <br />
173
+ <label for="wplp_post_feed" class="selectit"><input type="checkbox" id="wplp_post_feed" name="wplp_post_feed" value="1"<?php checked($wplp_post_feed, 1); ?>/>&nbsp;<?php _e('Hide in feeds.', 'wp-hide-post'); ?></label>
174
+ <input type="hidden" name="old_wplp_post_feed" value="<?php echo $wplp_post_feed; ?>"/>
175
+ <br />
176
+ <div style="float:right;font-size: xx-small;"><a href="http://anappleaday.konceptus.net/posts/wp-hide-post/#comments"><?php _e("Leave feedback and report bugs...", 'wp-hide-post'); ?></a></div>
177
+ <br />
178
+ <div style="float:right;font-size: xx-small;"><a href="http://wordpress.org/extend/plugins/wp-hide-post/"><?php _e("Give 'WP Hide Post' a good rating...", 'wp-hide-post'); ?></a></div>
179
+ <br />
180
+ <?php
181
+ }
182
+
183
+ /**
184
+ *
185
+ * @return unknown_type
186
+ */
187
+ function wphp_metabox_page_edit() {
188
+ wphp_log("called: wphp_metabox_page_edit");
189
+ global $wpdb;
190
+
191
+ $id = isset($_GET['post']) ? intval($_GET['post']) : 0;
192
+
193
+ $wplp_page = 'none';
194
+ $wplp_page_search_show = 1;
195
+
196
+ if($id > 0) {
197
+ $flags = $wpdb->get_results("SELECT meta_value from ".WPHP_TABLE_NAME." where post_id = $id and meta_key = '_wplp_page_flags'", ARRAY_N);
198
+ if( $flags )
199
+ $wplp_page = $flags[0][0];
200
+ $search = $wpdb->get_results("SELECT meta_value from ".WPHP_TABLE_NAME." where post_id = $id and meta_key = '_wplp_page_search'", ARRAY_N);
201
+ if( $search )
202
+ $wplp_page_search_show = ! $search[0][0];
203
+ }
204
+ ?>
205
+ <input type="hidden" name="old_wplp_page" value="<?php echo $wplp_page; ?>"/>
206
+ <label class="selectit"><input type="radio" id="wplp_page_none" name="wplp_page" value="none"<?php checked($wplp_page, 'none'); ?>/>&nbsp;<?php _e('Show normally everywhere.', 'wp-hide-post'); ?></label>
207
+ <br />
208
+ <br />
209
+ <label class="selectit"><input type="radio" id="wplp_page_front" name="wplp_page" value="front"<?php checked($wplp_page, 'front'); ?>/>&nbsp;<?php _e('Hide when listing pages on the front page.', 'wp-hide-post'); ?></label>
210
+ <br />
211
+ <br />
212
+ <label class="selectit"><input type="radio" id="wplp_page_all" name="wplp_page" value="all"<?php checked($wplp_page, 'all'); ?>/>&nbsp;<?php _e('Hide everywhere pages are listed.', 'wp-hide-post'); ?><sup>*</sup></label>
213
+ <div style="height:18px;margin-left:20px">
214
+ <div id="wplp_page_search_show_div">
215
+ <label class="selectit"><input type="checkbox" id="wplp_page_search_show" name="wplp_page_search_show" value="1"<?php checked($wplp_page_search_show, 1); ?>/>&nbsp;<?php _e('Keep in search results.', 'wp-hide-post'); ?></label>
216
+ <input type="hidden" name="old_wplp_page_search_show" value="<?php echo $wplp_page_search_show; ?>"/>
217
+ </div>
218
+ </div>
219
+ <br />
220
+ <div style="float:right;clear:both;font-size:x-small;">* Will still show up in sitemap.xml if you generate one automatically. See <a href="http://anappleaday.konceptus.net/posts/wp-low-profiler/">details</a>.</div>
221
+ <br />
222
+ <br />
223
+ <br />
224
+ <div style="float:right;font-size: xx-small;"><a href="http://anappleaday.konceptus.net/posts/wp-hide-post/#comments"><?php _e("Leave feedback and report bugs...", 'wp-hide-post'); ?></a></div>
225
+ <br />
226
+ <div style="float:right;clear:both;font-size:xx-small;"><a href="http://wordpress.org/extend/plugins/wp-hide-post/"><?php _e("Give 'WP Hide Post' a good rating...", 'wp-hide-post'); ?></a></div>
227
+ <br />
228
+ <script type="text/javascript">
229
+ <!--
230
+ // toggle the wplp_page_search_show checkbox
231
+ var wplp_page_search_show_callback = function () {
232
+ if(jQuery("#wplp_page_all").is(":checked"))
233
+ jQuery("#wplp_page_search_show_div").show();
234
+ else
235
+ jQuery("#wplp_page_search_show_div").hide();
236
+ };
237
+ jQuery("#wplp_page_all").change(wplp_page_search_show_callback);
238
+ jQuery("#wplp_page_front").change(wplp_page_search_show_callback);
239
+ jQuery("#wplp_page_none").change(wplp_page_search_show_callback);
240
+ jQuery(document).ready( wplp_page_search_show_callback );
241
+ //-->
242
+ </script>
243
+ <?php
244
+ }
245
+
246
+ /**
247
+ *
248
+ * @param $id
249
+ * @return unknown_type
250
+ */
251
+ function wphp_save_post($id) {
252
+ wphp_log("called: wphp_save_post");
253
+ $item_type = get_post_type($id);
254
+ if( $item_type == 'post' ) {
255
+ if( isset($_POST['wplp_post_front']) && isset($_POST['old_wplp_post_front']) && $_POST['wplp_post_front'] != $_POST['old_wplp_post_front'] )
256
+ wphp_update_visibility($id, '_wplp_post_front', $_POST['wplp_post_front']);
257
+ if( isset($_POST['wplp_post_category']) && isset($_POST['old_wplp_post_category']) && $_POST['wplp_post_category'] != $_POST['old_wplp_post_category'] )
258
+ wphp_update_visibility($id, '_wplp_post_category', $_POST['wplp_post_category']);
259
+ if( isset($_POST['wplp_post_tag']) && isset($_POST['old_wplp_post_tag']) && $_POST['wplp_post_tag'] != $_POST['old_wplp_post_tag'] )
260
+ wphp_update_visibility($id, '_wplp_post_tag', $_POST['wplp_post_tag']);
261
+ if( isset($_POST['wplp_post_author']) && isset($_POST['old_wplp_post_author']) && $_POST['wplp_post_author'] != $_POST['old_wplp_post_author'] )
262
+ wphp_update_visibility($id, '_wplp_post_author', $_POST['wplp_post_author']);
263
+ if( isset($_POST['wplp_post_archive']) && isset($_POST['old_wplp_post_archive']) && $_POST['wplp_post_archive'] != $_POST['old_wplp_post_archive'] )
264
+ wphp_update_visibility($id, '_wplp_post_archive', $_POST['wplp_post_archive']);
265
+ if( isset($_POST['wplp_post_search']) && isset($_POST['old_wplp_post_search']) && $_POST['wplp_post_search'] != $_POST['old_wplp_post_search'] )
266
+ wphp_update_visibility($id, '_wplp_post_search', $_POST['wplp_post_search']);
267
+ if( isset($_POST['wplp_post_feed']) && isset($_POST['old_wplp_post_feed']) && $_POST['wplp_post_feed'] != $_POST['old_wplp_post_feed'] )
268
+ wphp_update_visibility($id, '_wplp_post_feed', $_POST['wplp_post_feed']);
269
+ } elseif( $item_type == 'page' ) {
270
+ if( isset($_POST['wplp_page']) && isset($_POST['old_wplp_page']) ) {
271
+ if( $_POST['wplp_page'] != $_POST['old_wplp_page'] ) {
272
+ wphp_update_visibility($id, "_wplp_page_flags", $_POST['wplp_page']);
273
+ }
274
+ if( $_POST['wplp_page'] == 'all' ) {
275
+ if( isset($_POST['wplp_page_search_show']) && isset($_POST['old_wplp_page_search_show']) && $_POST['wplp_page_search_show'] != $_POST['old_wplp_page_search_show'] )
276
+ wphp_update_visibility($id, "_wplp_page_search", ! $_POST['wplp_page_search_show']);
277
+ } else
278
+ wphp_update_visibility($id, "_wplp_page_search", 0);
279
+ }
280
+ }
281
+ }
282
+ add_action('save_post', 'wphp_save_post');
283
+
284
+ /**
285
+ *
286
+ * @param $post_id
287
+ * @return unknown_type
288
+ */
289
+ function wphp_delete_post($post_id) {
290
+ wphp_log("called: wphp_delete_post");
291
+ global $wpdb;
292
+ // Delete all post flags from the database table
293
+ $wpdb->query("DELETE FROM ".WPHP_TABLE_NAME." WHERE post_id = $post_id and meta_key like '_wplp_%'");
294
+ }
295
+ add_action('delete_post', 'wphp_delete_post');
296
+
297
+
298
+ ?>
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: rmahfoud
3
  Donate link: http://anappleaday.konceptus.net/donate
4
  Tags: SEO,hide,show,visbility,privacy,customization,sitemap,filter
5
  Requires at least: 2.7.1
6
- Tested up to: 2.8.2
7
- Stable tag: 1.0.4
8
 
9
  Enables you to control the visibility of items on your blog by making posts/pages hidden on some parts of your blog, while still visible in other parts as well as to search engines. This plugin is the new incarnation of the 'WP low Profiler'. If this plugin already exists, it will be upgraded to this one, keeping all existing settings.
10
 
@@ -92,6 +92,7 @@ Ditto. It will be deleted. If you had any existing data (if you had it active be
92
 
93
  == Revision History ==
94
 
 
95
  * 07/24/2009: v1.0.4 - Minor bug fixes
96
  * 07/24/2009: v1.0.3 - Initial public release of 'WP Hide Post' and deprecation of 'WP low Profiler'
97
 
3
  Donate link: http://anappleaday.konceptus.net/donate
4
  Tags: SEO,hide,show,visbility,privacy,customization,sitemap,filter
5
  Requires at least: 2.7.1
6
+ Tested up to: 2.8.3
7
+ Stable tag: 1.1.0
8
 
9
  Enables you to control the visibility of items on your blog by making posts/pages hidden on some parts of your blog, while still visible in other parts as well as to search engines. This plugin is the new incarnation of the 'WP low Profiler'. If this plugin already exists, it will be upgraded to this one, keeping all existing settings.
10
 
92
 
93
  == Revision History ==
94
 
95
+ * 08/04/2009: v1.1.0 - Bug fix: bulk update clears "Visibility Attributes". Split code into separate files.
96
  * 07/24/2009: v1.0.4 - Minor bug fixes
97
  * 07/24/2009: v1.0.3 - Initial public release of 'WP Hide Post' and deprecation of 'WP low Profiler'
98
 
upgrade.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* Copyright 2009 Robert Mahfoud (email : robert.mahfoud@gmail.com)
3
+
4
+ This program is free software; you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation; either version 2 of the License, or
7
+ (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+ */
18
+
19
+
20
+ /**
21
+ * Migrate to the new database schema and clean up old schema...
22
+ * Should run only once in the lifetime of the plugin...
23
+ * @return unknown_type
24
+ */
25
+ function wphp_migrate_db() {
26
+ wphp_log("called: wphp_migrate_db");
27
+ /* When I first released this plugin, I was young and crazy and didn't know about the postmeta table.
28
+ * With time I became wiser and wiser and decided to migrate the implementation to rely on postmeta.
29
+ * I hope it was not a bad idea...
30
+ */
31
+ global $wpdb;
32
+ global $table_prefix;
33
+ $dbname = $wpdb->get_var("SELECT database()");
34
+ if( !$dbname )
35
+ return;
36
+ $legacy_table_name = "${table_prefix}lowprofiler_posts";
37
+ $legacy_table_exists = $wpdb->get_var("SELECT COUNT(*) AS count FROM information_schema.tables WHERE table_schema = '$dbname' AND table_name = '$legacy_table_name';");
38
+ if( $legacy_table_exists ) {
39
+ wphp_log("Migrating legacy table...");
40
+ // move everything to the postmeta table
41
+ $existing = $wpdb->get_results("SELECT wplp_post_id, wplp_flag, wplp_value from $legacy_table_name", ARRAY_N);
42
+ // scan them one by one and insert the corresponding fields in the postmeta table
43
+ $count = 0;
44
+ foreach($existing as $existing_array) {
45
+ $wplp_post_id = $existing_array[0];
46
+ $wplp_flag = $existing_array[1];
47
+ $wplp_value = $existing_array[2];
48
+ if( $wplp_flag == 'home' )
49
+ $wplp_flag = 'front';
50
+ if( $wplp_value == 'home' )
51
+ $wplp_value = 'front';
52
+ if( $wplp_flag != 'page' ) {
53
+ $wpdb->query("INSERT INTO ".WPHP_TABLE_NAME."(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_post_$wplp_flag', '1')");
54
+ } else {
55
+ $wpdb->query("INSERT INTO ".WPHP_TABLE_NAME."(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_page_flags', $wplp_value)");
56
+ }
57
+ ++$count;
58
+ }
59
+ wphp_log("$count entries migrated from legacy table.");
60
+ // delete the old table
61
+ $wpdb->query("TRUNCATE TABLE $legacy_table_name");
62
+ $wpdb->query("DROP TABLE $legacy_table_name");
63
+ wphp_log("Legacy table deleted.");
64
+ }
65
+ }
66
+
67
+
68
+ /**
69
+ *
70
+ * @return unknown_type
71
+ */
72
+ function wphp_remove_wp_low_profiler() {
73
+ wphp_log("called: wphp_remove_wp_low_profiler");
74
+ $plugin_list = get_plugins('/wp-low-profiler');
75
+ if( isset($plugin_list['wp-low-profiler.php']) ) {
76
+ wphp_log("The 'WP low Profiler' plugin is present. Cleaning it up...");
77
+ $plugins = array('wp-low-profiler/wp-low-profiler.php');
78
+ if( is_plugin_active('wp-low-profiler/wp-low-profiler.php') ) {
79
+ wphp_log("The 'WP low Profiler' plugin is active. Deactivating...");
80
+ deactivate_plugins($plugins, true); // silent deactivate
81
+ }
82
+ wphp_log("Deleting plugin 'WP low Profiler'...");
83
+ delete_plugins($plugins, '');
84
+ } else
85
+ wphp_log("The 'WP low Profiler' plugin does not exist.");
86
+
87
+ }
88
+
89
+ ?>
wp-hide-post.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Hide Post
4
  Plugin URI: http://anappleaday.konceptus.net/posts/wp-hide-post/
5
  Description: Enables a user to control the visibility of items on the blog by making posts and pages selectively hidden in different views throughout the blog, such as on the front page, category pages, search results, etc... The hidden item remains otherwise accessible directly using permalinks, and also visible to search engines as part of the sitemap (at least). This plugin enables new SEO possibilities for authors since it enables them to create new posts and pages without being forced to display them on their front and in feeds.
6
- Version: 1.0.4
7
  Author: Robert Mahfoud
8
  Author URI: http://anappleaday.konceptus.net
9
  Text Domain: wp_hide_post
@@ -128,76 +128,6 @@ function wphp_textdomain() {
128
  }
129
  add_action('init', 'wphp_textdomain');
130
 
131
- /**
132
- * Migrate to the new database schema and clean up old schema...
133
- * Should run only once in the lifetime of the plugin...
134
- * @return unknown_type
135
- */
136
- function wphp_migrate_db() {
137
- wphp_log("called: wphp_migrate_db");
138
- /* When I first released this plugin, I was young and crazy and didn't know about the postmeta table.
139
- * With time I became wiser and wiser and decided to migrate the implementation to rely on postmeta.
140
- * I hope it was not a bad idea...
141
- */
142
- global $wpdb;
143
- global $table_prefix;
144
- $dbname = $wpdb->get_var("SELECT database()");
145
- if( !$dbname )
146
- return;
147
- $legacy_table_name = "${table_prefix}lowprofiler_posts";
148
- $legacy_table_exists = $wpdb->get_var("SELECT COUNT(*) AS count FROM information_schema.tables WHERE table_schema = '$dbname' AND table_name = '$legacy_table_name';");
149
- if( $legacy_table_exists ) {
150
- wphp_log("Migrating legacy table...");
151
- // move everything to the postmeta table
152
- $existing = $wpdb->get_results("SELECT wplp_post_id, wplp_flag, wplp_value from $legacy_table_name", ARRAY_N);
153
- // scan them one by one and insert the corresponding fields in the postmeta table
154
- $count = 0;
155
- foreach($existing as $existing_array) {
156
- $wplp_post_id = $existing_array[0];
157
- $wplp_flag = $existing_array[1];
158
- $wplp_value = $existing_array[2];
159
- if( $wplp_flag == 'home' )
160
- $wplp_flag = 'front';
161
- if( $wplp_value == 'home' )
162
- $wplp_value = 'front';
163
- if( $wplp_flag != 'page' ) {
164
- $wpdb->query("INSERT INTO ".WPHP_TABLE_NAME."(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_post_$wplp_flag', '1')");
165
- } else {
166
- $wpdb->query("INSERT INTO ".WPHP_TABLE_NAME."(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_page_flags', $wplp_value)");
167
- }
168
- ++$count;
169
- }
170
- wphp_log("$count entries migrated from legacy table.");
171
- // delete the old table
172
- $wpdb->query("TRUNCATE TABLE $legacy_table_name");
173
- $wpdb->query("DROP TABLE $legacy_table_name");
174
- wphp_log("Legacy table deleted.");
175
- }
176
- }
177
-
178
-
179
- /**
180
- *
181
- * @return unknown_type
182
- */
183
- function wphp_remove_wp_low_profiler() {
184
- wphp_log("called: wphp_remove_wp_low_profiler");
185
- $plugin_list = get_plugins('/wp-low-profiler');
186
- if( isset($plugin_list['wp-low-profiler.php']) ) {
187
- wphp_log("The 'WP low Profiler' plugin is present. Cleaning it up...");
188
- $plugins = array('wp-low-profiler/wp-low-profiler.php');
189
- if( is_plugin_active('wp-low-profiler/wp-low-profiler.php') ) {
190
- wphp_log("The 'WP low Profiler' plugin is active. Deactivating...");
191
- deactivate_plugins($plugins, true); // silent deactivate
192
- }
193
- wphp_log("Deleting plugin 'WP low Profiler'...");
194
- delete_plugins($plugins, '');
195
- } else
196
- wphp_log("The 'WP low Profiler' plugin does not exist.");
197
-
198
- }
199
-
200
-
201
  /**
202
  * Hook called when activating the plugin
203
  * @return unknown_type
@@ -205,92 +135,14 @@ function wphp_remove_wp_low_profiler() {
205
  function wphp_activate() {
206
  wphp_init();
207
  wphp_log("called: wphp_activate");
 
 
208
  wphp_migrate_db();
209
  wphp_remove_wp_low_profiler();
210
  }
211
  add_action('activate_wp-hide-post/wp-hide-post.php', 'wphp_activate' );
212
  //register_activation_hook( __FILE__, 'wphp_activate' );
213
 
214
-
215
-
216
- /**
217
- * Hook to watch for the activation of 'WP low Profiler', and forbid it...
218
- * @return unknown_type
219
- */
220
- function wphp_activate_lowprofiler() {
221
- wphp_log("called: wphp_activate_lowprofiler");
222
- wphp_migrate_db(); // in case any tables were created, clean them up
223
- wphp_remove_wp_low_profiler(); // remove the files of the plugin
224
-
225
- $msgbox = __("'WP low Profiler' has been deprecated and replaced by 'WP Hide Post' which you already have active! Activation failed and plugin files cleaned up.", 'wp-hide-post');
226
- $err1_sorry = __("Cannot install 'WP low Profiler' because of a conflict. Sorry for this inconvenience.", 'wp-hide-post');
227
- $err2_cleanup = __("The downloaded files were cleaned-up and no further action is required.", 'wp-hide-post');
228
- $err3_return = __("Return to plugins page...", 'wp-hide-post');
229
- $return_url = admin_url('plugins.php');
230
-
231
- $html = <<<HTML
232
- ${err1_sorry}<br />${err2_cleanup}<br /><a href="${$return_url}">${err3_return}</a>
233
- <script language="javascript">window.alert("${msgbox}");</script>
234
- HTML;
235
- // show the error page with the message...
236
- wp_die($html, 'WP low Profiler Activation Not Allowed', array( 'response' => '200') );
237
- }
238
- add_action('activate_wp-low-profiler/wp-low-profiler.php', 'wphp_activate_lowprofiler' );
239
-
240
-
241
- /**
242
- *
243
- * @param $id
244
- * @param $lp_flag
245
- * @param $lp_value
246
- * @return unknown_type
247
- */
248
- function wphp_update_low_profile($id, $lp_flag, $lp_value) {
249
- wphp_log("called: wphp_update_low_profile");
250
- global $wpdb;
251
- $item_type = get_post_type($id);
252
- if( ($item_type == 'post' && !$lp_value) || ($item_type == 'page' && ( ($lp_flag == '_wplp_page_flags' && $lp_value == 'none') || ($lp_flag == '_wplp_page_search' && !$lp_value) ) ) ) {
253
- wphp_unset_low_profile($item_type, $id, $lp_flag);
254
- } else {
255
- wphp_set_low_profile($item_type, $id, $lp_flag, $lp_value);
256
- }
257
- }
258
-
259
- /**
260
- *
261
- * @param $item_type
262
- * @param $id
263
- * @param $lp_flag
264
- * @return unknown_type
265
- */
266
- function wphp_unset_low_profile($item_type, $id, $lp_flag) {
267
- wphp_log("called: wphp_unset_low_profile");
268
- global $wpdb;
269
- // Delete the flag from the database table
270
- $wpdb->query("DELETE FROM ".WPHP_TABLE_NAME." WHERE post_id = $id AND meta_key = '$lp_flag'");
271
- }
272
-
273
- /**
274
- *
275
- * @param $item_type
276
- * @param $id
277
- * @param $lp_flag
278
- * @param $lp_value
279
- * @return unknown_type
280
- */
281
- function wphp_set_low_profile($item_type, $id, $lp_flag, $lp_value) {
282
- wphp_log("called: wphp_set_low_profile");
283
- global $wpdb;
284
- // Ensure No Duplicates!
285
- $check = $wpdb->get_var("SELECT count(*) FROM ".WPHP_TABLE_NAME." WHERE post_id = $id AND meta_key='$lp_flag'");
286
- error_log("Check: $check");
287
- if(!$check) {
288
- $wpdb->query("INSERT INTO ".WPHP_TABLE_NAME."(post_id, meta_key, meta_value) VALUES($id, '$lp_flag', '$lp_value')");
289
- } elseif( $item_type == 'page' && $lp_flag == "_wplp_page_flags" ) {
290
- $wpdb->query("UPDATE ".WPHP_TABLE_NAME." set meta_value = '$lp_value' WHERE post_id = $id and meta_key = '$lp_flag'");
291
- }
292
- }
293
-
294
  /**
295
  *
296
  * @param $item_type
@@ -330,176 +182,6 @@ function wphp_exclude_low_profile_pages($posts) {
330
  }
331
  add_filter('get_pages', 'wphp_exclude_low_profile_pages');
332
 
333
- /**
334
- *
335
- * @return unknown_type
336
- */
337
- function wphp_add_post_edit_meta_box() {
338
- wphp_log("called: wphp_add_post_edit_meta_box");
339
- add_meta_box('hidepostdivpost', __('Post Visibility', 'wp-hide-post'), 'wphp_metabox_post_edit', 'post', 'side');
340
- add_meta_box('hidepostdivpage', __('Page Visibility', 'wp-hide-post'), 'wphp_metabox_page_edit', 'page', 'side');
341
- }
342
- add_action('admin_menu', 'wphp_add_post_edit_meta_box');
343
-
344
- /**
345
- *
346
- * @return unknown_type
347
- */
348
- function wphp_metabox_post_edit() {
349
- wphp_log("called: wphp_metabox_post_edit");
350
- global $wpdb;
351
-
352
- $id = isset($_GET['post']) ? intval($_GET['post']) : 0;
353
-
354
- $wplp_post_front = 0;
355
- $wplp_post_category = 0;
356
- $wplp_post_tag = 0;
357
- $wplp_post_author = 0;
358
- $wplp_post_archive = 0;
359
- $wplp_post_search = 0;
360
- $wplp_post_feed = 0;
361
-
362
- if($id > 0) {
363
- $flags = $wpdb->get_results("SELECT meta_key from ".WPHP_TABLE_NAME." where post_id = $id and meta_key like '_wplp_%'", ARRAY_N);
364
- if( $flags ) {
365
- foreach($flags as $flag_array) {
366
- $flag = $flag_array[0];
367
- // remove the leading _
368
- $flag = substr($flag, 1, strlen($flag)-1);
369
- ${$flag} = 1;
370
- }
371
- }
372
- }
373
- ?>
374
- <label for="wplp_post_front" class="selectit"><input type="checkbox" id="wplp_post_front" name="wplp_post_front" value="1"<?php checked($wplp_post_front, 1); ?>/>&nbsp;<?php _e('Hide on the front page.', 'wp-hide-post'); ?></label>
375
- <br />
376
- <label for="wplp_post_category" class="selectit"><input type="checkbox" id="wplp_post_category" name="wplp_post_category" value="1"<?php checked($wplp_post_category, 1); ?>/>&nbsp;<?php _e('Hide on category pages.', 'wp-hide-post'); ?></label>
377
- <br />
378
- <label for="wplp_post_tag" class="selectit"><input type="checkbox" id="wplp_post_tag" name="wplp_post_tag" value="1"<?php checked($wplp_post_tag, 1); ?>/>&nbsp;<?php _e('Hide on tag pages.', 'wp-hide-post'); ?></label>
379
- <br />
380
- <label for="wplp_post_author" class="selectit"><input type="checkbox" id="wplp_post_author" name="wplp_post_author" value="1"<?php checked($wplp_post_author, 1); ?>/>&nbsp;<?php _e('Hide on author pages.', 'wp-hide-post'); ?></label>
381
- <br />
382
- <label for="wplp_post_archive" class="selectit"><input type="checkbox" id="wplp_post_archive" name="wplp_post_archive" value="1"<?php checked($wplp_post_archive, 1); ?>/>&nbsp;<?php _e('Hide in date archives (month, day, year, etc...)', 'wp-hide-post'); ?></label>
383
- <br />
384
- <label for="wplp_post_search" class="selectit"><input type="checkbox" id="wplp_post_search" name="wplp_post_search" value="1"<?php checked($wplp_post_search, 1); ?>/>&nbsp;<?php _e('Hide in search results.', 'wp-hide-post'); ?></label>
385
- <br />
386
- <label for="wplp_post_feed" class="selectit"><input type="checkbox" id="wplp_post_feed" name="wplp_post_feed" value="1"<?php checked($wplp_post_feed, 1); ?>/>&nbsp;<?php _e('Hide in feeds.', 'wp-hide-post'); ?></label>
387
- <br />
388
- <div style="float:right;font-size: xx-small;"><a href="http://anappleaday.konceptus.net/posts/wp-hide-post/#comments"><?php _e("Leave feedback and report bugs...", 'wp-hide-post'); ?></a></div>
389
- <br />
390
- <div style="float:right;font-size: xx-small;"><a href="http://wordpress.org/extend/plugins/wp-hide-post/"><?php _e("Give 'WP Hide Post' a good rating...", 'wp-hide-post'); ?></a></div>
391
- <br />
392
- <?php
393
- }
394
-
395
- /**
396
- *
397
- * @return unknown_type
398
- */
399
- function wphp_metabox_page_edit() {
400
- wphp_log("called: wphp_metabox_page_edit");
401
- global $wpdb;
402
-
403
- $id = isset($_GET['post']) ? intval($_GET['post']) : 0;
404
-
405
- $wplp_page = 'none';
406
- $wplp_page_search_show = 1;
407
-
408
- if($id > 0) {
409
- $flags = $wpdb->get_results("SELECT meta_value from ".WPHP_TABLE_NAME." where post_id = $id and meta_key = '_wplp_page_flags'", ARRAY_N);
410
- if( $flags )
411
- $wplp_page = $flags[0][0];
412
- $search = $wpdb->get_results("SELECT meta_value from ".WPHP_TABLE_NAME." where post_id = $id and meta_key = '_wplp_page_search'", ARRAY_N);
413
- if( $search )
414
- $wplp_page_search_show = ! $search[0][0];
415
- }
416
- ?>
417
- <label class="selectit"><input type="radio" id="wplp_page_none" name="wplp_page" value="none"<?php checked($wplp_page, 'none'); ?>/>&nbsp;<?php _e('Show normally everywhere.', 'wp-hide-post'); ?></label>
418
- <br />
419
- <br />
420
- <label class="selectit"><input type="radio" id="wplp_page_front" name="wplp_page" value="front"<?php checked($wplp_page, 'front'); ?>/>&nbsp;<?php _e('Hide when listing pages on the front page.', 'wp-hide-post'); ?></label>
421
- <br />
422
- <br />
423
- <label class="selectit"><input type="radio" id="wplp_page_all" name="wplp_page" value="all"<?php checked($wplp_page, 'all'); ?>/>&nbsp;<?php _e('Hide everywhere pages are listed.', 'wp-hide-post'); ?><sup>*</sup></label>
424
- <div style="height:18px;margin-left:20px">
425
- <div id="wplp_page_search_show_div"><label class="selectit"><input type="checkbox" id="wplp_page_search_show" name="wplp_page_search_show" value="1"<?php checked($wplp_page_search_show, 1); ?>/>&nbsp;<?php _e('Keep in search results.', 'wp-hide-post'); ?></label></div>
426
- </div>
427
- <br />
428
- <div style="float:right;clear:both;font-size:x-small;">* Will still show up in sitemap.xml if you generate one automatically. See <a href="http://anappleaday.konceptus.net/posts/wp-low-profiler/">details</a>.</div>
429
- <br />
430
- <br />
431
- <br />
432
- <div style="float:right;font-size: xx-small;"><a href="http://anappleaday.konceptus.net/posts/wp-hide-post/#comments"><?php _e("Leave feedback and report bugs...", 'wp-hide-post'); ?></a></div>
433
- <br />
434
- <div style="float:right;clear:both;font-size:xx-small;"><a href="http://wordpress.org/extend/plugins/wp-hide-post/"><?php _e("Give 'WP Hide Post' a good rating...", 'wp-hide-post'); ?></a></div>
435
- <br />
436
- <script type="text/javascript">
437
- <!--
438
- // toggle the wplp_page_search_show checkbox
439
- var wplp_page_search_show_callback = function () {
440
- if(jQuery("#wplp_page_all").is(":checked"))
441
- jQuery("#wplp_page_search_show_div").show();
442
- else
443
- jQuery("#wplp_page_search_show_div").hide();
444
- };
445
- jQuery("#wplp_page_all").change(wplp_page_search_show_callback);
446
- jQuery("#wplp_page_front").change(wplp_page_search_show_callback);
447
- jQuery("#wplp_page_none").change(wplp_page_search_show_callback);
448
- jQuery(document).ready( wplp_page_search_show_callback );
449
- //-->
450
- </script>
451
- <?php
452
- }
453
-
454
- /**
455
- *
456
- * @param $id
457
- * @return unknown_type
458
- */
459
- function wphp_save_post($id) {
460
- wphp_log("called: wphp_save_post");
461
- $item_type = get_post_type($id);
462
- if( $item_type == 'post' ) {
463
- $wplp_post_front = isset($_POST['wplp_post_front']) ? $_POST['wplp_post_front'] : 0;
464
- $wplp_post_category = isset($_POST['wplp_post_category']) ? $_POST['wplp_post_category'] : 0;
465
- $wplp_post_tag = isset($_POST['wplp_post_tag']) ? $_POST['wplp_post_tag'] : 0;
466
- $wplp_post_author = isset($_POST['wplp_post_author']) ? $_POST['wplp_post_author'] : 0;
467
- $wplp_post_archive = isset($_POST['wplp_post_archive']) ? $_POST['wplp_post_archive'] : 0;
468
- $wplp_post_search = isset($_POST['wplp_post_search']) ? $_POST['wplp_post_search'] : 0;
469
- $wplp_post_feed = isset($_POST['wplp_post_feed']) ? $_POST['wplp_post_feed'] : 0;
470
-
471
- wphp_update_low_profile($id, '_wplp_post_front', $wplp_post_front);
472
- wphp_update_low_profile($id, '_wplp_post_category', $wplp_post_category);
473
- wphp_update_low_profile($id, '_wplp_post_tag', $wplp_post_tag);
474
- wphp_update_low_profile($id, '_wplp_post_author', $wplp_post_author);
475
- wphp_update_low_profile($id, '_wplp_post_archive', $wplp_post_archive);
476
- wphp_update_low_profile($id, '_wplp_post_search', $wplp_post_search);
477
- wphp_update_low_profile($id, '_wplp_post_feed', $wplp_post_feed);
478
- } elseif( $item_type == 'page' ) {
479
- $wplp_page = isset($_POST['wplp_page']) ? $_POST['wplp_page'] : 'none';
480
- wphp_update_low_profile($id, "_wplp_page_flags", $wplp_page);
481
- if( $wplp_page == 'all' ) {
482
- $wplp_page_search_show = isset($_POST['wplp_page_search_show']) ? $_POST['wplp_page_search_show'] : 0;
483
- wphp_update_low_profile($id, "_wplp_page_search", ! $wplp_page_search_show);
484
- } else
485
- wphp_update_low_profile($id, "_wplp_page_search", 0);
486
- }
487
- }
488
- add_action('save_post', 'wphp_save_post');
489
-
490
- /**
491
- *
492
- * @param $post_id
493
- * @return unknown_type
494
- */
495
- function wphp_delete_post($post_id) {
496
- wphp_log("called: wphp_delete_post");
497
- global $wpdb;
498
- // Delete all post flags from the database table
499
- $wpdb->query("DELETE FROM ".WPHP_TABLE_NAME." WHERE post_id = $post_id and meta_key like '_wplp_%'");
500
- }
501
- add_action('delete_post', 'wphp_delete_post');
502
-
503
  /**
504
  *
505
  * @param $where
@@ -514,6 +196,7 @@ function wphp_query_posts_where($where) {
514
  //echo "\n<!-- WPHP: ".$where." -->\n";
515
  return $where;
516
  }
 
517
 
518
  /**
519
  *
@@ -556,21 +239,11 @@ function wphp_query_posts_join($join) {
556
  //echo "\n<!-- WPHP: ".$join." -->\n";
557
  return $join;
558
  }
559
- add_filter('posts_where_paged', 'wphp_query_posts_where');
560
  add_filter('posts_join_paged', 'wphp_query_posts_join');
561
 
562
 
563
- function plugin_install_action_links_wp_lowprofiler($action_links, $plugin) {
564
- wphp_log("called: plugin_install_action_links_wp_lowprofiler");
565
- if( $plugin['name'] == 'WP low Profiler' ) {
566
- $alt = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&amp;plugin=wp-hide-post&amp;TB_iframe=true&amp;width=600&amp;height=800') . '" class="thickbox onclick" title="WP Hide Post">' . __('Check "WP Hide Post"') . '</a>';
567
- $action_links = array(
568
- __('Deprecated'),
569
- $alt);
570
- }
571
- return $action_links;
572
  }
573
- add_filter('plugin_install_action_links', 'plugin_install_action_links_wp_lowprofiler', 10, 2);
574
-
575
 
576
  ?>
3
  Plugin Name: WP Hide Post
4
  Plugin URI: http://anappleaday.konceptus.net/posts/wp-hide-post/
5
  Description: Enables a user to control the visibility of items on the blog by making posts and pages selectively hidden in different views throughout the blog, such as on the front page, category pages, search results, etc... The hidden item remains otherwise accessible directly using permalinks, and also visible to search engines as part of the sitemap (at least). This plugin enables new SEO possibilities for authors since it enables them to create new posts and pages without being forced to display them on their front and in feeds.
6
+ Version: 1.1.0
7
  Author: Robert Mahfoud
8
  Author URI: http://anappleaday.konceptus.net
9
  Text Domain: wp_hide_post
128
  }
129
  add_action('init', 'wphp_textdomain');
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  /**
132
  * Hook called when activating the plugin
133
  * @return unknown_type
135
  function wphp_activate() {
136
  wphp_init();
137
  wphp_log("called: wphp_activate");
138
+
139
+ require_once(dirname(__FILE__).'/upgrade.php');
140
  wphp_migrate_db();
141
  wphp_remove_wp_low_profiler();
142
  }
143
  add_action('activate_wp-hide-post/wp-hide-post.php', 'wphp_activate' );
144
  //register_activation_hook( __FILE__, 'wphp_activate' );
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  /**
147
  *
148
  * @param $item_type
182
  }
183
  add_filter('get_pages', 'wphp_exclude_low_profile_pages');
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  /**
186
  *
187
  * @param $where
196
  //echo "\n<!-- WPHP: ".$where." -->\n";
197
  return $where;
198
  }
199
+ add_filter('posts_where_paged', 'wphp_query_posts_where');
200
 
201
  /**
202
  *
239
  //echo "\n<!-- WPHP: ".$join." -->\n";
240
  return $join;
241
  }
 
242
  add_filter('posts_join_paged', 'wphp_query_posts_join');
243
 
244
 
245
+ if( is_admin() ) {
246
+ require_once(dirname(__FILE__).'/admin.php');
 
 
 
 
 
 
 
247
  }
 
 
248
 
249
  ?>