first commit

This commit is contained in:
2023-09-12 21:41:04 +02:00
commit 3361a7f053
13284 changed files with 2116755 additions and 0 deletions

View File

@@ -0,0 +1,135 @@
# Copyright (C) 2014 No Page Comment
# This file is distributed under the same license as the No Page Comment package.
msgid ""
msgstr ""
"Project-Id-Version: No Page Comment 1.0.5\n"
"Report-Msgid-Bugs-To: http://wordpress.org/tag/no-page-comment\n"
"POT-Creation-Date: 2014-03-02 01:02:56+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2014-08-15 13:14+0100\n"
"Last-Translator: Andréas Lundgren <adevade@gmail.com>\n"
"Language-Team: 035media <info@035media.se>\n"
"X-Generator: Poedit 1.6.7\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: sv_SE\n"
"X-Poedit-SourceCharset: UTF-8\n"
#: no-page-comment-settings.php:31
msgid "Settings Updated."
msgstr "Inställningarna sparades."
#: no-page-comment-settings.php:35 no-page-comment.php:152
msgid "No Page Comment Settings"
msgstr "Inställningar för No Page Comment"
#: no-page-comment-settings.php:44
msgid "Disable comments on new:"
msgstr "Inaktivera kommentarer på nya:"
#: no-page-comment-settings.php:53
msgid "Comments"
msgstr "Kommentarer"
#: no-page-comment-settings.php:55
msgid "Trackbacks"
msgstr "Trackbacks"
#: no-page-comment-settings.php:63
msgid "Update Settings"
msgstr "Uppdatera inställningar"
#: no-page-comment-settings.php:70
msgid "Modify all current:"
msgstr "Redigera alla nuvarande:"
#: no-page-comment-settings.php:79
msgid "Disable All Comments"
msgstr "Inaktivera alla kommentarer"
#: no-page-comment-settings.php:80
msgid "Enable All Comments"
msgstr "Aktivera alla kommentarer"
#: no-page-comment-settings.php:83
msgid "Disable All Trackbacks"
msgstr "Inaktivera alla trackbacks"
#: no-page-comment-settings.php:84
msgid "Enable All Trackbacks"
msgstr "Aktivera alla trackbacks"
#: no-page-comment-settings.php:101
msgid "Other plugins by"
msgstr "Andra tillägg av"
#: no-page-comment-settings.php:110
msgid "Support No Page Comment:"
msgstr "Stöd No Page Comment"
#: no-page-comment-settings.php:113
msgid "Donate to support the No Page Comment plugin development"
msgstr "Donera för att stödja utvecklingen av No Page Comment"
#: no-page-comment-settings.php:113
msgid "Donate"
msgstr "Donera"
#: no-page-comment-settings.php:114
msgid "Write a Review about No Page Comment"
msgstr "Skriv en recension om No Page Comment"
#: no-page-comment-settings.php:114
msgid "Write a Review"
msgstr "Skriv en recension"
#: no-page-comment-settings.php:115
msgid "Fork No Page Comment on Github"
msgstr "Fork No Page Comment på GitHub"
#: no-page-comment-settings.php:115
msgid "Fork No Page Comment"
msgstr "Fork No Page Comment"
#: no-page-comment-settings.php:116
msgid "Report an Issue on Github"
msgstr "Rapportera ett problem på GitHub"
#: no-page-comment-settings.php:116
msgid "Report an Issue about No Page Comment"
msgstr "Rapportera ett problem med No Page Comment"
#: no-page-comment-settings.php:117
msgid "Help Translate No Page Comment"
msgstr "Hjälp till att översätta No Page Comment"
#: no-page-comment-settings.php:117
msgid "Offer to Translate No Page Comment"
msgstr "Översätt No Page Comment"
#: no-page-comment-settings.php:123
msgid "Translation Thanks:"
msgstr "Översättningar av:"
#: no-page-comment.php:133
msgid "Settings"
msgstr "Inställningar"
#: no-page-comment.php:152
msgid "Comment and trackback defaults controlled through"
msgstr "Standardinställningar för kommentarer och trackbacks kontrolleras av"
#. Plugin Name of the plugin/theme
msgid "No Page Comment"
msgstr "No Page Comment"
#. Description of the plugin/theme
msgid ""
"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."
msgstr ""
"Ett tillägg som använder JavaScript för att inaktivera kommentarer på "
"inlägg, sidor och/eller egna inläggstyper men lämnar dem aktiverade på "
"andra. "

View File

@@ -0,0 +1,143 @@
# Copyright (C) 2015 No Page Comment
# This file is distributed under the same license as the No Page Comment package.
msgid ""
msgstr ""
"Project-Id-Version: No Page Comment 1.1\n"
"Report-Msgid-Bugs-To: http://wordpress.org/tag/no-page-comment\n"
"POT-Creation-Date: 2014-03-02 01:02:56+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
#: no-page-comment-settings.php:37
msgid "Settings Updated."
msgstr ""
#: no-page-comment-settings.php:41 no-page-comment.php:153 no-page-comment.php:163
msgid "No Page Comment Settings"
msgstr ""
#: no-page-comment-settings.php:50
msgid "Disable comments on new:"
msgstr ""
#: no-page-comment-settings.php:59
msgid "Comments"
msgstr ""
#: no-page-comment-settings.php:61
msgid "Trackbacks"
msgstr ""
#: no-page-comment-settings.php:69
msgid "Update Settings"
msgstr ""
#: no-page-comment-settings.php:76
msgid "Modify all current:"
msgstr ""
#: no-page-comment-settings.php:85
msgid "Disable All Comments"
msgstr ""
#: no-page-comment-settings.php:86
msgid "Enable All Comments"
msgstr ""
#: no-page-comment-settings.php:89
msgid "Disable All Trackbacks"
msgstr ""
#: no-page-comment-settings.php:90
msgid "Enable All Trackbacks"
msgstr ""
#: no-page-comment-settings.php:107
msgid "Other plugins by"
msgstr ""
#: no-page-comment-settings.php:116
msgid "Support No Page Comment:"
msgstr ""
#: no-page-comment-settings.php:119
msgid "Donate to support the No Page Comment plugin development"
msgstr ""
#: no-page-comment-settings.php:119
msgid "Donate"
msgstr ""
#: no-page-comment-settings.php:120
msgid "Write a Review about No Page Comment"
msgstr ""
#: no-page-comment-settings.php:120
msgid "Write a Review"
msgstr ""
#: no-page-comment-settings.php:121
msgid "Fork No Page Comment on Github"
msgstr ""
#: no-page-comment-settings.php:121
msgid "Fork No Page Comment"
msgstr ""
#: no-page-comment-settings.php:122
msgid "Report an Issue on Github"
msgstr ""
#: no-page-comment-settings.php:122
msgid "Report an Issue about No Page Comment"
msgstr ""
#: no-page-comment-settings.php:123
msgid "Help Translate No Page Comment"
msgstr ""
#: no-page-comment-settings.php:123
msgid "Offer to Translate No Page Comment"
msgstr ""
#: no-page-comment-settings.php:129
msgid "Translation Thanks:"
msgstr ""
#: no-page-comment-settings.php:132
msgid "Dutch and Italian:"
msgstr ""
#: no-page-comment-settings.php:133
msgid "Serbian:"
msgstr ""
#: no-page-comment-settings.php:134
msgid "Spanish:"
msgstr ""
#: no-page-comment-settings.php:135
msgid "Swedish:"
msgstr ""
#: no-page-comment.php:144
msgid "Settings"
msgstr ""
#: no-page-comment.php:163
msgid "Comment and trackback defaults controlled through"
msgstr ""
#. Plugin Name of the plugin/theme no-page-comment.php:153
msgid "No Page Comment"
msgstr ""
#. Description of the plugin/theme
msgid ""
"An admin interface to control the default comment and trackback settings on "
"new posts, pages and custom post types."
msgstr ""

View File

@@ -0,0 +1,153 @@
<?php
// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
exit( 'This plugin requires WordPress' );
}
?>
<form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" class="wrap npc-settings">
<?php
// Add nonce to prevent CSRF
wp_nonce_field( 'sta_npc_csrf_nonce' );
$nonce = ( isset( $_REQUEST['_wpnonce'] ) ) ? $_REQUEST['_wpnonce'] : false;
?>
<?php
// Prints out the admin settings page
$sta_npc_nonce = wp_create_nonce( 'sta_npc_nonce' );
$sta_npc_options = $this->sta_npc_get_admin_options();
if ( wp_verify_nonce( $nonce, 'sta_npc_csrf_nonce' ) && isset( $_POST['update_sta_npc_plugin_settings'] ) ) {
foreach ( get_post_types( '', 'objects' ) as $posttype ) {
if ( in_array( $posttype->name, $this->excluded_posttypes ) )
continue;
if ( isset( $_POST['sta_npc_disable_comments_' . $posttype->name] ) ) {
$sta_npc_options['disable_comments_' . $posttype->name] = $_POST['sta_npc_disable_comments_' . $posttype->name];
} else {
$sta_npc_options['disable_comments_' . $posttype->name] = 'false';
}
if ( isset( $_POST['sta_npc_disable_trackbacks_' . $posttype->name] ) ) {
$sta_npc_options['disable_trackbacks_' . $posttype->name] = $_POST['sta_npc_disable_trackbacks_' . $posttype->name];
} else {
$sta_npc_options['disable_trackbacks_' . $posttype->name] = 'false';
}
} // end foreach post types
update_option($this->admin_options_name, $sta_npc_options);
?>
<div class="updated"><p><strong><?php _e('Settings Updated.', $this->plugin_domain ); ?></strong></p></div>
<?php } ?>
<div id="icon-options-general" class="icon32"></div>
<h2><?php _e( 'No Page Comment Settings', $this->plugin_domain ); ?></h2>
<div id="poststuff">
<div id="post-body" class="metabox-holder columns-2">
<div id="post-body-content">
<div class="meta-box-sortables ui-sortable">
<div class="postbox">
<h3 style="cursor:default;"><span><?php _e('Disable comments on new:', $this->plugin_domain ); ?></span></h3>
<div class="inside">
<?php foreach ( get_post_types('','objects') as $posttype ) {
if ( in_array( $posttype->name, $this->excluded_posttypes ) )
continue; ?>
<div>
<strong class="post-type"><?php echo $posttype->label; ?></strong>
<div class="inner">
<label for="sta_npc_disable_comments_<?php echo $posttype->name; ?>">
<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' ) { echo 'checked="checked"'; } ?>> <?php _e('Comments', $this->plugin_domain ); ?></label>
<label for="sta_npc_disable_trackbacks_<?php echo $posttype->name; ?>">
<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' ) { echo 'checked="checked"'; } ?>> <?php _e('Trackbacks', $this->plugin_domain ); ?></label>
</div>
</div>
<br class="clear">
<?php } ?>
</div>
</div>
<p class="submit">
<input type="submit" name="update_sta_npc_plugin_settings" id="submit" class="button-primary" value="<?php _e('Update Settings', $this->plugin_domain ); ?>">
</p>
</div>
<div class="meta-box-sortables ui-sortable">
<div class="postbox">
<h3 style="cursor:default;"><span><?php _e('Modify all current:', $this->plugin_domain ); ?></span></h3>
<div class="inside buttons">
<?php foreach ( get_post_types('','objects') as $posttype ) {
if ( in_array( $posttype->name, $this->excluded_posttypes ) )
continue; ?>
<div>
<strong class="post-type"><?php echo $posttype->label; ?></strong>
<div class="inner">
<div>
<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 ); ?>">
<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 ); ?>">
</div>
<div>
<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 ); ?>">
<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 ); ?>">
</div>
</div>
</div>
<br class="clear">
<?php } ?>
</div>
</div>
</div>
</div>
<div id="postbox-container-1" class="postbox-container">
<div class="meta-box-sortables">
<?php /*<div class="postbox">
<h3 style="cursor:default;"><span><?php _e('Other plugins by', $this->plugin_domain ); ?> <a href="http://sethalling.com/" title="Seth Alling" style="font-size:15px;">Seth Alling</a>:</span></h3>
<div class="inside">
<ul>
<li style="padding:5px 0;"><a href="http://sethalling.com/plugins/wordpress/wp-faqs-pro" title="WP FAQs Pro" target="_blank">WP FAQs Pro</a></li>
</ul>
</div>
</div>*/ ?>
<div class="postbox">
<h3 style="cursor:default;"><span><?php _e('Support No Page Comment:', $this->plugin_domain ); ?></span></h3>
<div class="inside">
<ul>
<li style="padding:5px 0;"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5WWP2EDSCAJR4" title="<?php _e('Donate to support the No Page Comment plugin development', $this->plugin_domain ); ?>" target="_blank"><?php _e('Donate', $this->plugin_domain ); ?></a></li>
<li style="padding:5px 0;"><a href="http://wordpress.org/support/view/plugin-reviews/no-page-comment#postform" title="<?php _e('Write a Review about No Page Comment', $this->plugin_domain ); ?>" target="_blank"><?php _e('Write a Review', $this->plugin_domain ); ?></a></li>
<li style="padding:5px 0;"><a href="https://github.com/sethta/no-page-comment" title="<?php _e('Fork No Page Comment on Github', $this->plugin_domain ); ?>" target="_blank"><?php _e('Fork No Page Comment', $this->plugin_domain ); ?></a></li>
<li style="padding:5px 0;"><a href="https://github.com/sethta/no-page-comment/issues" title="<?php _e('Report an Issue on Github', $this->plugin_domain ); ?>" target="_blank"><?php _e('Report an Issue about No Page Comment', $this->plugin_domain ); ?></a></li>
<li style="padding:5px 0;"><a href="http://sethalling.com/contact/" title="<?php _e('Help Translate No Page Comment', $this->plugin_domain ); ?>" target="_blank"><?php _e('Offer to Translate No Page Comment', $this->plugin_domain ); ?></a></li>
</ul>
</div>
</div>
<div class="postbox">
<h3 style="cursor:default;"><span><?php _e('Translation Thanks:', $this->plugin_domain ); ?></span></h3>
<div class="inside">
<ul>
<li style="padding:5px 0;"><?php _e('Dutch and Italian:', $this->plugin_domain ); ?> <a href="http://www.fravaco.be/" title="Fravaco" target="_blank">Fravaco</a></li>
<li style="padding:5px 0;"><?php _e('Serbian:', $this->plugin_domain ); ?> <a href="http://firstsiteguide.com/" title="firstsiteguide.com" target="_blank">firstsiteguide.com</a></li>
<li style="padding:5px 0;"><?php _e('Spanish:', $this->plugin_domain ); ?> <a href="http://www.webhostinghub.com/" title="Maria Ramos, WebHostingHub" target="_blank">Maria Ramos, WebHostingHub</a></li>
<li style="padding:5px 0;"><?php _e('Swedish:', $this->plugin_domain ); ?> <a href="http://adevade.com/" title="Andréas Lundgren" target="_blank">Andréas Lundgren</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<br class="clear">
</div>
</form>

View File

@@ -0,0 +1,73 @@
.npc-settings .inside > div {
padding: 10px 0 0;
float: left;
width: 100%;
}
.npc-settings .inside .post-type {
width: 20%;
min-width: 120px;
margin-bottom: 10px;
float: left;
}
.npc-settings .inner {
float: left;
width: 80%;
}
.npc-settings .inner > div {
float: left;
width: 50%;
}
.npc-settings .inner label {
padding-right: 50px;
margin-bottom: 10px;
float:left;
}
.npc-settings .buttons input {
margin:0 1% 5px !important;
float:left;
width: 47%;
min-width: 150px;
}
@media (max-width: 1200px) {
.npc-settings .inside .post-type {
width: 30%;
}
.npc-settings .inner {
width: 70%;
}
.buttons .post-type {
min-width: 200px;
}
.npc-settings .buttons .inner {
width: 100%;
}
}
@media (max-width: 1152px) {
.npc-settings .buttons input {
margin:0 1% 5px !important;
width: 97%;
}
}
@media (max-width: 600px) {
.npc-settings .buttons input {
margin:0 1% 5px !important;
width: 97%;
}
}
@media (max-width: 380px) {
.npc-settings .inside .post-type {
min-width: 200px;
}
.npc-settings .inner > div {
width: 100%;
margin-bottom: 5px;
}
.npc-settings .buttons input {
margin:0 0 5px !important;
width: 100%;
}
}

View File

@@ -0,0 +1,464 @@
<?php
/*
Plugin Name: No Page Comment
Plugin URI: http://sethalling.com/plugins/no-page-comment
Description: An admin interface to control the default comment and trackback settings on new posts, pages and custom post types.
Version: 1.2
Author: Seth Alling
Author URI: http://sethalling.com/
Text Domain: no-page-comment
Plugin: Copyright (c) 2011-2015 Seth Alling
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
_____ _ _ _ _ _ _...._
/ ____| | | | | /\ | | (_) .'/ \ _'.
| (___ ___| |_| |__ / \ | | |_ _ __ __ _ /##\__/##\_\
\___ \ / _ \ __| '_ \ / /\ \ | | | | '_ \ / _` | |\##/ \##/ |
____) | __/ |_| | | | / ____ \| | | | | | | (_| | |/ \__/ \ _|
|_____/ \___|\__|_| |_| /_/ \_\_|_|_|_| |_|\__, | \ _/##\__/#/
__/ | '.\##/__.'
Plugin developed by: http://sethalling.com |___/ `""""`
*/
// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
exit( 'This plugin requires WordPress' );
}
register_activation_hook( __FILE__, 'sta_npc_activate' );
define( 'STA_NPC_WP_VERSION', version_compare( get_bloginfo( 'version' ), '3.4', '>=' ) );
if ( ! function_exists( 'sta_npc_activate' ) ) {
function sta_npc_activate() {
sta_npc_load();
global $sta_npc_plugin;
}
}
// Set text domain for translation
function sta_load_text_domain() {
load_plugin_textdomain( 'no-page-comment', false, basename( dirname( __FILE__ ) ) . '/lang/' );
}
add_action( 'init', 'sta_load_text_domain' ); // Set text domain for translation
if ( ! function_exists( 'sta_npc_load' ) ) {
function sta_npc_load() {
if ( ! class_exists( 'STA_NPC_Plugin' ) ) {
class STA_NPC_Plugin {
var $admin_options_name = 'sta_npc_options',
$admin_options_name_old = 'sta_npc_admin_options_name',
$plugin_domain = 'no-page-comment';
public $plugin_name = 'no-page-comment';
public $plugin_file;
public $plugin_dir;
public $wp_posttypes = array(
'post',
'page',
'revision',
'nav_menu_item',
'attachment'
);
public $excluded_posttypes = array(
'revision',
'nav_menu_item',
);
public $plugin_ver = '1.2';
// Plugin Constructor
function __construct() {
$this->plugin_dir = plugins_url( '/', __FILE__ );
$this->plugin_file = $this->plugin_name . '.php';
}
// Intialize Admin Options
function sta_npc_init() {
$this->sta_npc_get_admin_options();
}
// Returns an array of admin options
function sta_npc_get_admin_options() {
// Rename options from old options name
if ( get_option( $this->admin_options_name_old ) ) {
update_option( $this->admin_options_name, get_option( $this->admin_options_name_old ) );
delete_option( $this->admin_options_name_old );
}
$sta_npc_admin_options = array(
'disable_comments_post' => '',
'disable_trackbacks_post' => '',
'disable_comments_page' => 'true',
'disable_trackbacks_page' => 'true',
'disable_comments_attachment' => '',
'disable_trackbacks_attachment' => ''
);
foreach ( get_post_types( '', 'objects' ) as $posttype ) {
if ( in_array( $posttype->name, $this->wp_posttypes ) )
continue;
$sta_npc_admin_options['disable_comments_' . $posttype->name] = 'true';
$sta_npc_admin_options['disable_trackbacks_' . $posttype->name] = 'true';
} // end foreach post types
$sta_npc_options = get_option( $this->admin_options_name );
if ( ! empty( $sta_npc_options ) ) {
foreach ( $sta_npc_options as $key => $option )
$sta_npc_admin_options[$key] = $option;
}
update_option( $this->admin_options_name, $sta_npc_admin_options );
return $sta_npc_admin_options;
}
// Print out the admin page
function sta_npc_print_admin_page() {
include( dirname( __FILE__ ) . '/no-page-comment-settings.php' );
}
// Add stylesheet to admin page
function sta_npc_admin_styles( $hook ) {
if ( $hook == 'settings_page_no-page-comment' ) {
wp_register_style( 'sta_npc', $this->plugin_dir . '/no-page-comment.css', false, $this->plugin_ver );
wp_enqueue_style( 'sta_npc' );
}
}
// Add settings link to plugins page
function sta_npc_settings_link( $links, $file ) {
if ( basename( $file ) == $this->plugin_file ) {
$settings_link = '<a href="' . admin_url( 'options-general.php?page=' . $this->plugin_file ) . '">' . __( 'Settings', $this->plugin_domain ) . '</a>';
array_unshift( $links, $settings_link );
}
return $links;
}
// Add settings page to options sidebar
function sta_npc_plugin_admin() {
if ( function_exists( 'add_options_page' ) ) {
add_options_page( __( 'No Page Comment Settings', $this->plugin_domain ), __( 'No Page Comment', $this->plugin_domain ), 'manage_options', $this->plugin_file, array( $this, 'sta_npc_print_admin_page' ) );
}
}
// Modify discussion options page with a link to NPC settings page
function sta_discussion_options() {
global $pagenow;
global $post;
if ( ( is_admin() ) && ( $pagenow == 'options-discussion.php' ) ) {
$settings_link = __( 'Comment and trackback defaults controlled through', $this->plugin_domain ) . ' <a href="' . admin_url( 'options-general.php?page=' . $this->plugin_file ) . '">' . __( 'No Page Comment Settings', $this->plugin_domain ) . '</a>';
wp_enqueue_script( 'jquery' ); ?>
<script type="text/javascript">
jQuery(document).ready( function() {
jQuery('label[for="default_ping_status"]').remove().prev('br').remove();
jQuery('label[for="default_comment_status"]').prev('br').remove();
jQuery('label[for="default_comment_status"]').next('br').remove();
jQuery('label[for="default_comment_status"]').next('p').html('<?php echo $settings_link; ?>');
jQuery('label[for="default_comment_status"]').next('small').html('<?php echo $settings_link; ?>');
jQuery('label[for="default_comment_status"]').remove();
});
</script>
<?php }
}
// Disable comments and trackbacks on at least WP version 4.3 with a hook
function wpdocs_open_comments_for_myposttype( $status, $post_type, $comment_type ) {
$sta_npc_options = $this->sta_npc_get_admin_options();
if ( $comment_type == 'comment' ) { // Check if comment or trackback
if ( isset( $sta_npc_options['disable_comments_' . $post_type] ) ) {
if ( $sta_npc_options['disable_comments_' . $post_type] == 'true' ) {
return 'closed';
} else {
return 'open';
}
} else {
return $status;
}
} elseif ( $comment_type == 'pingback' ) { // Double check if trackback
if ( isset( $sta_npc_options['disable_trackbacks_' . $post_type] ) ) {
if ( $sta_npc_options['disable_trackbacks_' . $post_type] == 'true' ) {
return 'closed';
} else {
return 'open';
}
} else {
return $status;
}
} else { // This should never happen, but just in case
return $status;
}
}
// Disable comments with hook on WP versions 3.4-4.2
function sta_no_page_comment() {
global $pagenow;
$sta_npc_options = $this->sta_npc_get_admin_options();
if ( ( is_admin() ) && ( $pagenow == 'post-new.php' ) ) {
$posttype = ( isset( $_GET['post_type'] ) ) ? $_GET['post_type'] : 'post';
if ( $sta_npc_options['disable_comments_' . $posttype] == 'true' ) {
return 'closed';
} else {
return 'open';
}
}
}
// Disable trackbacks with hook on versions 3.4-4.2
function sta_no_page_trackback() {
global $pagenow;
$sta_npc_options = $this->sta_npc_get_admin_options();
if ( ( is_admin() ) && ( $pagenow == 'post-new.php' ) ) {
$posttype = ( isset( $_GET['post_type'] ) ) ? $_GET['post_type'] : 'post';
if ( $sta_npc_options['disable_trackbacks_' . $posttype] == 'true' ) {
return 'closed';
} else {
return 'open';
}
}
}
// Disable comments/trackbacks with jQuery (for WP versions earlier than 3.4)
function sta_no_page_comment_jquery() {
global $pagenow;
global $post;
$sta_npc_options = $this->sta_npc_get_admin_options();
if ( ( is_admin() ) && ( $pagenow == 'post-new.php' ) && ( $post->filter == 'raw' ) ) {
wp_enqueue_script( 'jquery' );
$posttype = $post->post_type; ?>
<script type="text/javascript">
jQuery(document).ready( function() {
<?php if ( isset($sta_npc_options['disable_comments_' . $posttype]) ) {
if ( $sta_npc_options['disable_comments_' . $posttype] == 'true' ) { ?>
if ( jQuery('#comment_status').length ) {
jQuery('#comment_status').attr('checked', false);
}
<?php } else { ?>
if ( jQuery('#comment_status').length ) {
jQuery('#comment_status').attr('checked', true);
}
<?php }
}
if ( isset($sta_npc_options['disable_trackbacks_' . $posttype]) ) {
if ( $sta_npc_options['disable_trackbacks_' . $posttype] == 'true' ) { ?>
if ( jQuery('#ping_status').length ) {
jQuery('#ping_status').attr('checked', false);
}
<?php } else { ?>
if ( jQuery('#ping_status').length ) {
jQuery('#ping_status').attr('checked', true);
}
<?php }
} ?>
});
</script>
<?php }
}
// Add ajax script to admin page
function sta_no_page_comment_ajax() {
global $pagenow;
global $post;
if ( ( is_admin() ) && ( $pagenow == 'options-general.php' ) && isset( $_GET['page'] ) ) {
if ( $_GET['page'] == 'no-page-comment.php' ) {
wp_enqueue_script( 'jquery' );
// Load Ajax File
wp_register_script( 'ajax-script', plugins_url( '/page-comment.js', __FILE__ ), array( 'jquery' ) );
wp_localize_script( 'ajax-script', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'ajax-script' );
}
}
}
// Ajax Function for WP Comment DB Modification
function sta_npc_mod() {
if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'sta_npc_nonce') ) {
exit( 'No naughty business please' );
}
global $wpdb;
$result[] = array();
$comment_type = $_REQUEST['comment_type'];
$comment_status = $_REQUEST['comment_status'];
if ( $comment_status == 'open' )
$comment_new_status = 'closed';
elseif ( $comment_status == 'closed' ) {
$comment_new_status = 'open';
}
$post_type = $_REQUEST['post_type'];
$post_label = $_REQUEST['post_label'];
if ( $comment_type == 'ping' ) {
$comment_label = 'trackbacks';
$comment_query = $wpdb->prepare(
"
UPDATE $wpdb->posts
SET ping_status = %s
WHERE ping_status = %s
AND post_type = %s
",
$comment_new_status,
$comment_status,
$post_type
);
} else {
$comment_label = 'comments';
$comment_query = $wpdb->prepare(
"
UPDATE $wpdb->posts
SET comment_status = %s
WHERE comment_status = %s
AND post_type = %s
",
$comment_new_status,
$comment_status,
$post_type
);
}
if ( $comment_query === FALSE ) {
$result['type'] = 'error';
$result['message'] = 'Something went wrong. Please refresh this page and try again.';
} else {
$wpdb->query( $comment_query );
$result['type'] = 'success';
$result['message'] = 'All ' . $comment_label . ' of ' . $post_label . ' have been marked as ' . $comment_new_status;
}
if ( ! empty( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) {
$result = json_encode( $result );
echo $result;
}
else {
header( 'Location: ' . $_SERVER['HTTP_REFERER'] );
}
die();
}
function nopriv_sta_npc_mod() {
exit( 'No naughty business please' );
}
// Disable comments/trackbacks on attachments
function attachment_comment( $id ) {
global $wpdb;
$sta_npc_options = $this->sta_npc_get_admin_options();
$comment_status = ( $sta_npc_options['disable_comments_attachment'] == 'true' ) ? 'closed' : 'open';
$trackback_status = ( $sta_npc_options['disable_trackbacks_attachment'] == 'true' ) ? 'closed' : 'open';
$comment_query = $wpdb->prepare(
"
UPDATE $wpdb->posts
SET comment_status = %s
WHERE ID = %s
",
$comment_status,
$id
);
$trackback_query = $wpdb->prepare(
"
UPDATE $wpdb->posts
SET ping_status = %s
WHERE ID = %s
",
$trackback_status,
$id
);
if ( $comment_query === FALSE ) {
} else {
$wpdb->query( $comment_query );
}
if ( $trackback_query === FALSE ) {
} else {
$wpdb->query( $trackback_query );
}
}
}
} // End Class STA_NPC_Plugin
if ( class_exists( 'STA_NPC_Plugin' ) ) {
global $sta_npc_plugin;
$sta_npc_plugin = new STA_NPC_Plugin();
}
// Actions, Filters and Shortcodes
if ( isset( $sta_npc_plugin ) ) {
// Actions
add_action( 'admin_menu', array( &$sta_npc_plugin, 'sta_npc_plugin_admin' ) ); // Activate admin settings page
add_action( 'activate_no-page-comment/no-page-comment.php', array( &$sta_npc_plugin, 'sta_npc_init' ) ); // Activate admin options
add_action( 'admin_enqueue_scripts', array( &$sta_npc_plugin, 'sta_npc_admin_styles' ) ); // Add admin stylesheet
add_action( 'admin_head', array( &$sta_npc_plugin, 'sta_no_page_comment_ajax' ) ); // Add ajax scripts
add_action( 'wp_ajax_sta_npc_mod', array( &$sta_npc_plugin, 'sta_npc_mod' ) ); // Add ajax function
add_action( 'wp_ajax_nopriv_sta_npc_mod', array( &$sta_npc_plugin, 'nopriv_sta_npc_mod' ) ); // Add logged out ajax function
add_action( 'add_attachment', array( &$sta_npc_plugin, 'attachment_comment' ) ); // Set comment status on new attachments
// Filters
add_filter( 'plugin_action_links', array( &$sta_npc_plugin, 'sta_npc_settings_link' ), 10, 2 ); // Add settings link to plugins page
add_filter( 'admin_head', array(&$sta_npc_plugin, 'sta_discussion_options' ) ); // Change discussion options replace defaults with link to NPC settings
// Run correct function depending on version
if ( function_exists( 'get_default_comment_status' ) ) {
add_filter( 'get_default_comment_status', array(&$sta_npc_plugin, 'wpdocs_open_comments_for_myposttype' ), 10, 3 ); // Comment settings
} elseif ( STA_NPC_WP_VERSION ) {
add_filter( 'pre_option_default_comment_status', array(&$sta_npc_plugin, 'sta_no_page_comment' ) ); // Comment settings
add_filter( 'pre_option_default_ping_status', array(&$sta_npc_plugin, 'sta_no_page_trackback' ) ); // Trackback settings
} else { // Use jQuery for WordPress versions earlier than 3.4
add_action( 'admin_head', array( &$sta_npc_plugin, 'sta_no_page_comment_jquery' ) ); // Add jquery scripts
}
}
}
}
sta_npc_load();

View File

@@ -0,0 +1,39 @@
jQuery(document).ready( function($) {
// Run WordPress Database Comment Modification
$('.sta_ajax_modify').click( function(e) {
e.preventDefault();
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.');
if(confirmresult == true ) {
nonce = $(this).attr('data-nonce');
post_type = $(this).attr('data-post_type');
post_label = $(this).attr('data-post_label');
comment_type = $(this).attr('data-comment_type');
comment_status = $(this).attr('data-comment_status');
$.ajax({
type : 'post',
dataType : 'json',
url : myAjax.ajaxurl,
data : {
action: 'sta_npc_mod',
nonce: nonce,
post_type: post_type,
post_label: post_label,
comment_type: comment_type,
comment_status: comment_status
},
success: function(response) {
if(response.type == 'success') {
alert(response.message);
console.log(response);
} else {
alert(response.message);
console.log(response);
}
},
error: function(MLHttpRequest, textStatus, errorThrown){
console.log(errorThrown);
}
});
}
});
});

View File

@@ -0,0 +1,147 @@
=== No Page Comment ===
Contributors: sethta
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5WWP2EDSCAJR4
Tags: admin, comments, custom post type, discussion, pages, posts, attachment, attachments, media, settings, tools, trackbacks
Requires at least: 3.1
Tested up to: 5.2.3
Stable tag: trunk
An admin interface to control the default comment and trackback settings on new posts, pages and custom post types.
== Description ==
Up until recently, WordPress gave two options: You could either disable comments and trackbacks by default for all pages and posts, or you could have them active by default. In WordPress version 4.3, this finally changed so comments are always disabled on new pages.
While the new change makes it easier for many of the sites, it make it harder for people who need to get the reverse and enable comments on all pages, or if they need to change the default for a custom post type. This plugin allows you to choose whether comments are enabled or disabled by default on all new posts, pages and custom post types, while still giving the ability to individually enable comments on posts or pages.
Also, this plugin provides a way to quickly disable all comments or pingbacks for a specific custom post type. 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 using this feature, but it's always good to play it safe.
[View No Page Comment Development on Github](https://github.com/sethta/no-page-comment "No Page Comment Development on Github")
[Please Report any Issues about No Page Comment on Github](https://github.com/sethta/no-page-comment/issues "Report an Issue about No Page Comment on Github")
[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")
== Installation ==
1. Unzip the `no-page-comment.zip` file and `no-page-comment` folder to your `wp-content/plugins` folder.
1. Alternatively, you can install it from the 'Add New' link in the 'Plugins' menu in WordPress.
1. Activate the plugin through the 'Plugins' menu in WordPress.
1. Comments and trackbacks will be turned off by default when adding a new page.
= Settings Page =
Click 'No Page Comment' in the settings panel. A screen will display showing the following settings for posts, pages, attachments and any other custom post type installed on your blog:
* Disable comments
* Disable trackbacks
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.
Also, there is now the option to globally enable/disable comments or pingbacks of a specific post type.
== Frequently Asked Questions ==
= Why aren't comments and trackbacks being disabled? =
There are two possible issues for this. The first is that you are using a version of WordPress earlier than 3.4 and have javascript disabled as it relies on jQuery. WordPress version of 3.4 and later do not require javascript.
The second possible issue is that you are duplicating a post or page. This plugin only works when you are on a new post/page screen, while plugins that duplicate posts, duplicate the post first and then take you to an edit screen. Unfortunately, there is no way to get around this issue, so if you plan on using a duplication plugin, then you will just have to remember to disable your comments.
= Why can't I enable comments of custom post type: "X" =
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 your theme/plugin author.
= Why is "Comments are closed" or some other text displayed after I disable my comments? =
Many themes will include text to show that comments are not enabled on a post. To remove it, you would need to talk to your theme author.
= How do I modify the comment settings on an individual post or page? =
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.
= I want to quickly disable all trackbacks throughout my blog posts. Is this possible? =
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 disable both comments and trackbacks for any post type you have installed on your blog.
= How can I help support No Page Comment? =
[Donations](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5WWP2EDSCAJR4 "Donate to support the No Page Comment Plugin development") are always accepted, but I am also looking for help from others who want to make this plugin better. Please [fork the plugin on Github](https://github.com/sethta/no-page-comment "Fork No Page Comment on Github") and feel free to [report any issues](https://github.com/sethta/no-page-comment/issues "Report an Issue about No Page Comment on Github"). Also, I am looking for people who are interested in translating No Page Comment into other languages. Please [contact me](http://sethalling.com/contact/ "Contact Seth Alling") me if you are interested.
== Screenshots ==
1. The Settings page on a fresh WordPress 4.3 installation
== Changelog ==
= 1.2 =
* SECURITY: Patch XSS security vulnerability.
* SECURITY: Patch CSRF security vulnerability.
* UPDATE: PHP 7 support.
= 1.1 =
* UPDATE: WordPress 4.3 support.
* UPDATE: Rename settings option in database.
* NEW: Clean up database on uninstall.
= 1.0.7 =
* NEW: Add Dutch language support.
* NEW: Add Italian language support.
= 1.0.6 =
* NEW: Add Swedish language support.
= 1.0.5 =
* FIX: Fix to make mu-plugin friendly. Thanks @swinggraphics.
= 1.0.4 =
* NEW: Add Spanish language support.
* NEW: Add Serbian language support.
= 1.0.3 =
* UPDATE: Complete translation support.
* NEW: Add .pot file for translation.
= 1.0.2 =
* FIX: Stop plugin CSS from loading on other admin pages.
= 1.0.1 =
* FIX: Add missing files from failed SVN commit.
= 1.0 =
* UPDATE: Rewrite plugin to decrease code bloat
* UPDATE: Remove javascript dependency by default for WordPress versions 3.4 and up
* UPDATE: Fix settings so they are not dependent on WordPress's comment settings
* UPDATE: Fix settings page so it displays responsively
* NEW: Add support for attachments
* NEW: Update discussion options page to include link to No Page Comment settings page
* NEW: Prepare plugin for translation into other languages
= 0.3 =
* 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.
= 0.2 =
* UPDATE: Style Admin Settings Page to match with WordPress
* NEW: Add support for posts
* NEW: Add support for custom post types
= 0.1 =
* NEW: Initial release.
== Upgrade Notice ==
= 1.2 =
Security fix. Supports PHP 7. Adds database cleanup on uninstall. All previous No Page Comment settings will remain intact with upgrade.
= 1.1 =
Supports new core default comment change in WordPress 4.3. Adds database cleanup on uninstall. All previous No Page Comment settings will remain intact with upgrade.
= 1.0 =
Improves plugin performance and adds ability to enable/disable all comments or trackbacks on attachment pages. All previous No Page Comment settings will remain intact with upgrade.
= 0.3 =
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.
= 0.2 =
Adds the ability to disable comments on posts, pages, and custom post types. All previous No Page Comment settings will remain intact with upgrade.

View File

@@ -0,0 +1,10 @@
<?php
// If uninstall is not called from WordPress, exit
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit();
}
$option_name = 'sta_npc_admin_options_name';
delete_option( $option_name );