Version Description
Download this release
Release Info
Developer | rmahfoud |
Plugin | WP Hide Post |
Version | 1.1.2 |
Comparing to | |
See all releases |
Code changes from version 1.1.1 to 1.1.2
- admin.php +0 -298
- readme.txt +2 -1
- wp-hide-post.php +289 -4
admin.php
DELETED
@@ -1,298 +0,0 @@
|
|
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&plugin=wp-hide-post&TB_iframe=true&width=600&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); ?>/> <?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); ?>/> <?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); ?>/> <?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); ?>/> <?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); ?>/> <?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); ?>/> <?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); ?>/> <?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'); ?>/> <?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'); ?>/> <?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'); ?>/> <?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); ?>/> <?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
@@ -4,7 +4,7 @@ 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.
|
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 |
* 08/05/2009: v1.1.1 - Reduce the number of SQL queries to hide pages to a single queries for all pages, rather than one query per page.
|
96 |
* 08/04/2009: v1.1.0 - Bug fix: bulk update clears "Visibility Attributes". Split code into separate files.
|
97 |
* 07/24/2009: v1.0.4 - Minor bug fixes
|
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.2
|
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/07/2009: v1.1.2 - Bug fixes.
|
96 |
* 08/05/2009: v1.1.1 - Reduce the number of SQL queries to hide pages to a single queries for all pages, rather than one query per page.
|
97 |
* 08/04/2009: v1.1.0 - Bug fix: bulk update clears "Visibility Attributes". Split code into separate files.
|
98 |
* 07/24/2009: v1.0.4 - Minor bug fixes
|
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.1.
|
7 |
Author: Robert Mahfoud
|
8 |
Author URI: http://anappleaday.konceptus.net
|
9 |
Text Domain: wp_hide_post
|
@@ -37,7 +37,7 @@ function wphp_init() {
|
|
37 |
if( !defined('WP_POSTS_TABLE_NAME') )
|
38 |
define('WP_POSTS_TABLE_NAME', "${table_prefix}posts");
|
39 |
if( !defined('WPHP_DEBUG') ) {
|
40 |
-
define('WPHP_DEBUG', defined('WP_DEBUG') && WP_DEBUG ? 1 :
|
41 |
}
|
42 |
}
|
43 |
wphp_init();
|
@@ -118,6 +118,13 @@ function wphp_is_applicable($item_type) {
|
|
118 |
}
|
119 |
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
/**
|
122 |
* Creates Text Domain For Translations
|
123 |
* @return unknown_type
|
@@ -243,8 +250,286 @@ function wphp_query_posts_join($join) {
|
|
243 |
add_filter('posts_join_paged', 'wphp_query_posts_join');
|
244 |
|
245 |
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
}
|
|
|
249 |
|
250 |
?>
|
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.2
|
7 |
Author: Robert Mahfoud
|
8 |
Author URI: http://anappleaday.konceptus.net
|
9 |
Text Domain: wp_hide_post
|
37 |
if( !defined('WP_POSTS_TABLE_NAME') )
|
38 |
define('WP_POSTS_TABLE_NAME', "${table_prefix}posts");
|
39 |
if( !defined('WPHP_DEBUG') ) {
|
40 |
+
define('WPHP_DEBUG', defined('WP_DEBUG') && WP_DEBUG ? 1 : 1);
|
41 |
}
|
42 |
}
|
43 |
wphp_init();
|
118 |
}
|
119 |
|
120 |
|
121 |
+
function _wphp_http_post($var, $default = null) {
|
122 |
+
if( isset($_POST[$var]) )
|
123 |
+
return $_POST[$var];
|
124 |
+
else
|
125 |
+
return $default;
|
126 |
+
}
|
127 |
+
|
128 |
/**
|
129 |
* Creates Text Domain For Translations
|
130 |
* @return unknown_type
|
250 |
add_filter('posts_join_paged', 'wphp_query_posts_join');
|
251 |
|
252 |
|
253 |
+
/*********************
|
254 |
+
* ADMIN FUNCTIONS
|
255 |
+
*********************/
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Hook to watch for the activation of 'WP low Profiler', and forbid it...
|
259 |
+
* @return unknown_type
|
260 |
+
*/
|
261 |
+
function wphp_activate_lowprofiler() {
|
262 |
+
wphp_log("called: wphp_activate_lowprofiler");
|
263 |
+
require_once(dirname(__FILE__).'/upgrade.php');
|
264 |
+
wphp_migrate_db(); // in case any tables were created, clean them up
|
265 |
+
wphp_remove_wp_low_profiler(); // remove the files of the plugin
|
266 |
+
|
267 |
+
$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');
|
268 |
+
$err1_sorry = __("Cannot install 'WP low Profiler' because of a conflict. Sorry for this inconvenience.", 'wp-hide-post');
|
269 |
+
$err2_cleanup = __("The downloaded files were cleaned-up and no further action is required.", 'wp-hide-post');
|
270 |
+
$err3_return = __("Return to plugins page...", 'wp-hide-post');
|
271 |
+
$return_url = admin_url('plugins.php');
|
272 |
+
|
273 |
+
$html = <<<HTML
|
274 |
+
${err1_sorry}<br />${err2_cleanup}<br /><a href="${$return_url}">${err3_return}</a>
|
275 |
+
<script language="javascript">window.alert("${msgbox}");</script>
|
276 |
+
HTML;
|
277 |
+
// show the error page with the message...
|
278 |
+
wp_die($html, 'WP low Profiler Activation Not Allowed', array( 'response' => '200') );
|
279 |
+
}
|
280 |
+
add_action('activate_wp-low-profiler/wp-low-profiler.php', 'wphp_activate_lowprofiler' );
|
281 |
+
|
282 |
+
/**
|
283 |
+
* @param $action_links
|
284 |
+
* @param $plugin
|
285 |
+
* @return unknown_type
|
286 |
+
*/
|
287 |
+
function plugin_install_action_links_wp_lowprofiler($action_links, $plugin) {
|
288 |
+
wphp_log("called: plugin_install_action_links_wp_lowprofiler");
|
289 |
+
if( $plugin['name'] == 'WP low Profiler' ) {
|
290 |
+
$alt = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&plugin=wp-hide-post&TB_iframe=true&width=600&height=800') . '" class="thickbox onclick" title="WP Hide Post">' . __('Check "WP Hide Post"') . '</a>';
|
291 |
+
$action_links = array(
|
292 |
+
__('Deprecated'),
|
293 |
+
$alt);
|
294 |
+
}
|
295 |
+
return $action_links;
|
296 |
+
}
|
297 |
+
add_filter('plugin_install_action_links', 'plugin_install_action_links_wp_lowprofiler', 10, 2);
|
298 |
+
|
299 |
+
/**
|
300 |
+
*
|
301 |
+
* @param $id
|
302 |
+
* @param $lp_flag
|
303 |
+
* @param $lp_value
|
304 |
+
* @return unknown_type
|
305 |
+
*/
|
306 |
+
function wphp_update_visibility($id, $lp_flag, $lp_value) {
|
307 |
+
wphp_log("called: wphp_update_visibility");
|
308 |
+
global $wpdb;
|
309 |
+
$item_type = get_post_type($id);
|
310 |
+
if( ($item_type == 'post' && !$lp_value) || ($item_type == 'page' && ( ($lp_flag == '_wplp_page_flags' && $lp_value == 'none') || ($lp_flag == '_wplp_page_search' && !$lp_value) ) ) ) {
|
311 |
+
wphp_unset_low_profile($item_type, $id, $lp_flag);
|
312 |
+
} else {
|
313 |
+
wphp_set_low_profile($item_type, $id, $lp_flag, $lp_value);
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
*
|
319 |
+
* @param $item_type
|
320 |
+
* @param $id
|
321 |
+
* @param $lp_flag
|
322 |
+
* @return unknown_type
|
323 |
+
*/
|
324 |
+
function wphp_unset_low_profile($item_type, $id, $lp_flag) {
|
325 |
+
wphp_log("called: wphp_unset_low_profile");
|
326 |
+
global $wpdb;
|
327 |
+
// Delete the flag from the database table
|
328 |
+
$wpdb->query("DELETE FROM ".WPHP_TABLE_NAME." WHERE post_id = $id AND meta_key = '$lp_flag'");
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
*
|
333 |
+
* @param $item_type
|
334 |
+
* @param $id
|
335 |
+
* @param $lp_flag
|
336 |
+
* @param $lp_value
|
337 |
+
* @return unknown_type
|
338 |
+
*/
|
339 |
+
function wphp_set_low_profile($item_type, $id, $lp_flag, $lp_value) {
|
340 |
+
wphp_log("called: wphp_set_low_profile");
|
341 |
+
global $wpdb;
|
342 |
+
// Ensure No Duplicates!
|
343 |
+
$check = $wpdb->get_var("SELECT count(*) FROM ".WPHP_TABLE_NAME." WHERE post_id = $id AND meta_key='$lp_flag'");
|
344 |
+
error_log("Check: $check");
|
345 |
+
if(!$check) {
|
346 |
+
$wpdb->query("INSERT INTO ".WPHP_TABLE_NAME."(post_id, meta_key, meta_value) VALUES($id, '$lp_flag', '$lp_value')");
|
347 |
+
} elseif( $item_type == 'page' && $lp_flag == "_wplp_page_flags" ) {
|
348 |
+
$wpdb->query("UPDATE ".WPHP_TABLE_NAME." set meta_value = '$lp_value' WHERE post_id = $id and meta_key = '$lp_flag'");
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
*
|
354 |
+
* @return unknown_type
|
355 |
+
*/
|
356 |
+
function wphp_add_post_edit_meta_box() {
|
357 |
+
wphp_log("called: wphp_add_post_edit_meta_box");
|
358 |
+
add_meta_box('hidepostdivpost', __('Post Visibility', 'wp-hide-post'), 'wphp_metabox_post_edit', 'post', 'side');
|
359 |
+
add_meta_box('hidepostdivpage', __('Page Visibility', 'wp-hide-post'), 'wphp_metabox_page_edit', 'page', 'side');
|
360 |
+
}
|
361 |
+
add_action('admin_menu', 'wphp_add_post_edit_meta_box');
|
362 |
+
|
363 |
+
/**
|
364 |
+
*
|
365 |
+
* @return unknown_type
|
366 |
+
*/
|
367 |
+
function wphp_metabox_post_edit() {
|
368 |
+
wphp_log("called: wphp_metabox_post_edit");
|
369 |
+
global $wpdb;
|
370 |
+
|
371 |
+
$id = isset($_GET['post']) ? intval($_GET['post']) : 0;
|
372 |
+
|
373 |
+
$wplp_post_front = 0;
|
374 |
+
$wplp_post_category = 0;
|
375 |
+
$wplp_post_tag = 0;
|
376 |
+
$wplp_post_author = 0;
|
377 |
+
$wplp_post_archive = 0;
|
378 |
+
$wplp_post_search = 0;
|
379 |
+
$wplp_post_feed = 0;
|
380 |
+
|
381 |
+
if($id > 0) {
|
382 |
+
$flags = $wpdb->get_results("SELECT meta_key from ".WPHP_TABLE_NAME." where post_id = $id and meta_key like '_wplp_%'", ARRAY_N);
|
383 |
+
if( $flags ) {
|
384 |
+
foreach($flags as $flag_array) {
|
385 |
+
$flag = $flag_array[0];
|
386 |
+
// remove the leading _
|
387 |
+
$flag = substr($flag, 1, strlen($flag)-1);
|
388 |
+
${$flag} = 1;
|
389 |
+
}
|
390 |
+
}
|
391 |
+
}
|
392 |
+
?>
|
393 |
+
<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); ?>/> <?php _e('Hide on the front page.', 'wp-hide-post'); ?></label>
|
394 |
+
<input type="hidden" name="old_wplp_post_front" value="<?php echo $wplp_post_front; ?>"/>
|
395 |
+
<br />
|
396 |
+
<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); ?>/> <?php _e('Hide on category pages.', 'wp-hide-post'); ?></label>
|
397 |
+
<input type="hidden" name="old_wplp_post_category" value="<?php echo $wplp_post_category; ?>"/>
|
398 |
+
<br />
|
399 |
+
<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); ?>/> <?php _e('Hide on tag pages.', 'wp-hide-post'); ?></label>
|
400 |
+
<input type="hidden" name="old_wplp_post_tag" value="<?php echo $wplp_post_tag; ?>"/>
|
401 |
+
<br />
|
402 |
+
<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); ?>/> <?php _e('Hide on author pages.', 'wp-hide-post'); ?></label>
|
403 |
+
<input type="hidden" name="old_wplp_post_author" value="<?php echo $wplp_post_author; ?>"/>
|
404 |
+
<br />
|
405 |
+
<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); ?>/> <?php _e('Hide in date archives (month, day, year, etc...)', 'wp-hide-post'); ?></label>
|
406 |
+
<input type="hidden" name="old_wplp_post_archive" value="<?php echo $wplp_post_archive; ?>"/>
|
407 |
+
<br />
|
408 |
+
<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); ?>/> <?php _e('Hide in search results.', 'wp-hide-post'); ?></label>
|
409 |
+
<input type="hidden" name="old_wplp_post_search" value="<?php echo $wplp_post_search; ?>"/>
|
410 |
+
<br />
|
411 |
+
<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); ?>/> <?php _e('Hide in feeds.', 'wp-hide-post'); ?></label>
|
412 |
+
<input type="hidden" name="old_wplp_post_feed" value="<?php echo $wplp_post_feed; ?>"/>
|
413 |
+
<br />
|
414 |
+
<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>
|
415 |
+
<br />
|
416 |
+
<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>
|
417 |
+
<br />
|
418 |
+
<?php
|
419 |
+
}
|
420 |
+
|
421 |
+
/**
|
422 |
+
*
|
423 |
+
* @return unknown_type
|
424 |
+
*/
|
425 |
+
function wphp_metabox_page_edit() {
|
426 |
+
wphp_log("called: wphp_metabox_page_edit");
|
427 |
+
global $wpdb;
|
428 |
+
|
429 |
+
$id = isset($_GET['post']) ? intval($_GET['post']) : 0;
|
430 |
+
|
431 |
+
$wplp_page = 'none';
|
432 |
+
$wplp_page_search_show = 1;
|
433 |
+
|
434 |
+
if($id > 0) {
|
435 |
+
$flags = $wpdb->get_results("SELECT meta_value from ".WPHP_TABLE_NAME." where post_id = $id and meta_key = '_wplp_page_flags'", ARRAY_N);
|
436 |
+
if( $flags )
|
437 |
+
$wplp_page = $flags[0][0];
|
438 |
+
$search = $wpdb->get_results("SELECT meta_value from ".WPHP_TABLE_NAME." where post_id = $id and meta_key = '_wplp_page_search'", ARRAY_N);
|
439 |
+
if( $search )
|
440 |
+
$wplp_page_search_show = ! $search[0][0];
|
441 |
+
}
|
442 |
+
?>
|
443 |
+
<input type="hidden" name="old_wplp_page" value="<?php echo $wplp_page; ?>"/>
|
444 |
+
<label class="selectit"><input type="radio" id="wplp_page_none" name="wplp_page" value="none"<?php checked($wplp_page, 'none'); ?>/> <?php _e('Show normally everywhere.', 'wp-hide-post'); ?></label>
|
445 |
+
<br />
|
446 |
+
<br />
|
447 |
+
<label class="selectit"><input type="radio" id="wplp_page_front" name="wplp_page" value="front"<?php checked($wplp_page, 'front'); ?>/> <?php _e('Hide when listing pages on the front page.', 'wp-hide-post'); ?></label>
|
448 |
+
<br />
|
449 |
+
<br />
|
450 |
+
<label class="selectit"><input type="radio" id="wplp_page_all" name="wplp_page" value="all"<?php checked($wplp_page, 'all'); ?>/> <?php _e('Hide everywhere pages are listed.', 'wp-hide-post'); ?><sup>*</sup></label>
|
451 |
+
<div style="height:18px;margin-left:20px">
|
452 |
+
<div id="wplp_page_search_show_div">
|
453 |
+
<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); ?>/> <?php _e('Keep in search results.', 'wp-hide-post'); ?></label>
|
454 |
+
<input type="hidden" name="old_wplp_page_search_show" value="<?php echo $wplp_page_search_show; ?>"/>
|
455 |
+
</div>
|
456 |
+
</div>
|
457 |
+
<br />
|
458 |
+
<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>
|
459 |
+
<br />
|
460 |
+
<br />
|
461 |
+
<br />
|
462 |
+
<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>
|
463 |
+
<br />
|
464 |
+
<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>
|
465 |
+
<br />
|
466 |
+
<script type="text/javascript">
|
467 |
+
<!--
|
468 |
+
// toggle the wplp_page_search_show checkbox
|
469 |
+
var wplp_page_search_show_callback = function () {
|
470 |
+
if(jQuery("#wplp_page_all").is(":checked"))
|
471 |
+
jQuery("#wplp_page_search_show_div").show();
|
472 |
+
else
|
473 |
+
jQuery("#wplp_page_search_show_div").hide();
|
474 |
+
};
|
475 |
+
jQuery("#wplp_page_all").change(wplp_page_search_show_callback);
|
476 |
+
jQuery("#wplp_page_front").change(wplp_page_search_show_callback);
|
477 |
+
jQuery("#wplp_page_none").change(wplp_page_search_show_callback);
|
478 |
+
jQuery(document).ready( wplp_page_search_show_callback );
|
479 |
+
//-->
|
480 |
+
</script>
|
481 |
+
<?php
|
482 |
+
}
|
483 |
+
|
484 |
+
/**
|
485 |
+
*
|
486 |
+
* @param $id
|
487 |
+
* @return unknown_type
|
488 |
+
*/
|
489 |
+
function wphp_save_post($id) {
|
490 |
+
wphp_log("called: wphp_save_post");
|
491 |
+
$item_type = get_post_type($id);
|
492 |
+
if( $item_type == 'post' ) {
|
493 |
+
if( isset($_POST['old_wplp_post_front']) && _wphp_http_post('wplp_post_front', 0) != _wphp_http_post('old_wplp_post_front', 0) )
|
494 |
+
wphp_update_visibility($id, '_wplp_post_front', _wphp_http_post('wplp_post_front', 0));
|
495 |
+
if( isset($_POST['old_wplp_post_category']) && _wphp_http_post('wplp_post_category', 0) != _wphp_http_post('old_wplp_post_category', 0) )
|
496 |
+
wphp_update_visibility($id, '_wplp_post_category', _wphp_http_post('wplp_post_category', 0));
|
497 |
+
if( isset($_POST['old_wplp_post_tag']) && _wphp_http_post('wplp_post_tag', 0) != _wphp_http_post('old_wplp_post_tag', 0) )
|
498 |
+
wphp_update_visibility($id, '_wplp_post_tag', _wphp_http_post('wplp_post_tag', 0));
|
499 |
+
if( isset($_POST['old_wplp_post_author']) && _wphp_http_post('wplp_post_author', 0) != _wphp_http_post('old_wplp_post_author', 0) )
|
500 |
+
wphp_update_visibility($id, '_wplp_post_author', _wphp_http_post('wplp_post_author', 0));
|
501 |
+
if( isset($_POST['old_wplp_post_archive']) && _wphp_http_post('wplp_post_archive', 0) != _wphp_http_post('old_wplp_post_archive', 0) )
|
502 |
+
wphp_update_visibility($id, '_wplp_post_archive', _wphp_http_post('wplp_post_archive', 0));
|
503 |
+
if( isset($_POST['old_wplp_post_search']) && _wphp_http_post('wplp_post_search', 0) != _wphp_http_post('old_wplp_post_search', 0) )
|
504 |
+
wphp_update_visibility($id, '_wplp_post_search', _wphp_http_post('wplp_post_search', 0));
|
505 |
+
if( isset($_POST['old_wplp_post_feed']) && _wphp_http_post('wplp_post_feed', 0) != _wphp_http_post('old_wplp_post_feed', 0) )
|
506 |
+
wphp_update_visibility($id, '_wplp_post_feed', _wphp_http_post('wplp_post_feed', 0));
|
507 |
+
} elseif( $item_type == 'page' ) {
|
508 |
+
if( isset($_POST['old_wplp_page']) ) {
|
509 |
+
if( _wphp_http_post('wplp_page', 'none') != _wphp_http_post('old_wplp_page', 'none') ) {
|
510 |
+
wphp_update_visibility($id, "_wplp_page_flags", _wphp_http_post('wplp_page', 'none'));
|
511 |
+
}
|
512 |
+
if( _wphp_http_post('wplp_page', 'none') == 'all' ) {
|
513 |
+
if( isset($_POST['old_wplp_page_search_show']) && _wphp_http_post('wplp_page_search_show', 0) != _wphp_http_post('old_wplp_page_search_show', 0) )
|
514 |
+
wphp_update_visibility($id, "_wplp_page_search", ! _wphp_http_post('wplp_page_search_show', 0));
|
515 |
+
} else
|
516 |
+
wphp_update_visibility($id, "_wplp_page_search", 0);
|
517 |
+
}
|
518 |
+
}
|
519 |
+
}
|
520 |
+
add_action('save_post', 'wphp_save_post');
|
521 |
+
|
522 |
+
/**
|
523 |
+
*
|
524 |
+
* @param $post_id
|
525 |
+
* @return unknown_type
|
526 |
+
*/
|
527 |
+
function wphp_delete_post($post_id) {
|
528 |
+
wphp_log("called: wphp_delete_post");
|
529 |
+
global $wpdb;
|
530 |
+
// Delete all post flags from the database table
|
531 |
+
$wpdb->query("DELETE FROM ".WPHP_TABLE_NAME." WHERE post_id = $post_id and meta_key like '_wplp_%'");
|
532 |
}
|
533 |
+
add_action('delete_post', 'wphp_delete_post');
|
534 |
|
535 |
?>
|