Clean up admin.class.php PHPcs complaints

This commit is contained in:
Jay Wood
2015-08-28 20:45:54 -04:00
parent 3887dc2e38
commit bd6f5fe6ef
4 changed files with 25 additions and 17 deletions

View File

@ -63,6 +63,10 @@ Please do not contact me with questions like this. If you cannot be descriptive
## Changelog ## Changelog
### 3.6.4
* Fixed denial redirects. [Issue #28](https://github.com/JayWood/content-warning-v3/issues/28)
* Passified all PHPcs complaints
### 3.6.3 ### 3.6.3
* Category fix, fixes [#18](https://github.com/JayWood/content-warning-v3/issues/18) * Category fix, fixes [#18](https://github.com/JayWood/content-warning-v3/issues/18)
* Alphabetize method names, because why not!? * Alphabetize method names, because why not!?

View File

@ -2,7 +2,7 @@
class CWV3Admin { class CWV3Admin {
function hooks(){ function hooks() {
// Post Meta Box for this. // Post Meta Box for this.
add_action( 'add_meta_boxes', array( $this, 'cw_meta' ) ); add_action( 'add_meta_boxes', array( $this, 'cw_meta' ) );
add_action( 'save_post', array( $this, 'cwv3_meta_save' ) ); add_action( 'save_post', array( $this, 'cwv3_meta_save' ) );
@ -27,13 +27,13 @@ class CWV3Admin {
$sw = get_option( 'cwv3_sitewide' ); $sw = get_option( 'cwv3_sitewide' );
switch ( $col ) { switch ( $col ) {
case 'cwv2': case 'cwv2':
if ( 'yes' == get_post_meta( $post->ID, 'cwv3_auth', true ) || 'enabled' == $sw[0] ) { if ( 'yes' == get_post_meta( $post->ID, 'cwv3_auth', true ) || 'enabled' == $sw[0] ) {
echo '<span style="color:#0F0; font-weight:bold;" class="cw_protected">Yes</span>'; echo '<span style="color:#0F0; font-weight:bold;" class="cw_protected">Yes</span>';
}else { } else {
echo '<span style="color:#F00; font-weight:bold;" class="cw_vulnerable">No</span>'; echo '<span style="color:#F00; font-weight:bold;" class="cw_vulnerable">No</span>';
} }
break; break;
} }
} }
@ -59,8 +59,8 @@ class CWV3Admin {
public function cwv3_meta_save( $post_id ) { public function cwv3_meta_save( $post_id ) {
// check isset before access (edit by @jgraup) // check isset before access (edit by @jgraup)
if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ){ if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_page', $post_id ) ){ if ( ! current_user_can( 'edit_page', $post_id ) ) {
return; return;
} else { } else {
if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } if ( ! current_user_can( 'edit_post', $post_id ) ) { return; }
@ -70,7 +70,7 @@ class CWV3Admin {
} }
// check isset before access (edit by @jgraup) // check isset before access (edit by @jgraup)
if ( isset( $_POST['cwv3_auth'] ) ){ if ( isset( $_POST['cwv3_auth'] ) ) {
$mydata = sanitize_text_field( $_POST['cwv3_auth'] ); $mydata = sanitize_text_field( $_POST['cwv3_auth'] );
update_post_meta( $post_id, 'cwv3_auth', $mydata ); update_post_meta( $post_id, 'cwv3_auth', $mydata );
} }
@ -80,7 +80,7 @@ class CWV3Admin {
wp_nonce_field( plugin_basename( __FILE__ ), 'cwv3_meta' ); wp_nonce_field( plugin_basename( __FILE__ ), 'cwv3_meta' );
$curval = get_post_meta( $post->ID, 'cwv3_auth', true ); $curval = get_post_meta( $post->ID, 'cwv3_auth', true );
$sw = get_option( 'cwv3_sitewide' ); $sw = get_option( 'cwv3_sitewide' );
$disabled = $sw[0] == 'enabled' ? true : false; $disabled = 'enabled' == $sw[0] ? true : false;
?> ?>
<label for="cwv3_auth"><?php _e( 'Use authorization for this content', 'cwv3' ); ?>:</label> <label for="cwv3_auth"><?php _e( 'Use authorization for this content', 'cwv3' ); ?>:</label>

View File

@ -4,15 +4,15 @@ Plugin Name: Content Warning v2
Plugin URI: http://plugish.com/plugins/content-warning-v3 Plugin URI: http://plugish.com/plugins/content-warning-v3
Description: A plugin based on my v2 code, while drastically deviating from the original. Used mainly for NSFW websites, this plugin provides a dialog popup to warn viewers of it's possible content. Description: A plugin based on my v2 code, while drastically deviating from the original. Used mainly for NSFW websites, this plugin provides a dialog popup to warn viewers of it's possible content.
Author: Jerry Wood Jr. Author: Jerry Wood Jr.
Version: 3.6.3 Version: 3.6.4
Author URI: http://plugish.com Author URI: http://plugish.com
Text Domain: cwv3 Text Domain: cwv3
*/ */
require_once dirname( __FILE__ ) . '/inc/api.php'; require_once dirname( __FILE__ ) . '/inc/api.php';
if ( is_admin() ){ if ( is_admin() ) {
require_once dirname( __FILE__ ) . '/inc/options.inc.php'; require_once dirname( __FILE__ ) . '/inc/options.inc.php';
if ( ! class_exists( 'JW_SIMPLE_OPTIONS' ) ){ if ( ! class_exists( 'JW_SIMPLE_OPTIONS' ) ) {
require_once dirname( __FILE__ ) . '/lib/jw_simple_options/simple_options.php'; require_once dirname( __FILE__ ) . '/lib/jw_simple_options/simple_options.php';
} }
require_once dirname( __FILE__ ) . '/class/admin.class.php'; require_once dirname( __FILE__ ) . '/class/admin.class.php';
@ -24,7 +24,7 @@ if ( is_admin() ){
} }
add_action( 'plugins_loaded', 'jw_cwv3_load_text_domain' ); add_action( 'plugins_loaded', 'jw_cwv3_load_text_domain' );
function jw_cwv3_load_text_domain(){ function jw_cwv3_load_text_domain() {
load_plugin_textdomain( 'cwv3', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' ); load_plugin_textdomain( 'cwv3', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
} }

View File

@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: warning, message, lading page, front page, enter page, adult content, consent, age verification, validation Tags: warning, message, lading page, front page, enter page, adult content, consent, age verification, validation
Requires at least: 3.5 Requires at least: 3.5
Tested up to: 4.0 Tested up to: 4.0
Stable tag: 3.6.3 Stable tag: 3.6.4
A plugin that provides a warning box with a ton more options completely re-written from the ground up. A plugin that provides a warning box with a ton more options completely re-written from the ground up.
== Description == == Description ==
@ -81,6 +81,10 @@ Please do not contact me with questions like this. If you cannot be descriptive
== Changelog == == Changelog ==
= 3.6.4 =
* Fixed denial redirects. [Issue #28](https://github.com/JayWood/content-warning-v3/issues/28)
* Passified all PHPcs complaints
= 3.6.3 = = 3.6.3 =
* Category fix, fixes [#18](https://github.com/JayWood/content-warning-v3/issues/18) * Category fix, fixes [#18](https://github.com/JayWood/content-warning-v3/issues/18)
* Alphabetize method names, because why not!? * Alphabetize method names, because why not!?