Skip to content

Commit

Permalink
TSF WPCS. Cleaned up code.
Browse files Browse the repository at this point in the history
  • Loading branch information
sybrew committed Oct 15, 2020
1 parent 0ccc266 commit 3cf00c9
Show file tree
Hide file tree
Showing 119 changed files with 1,138 additions and 932 deletions.
7 changes: 7 additions & 0 deletions bootstrap/define.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* Tells the world the plugin is present and to be used.
*
* @since 2.4.1
*/
define( 'TSF_EXTENSION_MANAGER_PRESENT', true );

/**
* NOTE:
* The definable constants should be defined in `wp-config.php`.
Expand Down
5 changes: 3 additions & 2 deletions bootstrap/envtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* @since 2.1.0 Now requires WordPress 4.8+, from 4.7+.
* @since 2.2.0 1. Now requires WordPress 4.9+, from 4.7+.
* 2. Now requires PHP 5.6+, from 5.5+.
* @since 2.4.1 Now requires WordPress 5.1+, from 4.9+.
* @access private
* @link http://php.net/eol.php
* @link https://codex.wordpress.org/WordPress_Versions
Expand All @@ -67,7 +68,7 @@ function tsf_extension_manager_pre_boot_test() {

$requirements = array(
'php' => 50605,
'wp' => '4.9-dev',
'wp' => '5.1-dev',
);

// phpcs:disable, Generic.Formatting.MultipleStatementAlignment, WordPress.WhiteSpace.PrecisionAlignment
Expand Down Expand Up @@ -114,7 +115,7 @@ function tsf_extension_manager_pre_boot_test() {

case 2:
//* WordPress requirements not met.
$requirement = 'WordPress 4.9 or later';
$requirement = 'WordPress 5.1 or later';
$issue = 'WordPress version';
$version = $GLOBALS['wp_version'];
$subtitle = 'WordPress Requirements';
Expand Down
10 changes: 5 additions & 5 deletions bootstrap/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TSF_Extension_Manager;

defined( 'TSF_EXTENSION_MANAGER_PLUGIN_BASE_FILE' ) or die;
\defined( 'TSF_EXTENSION_MANAGER_PLUGIN_BASE_FILE' ) or die;

/**
* The SEO Framework - Extension Manager plugin
Expand Down Expand Up @@ -66,7 +66,7 @@ function _init_locale( $ignore = false ) {
*/
function _protect_options() {

defined( 'PHP_INT_MIN' ) or define( 'PHP_INT_MIN', ~ PHP_INT_MAX );
\defined( 'PHP_INT_MIN' ) or \define( 'PHP_INT_MIN', ~ PHP_INT_MAX );

$current_options = (array) \get_option( TSF_EXTENSION_MANAGER_SITE_OPTIONS, [] );

Expand Down Expand Up @@ -125,7 +125,7 @@ function _pre_execute_protect_option( $new_value, $old_value, $option ) {
*/
function _init_tsf_extension_manager() {

//* Cache the class object. Do not run everything more than once.
// Cache the class object. Do not run everything more than once.
static $tsf_extension_manager = null;

if ( $tsf_extension_manager )
Expand All @@ -152,7 +152,7 @@ function _init_tsf_extension_manager() {
$tsf_extension_manager = new LoadFront;
}

//* Initialize extensions.
// Initialize extensions.
$tsf_extension_manager->_init_extensions();

/**
Expand Down Expand Up @@ -182,7 +182,7 @@ function _init_tsf_extension_manager() {
*/
function _register_autoloader() {

//* Prevent overriding of security classes by checking their existence.
// Prevent overriding of security classes by checking their existence.
$integrity_classes = [
'\TSF_Extension_Manager\Core',
'\TSF_Extension_Manager\Secure_Abstract',
Expand Down
6 changes: 3 additions & 3 deletions bootstrap/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TSF_Extension_Manager;

defined( 'TSF_EXTENSION_MANAGER_PLUGIN_BASE_FILE' ) or die;
\defined( 'TSF_EXTENSION_MANAGER_PLUGIN_BASE_FILE' ) or die;

\add_action( 'tsfem_needs_the_seo_framework', __NAMESPACE__ . '\\_prepare_tsf_installer' );
/**
Expand Down Expand Up @@ -157,12 +157,12 @@ function _check_external_blocking() {

if ( ! \current_user_can( 'update_plugins' ) ) return;

if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) && true === WP_HTTP_BLOCK_EXTERNAL ) {
if ( \defined( 'WP_HTTP_BLOCK_EXTERNAL' ) && true === WP_HTTP_BLOCK_EXTERNAL ) {

$parsed_url = \wp_parse_url( TSF_EXTENSION_MANAGER_DL_URI );
$host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : '';

if ( ! defined( 'WP_ACCESSIBLE_HOSTS' ) || false === stristr( WP_ACCESSIBLE_HOSTS, $host ) ) {
if ( ! \defined( 'WP_ACCESSIBLE_HOSTS' ) || false === stristr( WP_ACCESSIBLE_HOSTS, $host ) ) {
$notice = \the_seo_framework()->convert_markdown(
sprintf(
/* translators: Markdown. %s = Update API URL */
Expand Down
5 changes: 2 additions & 3 deletions bootstrap/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TSF_Extension_Manager;

defined( 'TSF_EXTENSION_MANAGER_DB_VERSION' ) or die;
\defined( 'TSF_EXTENSION_MANAGER_DB_VERSION' ) or die;

/**
* The SEO Framework - Extension Manager plugin
Expand Down Expand Up @@ -38,10 +38,9 @@
*/
function _do_critical_core_upgrade( Upgrader $upgrader ) {

// phpcs:disable -- Example with unused variable.
$version = $upgrader->get_current_version( 'core' );

// phpcs:disable

// Example:
// if ( $version < 1500 ) {
// $upgrader->_register_upgrade( 'core', '1500', function( $version ) { return (bool) $success; } );
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/upgrader.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TSF_Extension_Manager;

defined( 'TSF_EXTENSION_MANAGER_DB_VERSION' ) or die;
\defined( 'TSF_EXTENSION_MANAGER_DB_VERSION' ) or die;

/**
* The SEO Framework - Extension Manager plugin
Expand Down
14 changes: 7 additions & 7 deletions extensions/essentials/articles/trunk/articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Extension Menu Slug: theseoframework-extension-settings
*/

defined( 'ABSPATH' ) or die;
\defined( 'TSF_EXTENSION_MANAGER_PRESENT' ) or die;

/**
* Articles extension for The SEO Framework
Expand All @@ -41,43 +41,43 @@
* @since 1.0.0
* NOTE: The presence does NOT guarantee the extension is loaded!!!
*/
define( 'TSFEM_E_ARTICLES_VERSION', '2.1.0' );
\define( 'TSFEM_E_ARTICLES_VERSION', '2.1.0' );

/**
* The extension database version.
*
* @since ?.?.?
* @ignore
*/
// define( 'TSFEM_E_ARTICLES_DB_VERSION', '1000' );
// \define( 'TSFEM_E_ARTICLES_DB_VERSION', '1000' );

/**
* The extension file, absolute unix path.
*
* @since 1.1.0
*/
define( 'TSFEM_E_ARTICLES_BASE_FILE', __FILE__ );
\define( 'TSFEM_E_ARTICLES_BASE_FILE', __FILE__ );

/**
* The extension map URL. Used for calling browser files.
*
* @since 2.2.0
*/
define( 'TSFEM_E_ARTICLES_DIR_URL', \TSF_Extension_Manager\extension_dir_url( TSFEM_E_ARTICLES_BASE_FILE ) );
\define( 'TSFEM_E_ARTICLES_DIR_URL', \TSF_Extension_Manager\extension_dir_url( TSFEM_E_ARTICLES_BASE_FILE ) );

/**
* The extension file relative to the plugins dir.
*
* @since 1.2.0
*/
define( 'TSFEM_E_ARTICLES_DIR_PATH', \TSF_Extension_Manager\extension_dir_path( TSFEM_E_ARTICLES_BASE_FILE ) );
\define( 'TSFEM_E_ARTICLES_DIR_PATH', \TSF_Extension_Manager\extension_dir_path( TSFEM_E_ARTICLES_BASE_FILE ) );

/**
* The plugin class map absolute path.
*
* @since 1.2.0
*/
define( 'TSFEM_E_ARTICLES_PATH_CLASS', TSFEM_E_ARTICLES_DIR_PATH . 'inc' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR );
\define( 'TSFEM_E_ARTICLES_PATH_CLASS', TSFEM_E_ARTICLES_DIR_PATH . 'inc' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR );

/**
* Verify integrity and sets up autoloader.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TSF_Extension_Manager\Extension\Articles;

defined( 'ABSPATH' ) or die;
\defined( 'TSF_EXTENSION_MANAGER_PRESENT' ) or die;

if ( \tsf_extension_manager()->_has_died() or false === ( \tsf_extension_manager()->_verify_instance( $_instance, $bits[1] ) or \tsf_extension_manager()->_maybe_die() ) )
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TSF_Extension_Manager\Extension\Articles;

defined( 'ABSPATH' ) or die;
\defined( 'TSF_EXTENSION_MANAGER_PRESENT' ) or die;

if ( \tsf_extension_manager()->_has_died() or false === ( \tsf_extension_manager()->_verify_instance( $_instance, $bits[1] ) or \tsf_extension_manager()->_maybe_die() ) )
return;
Expand Down
10 changes: 5 additions & 5 deletions extensions/essentials/articles/trunk/inc/classes/front.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TSF_Extension_Manager\Extension\Articles;

defined( 'ABSPATH' ) or die;
\defined( 'TSF_EXTENSION_MANAGER_PRESENT' ) or die;

if ( \tsf_extension_manager()->_has_died() or false === ( \tsf_extension_manager()->_verify_instance( $_instance, $bits[1] ) or \tsf_extension_manager()->_maybe_die() ) )
return;
Expand Down Expand Up @@ -91,10 +91,10 @@ public function _init_articles_output() {
if ( empty( $settings[ $post_type ]['enabled'] ) ) return;

if ( $this->is_amp() ) {
//* Initialize output in The SEO Framework's front-end AMP meta object.
// Initialize output in The SEO Framework's front-end AMP meta object.
\add_filter( 'the_seo_framework_amp_pro', [ $this, '_articles_hook_amp_output' ] );
} else {
//* Initialize output in The SEO Framework's front-end meta object.
// Initialize output in The SEO Framework's front-end meta object.
\add_filter( 'the_seo_framework_after_output', [ $this, '_articles_hook_output' ] );
}
}
Expand Down Expand Up @@ -131,7 +131,7 @@ private function is_amp() {

if ( function_exists( '\\is_amp_endpoint' ) ) {
$is_amp = \is_amp_endpoint();
} elseif ( defined( 'AMP_QUERY_VAR' ) ) {
} elseif ( \defined( 'AMP_QUERY_VAR' ) ) {
$is_amp = \get_query_var( AMP_QUERY_VAR, false ) !== false;
} else {
$is_amp = false;
Expand Down Expand Up @@ -277,7 +277,7 @@ public function _get_articles_json_output() {
if ( ! $this->is_json_valid() )
return '';

//* Build data, fetch it later.
// Build data, fetch it later.
array_filter( array_filter( $data ), [ $this, 'build_article_data' ] );

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TSF_Extension_Manager\Extension\Articles;

defined( 'ABSPATH' ) or die;
\defined( 'TSF_EXTENSION_MANAGER_PRESENT' ) or die;

if ( \tsf_extension_manager()->_has_died() or false === ( \tsf_extension_manager()->_verify_instance( $_instance, $bits[1] ) or \tsf_extension_manager()->_maybe_die() ) )
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TSF_Extension_Manager\Extension\Articles;

defined( 'ABSPATH' ) or die;
\defined( 'TSF_EXTENSION_MANAGER_PRESENT' ) or die;

if ( \tsf_extension_manager()->_has_died() or false === ( \tsf_extension_manager()->_verify_instance( $_instance, $bits[1] ) or \tsf_extension_manager()->_maybe_die() ) )
return;
Expand Down
3 changes: 2 additions & 1 deletion extensions/essentials/articles/trunk/views/inpost/inpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* @package TSF_Extension_Manager\Extension\Articles\Views
* @subpackage TSF_Extension_Manager\Inpost\Structure;
*/

namespace TSF_Extension_Manager\Extension\Articles;

/**
Expand All @@ -11,7 +12,7 @@
use \TSF_Extension_Manager\InpostGUI as InpostGUI;
use \TSF_Extension_Manager\InpostHTML as InpostHTML;

defined( 'ABSPATH' ) and InpostGUI::verify( $_secret ) or die;
\defined( 'TSF_EXTENSION_MANAGER_PRESENT' ) and InpostGUI::verify( $_secret ) or die;

create_type_field :;
$type_title = sprintf( '<div><strong>%s</strong></div>', $post_meta['type']['label']['title'] );
Expand Down
6 changes: 3 additions & 3 deletions extensions/essentials/articles/trunk/views/list/bulkedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
// phpcs:disable, VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- includes.
// phpcs:disable, WordPress.WP.GlobalVariablesOverride -- This isn't the global scope.

defined( 'ABSPATH' ) and ListEdit::verify( $_secret ) or die;
\defined( 'TSF_EXTENSION_MANAGER_PRESENT' ) and ListEdit::verify( $_secret ) or die;

// NOTE: 'type' is the option name, confusingly so.

?>
<div class="inline-edit-group wp-clearfix">
<label class=clear>
<?php
<?php
// This is bad accessibility, but it's exactly as bad as WP is, and we don't want to stray away from their standards.
printf( '<span class=title>%s</span>', \esc_html( $post_meta['type']['label'] ) );
// phpcs:disable, WordPress.Security.EscapeOutput -- make_single_select_form() escapes.
Expand All @@ -32,6 +32,6 @@
'default' => 'nochange',
] );
// phpcs:enable, WordPress.Security.EscapeOutput
?>
?>
</label>
</div>
6 changes: 3 additions & 3 deletions extensions/essentials/articles/trunk/views/list/quickedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
// phpcs:disable, VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- includes.
// phpcs:disable, WordPress.WP.GlobalVariablesOverride -- This isn't the global scope.

defined( 'ABSPATH' ) and ListEdit::verify( $_secret ) or die;
\defined( 'TSF_EXTENSION_MANAGER_PRESENT' ) and ListEdit::verify( $_secret ) or die;

// NOTE: 'type' is the option name, confusingly so.

?>
<div class="inline-edit-group wp-clearfix">
<label class=clear>
<?php
<?php
// This is bad accessibility, but it's exactly as bad as WP is, and we don't want to stray away from their standards.
printf( '<span class=title>%s</span>', \esc_html( $post_meta['type']['label'] ) );
// phpcs:disable, WordPress.Security.EscapeOutput -- make_single_select_form() escapes.
Expand All @@ -32,6 +32,6 @@
'default' => '',
] );
// phpcs:enable, WordPress.Security.EscapeOutput
?>
?>
</label>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

defined( 'ABSPATH' ) and $this instanceof \TSF_Extension_Manager\Extension\Articles\Sitemap or die;
\defined( 'TSF_EXTENSION_MANAGER_PRESENT' ) and $this instanceof \TSF_Extension_Manager\Extension\Articles\Sitemap or die;

$tsf = \the_seo_framework();

Expand Down
Loading

0 comments on commit 3cf00c9

Please sign in to comment.