No Page Comment - Version 0.2

Version Description

  • UPDATE: Style Admin Settings Page to match with WordPress
  • NEW: Add support for posts
  • NEW: Add support for custom post types
Download this release

Release Info

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

Code changes from version 0.1 to 0.2

Files changed (2) hide show
  1. no-page-comment.php +114 -42
  2. readme.txt +24 -16
no-page-comment.php CHANGED
@@ -2,8 +2,8 @@
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 a page, but leave them enabled on posts, while still giving you the ability to individually set them on a page or post basis.
6
- Version: 0.1
7
  Author: Seth Alling
8
  Author URI: http://sethalling.com/
9
 
@@ -30,6 +30,7 @@ if ( ! function_exists('sta_npc_activate') ) {
30
  function sta_npc_activate() {
31
  sta_npc_load();
32
  global $sta_npc_plugin;
 
33
  }
34
  }
35
 
@@ -44,6 +45,20 @@ if ( ! function_exists('sta_npc_load') ) {
44
  public $plugin_file;
45
  public $plugin_dir;
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  // Plugin Constructor
48
  function sta_npc_plugin() {
49
  $this->plugin_dir = WP_PLUGIN_URL.'/'.$this->plugin_name;
@@ -57,12 +72,26 @@ if ( ! function_exists('sta_npc_load') ) {
57
 
58
  // Returns an array of admin options
59
  function sta_npc_get_admin_options() {
 
60
  $sta_npc_admin_options = array(
61
- 'disable_comments' => 'true',
62
- 'disable_trackbacks' => 'true'
 
 
63
  );
 
 
 
 
 
 
 
 
 
 
64
  $sta_npc_options = get_option($this->admin_options_name);
65
  if ( ! empty($sta_npc_options) ) {
 
66
  foreach ($sta_npc_options as $key => $option)
67
  $sta_npc_admin_options[$key] = $option;
68
  }
@@ -75,37 +104,77 @@ if ( ! function_exists('sta_npc_load') ) {
75
  $sta_npc_options = $this->sta_npc_get_admin_options();
76
 
77
  if ( isset($_POST['update_sta_npc_plugin_settings']) ) {
78
- if ( isset($_POST['sta_npc_disable_comments']) ) {
79
- $sta_npc_options['disable_comments'] = $_POST['sta_npc_disable_comments'];
80
- }
81
- if ( isset($_POST['sta_npc_disable_trackbacks']) ) {
82
- $sta_npc_options['disable_trackbacks'] = $_POST['sta_npc_disable_trackbacks'];
83
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  update_option($this->admin_options_name, $sta_npc_options);
85
  ?>
86
  <div class="updated"><p><strong><?php _e('Settings Updated.', $this->plugin_domain);?></strong></p></div>
87
  <?php } ?>
88
- <div class=wrap>
89
- <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" style="float:left; width:500px;">
 
 
90
  <h2>No Page Comment Settings</h2>
91
-
92
- <h3>Disable comments on new pages:</h3>
93
- <p><label for="sta_npc_disable_comments_yes" style="width:70px; float:left;"><input type="radio" id="sta_npc_disable_comments_yes" name="sta_npc_disable_comments" value="true" <?php if ( $sta_npc_options['disable_comments'] == 'true' ) { _e('checked="checked"', $this->plugin_domain); } ?> /> Yes</label><label for="sta_npc_disable_comments_no" style="width:70px; float:left;"><input type="radio" id="sta_npc_disable_comments_no" name="sta_npc_disable_comments" value="false" <?php if ( $sta_npc_options['disable_comments'] == 'false' ) { _e('checked="checked"', $this->plugin_domain); } ?>/> No</label></p><br style="clear:both;" />
94
-
95
- <h3>Disable trackbacks on new pages:</h3>
96
- <p><label for="sta_npc_disable_trackbacks_yes" style="width:70px; float:left;"><input type="radio" id="sta_npc_disable_trackbacks_yes" name="sta_npc_disable_trackbacks" value="true" <?php if ( $sta_npc_options['disable_trackbacks'] == 'true' ) { _e('checked="checked"', $this->plugin_domain); } ?> /> Yes</label><label for="sta_npc_disable_trackbacks_no" style="width:70px; float:left;"><input type="radio" id="sta_npc_disable_trackbacks_no" name="sta_npc_disable_trackbacks" value="false" <?php if ( $sta_npc_options['disable_trackbacks'] == 'false' ) { _e('checked="checked"', $this->plugin_domain); } ?>/> No</label></p><br style="clear:both;" />
97
-
98
- <div class="submit">
99
- <input type="submit" name="update_sta_npc_plugin_settings" value="<?php _e('Update Settings', $this->plugin_domain); ?>" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  </div>
101
  </form>
102
- <div style="float:left; margin-left:20px;">
103
- <h3>View other plugins created by <a href="http://sethalling.com/" title="Seth Alling">Seth Alling</a>:</h3>
104
- <ul>
105
- <li><a href="http://sethalling.com/plugins/wp-faqs-pro" title="WP FAQs Pro">WP FAQs Pro</a></li>
106
- </ul>
107
- </div>
108
  </div>
 
 
109
  <?php } // End sta_npc_print_admin_page function
110
 
111
  function sta_npc_settings_link($links, $file) {
@@ -126,21 +195,26 @@ if ( ! function_exists('sta_npc_load') ) {
126
  global $pagenow;
127
  global $post;
128
  $sta_npc_options = $this->sta_npc_get_admin_options();
129
- if ( (is_admin()) && ($pagenow=='post-new.php') && ($post->filter=='raw') && ($post->post_type=='page') ) {
130
- wp_enqueue_script('jquery'); ?>
 
131
 
132
  <script type="text/javascript">
133
  jQuery(document).ready(function() {
134
- <?php if ( $sta_npc_options['disable_comments'] == 'true' ) { ?>
135
- if ( jQuery('#comment_status').length ) {
136
- jQuery('#comment_status').attr('checked', false);
137
- }
138
- <?php }
139
- if ( $sta_npc_options['disable_trackbacks'] == 'true' ) { ?>
140
- if ( jQuery('#ping_status').length ) {
141
- jQuery('#ping_status').attr('checked', false);
142
- }
143
- <?php } ?>
 
 
 
 
144
  });
145
  </script>
146
 
@@ -169,6 +243,4 @@ if ( ! function_exists('sta_npc_load') ) {
169
  }
170
  }
171
 
172
- sta_npc_load();
173
-
174
-
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
 
30
  function sta_npc_activate() {
31
  sta_npc_load();
32
  global $sta_npc_plugin;
33
+ $sta_npc_plugin->sta_npc_activate();
34
  }
35
  }
36
 
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'];
53
+ unset($sta_npc_options_retrieve['disable_comments']);
54
+ }
55
+ if ( isset($sta_npc_options_retrieve['disable_trackbacks']) ) {
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;
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
  }
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>
134
  <h2>No Page Comment Settings</h2>
135
+ <div id="poststuff" class="metabox-holder has-right-sidebar">
136
+ <div id="side-info-column" class="inner-sidebar">
137
+ <div id="side-sortables" class="meta-box-sortables ui-sortable">
138
+ <div id="pageparentdiv" class="postbox">
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>
146
+ </div>
147
+ </div>
148
+ <div id="post-body">
149
+ <div id="post-body-content">
150
+ <div id="postcustom" class="postbox" style="">
151
+ <h3 class="hndle" style="cursor:default;"><span>Disable comments on new:</span></h3>
152
+ <div class="inside">
153
+ <?php foreach ( get_post_types('','objects') as $posttype ) {
154
+ if ( in_array( $posttype->name, array('revision','nav_menu_item','attachment') ) )
155
+ continue; ?>
156
+ <p style="padding:5px 0;">
157
+ <strong class="post_type" style="width:160px; float:left;"><?php echo $posttype->label; ?></strong>
158
+ <label for="sta_npc_disable_comments_<?php echo $posttype->name; ?>" style="width:110px; float:left;">
159
+ <input type="checkbox" id="sta_npc_disable_comments_<?php echo $posttype->name; ?>" name="sta_npc_disable_comments_<?php echo $posttype->name; ?>" value="true" <?php if ( $sta_npc_options['disable_comments_' . $posttype->name] == 'true' ) { _e('checked="checked"', $this->plugin_domain); } ?> />
160
+ Comments</label>
161
+ <label for="sta_npc_disable_trackbacks_<?php echo $posttype->name; ?>" style="width:110px; float:left;">
162
+ <input type="checkbox" id="sta_npc_disable_trackbacks_<?php echo $posttype->name; ?>" name="sta_npc_disable_trackbacks_<?php echo $posttype->name; ?>" value="true" <?php if ( $sta_npc_options['disable_trackbacks_' . $posttype->name] == 'true' ) { _e('checked="checked"', $this->plugin_domain); } ?>/> Trackbacks</label>
163
+ </p>
164
+ <br style="clear:both;" />
165
+ <?php } ?>
166
+ </div>
167
+ </div>
168
+ <p class="submit">
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) {
195
  global $pagenow;
196
  global $post;
197
  $sta_npc_options = $this->sta_npc_get_admin_options();
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]) ) {
205
+ if ( $sta_npc_options['disable_comments_' . $posttype] == 'true' ) { ?>
206
+ if ( jQuery('#comment_status').length ) {
207
+ jQuery('#comment_status').attr('checked', false);
208
+ }
209
+ <?php }
210
+ }
211
+ if ( isset($sta_npc_options['disable_trackbacks_' . $posttype]) ) {
212
+ if ( $sta_npc_options['disable_trackbacks_' . $posttype] == 'true' ) { ?>
213
+ if ( jQuery('#ping_status').length ) {
214
+ jQuery('#ping_status').attr('checked', false);
215
+ }
216
+ <?php }
217
+ } ?>
218
  });
219
  </script>
220
 
243
  }
244
  }
245
 
246
+ sta_npc_load();
 
 
readme.txt CHANGED
@@ -2,21 +2,23 @@
2
 
3
  Contributors: sethta
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5WWP2EDSCAJR4
5
- Tags: admin, comments, javascript, page, pages, plugin, settings, tools, trackbacks
6
  Requires at least: 3.1
7
- Tested up to: 3.2.1
8
- Stable tag: 0.1
9
 
10
- Disable comments by default on new pages, while still giving you the ability to individually set them on a page or post basis.
11
 
12
  == Description ==
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.
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.
17
 
18
  [Official No Page Comment Plugin Page](http://sethalling.com/plugins/no-page-comment "No Page Comment WordPress Plugin")
19
 
 
 
20
  == Installation ==
21
 
22
  1. Unzip the `no-page-comment.zip` file and `no-page-comment` folder to your `wp-content/plugins` folder.
@@ -26,12 +28,12 @@ There have been workarounds created by disabling comments site-wide on all pages
26
 
27
  = Settings Page =
28
 
29
- Click 'FAQs Settings' in the settings panel:
30
 
31
- * Disable comments on pages
32
- * Disable trackbacks on pages
33
 
34
- Note: These settings set the default when creating a new page. Once a new page has been created, comments can be enabled by modifying the Discussion settings for that page.
35
 
36
  == Frequently Asked Questions ==
37
 
@@ -41,17 +43,23 @@ Javascript probably isn't active on your browser. Enable javascript for the plug
41
 
42
  = Why are comments disabled in posts as well? =
43
 
44
- This is most likely due to a setting in WordPress. Go to the Discussion settings page and make sure that comments are enabled on. The plugin will only block comments on pages.
45
 
46
  = How do I modify the comment settings on an individual post or page? =
47
 
48
  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.
49
 
50
- = What are your plans for the future? =
51
-
52
- I am hoping to add in custom post type support. Please [donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5WWP2EDSCAJR4 "Donate to Seth Alling for the No Page Comment Plugin") to continue development.
53
-
54
  == Changelog ==
55
 
 
 
 
 
 
56
  = 0.1 =
57
- * NEW: Initial release.
 
 
 
 
 
2
 
3
  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.
11
 
12
  == Description ==
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
+
22
  == Installation ==
23
 
24
  1. Unzip the `no-page-comment.zip` file and `no-page-comment` folder to your `wp-content/plugins` folder.
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
 
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
+
59
  = 0.1 =
60
+ * NEW: Initial release.
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.