No Page Comment - Version 0.3

Version Description

  • NEW: Add ability to enable/disable all comments or trackbacks on any specific custom post type. It is highly recommended that you backup your blog's database prior to doing this.
Download this release

Release Info

Developer sethta
Plugin Icon 128x128 No Page Comment
Version 0.3
Comparing to
See all releases

Code changes from version 0.2 to 0.3

Files changed (3) hide show
  1. no-page-comment.php +164 -48
  2. page-comment.js +39 -0
  3. readme.txt +30 -8
no-page-comment.php CHANGED
@@ -2,26 +2,26 @@
2
  /*
3
  Plugin Name: No Page Comment
4
  Plugin URI: http://sethalling.com/plugins/no-page-comment
5
- Description: A plugin that uses javascript to disable comments by default on posts, pages and/or custom post types but leave them enabled on others, while still giving you the ability to individually set them on a page or post basis.
6
- Version: 0.2
7
  Author: Seth Alling
8
  Author URI: http://sethalling.com/
9
 
10
- Plugin: Copyright (c) 2011 Seth Alling
11
 
12
- This program is free software; you can redistribute it and/or
13
- modify it under the terms of the GNU General Public License
14
- as published by the Free Software Foundation; either version 2
15
- of the License, or (at your option) any later version.
16
 
17
- This program is distributed in the hope that it will be useful,
18
- but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- GNU General Public License for more details.
21
 
22
- You should have received a copy of the GNU General Public License
23
- along with this program; if not, write to the Free Software
24
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
  */
26
 
27
  register_activation_hook(__FILE__, 'sta_npc_activate');
@@ -44,9 +44,9 @@ if ( ! function_exists('sta_npc_load') ) {
44
  public $plugin_name = 'no-page-comment';
45
  public $plugin_file;
46
  public $plugin_dir;
47
-
48
  // tansfer version 0.1.options to 0.2
49
- public function sta_npc_activate( ) {
50
  $sta_npc_options_retrieve = get_option($this->admin_options_name);
51
  if ( isset($sta_npc_options_retrieve['disable_comments']) ) {
52
  $sta_npc_options_retrieve['disable_comments_page'] = $sta_npc_options_retrieve['disable_comments'];
@@ -56,78 +56,79 @@ if ( ! function_exists('sta_npc_load') ) {
56
  $sta_npc_options_retrieve['disable_trackbacks_page'] = $sta_npc_options_retrieve['disable_trackbacks'];
57
  unset($sta_npc_options_retrieve['disable_trackbacks']);
58
  }
59
- update_option($this->admin_options_name, $sta_npc_options_retrieve);
60
  }
61
-
62
  // Plugin Constructor
63
  function sta_npc_plugin() {
64
  $this->plugin_dir = WP_PLUGIN_URL.'/'.$this->plugin_name;
65
  $this->plugin_file = $this->plugin_name . '.php';
66
  }
67
-
68
  // Intialize Admin Options
69
  function sta_npc_init() {
70
  $this->sta_npc_get_admin_options();
71
  }
72
-
73
  // Returns an array of admin options
74
  function sta_npc_get_admin_options() {
75
-
76
  $sta_npc_admin_options = array(
77
  'disable_comments_post' => '',
78
  'disable_trackbacks_post' => '',
79
  'disable_comments_page' => 'true',
80
  'disable_trackbacks_page' => 'true'
81
  );
82
-
83
  foreach ( get_post_types('','objects') as $posttype ) {
84
  if ( in_array( $posttype->name, array('post','page','revision','nav_menu_item','attachment') ) )
85
  continue;
86
-
87
  $sta_npc_admin_options['disable_comments_' . $posttype->name] = 'true';
88
  $sta_npc_admin_options['disable_trackbacks_' . $posttype->name] = 'true';
89
-
90
  } // end foreach post types
91
-
92
  $sta_npc_options = get_option($this->admin_options_name);
93
  if ( ! empty($sta_npc_options) ) {
94
-
95
  foreach ($sta_npc_options as $key => $option)
96
  $sta_npc_admin_options[$key] = $option;
97
- }
98
  update_option($this->admin_options_name, $sta_npc_admin_options);
99
  return $sta_npc_admin_options;
100
  }
101
-
102
  // Prints out the admin page
103
  function sta_npc_print_admin_page() {
 
104
  $sta_npc_options = $this->sta_npc_get_admin_options();
105
-
106
  if ( isset($_POST['update_sta_npc_plugin_settings']) ) {
107
-
108
  foreach ( get_post_types('','objects') as $posttype ) {
109
  if ( in_array( $posttype->name, array('revision','nav_menu_item','attachment') ) )
110
  continue;
111
-
112
  if ( isset($_POST['sta_npc_disable_comments_' . $posttype->name]) ) {
113
  $sta_npc_options['disable_comments_' . $posttype->name] = $_POST['sta_npc_disable_comments_' . $posttype->name];
114
  } else {
115
  $sta_npc_options['disable_comments_' . $posttype->name] = 'false';
116
  }
117
-
118
  if ( isset($_POST['sta_npc_disable_trackbacks_' . $posttype->name]) ) {
119
  $sta_npc_options['disable_trackbacks_' . $posttype->name] = $_POST['sta_npc_disable_trackbacks_' . $posttype->name];
120
  } else {
121
  $sta_npc_options['disable_trackbacks_' . $posttype->name] = 'false';
122
  }
123
-
124
  } // end foreach post types
125
-
126
  update_option($this->admin_options_name, $sta_npc_options);
127
  ?>
128
  <div class="updated"><p><strong><?php _e('Settings Updated.', $this->plugin_domain);?></strong></p></div>
129
  <?php } ?>
130
-
131
  <div class="wrap">
132
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
133
  <div id="icon-options-general" class="icon32"><br></div>
@@ -139,7 +140,16 @@ if ( ! function_exists('sta_npc_load') ) {
139
  <h3 class="hndle" style="cursor:default;"><span>Other plugins by <a href="http://sethalling.com/" title="Seth Alling" style="font-size:15px;">Seth Alling</a>:</span></h3>
140
  <div class="inside">
141
  <ul>
142
- <li style="padding:5px 0;"><a href="http://sethalling.com/plugins/wp-faqs-pro" title="WP FAQs Pro">WP FAQs Pro</a></li>
 
 
 
 
 
 
 
 
 
143
  </ul>
144
  </div>
145
  </div>
@@ -169,14 +179,37 @@ if ( ! function_exists('sta_npc_load') ) {
169
  <input type="submit" name="update_sta_npc_plugin_settings" id="submit" class="button-primary" value="<?php _e('Update Settings', $this->plugin_domain); ?>">
170
  </p>
171
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  </div>
173
  </div>
174
  </form>
175
  </div>
176
-
177
-
178
  <?php } // End sta_npc_print_admin_page function
179
-
180
  function sta_npc_settings_link($links, $file) {
181
  if ( basename($file) == $this->plugin_file ) {
182
  $settings_link = '<a href="' . admin_url('options-general.php?page=' . $this->plugin_file) . '">Settings</a>';
@@ -184,7 +217,7 @@ if ( ! function_exists('sta_npc_load') ) {
184
  }
185
  return $links;
186
  }
187
-
188
  function sta_npc_plugin_admin() {
189
  if ( function_exists('add_options_page') ) {
190
  add_options_page('No Page Comment Settings', 'No Page Comment', 'manage_options', $this->plugin_file, array( $this, 'sta_npc_print_admin_page' ));
@@ -198,7 +231,7 @@ if ( ! function_exists('sta_npc_load') ) {
198
  if ( (is_admin()) && ($pagenow=='post-new.php') && ($post->filter=='raw') ) {
199
  wp_enqueue_script('jquery');
200
  $posttype = $post->post_type; ?>
201
-
202
  <script type="text/javascript">
203
  jQuery(document).ready(function() {
204
  <?php if ( isset($sta_npc_options['disable_comments_' . $posttype]) ) {
@@ -217,26 +250,109 @@ if ( ! function_exists('sta_npc_load') ) {
217
  } ?>
218
  });
219
  </script>
220
-
221
- <?php }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  }
223
 
224
  }
225
-
226
  } // End Class STA_NPC_Plugin
227
-
228
  if ( class_exists('STA_NPC_Plugin') ) {
229
  global $sta_npc_plugin;
230
  $sta_npc_plugin = new STA_NPC_Plugin();
231
  }
232
-
233
  // Actions, Filters and Shortcodes
234
  if ( isset($sta_npc_plugin) ) {
235
  // Actions
236
  add_action('admin_menu', array( &$sta_npc_plugin, 'sta_npc_plugin_admin' )); // Activate admin settings page
237
  add_action('activate_no-page-comment/no-page-comment.php', array( &$sta_npc_plugin, 'sta_npc_init' )); // Activate admin options
238
- add_action( 'admin_head', array( &$sta_npc_plugin, 'sta_no_page_comment' ));
239
-
 
 
240
  // Filters
241
  add_filter('plugin_action_links', array( &$sta_npc_plugin, 'sta_npc_settings_link'), 10, 2 );
242
  }
2
  /*
3
  Plugin Name: No Page Comment
4
  Plugin URI: http://sethalling.com/plugins/no-page-comment
5
+ Description: A plugin that uses javascript to disable comments by default on posts, pages and/or custom post types but leave them enabled on others, while still giving you the ability to individually set them on a page or post basis.
6
+ Version: 0.3
7
  Author: Seth Alling
8
  Author URI: http://sethalling.com/
9
 
10
+ Plugin: Copyright (c) 2011-2013 Seth Alling
11
 
12
+ This program is free software; you can redistribute it and/or
13
+ modify it under the terms of the GNU General Public License
14
+ as published by the Free Software Foundation; either version 2
15
+ of the License, or (at your option) any later version.
16
 
17
+ This program is distributed in the hope that it will be useful,
18
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ GNU General Public License for more details.
21
 
22
+ You should have received a copy of the GNU General Public License
23
+ along with this program; if not, write to the Free Software
24
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
  */
26
 
27
  register_activation_hook(__FILE__, 'sta_npc_activate');
44
  public $plugin_name = 'no-page-comment';
45
  public $plugin_file;
46
  public $plugin_dir;
47
+
48
  // tansfer version 0.1.options to 0.2
49
+ public function sta_npc_activate( ) {
50
  $sta_npc_options_retrieve = get_option($this->admin_options_name);
51
  if ( isset($sta_npc_options_retrieve['disable_comments']) ) {
52
  $sta_npc_options_retrieve['disable_comments_page'] = $sta_npc_options_retrieve['disable_comments'];
56
  $sta_npc_options_retrieve['disable_trackbacks_page'] = $sta_npc_options_retrieve['disable_trackbacks'];
57
  unset($sta_npc_options_retrieve['disable_trackbacks']);
58
  }
59
+ update_option($this->admin_options_name, $sta_npc_options_retrieve);
60
  }
61
+
62
  // Plugin Constructor
63
  function sta_npc_plugin() {
64
  $this->plugin_dir = WP_PLUGIN_URL.'/'.$this->plugin_name;
65
  $this->plugin_file = $this->plugin_name . '.php';
66
  }
67
+
68
  // Intialize Admin Options
69
  function sta_npc_init() {
70
  $this->sta_npc_get_admin_options();
71
  }
72
+
73
  // Returns an array of admin options
74
  function sta_npc_get_admin_options() {
75
+
76
  $sta_npc_admin_options = array(
77
  'disable_comments_post' => '',
78
  'disable_trackbacks_post' => '',
79
  'disable_comments_page' => 'true',
80
  'disable_trackbacks_page' => 'true'
81
  );
82
+
83
  foreach ( get_post_types('','objects') as $posttype ) {
84
  if ( in_array( $posttype->name, array('post','page','revision','nav_menu_item','attachment') ) )
85
  continue;
86
+
87
  $sta_npc_admin_options['disable_comments_' . $posttype->name] = 'true';
88
  $sta_npc_admin_options['disable_trackbacks_' . $posttype->name] = 'true';
89
+
90
  } // end foreach post types
91
+
92
  $sta_npc_options = get_option($this->admin_options_name);
93
  if ( ! empty($sta_npc_options) ) {
94
+
95
  foreach ($sta_npc_options as $key => $option)
96
  $sta_npc_admin_options[$key] = $option;
97
+ }
98
  update_option($this->admin_options_name, $sta_npc_admin_options);
99
  return $sta_npc_admin_options;
100
  }
101
+
102
  // Prints out the admin page
103
  function sta_npc_print_admin_page() {
104
+ $sta_npc_nonce = wp_create_nonce('sta_npc_nonce');
105
  $sta_npc_options = $this->sta_npc_get_admin_options();
106
+
107
  if ( isset($_POST['update_sta_npc_plugin_settings']) ) {
108
+
109
  foreach ( get_post_types('','objects') as $posttype ) {
110
  if ( in_array( $posttype->name, array('revision','nav_menu_item','attachment') ) )
111
  continue;
112
+
113
  if ( isset($_POST['sta_npc_disable_comments_' . $posttype->name]) ) {
114
  $sta_npc_options['disable_comments_' . $posttype->name] = $_POST['sta_npc_disable_comments_' . $posttype->name];
115
  } else {
116
  $sta_npc_options['disable_comments_' . $posttype->name] = 'false';
117
  }
118
+
119
  if ( isset($_POST['sta_npc_disable_trackbacks_' . $posttype->name]) ) {
120
  $sta_npc_options['disable_trackbacks_' . $posttype->name] = $_POST['sta_npc_disable_trackbacks_' . $posttype->name];
121
  } else {
122
  $sta_npc_options['disable_trackbacks_' . $posttype->name] = 'false';
123
  }
124
+
125
  } // end foreach post types
126
+
127
  update_option($this->admin_options_name, $sta_npc_options);
128
  ?>
129
  <div class="updated"><p><strong><?php _e('Settings Updated.', $this->plugin_domain);?></strong></p></div>
130
  <?php } ?>
131
+
132
  <div class="wrap">
133
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
134
  <div id="icon-options-general" class="icon32"><br></div>
140
  <h3 class="hndle" style="cursor:default;"><span>Other plugins by <a href="http://sethalling.com/" title="Seth Alling" style="font-size:15px;">Seth Alling</a>:</span></h3>
141
  <div class="inside">
142
  <ul>
143
+ <li style="padding:5px 0;"><a href="http://sethalling.com/plugins/wordpress/wp-faqs-pro" title="WP FAQs Pro">WP FAQs Pro</a></li>
144
+ </ul>
145
+ </div>
146
+ </div>
147
+ <div id="pageparentdiv" class="postbox">
148
+ <h3 class="hndle" style="cursor:default;"><span>Support No Page Comment</span></h3>
149
+ <div class="inside">
150
+ <ul>
151
+ <li style="padding:5px 0;"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5WWP2EDSCAJR4" title="Donate to support the No Page Comment plugin development">Donate</a></li>
152
+ <li style="padding:5px 0;"><a href="http://wordpress.org/support/view/plugin-reviews/no-page-comment#postform" title="Write a Review about No Page Comment">Write a Review</a></li>
153
  </ul>
154
  </div>
155
  </div>
179
  <input type="submit" name="update_sta_npc_plugin_settings" id="submit" class="button-primary" value="<?php _e('Update Settings', $this->plugin_domain); ?>">
180
  </p>
181
  </div>
182
+ <div id="post-body-content">
183
+ <div id="postcustom" class="postbox" style="">
184
+ <h3 class="hndle" style="cursor:default;"><span><?php _e('Modify all current:', $this->plugin_domain); ?></span></h3>
185
+ <div class="inside">
186
+ <?php foreach ( get_post_types('','objects') as $posttype ) {
187
+ if ( in_array( $posttype->name, array('revision','nav_menu_item','attachment') ) )
188
+ continue; ?>
189
+ <p class="submit" style="padding:5px 0;">
190
+ <strong class="post_type" style="width:160px; float:left;"><?php echo $posttype->label; ?></strong>
191
+ <span style="float:left; margin-right:10px;">
192
+ <input type="submit" name="disable_all_<?php echo $posttype->name; ?>_comments" class="button-primary sta_ajax_modify" data-nonce="<?php echo $sta_npc_nonce; ?>" data-post_type="<?php echo $posttype->name; ?>" data-post_label="<?php echo $posttype->label; ?>" data-comment_status="open" data-comment_type="comment" value="<?php _e('Disable All Comments', $this->plugin_domain); ?>" style="margin-bottom:5px; float:left;">
193
+ <input type="submit" name="disable_all_<?php echo $posttype->name; ?>_trackbacks" class="button-primary sta_ajax_modify" data-nonce="<?php echo $sta_npc_nonce; ?>" data-post_type="<?php echo $posttype->name; ?>" data-post_label="<?php echo $posttype->label; ?>" data-comment_status="open" data-comment_type="ping" value="<?php _e('Disable All Trackbacks', $this->plugin_domain); ?>" style="clear:both; margin-bottom:5px; float:left;">
194
+ </span>
195
+ <span style="float:left;">
196
+ <input type="submit" name="enable_all_<?php echo $posttype->name; ?>_comments" class="button-primary sta_ajax_modify" data-nonce="<?php echo $sta_npc_nonce; ?>" data-post_type="<?php echo $posttype->name; ?>" data-post_label="<?php echo $posttype->label; ?>" data-comment_status="closed" data-comment_type="comment" value="<?php _e('Enable All Comments', $this->plugin_domain); ?>" style="margin-bottom:5px; float:left;">
197
+ <input type="submit" name="enable_all_<?php echo $posttype->name; ?>_trackbacks" class="button-primary sta_ajax_modify" data-nonce="<?php echo $sta_npc_nonce; ?>" data-post_type="<?php echo $posttype->name; ?>" data-post_label="<?php echo $posttype->label; ?>" data-comment_status="closed" data-comment_type="ping" value="<?php _e('Enable All Trackbacks', $this->plugin_domain); ?>" style="clear:both; float:left;">
198
+ </span>
199
+ </p>
200
+ <br style="clear:both;" />
201
+ <?php } ?>
202
+ </div>
203
+ </div>
204
+ </div>
205
  </div>
206
  </div>
207
  </form>
208
  </div>
209
+
210
+
211
  <?php } // End sta_npc_print_admin_page function
212
+
213
  function sta_npc_settings_link($links, $file) {
214
  if ( basename($file) == $this->plugin_file ) {
215
  $settings_link = '<a href="' . admin_url('options-general.php?page=' . $this->plugin_file) . '">Settings</a>';
217
  }
218
  return $links;
219
  }
220
+
221
  function sta_npc_plugin_admin() {
222
  if ( function_exists('add_options_page') ) {
223
  add_options_page('No Page Comment Settings', 'No Page Comment', 'manage_options', $this->plugin_file, array( $this, 'sta_npc_print_admin_page' ));
231
  if ( (is_admin()) && ($pagenow=='post-new.php') && ($post->filter=='raw') ) {
232
  wp_enqueue_script('jquery');
233
  $posttype = $post->post_type; ?>
234
+
235
  <script type="text/javascript">
236
  jQuery(document).ready(function() {
237
  <?php if ( isset($sta_npc_options['disable_comments_' . $posttype]) ) {
250
  } ?>
251
  });
252
  </script>
253
+
254
+ <?php } elseif ( (is_admin()) && ($pagenow=='options-general.php') && isset($_GET['page']) && ( $_GET['page'] == 'no-page-comment.php' ) ) {
255
+ wp_enqueue_script('jquery');
256
+ // Load Ajax File
257
+ wp_register_script( 'ajax-script', plugins_url('/page-comment.js',__FILE__), array('jquery') );
258
+ wp_localize_script( 'ajax-script', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
259
+
260
+ wp_enqueue_script( 'jquery' );
261
+ wp_enqueue_script( 'ajax-script' );
262
+ }
263
+ }
264
+
265
+ // Ajax Function for WP Comment DB Modification
266
+ function sta_npc_mod() {
267
+ if ( !wp_verify_nonce( $_REQUEST['nonce'], 'sta_npc_nonce')) {
268
+ exit('No naughty business please');
269
+ }
270
+
271
+ global $wpdb;
272
+
273
+ $result[] = array();
274
+ $comment_type = $_REQUEST['comment_type'];
275
+ $comment_status = $_REQUEST['comment_status'];
276
+ if ($comment_status == 'open')
277
+ $comment_new_status = 'closed';
278
+ elseif ($comment_status == 'closed') {
279
+ $comment_new_status = 'open';
280
+ }
281
+ $post_type = $_REQUEST['post_type'];
282
+ $post_label = $_REQUEST['post_label'];
283
+
284
+
285
+ if ($comment_type == 'ping') {
286
+ $comment_label = 'trackbacks';
287
+ $comment_query = $wpdb->prepare(
288
+ "
289
+ UPDATE $wpdb->posts
290
+ SET ping_status = %s
291
+ WHERE ping_status = %s
292
+ AND post_type = %s
293
+ ",
294
+ $comment_new_status,
295
+ $comment_status,
296
+ $post_type
297
+ );
298
+ } else {
299
+ $comment_label = 'comments';
300
+ $comment_query = $wpdb->prepare(
301
+ "
302
+ UPDATE $wpdb->posts
303
+ SET comment_status = %s
304
+ WHERE comment_status = %s
305
+ AND post_type = %s
306
+ ",
307
+ $comment_new_status,
308
+ $comment_status,
309
+ $post_type
310
+ );
311
+ }
312
+
313
+ if( $comment_query === FALSE ) {
314
+ $result['type'] = 'error';
315
+ $result['message'] = 'Something went wrong. Please refresh this page and try again.';
316
+ } else {
317
+ $wpdb->query($comment_query);
318
+ $result['type'] = 'success';
319
+ $result['message'] = 'All ' . $comment_label . ' of ' . $post_label . ' have been marked as ' . $comment_new_status;
320
+ }
321
+
322
+ if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
323
+ $result = json_encode($result);
324
+ echo $result;
325
+ }
326
+ else {
327
+ header('Location: '.$_SERVER['HTTP_REFERER']);
328
+ }
329
+
330
+ die();
331
+
332
+ }
333
+
334
+ function nopriv_sta_npc_mod() {
335
+ exit('No naughty business please');
336
  }
337
 
338
  }
339
+
340
  } // End Class STA_NPC_Plugin
341
+
342
  if ( class_exists('STA_NPC_Plugin') ) {
343
  global $sta_npc_plugin;
344
  $sta_npc_plugin = new STA_NPC_Plugin();
345
  }
346
+
347
  // Actions, Filters and Shortcodes
348
  if ( isset($sta_npc_plugin) ) {
349
  // Actions
350
  add_action('admin_menu', array( &$sta_npc_plugin, 'sta_npc_plugin_admin' )); // Activate admin settings page
351
  add_action('activate_no-page-comment/no-page-comment.php', array( &$sta_npc_plugin, 'sta_npc_init' )); // Activate admin options
352
+ add_action( 'admin_head', array( &$sta_npc_plugin, 'sta_no_page_comment' )); // Add ajax scripts
353
+ add_action('wp_ajax_sta_npc_mod', array( &$sta_npc_plugin, 'sta_npc_mod')); // Add ajax function
354
+ add_action('wp_ajax_nopriv_sta_npc_mod', array( &$sta_npc_plugin, 'nopriv_sta_npc_mod')); // Add logged out ajax function
355
+
356
  // Filters
357
  add_filter('plugin_action_links', array( &$sta_npc_plugin, 'sta_npc_settings_link'), 10, 2 );
358
  }
page-comment.js ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready( function($) {
2
+ // Run WordPress Database Comment Modification
3
+ $('.sta_ajax_modify').click( function(e) {
4
+ e.preventDefault();
5
+ confirmresult = confirm('Are you sure you want to do this? This request cannot be undone.\n\nIt is highly recommended that you backup your database before proceeding.');
6
+ if(confirmresult == true ) {
7
+ nonce = $(this).attr('data-nonce');
8
+ post_type = $(this).attr('data-post_type');
9
+ post_label = $(this).attr('data-post_label');
10
+ comment_type = $(this).attr('data-comment_type');
11
+ comment_status = $(this).attr('data-comment_status');
12
+ $.ajax({
13
+ type : 'post',
14
+ dataType : 'json',
15
+ url : myAjax.ajaxurl,
16
+ data : {
17
+ action: 'sta_npc_mod',
18
+ nonce: nonce,
19
+ post_type: post_type,
20
+ post_label: post_label,
21
+ comment_type: comment_type,
22
+ comment_status: comment_status
23
+ },
24
+ success: function(response) {
25
+ if(response.type == 'success') {
26
+ alert(response.message);
27
+ console.log(response);
28
+ } else {
29
+ alert(response.message);
30
+ console.log(response);
31
+ }
32
+ },
33
+ error: function(MLHttpRequest, textStatus, errorThrown){
34
+ console.log(errorThrown);
35
+ }
36
+ });
37
+ }
38
+ });
39
+ });
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: sethta
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5WWP2EDSCAJR4
5
  Tags: admin, comments, custom post type, javascript, page, pages, post, posts, plugin, settings, tools, trackbacks
6
  Requires at least: 3.1
7
- Tested up to: 3.4.2
8
  Stable tag: trunk
9
 
10
  Disable comments by default on new pages and custom post types, while still giving you the ability to individually set them on a page or post basis.
@@ -13,9 +13,11 @@ Disable comments by default on new pages and custom post types, while still givi
13
 
14
  By default, WordPress gives you two options. You can either disable comments and trackbacks by default for all pages and posts, or you can have them active by default. Unfortunately, there is no specific WordPress setting that allows comments and trackbacks to be active by default for posts, while disabling them on pages or any other post type.
15
 
16
- There have been workarounds created by disabling comments site-wide on all pages and/or posts, but what if you may actually want to have comments on a page or two. The difference between this plugin and others is that it will automatically uncheck to discussion settings boxes for you when creating a new page, while still giving you the flexibility to open comments up specifically on individual pages and post types.
17
 
18
- [Official No Page Comment Plugin Page](http://sethalling.com/plugins/no-page-comment "No Page Comment WordPress Plugin")
 
 
19
 
20
  [Donate to Support No Page Comment Development](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5WWP2EDSCAJR4 "Donate to support the No Page Comment Plugin development")
21
 
@@ -26,15 +28,17 @@ There have been workarounds created by disabling comments site-wide on all pages
26
  1. Activate the plugin through the 'Plugins' menu in WordPress.
27
  1. Comments and trackbacks will be turned off by default when adding a new page.
28
 
29
- = Settings Page =
30
 
31
- Click 'FAQs Settings' in the settings panel. A screen will display showing the following settings for posts, pages, and any other custom post type installed on your blog:
32
 
33
  * Disable comments
34
  * Disable trackbacks
35
 
36
  Note: These settings set the default when creating a new page. Once a new post, page, or custom post type is added, comments can be enabled by modifying the Discussion settings for that page.
37
 
 
 
38
  == Frequently Asked Questions ==
39
 
40
  = Why aren't comments and trackbacks being disabled? =
@@ -43,16 +47,31 @@ Javascript probably isn't active on your browser. Enable javascript for the plug
43
 
44
  = Why are comments disabled in posts as well? =
45
 
46
- This is most likely due to a setting in WordPress. Go to the Discussion settings page and make sure that comments are enabled. The plugin will only block comments on pages.
 
 
 
 
47
 
48
  = How do I modify the comment settings on an individual post or page? =
49
 
50
  First, you must make sure you can see the Discussion admin box. Enable this by clicking on the 'Screen Options' tab at the top right and then checking the discussion checkbox. Below the post/page editor, there will be a new admin box allowing you to specifically enable or disable comments and trackbacks for that page or post.
51
 
 
 
 
 
 
 
 
 
52
  == Changelog ==
53
 
 
 
 
54
  = 0.2 =
55
- * UPDATE: Style Admin Settings Page to match with WordPress
56
  * NEW: Add support for posts
57
  * NEW: Add support for custom post types
58
 
@@ -61,5 +80,8 @@ First, you must make sure you can see the Discussion admin box. Enable this by c
61
 
62
  == Upgrade Notice ==
63
 
 
 
 
64
  = 0.2 =
65
- Adds the ability to disable comments on posts and pages. All previous No Page Comment settings will remain intact with upgrade.
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5WWP2EDSCAJR4
5
  Tags: admin, comments, custom post type, javascript, page, pages, post, posts, plugin, settings, tools, trackbacks
6
  Requires at least: 3.1
7
+ Tested up to: 3.5
8
  Stable tag: trunk
9
 
10
  Disable comments by default on new pages and custom post types, while still giving you the ability to individually set them on a page or post basis.
13
 
14
  By default, WordPress gives you two options. You can either disable comments and trackbacks by default for all pages and posts, or you can have them active by default. Unfortunately, there is no specific WordPress setting that allows comments and trackbacks to be active by default for posts, while disabling them on pages or any other post type.
15
 
16
+ There have been workarounds created by disabling comments site-wide on all pages and/or posts, but what if you actually want to have comments on a page or two? The difference between this plugin and others is that it will automatically uncheck to discussion settings boxes for you when creating a new page, while still giving you the flexibility to open comments up specifically on individual pages and post types.
17
 
18
+ Also, if you are looking for a quick way to disable all comments or pingbacks for a specific custom post type, that feature has now been built into the plugin. It directly interacts with your database to modify the status, so it is highly recommended that you backup your database first. There shouldn't be any issues with this feature, but it's always good to play it safe.
19
+
20
+ [Official No Page Comment Plugin Page](http://sethalling.com/plugins/wordpress/no-page-comment "No Page Comment WordPress Plugin")
21
 
22
  [Donate to Support No Page Comment Development](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5WWP2EDSCAJR4 "Donate to support the No Page Comment Plugin development")
23
 
28
  1. Activate the plugin through the 'Plugins' menu in WordPress.
29
  1. Comments and trackbacks will be turned off by default when adding a new page.
30
 
31
+ = Settings Page =
32
 
33
+ Click 'No Page Comment' in the settings panel. A screen will display showing the following settings for posts, pages, and any other custom post type installed on your blog:
34
 
35
  * Disable comments
36
  * Disable trackbacks
37
 
38
  Note: These settings set the default when creating a new page. Once a new post, page, or custom post type is added, comments can be enabled by modifying the Discussion settings for that page.
39
 
40
+ Also, there is now the option to globally enable/disable comments or pingbacks of a specific post type.
41
+
42
  == Frequently Asked Questions ==
43
 
44
  = Why aren't comments and trackbacks being disabled? =
47
 
48
  = Why are comments disabled in posts as well? =
49
 
50
+ This is most likely due to a setting in WordPress. Go to the 'Discussion' settings page and make sure that comments are enabled. This is required for the plugin to work properly.
51
+
52
+ = Why can't I enable comments of custom post type: "X" =
53
+
54
+ Depending on your theme or plugin that created custom post type "X", that post type may not have comments set up. If this is the case, this plugin cannot help you and you will have to talk to that theme/plugin author.
55
 
56
  = How do I modify the comment settings on an individual post or page? =
57
 
58
  First, you must make sure you can see the Discussion admin box. Enable this by clicking on the 'Screen Options' tab at the top right and then checking the discussion checkbox. Below the post/page editor, there will be a new admin box allowing you to specifically enable or disable comments and trackbacks for that page or post.
59
 
60
+ = I want to quickly disable all trackbacks throughout my blog posts. Is this possible? =
61
+
62
+ Of course, although *it is highly recommended that you backup your blog's database prior to completing this step*. Go to the 'No Page Comment' settings page and scroll to the bottom of the page. There is an area that will allow you to either enable or disble both comments and trackbacks for any post type you have installed on your blog.
63
+
64
+ == Screenshots ==
65
+
66
+ 1. The Settings page on a fresh WordPress 3.5 installation
67
+
68
  == Changelog ==
69
 
70
+ = 0.3 =
71
+ * NEW: Add ability to enable/disable all comments or trackbacks on any specific custom post type. It is highly recommended that you backup your blog's database prior to doing this.
72
+
73
  = 0.2 =
74
+ * UPDATE: Style Admin Settings Page to match with WordPress
75
  * NEW: Add support for posts
76
  * NEW: Add support for custom post types
77
 
80
 
81
  == Upgrade Notice ==
82
 
83
+ = 0.3 =
84
+ Adds the ability to enable/disable all comments or trackbacks on any specific custom post type. All previous No Page Comment settings will remain intact with upgrade.
85
+
86
  = 0.2 =
87
+ Adds the ability to disable comments on posts, pages, and custom post types. All previous No Page Comment settings will remain intact with upgrade.