WP Hide Post - Version 1.0.3

Version Description

Download this release

Release Info

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

Version 1.0.3

readme.txt ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WP Hide Post ===
2
+ 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.3
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
+
11
+ == Description ==
12
+
13
+ This plugin excels in giving you full control over the visibility of your a post. By default, any post you add to your WordPress blog will become the topmost post, and will show up immediately on the front page in the first position, and similarly in category/tag/archive pages. Sometimes, you want to create a "low-profile" addition to your blog that doesn't belong on the front page, or maybe you don't want it to show up anywhere else in your blog except when you explicitly link to it. This plugin allows you to create such "hidden gems".
14
+
15
+ In particular, this plugin allows you to control the visibility of a **post** in various different views:
16
+
17
+ * The Front Page (Homepage, depending on your theme, this may not be relevant)
18
+ * The Category Page (listing the posts belonging to a category)
19
+ * The Tag Page (listing the posts tagged with a given tag)
20
+ * The Authors Page (listing the posts belonging to an author)
21
+ * The Archive Pages (listing the posts belonging to time period: month, week, day, etc..)
22
+ * The Search Results
23
+ * Feeds
24
+
25
+ The posts will disappear from the places you choose them to disappear. Everywhere else they will show up as regular posts. In particular, permalinks of the posts still work, and if you generate a sitemap, with something like the [Google XML Sitemaps](http://wordpress.org/extend/plugins/google-sitemap-generator/) the post will be there as well. This means that the content of your post will be indexed and searchable by search engines.
26
+
27
+ For a WordPress **page**, this plugin also allows you to control the visibility with two options:
28
+
29
+ * Hide a page on the front page (homepage) only.
30
+ * Hide a page everywhere in the blog (hiding the page in the search results is optional).
31
+
32
+ This means, technically, whenever pages are listed somewhere using the `get_pages` filter, this plugin will kick in and either filter it out or not according to the options you choose. The same rules apply regarding permalinks and sitemaps as they do for regular posts.
33
+
34
+ "WP Hide Post" plugin is a great tool in your arsenal for SEO optimization. It allows you to add plenty of content to your blog, without forcing you to change the nature and presentation of your front page, for example. You can now create content that you otherwise would be reluctant to add to your blog because it would show immediately on the front page, or somewhere else where it would not belong. It's a must-have feature of WordPress.
35
+
36
+ Please enjoy this plugin freely, comment and rate it profusely, and send me feedback and any ideas for new features.
37
+
38
+ == Installation ==
39
+
40
+ 1. Upload the `wp-hide-post` folder to the `/wp-content/plugins/` directory
41
+ 1. Activate the plugin through the `Plugins` menu in WordPress
42
+ 1. That's it!! Now whenever you edit a post/page or create a new one, you will see a small panel on the bottom right of the screen that shows the applicable options.
43
+
44
+ == Frequently Asked Questions ==
45
+
46
+ = What does this plugin do? =
47
+
48
+ It enables you to create posts/pages that can be *hidden* (temporarily or permanently) from the homepage, feeds and/or other places. The post/page will remain accessible normally through other means, such as permalinks, archives, search, etc... and thus will remain visible to search engines.
49
+
50
+ = How can I make a post or a page private so that no one can see it? =
51
+
52
+ If you want to make a post/page completely private you don't need this plugin. WordPress supports options such as private and/or password-protected posts/pages out of the box.
53
+
54
+ = Can I make a post or a page *hidden* for a while, but then make it normal again? =
55
+
56
+ Yes. The *hidden* flags are just another set of attributes of a post/page. They can be added or removed at any time, just like editing anything else about the post.
57
+
58
+ = I have an idea to improve this feature further, what can I do? =
59
+
60
+ Please contact me on my blog [An Apple a Day](http://anappleaday.konceptus.net/posts/wp-hide-post/). I'm looking forward to hearing any suggestions.
61
+
62
+ = I just found something that doesn't look right, do I just sit on it? =
63
+
64
+ By all means no! Please report any bugs on my blog [An Apple a Day](http://anappleaday.konceptus.net/posts/wp-hide-post/). I'd really appreciate it. This is free software and I rely on the help of people like you to maintain it.
65
+
66
+ = I'm worried this could reduce my search engine ranking. Is it gonna? =
67
+
68
+ Not at all. On the contrary. All the content you include on your blog, even though it's not directly accessible from the homepage for example, it's still to be available when search engines crawl your site, and will remain linkable for those individuals that are interested in it. Furthermore, if you use some sitemap generation plugin (like the [Google XML Sitemaps](http://wordpress.org/extend/plugins/google-sitemap-generator/) plugin I use on my own [blog](http://anappleaday.konceptus.net/)) all the content will be published to web crawlers and will be picked up by search engines. In fact, this plugin will make your SEO more effective by allowing you to add content that you wouldn't otherwise want to show on your homepage.
69
+
70
+ = I used the 'WP low Profiler' plugin before. This one sounds just like it. =
71
+
72
+ This plugin is the new version of the 'WP low Profiler'. The name has been changed, but the functionality and codebase is identical. In fact, once you activate this plugin, it will upgrade the existing 'WP low Profiler' plugin and take its place. The last version of 'WP low Profiler', 2.0.3, corresponds to the first version of 'WP Hide Post', 1.0.3.
73
+
74
+ = I already have 'WP low Profiler' installed and activated. What's going to happen to it? =
75
+
76
+ 'WP Hide Post' will take the place of 'WP low Profiler'. Once 'WP Hide Post' is activated, 'WP low Profiler' is deactivated and deleted. All its data is imported first, so you won't loose any data.
77
+
78
+ = I already have 'WP low Profiler' installed but it's not activated. What's going to happen to it? =
79
+
80
+ Ditto. It will be deleted. If you had any existing data (if you had it active before) the data will persist.
81
+
82
+ = Why did you change the name of 'WP low Profiler' 'to WP Hide Post'? =
83
+
84
+ 'WP low Profiler' wasn't descriptive enough of the functionality of the plugin. Being 'low profile' could mean many things to many people. It was hard to find and many people who needed it didn't know it exists because of that.
85
+
86
+ == Screenshots ==
87
+
88
+ 1. Closup showing the *Visibility Attributes* for posts. [See Larger Version](http://anappleaday.konceptus.net/wp-content/uploads/screenshot-11.png)
89
+ 2. A small panel will appear whenever you are editing or creating a **post**. You can check one or more of the *Visibility Attributes* as needed. [See Larger Version](http://anappleaday.konceptus.net/wp-content/uploads/screenshot-21.png)
90
+ 3. Closup showing the *Visibility Attributes* for pages. [See Larger Version](http://anappleaday.konceptus.net/wp-content/uploads/screenshot-31.png)
91
+ 4. Another panel will appear whenever you are editing or creating a new **page**. You can check one or more of the *Visibility Attributes* as needed. Note that options for pages are different from those of posts. [See Larger Version](http://anappleaday.konceptus.net/wp-content/uploads/screenshot-41.png)
92
+
93
+ == Revision History ==
94
+
95
+ * 07/24/2009: v1.0.3 - Initial public release of 'WP Hide Post' and deprecation of 'WP low Profiler'
96
+
97
+ == Development Blog ==
98
+
99
+ Please visit the plugin page at [An Apple a Day](http://anappleaday.konceptus.net/posts/wp-hide-post/), and feel free to leave feedback, bug reports and comments.
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file
wp-hide-post.php ADDED
@@ -0,0 +1,574 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
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.3
7
+ Author: Robert Mahfoud
8
+ Author URI: http://anappleaday.konceptus.net
9
+ Text Domain: wp_hide_post
10
+ */
11
+
12
+ /* Copyright 2009 Robert Mahfoud (email : robert.mahfoud@gmail.com)
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation; either version 2 of the License, or
17
+ (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
+ */
28
+
29
+ /**
30
+ *
31
+ * @return unknown_type
32
+ */
33
+ function wphp_init() {
34
+ global $table_prefix;
35
+ if( !defined('WPHP_TABLE_NAME') )
36
+ define('WPHP_TABLE_NAME', "${table_prefix}postmeta");
37
+ if( !defined('WPHP_DEBUG') ) {
38
+ define('WPHP_DEBUG', defined('WP_DEBUG') && WP_DEBUG ? 1 : 0);
39
+ }
40
+ }
41
+ wphp_init();
42
+
43
+ /**
44
+ *
45
+ * @param $msg
46
+ * @return unknown_type
47
+ */
48
+ function wphp_log($msg) {
49
+ if( defined('WPHP_DEBUG') && WPHP_DEBUG )
50
+ error_log("WPHP-> $msg");
51
+ }
52
+
53
+ /**
54
+ *
55
+ * @return unknown_type
56
+ */
57
+ function wphp_is_front_page() {
58
+ return is_front_page();
59
+ }
60
+
61
+ /**
62
+ *
63
+ * @return unknown_type
64
+ */
65
+ function wphp_is_feed() {
66
+ return is_feed();
67
+ }
68
+
69
+ /**
70
+ *
71
+ * @return unknown_type
72
+ */
73
+ function wphp_is_category() {
74
+ return !wphp_is_front_page() && !wphp_is_feed() && is_category();
75
+ }
76
+
77
+ /**
78
+ *
79
+ * @return unknown_type
80
+ */
81
+ function wphp_is_tag() {
82
+ return !wphp_is_front_page() && !wphp_is_feed() && is_tag();
83
+ }
84
+
85
+ /**
86
+ *
87
+ * @return unknown_type
88
+ */
89
+ function wphp_is_author() {
90
+ return !wphp_is_front_page() && !wphp_is_feed() && is_author();
91
+ }
92
+
93
+ /**
94
+ *
95
+ * @return unknown_type
96
+ */
97
+ function wphp_is_archive() {
98
+ return !wphp_is_front_page() && !wphp_is_feed() && is_date();
99
+ }
100
+
101
+ /**
102
+ *
103
+ * @return unknown_type
104
+ */
105
+ function wphp_is_search() {
106
+ return is_search();
107
+ }
108
+
109
+ /**
110
+ *
111
+ * @param $item_type
112
+ * @return unknown_type
113
+ */
114
+ function wphp_is_applicable($item_type) {
115
+ return !is_admin() && (($item_type == 'post' && !is_single()) || $item_type == 'page') ;
116
+ }
117
+
118
+
119
+ /**
120
+ * Creates Text Domain For Translations
121
+ * @return unknown_type
122
+ */
123
+ function wphp_textdomain() {
124
+ $plugin_dir = basename(dirname(__FILE__));
125
+ load_plugin_textdomain('wp-hide-post', ABSPATH."/$plugin_dir", $plugin_dir);
126
+ }
127
+ add_action('init', 'wphp_textdomain');
128
+
129
+ /**
130
+ * Migrate to the new database schema and clean up old schema...
131
+ * Should run only once in the lifetime of the plugin...
132
+ * @return unknown_type
133
+ */
134
+ function wphp_migrate_db() {
135
+ wphp_log("called: wphp_migrate_db");
136
+ /* When I first released this plugin, I was young and crazy and didn't know about the postmeta table.
137
+ * With time I became wiser and wiser and decided to migrate the implementation to rely on postmeta.
138
+ * I hope it was not a bad idea...
139
+ */
140
+ global $wpdb;
141
+ global $table_prefix;
142
+ $dbname = $wpdb->get_var("SELECT database()");
143
+ if( !$dbname )
144
+ return;
145
+ $legacy_table_name = "${table_prefix}lowprofiler_posts";
146
+ $legacy_table_exists = $wpdb->get_var("SELECT COUNT(*) AS count FROM information_schema.tables WHERE table_schema = '$dbname' AND table_name = '$legacy_table_name';");
147
+ if( $legacy_table_exists ) {
148
+ wphp_log("Migrating legacy table...");
149
+ // move everything to the postmeta table
150
+ $existing = $wpdb->get_results("SELECT wplp_post_id, wplp_flag, wplp_value from $legacy_table_name", ARRAY_N);
151
+ // scan them one by one and insert the corresponding fields in the postmeta table
152
+ $count = 0;
153
+ foreach($existing as $existing_array) {
154
+ $wplp_post_id = $existing_array[0];
155
+ $wplp_flag = $existing_array[1];
156
+ $wplp_value = $existing_array[2];
157
+ if( $wplp_flag == 'home' )
158
+ $wplp_flag = 'front';
159
+ if( $wplp_value == 'home' )
160
+ $wplp_value = 'front';
161
+ if( $wplp_flag != 'page' ) {
162
+ $wpdb->query("INSERT INTO ".WPHP_TABLE_NAME."(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_post_$wplp_flag', '1')");
163
+ } else {
164
+ $wpdb->query("INSERT INTO ".WPHP_TABLE_NAME."(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_page_flags', $wplp_value)");
165
+ }
166
+ ++$count;
167
+ }
168
+ wphp_log("$count entries migrated from legacy table.");
169
+ // delete the old table
170
+ $wpdb->query("TRUNCATE TABLE $legacy_table_name");
171
+ $wpdb->query("DROP TABLE $legacy_table_name");
172
+ wphp_log("Legacy table deleted.");
173
+ }
174
+ }
175
+
176
+
177
+ /**
178
+ *
179
+ * @return unknown_type
180
+ */
181
+ function wphp_remove_wp_low_profiler() {
182
+ wphp_log("called: wphp_remove_wp_low_profiler");
183
+ $plugin_list = get_plugins('/wp-low-profiler');
184
+ if( isset($plugin_list['wp-low-profiler.php']) ) {
185
+ wphp_log("The 'WP low Profiler' plugin is present. Cleaning it up...");
186
+ $plugins = array('wp-low-profiler/wp-low-profiler.php');
187
+ if( is_plugin_active('wp-low-profiler/wp-low-profiler.php') ) {
188
+ wphp_log("The 'WP low Profiler' plugin is active. Deactivating...");
189
+ deactivate_plugins($plugins, true); // silent deactivate
190
+ }
191
+ wphp_log("Deleting plugin 'WP low Profiler'...");
192
+ delete_plugins($plugins, '');
193
+ } else
194
+ wphp_log("The 'WP low Profiler' plugin does not exist.");
195
+
196
+ }
197
+
198
+
199
+ /**
200
+ * Hook called when activating the plugin
201
+ * @return unknown_type
202
+ */
203
+ function wphp_activate() {
204
+ wphp_init();
205
+ wphp_log("called: wphp_activate");
206
+ wphp_migrate_db();
207
+ wphp_remove_wp_low_profiler();
208
+ }
209
+ add_action('activate_wp-hide-post/wp-hide-post.php', 'wphp_activate' );
210
+ //register_activation_hook( __FILE__, 'wphp_activate' );
211
+
212
+
213
+
214
+ /**
215
+ * Hook to watch for the activation of 'WP low Profiler', and forbid it...
216
+ * @return unknown_type
217
+ */
218
+ function wphp_activate_lowprofiler() {
219
+ wphp_log("called: wphp_activate_lowprofiler");
220
+ wphp_migrate_db(); // in case any tables were created, clean them up
221
+ wphp_remove_wp_low_profiler(); // remove the files of the plugin
222
+
223
+ $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');
224
+ $err1_sorry = __("Cannot install 'WP low Profiler' because of a conflict. Sorry for this inconvenience.", 'wp-hide-post');
225
+ $err2_cleanup = __("The downloaded files were cleaned-up and no further action is required.", 'wp-hide-post');
226
+ $err3_return = __("Return to plugins page...", 'wp-hide-post');
227
+ $return_url = admin_url('plugins.php');
228
+
229
+ $html = <<<HTML
230
+ ${err1_sorry}<br />${err2_cleanup}<br /><a href="${$return_url}">${err3_return}</a>
231
+ <script language="javascript">window.alert("${msgbox}");</script>
232
+ HTML;
233
+ // show the error page with the message...
234
+ wp_die($html, 'WP low Profiler Activation Not Allowed', array( 'response' => '200') );
235
+ }
236
+ add_action('activate_wp-low-profiler/wp-low-profiler.php', 'wphp_activate_lowprofiler' );
237
+
238
+
239
+ /**
240
+ *
241
+ * @param $id
242
+ * @param $lp_flag
243
+ * @param $lp_value
244
+ * @return unknown_type
245
+ */
246
+ function wphp_update_low_profile($id, $lp_flag, $lp_value) {
247
+ wphp_log("called: wphp_update_low_profile");
248
+ global $wpdb;
249
+ $item_type = get_post_type($id);
250
+ if( ($item_type == 'post' && !$lp_value) || ($item_type == 'page' && ( ($lp_flag == '_wplp_page_flags' && $lp_value == 'none') || ($lp_flag == '_wplp_page_search' && !$lp_value) ) ) ) {
251
+ wphp_unset_low_profile($item_type, $id, $lp_flag);
252
+ } else {
253
+ wphp_set_low_profile($item_type, $id, $lp_flag, $lp_value);
254
+ }
255
+ }
256
+
257
+ /**
258
+ *
259
+ * @param $item_type
260
+ * @param $id
261
+ * @param $lp_flag
262
+ * @return unknown_type
263
+ */
264
+ function wphp_unset_low_profile($item_type, $id, $lp_flag) {
265
+ wphp_log("called: wphp_unset_low_profile");
266
+ global $wpdb;
267
+ // Delete the flag from the database table
268
+ $wpdb->query("DELETE FROM ".WPHP_TABLE_NAME." WHERE post_id = $id AND meta_key = '$lp_flag'");
269
+ }
270
+
271
+ /**
272
+ *
273
+ * @param $item_type
274
+ * @param $id
275
+ * @param $lp_flag
276
+ * @param $lp_value
277
+ * @return unknown_type
278
+ */
279
+ function wphp_set_low_profile($item_type, $id, $lp_flag, $lp_value) {
280
+ wphp_log("called: wphp_set_low_profile");
281
+ global $wpdb;
282
+ // Ensure No Duplicates!
283
+ $check = $wpdb->get_var("SELECT count(*) FROM ".WPHP_TABLE_NAME." WHERE post_id = $id AND meta_key='$lp_flag'");
284
+ error_log("Check: $check");
285
+ if(!$check) {
286
+ $wpdb->query("INSERT INTO ".WPHP_TABLE_NAME."(post_id, meta_key, meta_value) VALUES($id, '$lp_flag', '$lp_value')");
287
+ } elseif( $item_type == 'page' && $lp_flag == "_wplp_page_flags" ) {
288
+ $wpdb->query("UPDATE ".WPHP_TABLE_NAME." set meta_value = '$lp_value' WHERE post_id = $id and meta_key = '$lp_flag'");
289
+ }
290
+ }
291
+
292
+ /**
293
+ *
294
+ * @param $item_type
295
+ * @param $posts
296
+ * @return unknown_type
297
+ */
298
+ function wphp_exclude_low_profile_items($item_type, $posts) {
299
+ wphp_log("called: wphp_exclude_low_profile_items");
300
+ if( $item_type != 'page' )
301
+ return $posts; // regular posts & search results are filtered in wphp_query_posts_join
302
+ else {
303
+ if( wphp_is_applicable('page') ) {
304
+ global $wpdb;
305
+ // now loop over the pages, and exclude the ones with low profile in this context
306
+ $result = array();
307
+ foreach($posts as $post) {
308
+ $check = strval($wpdb->get_var("SELECT meta_value FROM ".WPHP_TABLE_NAME." WHERE post_id = $post->ID and meta_key = '_wplp_page_flags'"));
309
+ if( ($check == 'front' && wphp_is_front_page()) || $check == 'all') {
310
+ // exclude page
311
+ } else
312
+ $result[] = $post;
313
+ }
314
+ return $result;
315
+ } else
316
+ return $posts;
317
+ }
318
+ }
319
+
320
+ /**
321
+ * Hook function to filter out hidden pages (get_pages)
322
+ * @param $posts
323
+ * @return unknown_type
324
+ */
325
+ function wphp_exclude_low_profile_pages($posts) {
326
+ wphp_log("called: wphp_exclude_low_profile_pages");
327
+ return wphp_exclude_low_profile_items('page', $posts);
328
+ }
329
+ add_filter('get_pages', 'wphp_exclude_low_profile_pages');
330
+
331
+ /**
332
+ *
333
+ * @return unknown_type
334
+ */
335
+ function wphp_add_post_edit_meta_box() {
336
+ wphp_log("called: wphp_add_post_edit_meta_box");
337
+ add_meta_box('hidepostdivpost', __('Post Visibility', 'wp-hide-post'), 'wphp_metabox_post_edit', 'post', 'side');
338
+ add_meta_box('hidepostdivpage', __('Page Visibility', 'wp-hide-post'), 'wphp_metabox_page_edit', 'page', 'side');
339
+ }
340
+ add_action('admin_menu', 'wphp_add_post_edit_meta_box');
341
+
342
+ /**
343
+ *
344
+ * @return unknown_type
345
+ */
346
+ function wphp_metabox_post_edit() {
347
+ wphp_log("called: wphp_metabox_post_edit");
348
+ global $wpdb;
349
+
350
+ $id = isset($_GET['post']) ? intval($_GET['post']) : 0;
351
+
352
+ $wplp_post_front = 0;
353
+ $wplp_post_category = 0;
354
+ $wplp_post_tag = 0;
355
+ $wplp_post_author = 0;
356
+ $wplp_post_archive = 0;
357
+ $wplp_post_search = 0;
358
+ $wplp_post_feed = 0;
359
+
360
+ if($id > 0) {
361
+ $flags = $wpdb->get_results("SELECT meta_key from ".WPHP_TABLE_NAME." where post_id = $id and meta_key like '_wplp_%'", ARRAY_N);
362
+ if( $flags ) {
363
+ foreach($flags as $flag_array) {
364
+ $flag = $flag_array[0];
365
+ // remove the leading _
366
+ $flag = substr($flag, 1, strlen($flag)-1);
367
+ ${$flag} = 1;
368
+ }
369
+ }
370
+ }
371
+ ?>
372
+ <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>
373
+ <br />
374
+ <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>
375
+ <br />
376
+ <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>
377
+ <br />
378
+ <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>
379
+ <br />
380
+ <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>
381
+ <br />
382
+ <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>
383
+ <br />
384
+ <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>
385
+ <br />
386
+ <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>
387
+ <br />
388
+ <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>
389
+ <br />
390
+ <?php
391
+ }
392
+
393
+ /**
394
+ *
395
+ * @return unknown_type
396
+ */
397
+ function wphp_metabox_page_edit() {
398
+ wphp_log("called: wphp_metabox_page_edit");
399
+ global $wpdb;
400
+
401
+ $id = isset($_GET['post']) ? intval($_GET['post']) : 0;
402
+
403
+ $wplp_page = 'none';
404
+ $wplp_page_search_show = 1;
405
+
406
+ if($id > 0) {
407
+ $flags = $wpdb->get_results("SELECT meta_value from ".WPHP_TABLE_NAME." where post_id = $id and meta_key = '_wplp_page_flags'", ARRAY_N);
408
+ if( $flags )
409
+ $wplp_page = $flags[0][0];
410
+ $search = $wpdb->get_results("SELECT meta_value from ".WPHP_TABLE_NAME." where post_id = $id and meta_key = '_wplp_page_search'", ARRAY_N);
411
+ if( $search )
412
+ $wplp_page_search_show = ! $search[0][0];
413
+ }
414
+ ?>
415
+ <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>
416
+ <br />
417
+ <br />
418
+ <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>
419
+ <br />
420
+ <br />
421
+ <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>
422
+ <div style="height:18px;margin-left:20px">
423
+ <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>
424
+ </div>
425
+ <br />
426
+ <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>
427
+ <br />
428
+ <br />
429
+ <br />
430
+ <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>
431
+ <br />
432
+ <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>
433
+ <br />
434
+ <script type="text/javascript">
435
+ <!--
436
+ // toggle the wplp_page_search_show checkbox
437
+ var wplp_page_search_show_callback = function () {
438
+ if(jQuery("#wplp_page_all").is(":checked"))
439
+ jQuery("#wplp_page_search_show_div").show();
440
+ else
441
+ jQuery("#wplp_page_search_show_div").hide();
442
+ };
443
+ jQuery("#wplp_page_all").change(wplp_page_search_show_callback);
444
+ jQuery("#wplp_page_front").change(wplp_page_search_show_callback);
445
+ jQuery("#wplp_page_none").change(wplp_page_search_show_callback);
446
+ jQuery(document).ready( wplp_page_search_show_callback );
447
+ //-->
448
+ </script>
449
+ <?php
450
+ }
451
+
452
+ /**
453
+ *
454
+ * @param $id
455
+ * @return unknown_type
456
+ */
457
+ function wphp_save_post($id) {
458
+ wphp_log("called: wphp_save_post");
459
+ $item_type = get_post_type($id);
460
+ if( $item_type == 'post' ) {
461
+ $wplp_post_front = isset($_POST['wplp_post_front']) ? $_POST['wplp_post_front'] : 0;
462
+ $wplp_post_category = isset($_POST['wplp_post_category']) ? $_POST['wplp_post_category'] : 0;
463
+ $wplp_post_tag = isset($_POST['wplp_post_tag']) ? $_POST['wplp_post_tag'] : 0;
464
+ $wplp_post_author = isset($_POST['wplp_post_author']) ? $_POST['wplp_post_author'] : 0;
465
+ $wplp_post_archive = isset($_POST['wplp_post_archive']) ? $_POST['wplp_post_archive'] : 0;
466
+ $wplp_post_search = isset($_POST['wplp_post_search']) ? $_POST['wplp_post_search'] : 0;
467
+ $wplp_post_feed = isset($_POST['wplp_post_feed']) ? $_POST['wplp_post_feed'] : 0;
468
+
469
+ wphp_update_low_profile($id, '_wplp_post_front', $wplp_post_front);
470
+ wphp_update_low_profile($id, '_wplp_post_category', $wplp_post_category);
471
+ wphp_update_low_profile($id, '_wplp_post_tag', $wplp_post_tag);
472
+ wphp_update_low_profile($id, '_wplp_post_author', $wplp_post_author);
473
+ wphp_update_low_profile($id, '_wplp_post_archive', $wplp_post_archive);
474
+ wphp_update_low_profile($id, '_wplp_post_search', $wplp_post_search);
475
+ wphp_update_low_profile($id, '_wplp_post_feed', $wplp_post_feed);
476
+ } elseif( $item_type == 'page' ) {
477
+ $wplp_page = isset($_POST['wplp_page']) ? $_POST['wplp_page'] : 'none';
478
+ wphp_update_low_profile($id, "_wplp_page_flags", $wplp_page);
479
+ if( $wplp_page == 'all' ) {
480
+ $wplp_page_search_show = isset($_POST['wplp_page_search_show']) ? $_POST['wplp_page_search_show'] : 0;
481
+ wphp_update_low_profile($id, "_wplp_page_search", ! $wplp_page_search_show);
482
+ } else
483
+ wphp_update_low_profile($id, "_wplp_page_search", 0);
484
+ }
485
+ }
486
+ add_action('save_post', 'wphp_save_post');
487
+
488
+ /**
489
+ *
490
+ * @param $post_id
491
+ * @return unknown_type
492
+ */
493
+ function wphp_delete_post($post_id) {
494
+ wphp_log("called: wphp_delete_post");
495
+ global $wpdb;
496
+ // Delete all post flags from the database table
497
+ $wpdb->query("DELETE FROM ".WPHP_TABLE_NAME." WHERE post_id = $post_id and meta_key like '_wplp_%'");
498
+ }
499
+ add_action('delete_post', 'wphp_delete_post');
500
+
501
+ /**
502
+ *
503
+ * @param $where
504
+ * @return unknown_type
505
+ */
506
+ function wphp_query_posts_where($where) {
507
+ wphp_log("called: wphp_query_posts_where");
508
+ // filter posts on one of the three kinds of contexts: front, category, feed
509
+ if( wphp_is_applicable('post') && wphp_is_applicable('page') ) {
510
+ $where .= ' AND wphptbl.post_id IS NULL ';
511
+ }
512
+ //echo "\n<!-- WPHP: ".$where." -->\n";
513
+ return $where;
514
+ }
515
+
516
+ /**
517
+ *
518
+ * @param $join
519
+ * @return unknown_type
520
+ */
521
+ function wphp_query_posts_join($join) {
522
+ wphp_log("called: wphp_query_posts_join");
523
+ if( wphp_is_applicable('post') && wphp_is_applicable('page')) {
524
+ if( !$join )
525
+ $join = '';
526
+ $join .= ' LEFT JOIN '.WPHP_TABLE_NAME.' wphptbl ON wp_posts.ID = wphptbl.post_id and wphptbl.meta_key like \'_wplp_%\'';
527
+ // filter posts
528
+ $join .= ' AND ((wp_posts.post_type = \'post\' ';
529
+ if( wphp_is_front_page() )
530
+ $join .= ' AND wphptbl.meta_key = \'_wplp_post_front\' ';
531
+ elseif( wphp_is_category())
532
+ $join .= ' AND wphptbl.meta_key = \'_wplp_post_category\' ';
533
+ elseif( wphp_is_tag() )
534
+ $join .= ' AND wphptbl.meta_key = \'_wplp_post_tag\' ';
535
+ elseif( wphp_is_author() )
536
+ $join .= ' AND wphptbl.meta_key = \'_wplp_post_author\' ';
537
+ elseif( wphp_is_archive() )
538
+ $join .= ' AND wphptbl.meta_key = \'_wplp_post_archive\' ';
539
+ elseif( wphp_is_feed())
540
+ $join .= ' AND wphptbl.meta_key = \'_wplp_post_feed\' ';
541
+ elseif( wphp_is_search())
542
+ $join .= ' AND wphptbl.meta_key = \'_wplp_post_search\' ';
543
+ else
544
+ $join .= ' AND wphptbl.meta_key not like \'_wplp_%\' ';
545
+ $join .= ')';
546
+ // pages
547
+ $join .= ' OR (wp_posts.post_type = \'page\' AND wphptbl.meta_key <> \'_wplp_page_flags\'';
548
+ if( wphp_is_search())
549
+ $join .= ' AND wphptbl.meta_key = \'_wplp_page_search\' ';
550
+ else
551
+ $join .= ' AND wphptbl.meta_key not like \'_wplp_%\' ';
552
+ $join .= '))';
553
+ }
554
+ //echo "\n<!-- WPHP: ".$join." -->\n";
555
+ return $join;
556
+ }
557
+ add_filter('posts_where_paged', 'wphp_query_posts_where');
558
+ add_filter('posts_join_paged', 'wphp_query_posts_join');
559
+
560
+
561
+ function plugin_install_action_links_wp_lowprofiler($action_links, $plugin) {
562
+ wphp_log("called: plugin_install_action_links_wp_lowprofiler");
563
+ if( $plugin['name'] == 'WP low Profiler' ) {
564
+ $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>';
565
+ $action_links = array(
566
+ __('Deprecated'),
567
+ $alt);
568
+ }
569
+ return $action_links;
570
+ }
571
+ add_filter('plugin_install_action_links', 'plugin_install_action_links_wp_lowprofiler', 10, 2);
572
+
573
+
574
+ ?>
wp-hide-post.pot ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR Robert Mahfoud
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/wp-hide-post\n"
11
+ "POT-Creation-Date: 2009-07-24 08:52+0000\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=CHARSET\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+
19
+ #: wp-hide-post.php:223
20
+ msgid ""
21
+ "'WP low Profiler' has been deprecated and replaced by 'WP Hide Post' which "
22
+ "you already have active! Activation failed and plugin files cleaned up."
23
+ msgstr ""
24
+
25
+ #: wp-hide-post.php:224
26
+ msgid ""
27
+ "Cannot install 'WP low Profiler' because of a conflict. Sorry for this "
28
+ "inconvenience."
29
+ msgstr ""
30
+
31
+ #: wp-hide-post.php:225
32
+ msgid "The downloaded files were cleaned-up and no further action is required."
33
+ msgstr ""
34
+
35
+ #: wp-hide-post.php:226
36
+ msgid "Return to plugins page..."
37
+ msgstr ""
38
+
39
+ #: wp-hide-post.php:337
40
+ msgid "Post Visibility"
41
+ msgstr ""
42
+
43
+ #: wp-hide-post.php:338
44
+ msgid "Page Visibility"
45
+ msgstr ""
46
+
47
+ #: wp-hide-post.php:372
48
+ msgid "Hide on the front page."
49
+ msgstr ""
50
+
51
+ #: wp-hide-post.php:374
52
+ msgid "Hide on category pages."
53
+ msgstr ""
54
+
55
+ #: wp-hide-post.php:376
56
+ msgid "Hide on tag pages."
57
+ msgstr ""
58
+
59
+ #: wp-hide-post.php:378
60
+ msgid "Hide on author pages."
61
+ msgstr ""
62
+
63
+ #: wp-hide-post.php:380
64
+ msgid "Hide in date archives (month, day, year, etc...)"
65
+ msgstr ""
66
+
67
+ #: wp-hide-post.php:382
68
+ msgid "Hide in search results."
69
+ msgstr ""
70
+
71
+ #: wp-hide-post.php:384
72
+ msgid "Hide in feeds."
73
+ msgstr ""
74
+
75
+ #: wp-hide-post.php:386 wp-hide-post.php:430
76
+ msgid "Leave feedback and report bugs..."
77
+ msgstr ""
78
+
79
+ #: wp-hide-post.php:388 wp-hide-post.php:432
80
+ msgid "Give 'WP Hide Post' a good rating..."
81
+ msgstr ""
82
+
83
+ #: wp-hide-post.php:415
84
+ msgid "Show normally everywhere."
85
+ msgstr ""
86
+
87
+ #: wp-hide-post.php:418
88
+ msgid "Hide when listing pages on the front page."
89
+ msgstr ""
90
+
91
+ #: wp-hide-post.php:421
92
+ msgid "Hide everywhere pages are listed."
93
+ msgstr ""
94
+
95
+ #: wp-hide-post.php:423
96
+ msgid "Keep in search results."
97
+ msgstr ""
98
+
99
+ #: wp-hide-post.php:564
100
+ msgid "Check \"WP Hide Post\""
101
+ msgstr ""
102
+
103
+ #: wp-hide-post.php:566
104
+ msgid "Deprecated"
105
+ msgstr ""
106
+
107
+ #. Plugin Name of an extension
108
+ msgid "WP Hide Post"
109
+ msgstr ""
110
+
111
+ #. Plugin URI of an extension
112
+ msgid "http://anappleaday.konceptus.net/posts/wp-hide-post/"
113
+ msgstr ""
114
+
115
+ #. Description of an extension
116
+ msgid ""
117
+ "Enables a user to control the visibility of items on the blog by making "
118
+ "posts and pages selectively hidden in different views throughout the blog, "
119
+ "such as on the front page, category pages, search results, etc... The hidden "
120
+ "item remains otherwise accessible directly using permalinks, and also "
121
+ "visible to search engines as part of the sitemap (at least). This plugin "
122
+ "enables new SEO possibilities for authors since it enables them to create "
123
+ "new posts and pages without being forced to display them on their front and "
124
+ "in feeds."
125
+ msgstr ""
126
+
127
+ #. Author of an extension
128
+ msgid "Robert Mahfoud"
129
+ msgstr ""
130
+
131
+ #. Author URI of an extension
132
+ msgid "http://anappleaday.konceptus.net"
133
+ msgstr ""