Version Description
- NEW: Initial release.
Download this release
Release Info
Developer | sethta |
Plugin | No Page Comment |
Version | 0.1 |
Comparing to | |
See all releases |
Version 0.1
- no-page-comment.php +174 -0
- readme.txt +57 -0
no-page-comment.php
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
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 |
+
|
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');
|
28 |
+
|
29 |
+
if ( ! function_exists('sta_npc_activate') ) {
|
30 |
+
function sta_npc_activate() {
|
31 |
+
sta_npc_load();
|
32 |
+
global $sta_npc_plugin;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( ! function_exists('sta_npc_load') ) {
|
37 |
+
function sta_npc_load() {
|
38 |
+
if ( ! class_exists('STA_NPC_Plugin') ) {
|
39 |
+
class STA_NPC_Plugin {
|
40 |
+
var $admin_options_name = 'sta_npc_admin_options_name';
|
41 |
+
var $admin_users_name = 'sta_npc_admin_options_name';
|
42 |
+
var $plugin_domain = 'sta_npc_lang';
|
43 |
+
public $plugin_name = 'no-page-comment';
|
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;
|
50 |
+
$this->plugin_file = $this->plugin_name . '.php';
|
51 |
+
}
|
52 |
+
|
53 |
+
// Intialize Admin Options
|
54 |
+
function sta_npc_init() {
|
55 |
+
$this->sta_npc_get_admin_options();
|
56 |
+
}
|
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 |
+
}
|
69 |
+
update_option($this->admin_options_name, $sta_npc_admin_options);
|
70 |
+
return $sta_npc_admin_options;
|
71 |
+
}
|
72 |
+
|
73 |
+
// Prints out the admin page
|
74 |
+
function sta_npc_print_admin_page() {
|
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) {
|
112 |
+
if ( basename($file) == $this->plugin_file ) {
|
113 |
+
$settings_link = '<a href="' . admin_url('options-general.php?page=' . $this->plugin_file) . '">Settings</a>';
|
114 |
+
array_unshift($links, $settings_link);
|
115 |
+
}
|
116 |
+
return $links;
|
117 |
+
}
|
118 |
+
|
119 |
+
function sta_npc_plugin_admin() {
|
120 |
+
if ( function_exists('add_options_page') ) {
|
121 |
+
add_options_page('No Page Comment Settings', 'No Page Comment', 'manage_options', $this->plugin_file, array( $this, 'sta_npc_print_admin_page' ));
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
function sta_no_page_comment() {
|
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 |
+
|
147 |
+
<?php }
|
148 |
+
}
|
149 |
+
|
150 |
+
}
|
151 |
+
|
152 |
+
} // End Class STA_NPC_Plugin
|
153 |
+
|
154 |
+
if ( class_exists('STA_NPC_Plugin') ) {
|
155 |
+
global $sta_npc_plugin;
|
156 |
+
$sta_npc_plugin = new STA_NPC_Plugin();
|
157 |
+
}
|
158 |
+
|
159 |
+
// Actions, Filters and Shortcodes
|
160 |
+
if ( isset($sta_npc_plugin) ) {
|
161 |
+
// Actions
|
162 |
+
add_action('admin_menu', array( &$sta_npc_plugin, 'sta_npc_plugin_admin' )); // Activate admin settings page
|
163 |
+
add_action('activate_no-page-comment/no-page-comment.php', array( &$sta_npc_plugin, 'sta_npc_init' )); // Activate admin options
|
164 |
+
add_action( 'admin_head', array( &$sta_npc_plugin, 'sta_no_page_comment' ));
|
165 |
+
|
166 |
+
// Filters
|
167 |
+
add_filter('plugin_action_links', array( &$sta_npc_plugin, 'sta_npc_settings_link'), 10, 2 );
|
168 |
+
}
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
sta_npc_load();
|
173 |
+
|
174 |
+
|
readme.txt
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== No Page Comment ===
|
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.
|
23 |
+
1. Alternatively, you can install it from the 'Add New' link in the 'Plugins' menu in WordPress.
|
24 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress.
|
25 |
+
1. Comments and trackbacks will be turned off by default when adding a new page.
|
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 |
+
|
38 |
+
= Why aren't comments and trackbacks being disabled? =
|
39 |
+
|
40 |
+
Javascript probably isn't active on your browser. Enable javascript for the plugin to work correctly.
|
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.
|