Plugin Directory

Changeset 1516997


Ignore:
Timestamp:
10/17/2016 10:07:41 PM (9 years ago)
Author:
sethta
Message:

PHP 7 support and security fix

Location:
no-page-comment/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • no-page-comment/trunk/no-page-comment-settings.php

    r1217695 r1516997  
    66?>
    77
    8 <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" class="wrap npc-settings">
     8<form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" class="wrap npc-settings">
     9
     10<?php
     11// Add nonce to prevent CSRF
     12wp_nonce_field( 'sta_npc_csrf_nonce' );
     13$nonce = ( isset( $_REQUEST['_wpnonce'] ) ) ? $_REQUEST['_wpnonce'] : false;
     14?>
    915
    1016<?php
    1117// Prints out the admin settings page
    12 $sta_npc_nonce = wp_create_nonce('sta_npc_nonce');
     18$sta_npc_nonce = wp_create_nonce( 'sta_npc_nonce' );
    1319$sta_npc_options = $this->sta_npc_get_admin_options();
    1420
    15 if ( isset($_POST['update_sta_npc_plugin_settings']) ) {
     21if ( wp_verify_nonce( $nonce, 'sta_npc_csrf_nonce' ) && isset( $_POST['update_sta_npc_plugin_settings'] ) ) {
    1622
    17     foreach ( get_post_types('','objects') as $posttype ) {
     23    foreach ( get_post_types( '', 'objects' ) as $posttype ) {
    1824        if ( in_array( $posttype->name, $this->excluded_posttypes ) )
    1925            continue;
    2026
    21         if ( isset($_POST['sta_npc_disable_comments_' . $posttype->name]) ) {
     27        if ( isset( $_POST['sta_npc_disable_comments_' . $posttype->name] ) ) {
    2228            $sta_npc_options['disable_comments_' . $posttype->name] = $_POST['sta_npc_disable_comments_' . $posttype->name];
    2329        } else {
     
    2531        }
    2632
    27         if ( isset($_POST['sta_npc_disable_trackbacks_' . $posttype->name]) ) {
     33        if ( isset( $_POST['sta_npc_disable_trackbacks_' . $posttype->name] ) ) {
    2834            $sta_npc_options['disable_trackbacks_' . $posttype->name] = $_POST['sta_npc_disable_trackbacks_' . $posttype->name];
    2935        } else {
  • no-page-comment/trunk/no-page-comment.php

    r1217740 r1516997  
    44Plugin URI: http://sethalling.com/plugins/no-page-comment
    55Description: An admin interface to control the default comment and trackback settings on new posts, pages and custom post types.
    6 Version: 1.1
     6Version: 1.2
    77Author: Seth Alling
    88Author URI: http://sethalling.com/
     
    5757
    5858if ( ! function_exists( 'sta_npc_load' ) ) {
     59
    5960    function sta_npc_load() {
     61
    6062        if ( ! class_exists( 'STA_NPC_Plugin' ) ) {
     63
    6164            class STA_NPC_Plugin {
     65
    6266                var $admin_options_name     = 'sta_npc_options',
    6367                    $admin_options_name_old = 'sta_npc_admin_options_name',
     
    7377                    'attachment'
    7478                );
     79
    7580                public $excluded_posttypes = array(
    7681                    'revision',
    7782                    'nav_menu_item',
    7883                );
    79                 public $plugin_ver = '1.0.7';
     84
     85                public $plugin_ver = '1.2';
    8086
    8187                // Plugin Constructor
    82                 function sta_npc_plugin() {
     88                function __construct() {
    8389                    $this->plugin_dir = plugins_url( '/', __FILE__ );
    8490                    $this->plugin_file = $this->plugin_name . '.php';
     
    122128                            $sta_npc_admin_options[$key] = $option;
    123129                    }
     130
    124131                    update_option( $this->admin_options_name, $sta_npc_admin_options );
    125132                    return $sta_npc_admin_options;
     
    450457
    451458        }
     459
    452460    }
     461
    453462}
    454463
Note: See TracChangeset for help on using the changeset viewer.