Plugin Directory

Changeset 3392279


Ignore:
Timestamp:
11/08/2025 11:43:44 PM (5 months ago)
Author:
sethta
Message:

Update to version 1.3.0

Location:
no-page-comment
Files:
62 added
2 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • no-page-comment/trunk/lang/no-page-comment-sv_SE.po

    r966390 r3392279  
    44msgstr ""
    55"Project-Id-Version: No Page Comment 1.0.5\n"
    6 "Report-Msgid-Bugs-To: http://wordpress.org/tag/no-page-comment\n"
    7 "POT-Creation-Date: 2014-03-02 01:02:56+00:00\n"
     6"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/no-page-comment\n"
     7"POT-Creation-Date: 2025-11-08T23:23:22+00:00\n"
     8"PO-Revision-Date: 2014-08-15 13:14+0100\n"
     9"Last-Translator: Andréas Lundgren <adevade@gmail.com>\n"
     10"Language-Team: 035media <info@035media.se>\n"
     11"Language: sv_SE\n"
    812"MIME-Version: 1.0\n"
    913"Content-Type: text/plain; charset=UTF-8\n"
    1014"Content-Transfer-Encoding: 8bit\n"
    11 "PO-Revision-Date: 2014-08-15 13:14+0100\n"
    12 "Last-Translator: Andréas Lundgren <adevade@gmail.com>\n"
    13 "Language-Team: 035media <info@035media.se>\n"
    1415"X-Generator: Poedit 1.6.7\n"
    1516"Plural-Forms: nplurals=2; plural=(n != 1);\n"
    16 "Language: sv_SE\n"
    1717"X-Poedit-SourceCharset: UTF-8\n"
    1818
    19 #: no-page-comment-settings.php:31
     19#. Plugin Name of the plugin
     20#: no-page-comment.php inc/class-settings.php:74
     21msgid "No Page Comment"
     22msgstr "No Page Comment"
     23
     24#. Description of the plugin
     25#: no-page-comment.php
     26msgid ""
     27"An admin interface to control the default comment and trackback settings on "
     28"new posts, pages and custom post types."
     29msgstr ""
     30
     31#. Author of the plugin
     32#: no-page-comment.php
     33msgid "Seth Alling"
     34msgstr ""
     35
     36#. Author URI of the plugin
     37#: no-page-comment.php
     38msgid "https://sethalling.com/"
     39msgstr ""
     40
     41#: inc/class-notification.php:106
     42msgid "View"
     43msgstr ""
     44
     45#: inc/class-notification.php:109
     46msgid "Install"
     47msgstr ""
     48
     49#: inc/class-notification.php:115
     50msgid "Help your pages load faster for readers with Easy Critical CSS."
     51msgstr ""
     52
     53#: inc/class-notification.php:117
     54msgid "Dismiss this notice"
     55msgstr ""
     56
     57#: inc/class-notification.php:127
     58msgid "Insufficient permissions"
     59msgstr ""
     60
     61#: inc/class-settings-view.php:36
    2062msgid "Settings Updated."
    2163msgstr "Inställningarna sparades."
    2264
    23 #: no-page-comment-settings.php:35 no-page-comment.php:152
     65#: inc/class-settings-view.php:48 inc/class-settings.php:73
     66#: inc/class-settings.php:114
    2467msgid "No Page Comment Settings"
    2568msgstr "Inställningar för No Page Comment"
    2669
    27 #: no-page-comment-settings.php:44
    28 msgid "Disable comments on new:"
    29 msgstr "Inaktivera kommentarer på nya:"
    30 
    31 #: no-page-comment-settings.php:53
     70#: inc/class-settings-view.php:57
     71msgid "Checked boxes will disable comments or trackbacks on new:"
     72msgstr ""
     73
     74#: inc/class-settings-view.php:75
    3275msgid "Comments"
    3376msgstr "Kommentarer"
    3477
    35 #: no-page-comment-settings.php:55
     78#: inc/class-settings-view.php:77
    3679msgid "Trackbacks"
    3780msgstr "Trackbacks"
    3881
    39 #: no-page-comment-settings.php:63
     82#: inc/class-settings-view.php:85
     83#, fuzzy
     84msgctxt "button"
    4085msgid "Update Settings"
    4186msgstr "Uppdatera inställningar"
    4287
    43 #: no-page-comment-settings.php:70
     88#: inc/class-settings-view.php:92
    4489msgid "Modify all current:"
    4590msgstr "Redigera alla nuvarande:"
    4691
    47 #: no-page-comment-settings.php:79
     92#: inc/class-settings-view.php:104
    4893msgid "Disable All Comments"
    4994msgstr "Inaktivera alla kommentarer"
    5095
    51 #: no-page-comment-settings.php:80
     96#: inc/class-settings-view.php:105
    5297msgid "Enable All Comments"
    5398msgstr "Aktivera alla kommentarer"
    5499
    55 #: no-page-comment-settings.php:83
     100#: inc/class-settings-view.php:108
    56101msgid "Disable All Trackbacks"
    57102msgstr "Inaktivera alla trackbacks"
    58103
    59 #: no-page-comment-settings.php:84
     104#: inc/class-settings-view.php:109
    60105msgid "Enable All Trackbacks"
    61106msgstr "Aktivera alla trackbacks"
    62107
    63 #: no-page-comment-settings.php:101
    64 msgid "Other plugins by"
    65 msgstr "Andra tillägg av"
    66 
    67 #: no-page-comment-settings.php:110
     108#: inc/class-settings-view.php:126
    68109msgid "Support No Page Comment:"
    69110msgstr "Stöd No Page Comment"
    70111
    71 #: no-page-comment-settings.php:113
     112#: inc/class-settings-view.php:129
    72113msgid "Donate to support the No Page Comment plugin development"
    73114msgstr "Donera för att stödja utvecklingen av No Page Comment"
    74115
    75 #: no-page-comment-settings.php:113
     116#: inc/class-settings-view.php:129
    76117msgid "Donate"
    77118msgstr "Donera"
    78119
    79 #: no-page-comment-settings.php:114
     120#: inc/class-settings-view.php:130
    80121msgid "Write a Review about No Page Comment"
    81122msgstr "Skriv en recension om No Page Comment"
    82123
    83 #: no-page-comment-settings.php:114
     124#: inc/class-settings-view.php:130
    84125msgid "Write a Review"
    85126msgstr "Skriv en recension"
    86127
    87 #: no-page-comment-settings.php:115
     128#: inc/class-settings-view.php:131
    88129msgid "Fork No Page Comment on Github"
    89130msgstr "Fork No Page Comment på GitHub"
    90131
    91 #: no-page-comment-settings.php:115
     132#: inc/class-settings-view.php:131
    92133msgid "Fork No Page Comment"
    93134msgstr "Fork No Page Comment"
    94135
    95 #: no-page-comment-settings.php:116
     136#: inc/class-settings-view.php:132
    96137msgid "Report an Issue on Github"
    97138msgstr "Rapportera ett problem på GitHub"
    98139
    99 #: no-page-comment-settings.php:116
     140#: inc/class-settings-view.php:132
    100141msgid "Report an Issue about No Page Comment"
    101142msgstr "Rapportera ett problem med No Page Comment"
    102143
    103 #: no-page-comment-settings.php:117
    104 msgid "Help Translate No Page Comment"
    105 msgstr "Hjälp till att översätta No Page Comment"
    106 
    107 #: no-page-comment-settings.php:117
    108 msgid "Offer to Translate No Page Comment"
    109 msgstr "Översätt No Page Comment"
    110 
    111 #: no-page-comment-settings.php:123
     144#: inc/class-settings-view.php:138
    112145msgid "Translation Thanks:"
    113146msgstr "Översättningar av:"
    114147
    115 #: no-page-comment.php:133
     148#: inc/class-settings-view.php:141
     149msgid "Dutch and Italian:"
     150msgstr ""
     151
     152#: inc/class-settings-view.php:142
     153msgid "French:"
     154msgstr ""
     155
     156#: inc/class-settings-view.php:143
     157msgid "Serbian:"
     158msgstr ""
     159
     160#: inc/class-settings-view.php:144
     161msgid "Spanish:"
     162msgstr ""
     163
     164#: inc/class-settings-view.php:145
     165msgid "Swedish:"
     166msgstr ""
     167
     168#: inc/class-settings.php:66
    116169msgid "Settings"
    117170msgstr "Inställningar"
    118171
    119 #: no-page-comment.php:152
     172#: inc/class-settings.php:112
    120173msgid "Comment and trackback defaults controlled through"
    121174msgstr "Standardinställningar för kommentarer och trackbacks kontrolleras av"
    122175
    123 #. Plugin Name of the plugin/theme
    124 msgid "No Page Comment"
    125 msgstr "No Page Comment"
    126 
    127 #. Description of the plugin/theme
    128 msgid ""
    129 "A plugin that uses javascript to disable comments by default on posts, pages "
    130 "and/or custom post types but leave them enabled on others, while still "
    131 "giving you the ability to individually set them on a page or post basis."
    132 msgstr ""
    133 "Ett tillägg som använder JavaScript för att inaktivera kommentarer på "
    134 "inlägg, sidor och/eller egna inläggstyper men lämnar dem aktiverade på "
    135 "andra. "
     176#: inc/class-settings.php:142 inc/class-settings.php:145
     177msgid "You don't have permission to perform this action."
     178msgstr ""
     179
     180#: inc/class-settings.php:162
     181msgid "Invalid comment status."
     182msgstr ""
     183
     184#: inc/class-settings.php:183
     185msgid "Invalid comment type."
     186msgstr ""
     187
     188#: inc/class-settings.php:189
     189msgid "Something went wrong. Please refresh this page and try again."
     190msgstr ""
     191
     192#. translators: 1: comment label, 2: post type label, 3: new status.
     193#: inc/class-settings.php:196
     194msgid "All %1$s of %2$s have been marked as %3$s."
     195msgstr ""
     196
     197#~ msgid "Disable comments on new:"
     198#~ msgstr "Inaktivera kommentarer på nya:"
     199
     200#~ msgid "Other plugins by"
     201#~ msgstr "Andra tillägg av"
     202
     203#~ msgid "Help Translate No Page Comment"
     204#~ msgstr "Hjälp till att översätta No Page Comment"
     205
     206#~ msgid "Offer to Translate No Page Comment"
     207#~ msgstr "Översätt No Page Comment"
     208
     209#~ msgid ""
     210#~ "A plugin that uses javascript to disable comments by default on posts, "
     211#~ "pages and/or custom post types but leave them enabled on others, while "
     212#~ "still giving you the ability to individually set them on a page or post "
     213#~ "basis."
     214#~ msgstr ""
     215#~ "Ett tillägg som använder JavaScript för att inaktivera kommentarer på "
     216#~ "inlägg, sidor och/eller egna inläggstyper men lämnar dem aktiverade på "
     217#~ "andra. "
  • no-page-comment/trunk/lang/no-page-comment.pot

    r1217740 r3392279  
    1 # Copyright (C) 2015 No Page Comment
    2 # This file is distributed under the same license as the No Page Comment package.
     1# Copyright (C) 2025 Seth Alling
     2# This file is distributed under the same license as the No Page Comment plugin.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: No Page Comment 1.1\n"
    6 "Report-Msgid-Bugs-To: http://wordpress.org/tag/no-page-comment\n"
    7 "POT-Creation-Date: 2014-03-02 01:02:56+00:00\n"
     5"Project-Id-Version: No Page Comment 1.3.0\n"
     6"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/no-page-comment\n"
     7"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     8"Language-Team: LANGUAGE <LL@li.org>\n"
    89"MIME-Version: 1.0\n"
    910"Content-Type: text/plain; charset=UTF-8\n"
    1011"Content-Transfer-Encoding: 8bit\n"
    11 "PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n"
    12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    13 "Language-Team: LANGUAGE <LL@li.org>\n"
     12"POT-Creation-Date: 2025-11-08T23:23:22+00:00\n"
     13"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
     14"X-Generator: WP-CLI 2.11.0\n"
     15"X-Domain: no-page-comment\n"
    1416
    15 #: no-page-comment-settings.php:37
     17#. Plugin Name of the plugin
     18#: no-page-comment.php
     19#: inc/class-settings.php:74
     20msgid "No Page Comment"
     21msgstr ""
     22
     23#. Description of the plugin
     24#: no-page-comment.php
     25msgid "An admin interface to control the default comment and trackback settings on new posts, pages and custom post types."
     26msgstr ""
     27
     28#. Author of the plugin
     29#: no-page-comment.php
     30msgid "Seth Alling"
     31msgstr ""
     32
     33#. Author URI of the plugin
     34#: no-page-comment.php
     35msgid "https://sethalling.com/"
     36msgstr ""
     37
     38#: inc/class-notification.php:106
     39msgid "View"
     40msgstr ""
     41
     42#: inc/class-notification.php:109
     43msgid "Install"
     44msgstr ""
     45
     46#: inc/class-notification.php:115
     47msgid "Help your pages load faster for readers with Easy Critical CSS."
     48msgstr ""
     49
     50#: inc/class-notification.php:117
     51msgid "Dismiss this notice"
     52msgstr ""
     53
     54#: inc/class-notification.php:127
     55msgid "Insufficient permissions"
     56msgstr ""
     57
     58#: inc/class-settings-view.php:36
    1659msgid "Settings Updated."
    1760msgstr ""
    1861
    19 #: no-page-comment-settings.php:41 no-page-comment.php:153 no-page-comment.php:163
     62#: inc/class-settings-view.php:48
     63#: inc/class-settings.php:73
     64#: inc/class-settings.php:114
    2065msgid "No Page Comment Settings"
    2166msgstr ""
    2267
    23 #: no-page-comment-settings.php:50
    24 msgid "Disable comments on new:"
     68#: inc/class-settings-view.php:57
     69msgid "Checked boxes will disable comments or trackbacks on new:"
    2570msgstr ""
    2671
    27 #: no-page-comment-settings.php:59
     72#: inc/class-settings-view.php:75
    2873msgid "Comments"
    2974msgstr ""
    3075
    31 #: no-page-comment-settings.php:61
     76#: inc/class-settings-view.php:77
    3277msgid "Trackbacks"
    3378msgstr ""
    3479
    35 #: no-page-comment-settings.php:69
     80#: inc/class-settings-view.php:85
     81msgctxt "button"
    3682msgid "Update Settings"
    3783msgstr ""
    3884
    39 #: no-page-comment-settings.php:76
     85#: inc/class-settings-view.php:92
    4086msgid "Modify all current:"
    4187msgstr ""
    4288
    43 #: no-page-comment-settings.php:85
     89#: inc/class-settings-view.php:104
    4490msgid "Disable All Comments"
    4591msgstr ""
    4692
    47 #: no-page-comment-settings.php:86
     93#: inc/class-settings-view.php:105
    4894msgid "Enable All Comments"
    4995msgstr ""
    5096
    51 #: no-page-comment-settings.php:89
     97#: inc/class-settings-view.php:108
    5298msgid "Disable All Trackbacks"
    5399msgstr ""
    54100
    55 #: no-page-comment-settings.php:90
     101#: inc/class-settings-view.php:109
    56102msgid "Enable All Trackbacks"
    57103msgstr ""
    58104
    59 #: no-page-comment-settings.php:107
    60 msgid "Other plugins by"
    61 msgstr ""
    62 
    63 #: no-page-comment-settings.php:116
     105#: inc/class-settings-view.php:126
    64106msgid "Support No Page Comment:"
    65107msgstr ""
    66108
    67 #: no-page-comment-settings.php:119
     109#: inc/class-settings-view.php:129
    68110msgid "Donate to support the No Page Comment plugin development"
    69111msgstr ""
    70112
    71 #: no-page-comment-settings.php:119
     113#: inc/class-settings-view.php:129
    72114msgid "Donate"
    73115msgstr ""
    74116
    75 #: no-page-comment-settings.php:120
     117#: inc/class-settings-view.php:130
    76118msgid "Write a Review about No Page Comment"
    77119msgstr ""
    78120
    79 #: no-page-comment-settings.php:120
     121#: inc/class-settings-view.php:130
    80122msgid "Write a Review"
    81123msgstr ""
    82124
    83 #: no-page-comment-settings.php:121
     125#: inc/class-settings-view.php:131
    84126msgid "Fork No Page Comment on Github"
    85127msgstr ""
    86128
    87 #: no-page-comment-settings.php:121
     129#: inc/class-settings-view.php:131
    88130msgid "Fork No Page Comment"
    89131msgstr ""
    90132
    91 #: no-page-comment-settings.php:122
     133#: inc/class-settings-view.php:132
    92134msgid "Report an Issue on Github"
    93135msgstr ""
    94136
    95 #: no-page-comment-settings.php:122
     137#: inc/class-settings-view.php:132
    96138msgid "Report an Issue about No Page Comment"
    97139msgstr ""
    98140
    99 #: no-page-comment-settings.php:123
    100 msgid "Help Translate No Page Comment"
    101 msgstr ""
    102 
    103 #: no-page-comment-settings.php:123
    104 msgid "Offer to Translate No Page Comment"
    105 msgstr ""
    106 
    107 #: no-page-comment-settings.php:129
     141#: inc/class-settings-view.php:138
    108142msgid "Translation Thanks:"
    109143msgstr ""
    110144
    111 #: no-page-comment-settings.php:132
     145#: inc/class-settings-view.php:141
    112146msgid "Dutch and Italian:"
    113147msgstr ""
    114148
    115 #: no-page-comment-settings.php:133
     149#: inc/class-settings-view.php:142
     150msgid "French:"
     151msgstr ""
     152
     153#: inc/class-settings-view.php:143
    116154msgid "Serbian:"
    117155msgstr ""
    118156
    119 #: no-page-comment-settings.php:134
     157#: inc/class-settings-view.php:144
    120158msgid "Spanish:"
    121159msgstr ""
    122160
    123 #: no-page-comment-settings.php:135
     161#: inc/class-settings-view.php:145
    124162msgid "Swedish:"
    125163msgstr ""
    126164
    127 #: no-page-comment.php:144
     165#: inc/class-settings.php:66
    128166msgid "Settings"
    129167msgstr ""
    130168
    131 #: no-page-comment.php:163
     169#: inc/class-settings.php:112
    132170msgid "Comment and trackback defaults controlled through"
    133171msgstr ""
    134172
    135 #. Plugin Name of the plugin/theme no-page-comment.php:153
    136 msgid "No Page Comment"
     173#: inc/class-settings.php:142
     174#: inc/class-settings.php:145
     175msgid "You don't have permission to perform this action."
    137176msgstr ""
    138177
    139 #. Description of the plugin/theme
    140 msgid ""
    141 "An admin interface to control the default comment and trackback settings on "
    142 "new posts, pages and custom post types."
     178#: inc/class-settings.php:162
     179msgid "Invalid comment status."
    143180msgstr ""
     181
     182#: inc/class-settings.php:183
     183msgid "Invalid comment type."
     184msgstr ""
     185
     186#: inc/class-settings.php:189
     187msgid "Something went wrong. Please refresh this page and try again."
     188msgstr ""
     189
     190#. translators: 1: comment label, 2: post type label, 3: new status.
     191#: inc/class-settings.php:196
     192msgid "All %1$s of %2$s have been marked as %3$s."
     193msgstr ""
  • no-page-comment/trunk/no-page-comment.php

    r2787342 r3392279  
    11<?php
    22/*
    3 Plugin Name: No Page Comment
    4 Plugin URI: http://sethalling.com/plugins/no-page-comment
    5 Description: An admin interface to control the default comment and trackback settings on new posts, pages and custom post types.
    6 Version: 1.2
    7 Requires at least: 3.1
    8 Requires PHP:      7.0
    9 Author: Seth Alling
    10 Author URI: http://sethalling.com/
    11 Text Domain: no-page-comment
     3 * Plugin Name:       No Page Comment
     4 * Description:       An admin interface to control the default comment and trackback settings on new posts, pages and custom post types.
     5 * Version:           1.3.0
     6 * Requires at least: 6.2
     7 * Tested up to:      6.8.2
     8 * Requires PHP:      7.4
     9 * Author:            Seth Alling
     10 * Author URI:        https://sethalling.com/
     11 * Text Domain:       no-page-comment
     12 *
     13 * @package NoPageComment
     14 *
     15 *   _____      _   _                _ _ _                   _...._
     16 *  / ____|    | | | |         /\   | | (_)                .'/  \ _'.
     17 * | (___   ___| |_| |__      /  \  | | |_ _ __   __ _    /##\__/##\_\
     18 *  \___ \ / _ \ __| '_ \    / /\ \ | | | | '_ \ / _` |  |\##/  \##/  |
     19 *  ____) |  __/ |_| | | |  / ____ \| | | | | | | (_| |  |/  \__/  \ _|
     20 * |_____/ \___|\__|_| |_| /_/    \_\_|_|_|_| |_|\__, |   \ _/##\__/#/
     21 *                                                __/ |    '.\##/__.'
     22 * Plugin developed by: https://sethalling.com   |___/       `""""`
     23 */
    1224
    13     Plugin: Copyright (c) 2011-2022 Seth Alling
    14 
    15     This program is free software; you can redistribute it and/or
    16     modify it under the terms of the GNU General Public License
    17     as published by the Free Software Foundation; either version 2
    18     of the License, or (at your option) any later version.
    19 
    20     This program is distributed in the hope that it will be useful,
    21     but WITHOUT ANY WARRANTY; without even the implied warranty of
    22     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    23     GNU General Public License for more details.
    24 
    25     You should have received a copy of the GNU General Public License
    26     along with this program; if not, write to the Free Software
    27     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    28       _____      _   _                _ _ _                   _...._
    29      / ____|    | | | |         /\   | | (_)                .'/  \ _'.
    30     | (___   ___| |_| |__      /  \  | | |_ _ __   __ _    /##\__/##\_\
    31      \___ \ / _ \ __| '_ \    / /\ \ | | | | '_ \ / _` |  |\##/  \##/  |
    32      ____) |  __/ |_| | | |  / ____ \| | | | | | | (_| |  |/  \__/  \ _|
    33     |_____/ \___|\__|_| |_| /_/    \_\_|_|_|_| |_|\__, |   \ _/##\__/#/
    34                                                    __/ |    '.\##/__.'
    35     Plugin developed by: http://sethalling.com    |___/       `""""`
    36 */
     25namespace NoPageComment;
    3726
    3827// Prevent direct access
     
    4130}
    4231
    43 register_activation_hook( __FILE__, 'sta_npc_activate' );
    44 
    45 define( 'STA_NPC_WP_VERSION', version_compare( get_bloginfo( 'version' ), '3.4', '>=' ) );
    46 
    47 if ( ! function_exists( 'sta_npc_activate' ) ) {
    48     function sta_npc_activate() {
    49         sta_npc_load();
    50         global $sta_npc_plugin;
    51     }
     32if ( ! defined( 'ABSPATH' ) ) {
     33    exit;
    5234}
    5335
    54 // Set text domain for translation
    55 function sta_load_text_domain() {
    56     load_plugin_textdomain( 'no-page-comment', false, basename( dirname( __FILE__ ) ) . '/lang/' );
    57 }
    58 add_action( 'init', 'sta_load_text_domain' ); // Set text domain for translation
     36// Load Composer autoload.
     37require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
    5938
    60 if ( ! function_exists( 'sta_npc_load' ) ) {
    61 
    62     function sta_npc_load() {
    63 
    64         if ( ! class_exists( 'STA_NPC_Plugin' ) ) {
    65 
    66             class STA_NPC_Plugin {
    67 
    68                 var $admin_options_name     = 'sta_npc_options',
    69                     $admin_options_name_old = 'sta_npc_admin_options_name',
    70                     $plugin_domain          = 'no-page-comment';
    71                 public $plugin_name         = 'no-page-comment';
    72                 public $plugin_file;
    73                 public $plugin_dir;
    74                 public $wp_posttypes = array(
    75                     'post',
    76                     'page',
    77                     'revision',
    78                     'nav_menu_item',
    79                     'attachment'
    80                 );
    81 
    82                 public $excluded_posttypes = array(
    83                     'revision',
    84                     'nav_menu_item',
    85                 );
    86 
    87                 public $plugin_ver = '1.2';
    88 
    89                 // Plugin Constructor
    90                 function __construct() {
    91                     $this->plugin_dir = plugins_url( '/', __FILE__ );
    92                     $this->plugin_file = $this->plugin_name . '.php';
    93                 }
    94 
    95                 // Intialize Admin Options
    96                 function sta_npc_init() {
    97                     $this->sta_npc_get_admin_options();
    98                 }
    99 
    100                 // Returns an array of admin options
    101                 function sta_npc_get_admin_options() {
    102 
    103                     // Rename options from old options name
    104                     if ( get_option( $this->admin_options_name_old ) ) {
    105                         update_option( $this->admin_options_name, get_option( $this->admin_options_name_old ) );
    106                         delete_option( $this->admin_options_name_old );
    107                     }
    108 
    109                     $sta_npc_admin_options = array(
    110                         'disable_comments_post'   => '',
    111                         'disable_trackbacks_post' => '',
    112                         'disable_comments_page'   => 'true',
    113                         'disable_trackbacks_page' => 'true',
    114                         'disable_comments_attachment'   => '',
    115                         'disable_trackbacks_attachment' => ''
    116                     );
    117 
    118                     foreach ( get_post_types( '', 'objects' ) as $posttype ) {
    119                         if ( in_array( $posttype->name, $this->wp_posttypes ) )
    120                             continue;
    121 
    122                         $sta_npc_admin_options['disable_comments_' . $posttype->name] = 'true';
    123                         $sta_npc_admin_options['disable_trackbacks_' . $posttype->name] = 'true';
    124                     } // end foreach post types
    125 
    126                     $sta_npc_options = get_option( $this->admin_options_name );
    127                     if ( ! empty( $sta_npc_options ) ) {
    128 
    129                         foreach ( $sta_npc_options as $key => $option )
    130                             $sta_npc_admin_options[$key] = $option;
    131                     }
    132 
    133                     update_option( $this->admin_options_name, $sta_npc_admin_options );
    134                     return $sta_npc_admin_options;
    135                 }
    136 
    137                 // Print out the admin page
    138                 function sta_npc_print_admin_page() {
    139                     include( dirname( __FILE__ ) . '/no-page-comment-settings.php' );
    140                 }
    141 
    142                 // Add stylesheet to admin page
    143                 function sta_npc_admin_styles( $hook ) {
    144                     if ( $hook == 'settings_page_no-page-comment' ) {
    145                         wp_register_style( 'sta_npc', $this->plugin_dir . '/no-page-comment.css', false, $this->plugin_ver );
    146                         wp_enqueue_style( 'sta_npc' );
    147                     }
    148                 }
    149 
    150                 // Add settings link to plugins page
    151                 function sta_npc_settings_link( $links, $file ) {
    152                     if ( basename( $file ) == $this->plugin_file ) {
    153                         $settings_link = '<a href="' . admin_url( 'options-general.php?page=' . $this->plugin_file ) . '">' . __( 'Settings', $this->plugin_domain ) . '</a>';
    154                         array_unshift( $links, $settings_link );
    155                     }
    156                     return $links;
    157                 }
    158 
    159                 // Add settings page to options sidebar
    160                 function sta_npc_plugin_admin() {
    161                     if ( function_exists( 'add_options_page' ) ) {
    162                         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' ) );
    163                     }
    164                 }
    165 
    166                 // Modify discussion options page with a link to NPC settings page
    167                 function sta_discussion_options() {
    168                     global $pagenow;
    169                     global $post;
    170 
    171                     if ( ( is_admin() ) && ( $pagenow == 'options-discussion.php' ) ) {
    172                         $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>';
    173                         wp_enqueue_script( 'jquery' ); ?>
    174 
    175                         <script type="text/javascript">
    176                         jQuery(document).ready( function() {
    177                             jQuery('label[for="default_ping_status"]').remove().prev('br').remove();
    178                             jQuery('label[for="default_comment_status"]').prev('br').remove();
    179                             jQuery('label[for="default_comment_status"]').next('br').remove();
    180                             jQuery('label[for="default_comment_status"]').next('p').html('<?php echo $settings_link; ?>');
    181                             jQuery('label[for="default_comment_status"]').next('small').html('<?php echo $settings_link; ?>');
    182                             jQuery('label[for="default_comment_status"]').remove();
    183                         });
    184                         </script>
    185 
    186                     <?php }
    187                 }
    188 
    189                 // Disable comments and trackbacks on at least WP version 4.3 with a hook
    190                 function wpdocs_open_comments_for_myposttype( $status, $post_type, $comment_type ) {
    191                     $sta_npc_options = $this->sta_npc_get_admin_options();
    192 
    193                     if ( $comment_type == 'comment' ) { // Check if comment or trackback
    194 
    195                         if ( isset( $sta_npc_options['disable_comments_' . $post_type] ) ) {
    196 
    197                             if ( $sta_npc_options['disable_comments_' . $post_type] == 'true' ) {
    198                                 return 'closed';
    199                             } else {
    200                                 return 'open';
    201                             }
    202 
    203                         } else {
    204                             return $status;
    205                         }
    206 
    207                     } elseif ( $comment_type == 'pingback' ) { // Double check if trackback
    208 
    209                         if ( isset( $sta_npc_options['disable_trackbacks_' . $post_type] ) ) {
    210 
    211                             if ( $sta_npc_options['disable_trackbacks_' . $post_type] == 'true' ) {
    212                                 return 'closed';
    213                             } else {
    214                                 return 'open';
    215                             }
    216 
    217                         } else {
    218                             return $status;
    219                         }
    220 
    221                     } else { // This should never happen, but just in case
    222                         return $status;
    223                     }
    224 
    225                 }
    226 
    227                 // Disable comments with hook on WP versions 3.4-4.2
    228                 function sta_no_page_comment() {
    229                     global $pagenow;
    230                     $sta_npc_options = $this->sta_npc_get_admin_options();
    231                     if ( ( is_admin() ) && ( $pagenow == 'post-new.php' ) ) {
    232                         $posttype = ( isset( $_GET['post_type'] ) ) ? $_GET['post_type'] : 'post';
    233 
    234                         if ( $sta_npc_options['disable_comments_' . $posttype] == 'true' ) {
    235                             return 'closed';
    236                         } else {
    237                             return 'open';
    238                         }
    239                     }
    240                 }
    241 
    242                 // Disable trackbacks with hook on versions 3.4-4.2
    243                 function sta_no_page_trackback() {
    244                     global $pagenow;
    245                     $sta_npc_options = $this->sta_npc_get_admin_options();
    246                     if ( ( is_admin() ) && ( $pagenow == 'post-new.php' ) ) {
    247                         $posttype = ( isset( $_GET['post_type'] ) ) ? $_GET['post_type'] : 'post';
    248 
    249                         if ( $sta_npc_options['disable_trackbacks_' . $posttype] == 'true' ) {
    250                             return 'closed';
    251                         } else {
    252                             return 'open';
    253                         }
    254                     }
    255                 }
    256 
    257                 // Disable comments/trackbacks with jQuery (for WP versions earlier than 3.4)
    258                 function sta_no_page_comment_jquery() {
    259                     global $pagenow;
    260                     global $post;
    261 
    262                     $sta_npc_options = $this->sta_npc_get_admin_options();
    263                     if ( ( is_admin() ) && ( $pagenow == 'post-new.php' ) && ( $post->filter == 'raw' ) ) {
    264                         wp_enqueue_script( 'jquery' );
    265                         $posttype = $post->post_type; ?>
    266 
    267                         <script type="text/javascript">
    268                         jQuery(document).ready( function() {
    269                             <?php if ( isset($sta_npc_options['disable_comments_' . $posttype]) ) {
    270                                 if ( $sta_npc_options['disable_comments_' . $posttype] == 'true' ) { ?>
    271                                     if ( jQuery('#comment_status').length ) {
    272                                         jQuery('#comment_status').attr('checked', false);
    273                                     }
    274                                 <?php } else { ?>
    275                                     if ( jQuery('#comment_status').length ) {
    276                                         jQuery('#comment_status').attr('checked', true);
    277                                     }
    278                                 <?php }
    279                             }
    280                             if ( isset($sta_npc_options['disable_trackbacks_' . $posttype]) ) {
    281                                 if ( $sta_npc_options['disable_trackbacks_' . $posttype] == 'true' ) { ?>
    282                                     if ( jQuery('#ping_status').length ) {
    283                                         jQuery('#ping_status').attr('checked', false);
    284                                     }
    285                                 <?php } else { ?>
    286                                     if ( jQuery('#ping_status').length ) {
    287                                         jQuery('#ping_status').attr('checked', true);
    288                                     }
    289                                 <?php }
    290                             } ?>
    291                         });
    292                         </script>
    293 
    294                     <?php }
    295                 }
    296 
    297                 // Add ajax script to admin page
    298                 function sta_no_page_comment_ajax() {
    299                     global $pagenow;
    300                     global $post;
    301                     if ( ( is_admin() ) && ( $pagenow == 'options-general.php' ) && isset( $_GET['page'] ) ) {
    302                         if ( $_GET['page'] == 'no-page-comment.php' ) {
    303                             wp_enqueue_script( 'jquery' );
    304                             // Load Ajax File
    305                             wp_register_script( 'ajax-script', plugins_url( '/page-comment.js', __FILE__ ), array( 'jquery' ) );
    306                             wp_localize_script( 'ajax-script', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
    307 
    308                             wp_enqueue_script( 'jquery' );
    309                             wp_enqueue_script( 'ajax-script' );
    310                         }
    311                     }
    312                 }
    313 
    314                 // Ajax Function for WP Comment DB Modification
    315                 function sta_npc_mod() {
    316                     if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'sta_npc_nonce') ) {
    317                         exit( 'No naughty business please' );
    318                     }
    319 
    320                     global $wpdb;
    321 
    322                     $result[] = array();
    323                     $comment_type = $_REQUEST['comment_type'];
    324                     $comment_status = $_REQUEST['comment_status'];
    325                     if ( $comment_status == 'open' )
    326                         $comment_new_status = 'closed';
    327                     elseif ( $comment_status == 'closed' ) {
    328                         $comment_new_status = 'open';
    329                     }
    330                     $post_type = $_REQUEST['post_type'];
    331                     $post_label = $_REQUEST['post_label'];
    332 
    333 
    334                     if ( $comment_type == 'ping' ) {
    335                         $comment_label = 'trackbacks';
    336                         $comment_query = $wpdb->prepare(
    337                             "
    338                             UPDATE $wpdb->posts
    339                             SET ping_status = %s
    340                             WHERE ping_status = %s
    341                             AND post_type = %s
    342                             ",
    343                             $comment_new_status,
    344                             $comment_status,
    345                             $post_type
    346                         );
    347                     } else {
    348                         $comment_label = 'comments';
    349                         $comment_query = $wpdb->prepare(
    350                             "
    351                             UPDATE $wpdb->posts
    352                             SET comment_status = %s
    353                             WHERE comment_status = %s
    354                             AND post_type = %s
    355                             ",
    356                             $comment_new_status,
    357                             $comment_status,
    358                             $post_type
    359                         );
    360                     }
    361 
    362                     if ( $comment_query === FALSE ) {
    363                         $result['type'] = 'error';
    364                         $result['message'] = 'Something went wrong. Please refresh this page and try again.';
    365                     } else {
    366                         $wpdb->query( $comment_query );
    367                         $result['type'] = 'success';
    368                         $result['message'] = 'All ' . $comment_label . ' of ' . $post_label . ' have been marked as ' . $comment_new_status;
    369                     }
    370 
    371                     if ( ! empty( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) {
    372                             $result = json_encode( $result );
    373                             echo $result;
    374                     }
    375                     else {
    376                             header( 'Location: ' . $_SERVER['HTTP_REFERER'] );
    377                     }
    378 
    379                     die();
    380 
    381                 }
    382 
    383                 function nopriv_sta_npc_mod() {
    384                     exit( 'No naughty business please' );
    385                 }
    386 
    387                 // Disable comments/trackbacks on attachments
    388                 function attachment_comment( $id ) {
    389                     global $wpdb;
    390                     $sta_npc_options = $this->sta_npc_get_admin_options();
    391                     $comment_status = ( $sta_npc_options['disable_comments_attachment'] == 'true' ) ? 'closed' : 'open';
    392                     $trackback_status = ( $sta_npc_options['disable_trackbacks_attachment'] == 'true' ) ? 'closed' : 'open';
    393 
    394                     $comment_query = $wpdb->prepare(
    395                         "
    396                         UPDATE $wpdb->posts
    397                         SET comment_status = %s
    398                         WHERE ID = %s
    399                         ",
    400                         $comment_status,
    401                         $id
    402                     );
    403 
    404                     $trackback_query = $wpdb->prepare(
    405                         "
    406                         UPDATE $wpdb->posts
    407                         SET ping_status = %s
    408                         WHERE ID = %s
    409                         ",
    410                         $trackback_status,
    411                         $id
    412                     );
    413 
    414                     if ( $comment_query === FALSE ) {
    415                     } else {
    416                         $wpdb->query( $comment_query );
    417                     }
    418 
    419                     if ( $trackback_query === FALSE ) {
    420                     } else {
    421                         $wpdb->query( $trackback_query );
    422                     }
    423 
    424                 }
    425 
    426             }
    427 
    428         } // End Class STA_NPC_Plugin
    429 
    430         if ( class_exists( 'STA_NPC_Plugin' ) ) {
    431             global $sta_npc_plugin;
    432             $sta_npc_plugin = new STA_NPC_Plugin();
    433         }
    434 
    435         // Actions, Filters and Shortcodes
    436         if ( isset( $sta_npc_plugin ) ) {
    437             // Actions
    438             add_action( 'admin_menu', array( &$sta_npc_plugin, 'sta_npc_plugin_admin' ) ); // Activate admin settings page
    439             add_action( 'activate_no-page-comment/no-page-comment.php', array( &$sta_npc_plugin, 'sta_npc_init' ) ); // Activate admin options
    440             add_action( 'admin_enqueue_scripts', array( &$sta_npc_plugin, 'sta_npc_admin_styles' ) ); // Add admin stylesheet
    441             add_action( 'admin_head', array( &$sta_npc_plugin, 'sta_no_page_comment_ajax' ) ); // Add ajax scripts
    442             add_action( 'wp_ajax_sta_npc_mod', array( &$sta_npc_plugin, 'sta_npc_mod' ) ); // Add ajax function
    443             add_action( 'wp_ajax_nopriv_sta_npc_mod', array( &$sta_npc_plugin, 'nopriv_sta_npc_mod' ) ); // Add logged out ajax function
    444             add_action( 'add_attachment', array( &$sta_npc_plugin, 'attachment_comment' ) ); // Set comment status on new attachments
    445 
    446             // Filters
    447             add_filter( 'plugin_action_links', array( &$sta_npc_plugin, 'sta_npc_settings_link' ), 10, 2 ); // Add settings link to plugins page
    448             add_filter( 'admin_head', array(&$sta_npc_plugin, 'sta_discussion_options' ) ); // Change discussion options replace defaults with link to NPC settings
    449 
    450             // Run correct function depending on version
    451             if ( function_exists( 'get_default_comment_status' ) ) {
    452                 add_filter( 'get_default_comment_status', array(&$sta_npc_plugin, 'wpdocs_open_comments_for_myposttype' ), 10, 3 ); // Comment settings
    453             } elseif ( STA_NPC_WP_VERSION ) {
    454                 add_filter( 'pre_option_default_comment_status', array(&$sta_npc_plugin, 'sta_no_page_comment' ) ); // Comment settings
    455                 add_filter( 'pre_option_default_ping_status', array(&$sta_npc_plugin, 'sta_no_page_trackback' ) ); // Trackback settings
    456             } else { // Use jQuery for WordPress versions earlier than 3.4
    457                 add_action( 'admin_head', array( &$sta_npc_plugin, 'sta_no_page_comment_jquery' ) ); // Add jquery scripts
    458             }
    459 
    460         }
    461 
    462     }
    463 
    464 }
    465 
    466 sta_npc_load();
     39// Initialize the plugin.
     40Plugin::get_instance( __FILE__ );
  • no-page-comment/trunk/readme.txt

    r2787342 r3392279  
    44Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5WWP2EDSCAJR4
    55Tags: admin, comments, custom post type, discussion, pages, posts, attachment, attachments, media, settings, tools, trackbacks
    6 Requires at least: 3.1
    7 Tested up to: 6.0.1
    8 Requires PHP: 7.0
     6Requires at least: 6.2
     7Tested up to: 6.8.2
     8Requires PHP: 7.4
    99Stable tag: trunk
    1010
     
    7777== Changelog ==
    7878
     79= 1.3.0 =
     80* OPTIMIZATION: Convert to class-based architecture and move code into namespaced classes.
     81* OPTIMIZATION: Apply WPCS/PHPCS fixes and improve code cleanliness.
     82* FIX: Hardened nonce checks and input/output sanitization.
     83
    7984= 1.2 =
    8085* SECURITY: Patch XSS security vulnerability.
     
    133138== Upgrade Notice ==
    134139
     140= 1.3.0 =
     141Refactor to class-based architecture, security hardening, code style and standards improvements, and uninstall cleanup. No user-visible settings were removed; existing settings are preserved during upgrade.
     142
    135143= 1.2 =
    136144Security fix. Supports PHP 7. Adds database cleanup on uninstall. All previous No Page Comment settings will remain intact with upgrade.
  • no-page-comment/trunk/uninstall.php

    r1217695 r3392279  
    1 
    21<?php
    3 // If uninstall is not called from WordPress, exit
     2// If uninstall is not called from WordPress, exit.
    43if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
    5     exit();
     4    exit;
    65}
    76
    8 $option_name = 'sta_npc_admin_options_name';
     7$sta_npc_options = [
     8    'sta_npc_options',
     9    'sta_npc_version',
     10    'sta_npc_activation',
     11    'sta_npc_admin_options_name', // Very old legacy option in case older installs still have it
     12];
    913
    10 delete_option( $option_name );
     14foreach ( $sta_npc_options as $sta_npc_option ) {
     15    delete_option( $sta_npc_option );
     16}
     17
     18// If this is a multisite installation also remove site/network options.
     19if ( function_exists( 'is_multisite' ) && is_multisite() ) {
     20    foreach ( $sta_npc_options as $sta_npc_option ) {
     21        if ( function_exists( 'delete_site_option' ) ) {
     22            delete_site_option( $sta_npc_option );
     23        }
     24    }
     25}
Note: See TracChangeset for help on using the changeset viewer.