From bf183aac5a11592f07f1248d0742f455ddf73096 Mon Sep 17 00:00:00 2001 From: Lem Smyth Date: Sat, 12 Feb 2022 15:28:25 -0600 Subject: [PATCH] Whitespace & typos --- classes/LBRYPress.php | 42 +++++----- classes/LBRY_Admin.php | 14 ++-- classes/LBRY_Admin_Notice.php | 29 +++---- classes/LBRY_Daemon.php | 118 ++++++++++++++--------------- classes/LBRY_Daemon_Logger.php | 1 + classes/LBRY_Network.php | 4 +- classes/LBRY_Network_Publisher.php | 50 ++++++------ templates/options-page.php | 1 - 8 files changed, 130 insertions(+), 129 deletions(-) diff --git a/classes/LBRYPress.php b/classes/LBRYPress.php index 95113b7..21706fd 100644 --- a/classes/LBRYPress.php +++ b/classes/LBRYPress.php @@ -64,7 +64,7 @@ class LBRYPress */ public static function instance() { - if (is_null(self::$_instance)) { + if ( is_null( self::$_instance ) ) { self::$_instance = new self(); } return self::$_instance; @@ -77,7 +77,7 @@ class LBRYPress public function __construct() { $this->define_constants(); - spl_autoload_register(array($this, 'lbry_autoload_register')); + spl_autoload_register( array( $this, 'lbry_autoload_register' ) ); $this->init(); $this->init_hooks(); } @@ -88,10 +88,10 @@ class LBRYPress * @param string $name Constant name. * @param string|bool $value Constant value. */ - private function define($name, $value) + private function define( $name, $value ) { - if (! defined($name)) { - define($name, $value); + if ( ! defined( $name ) ) { + define( $name, $value ); } } @@ -130,11 +130,11 @@ class LBRYPress /** * Autoloader Registration */ - private function lbry_autoload_register($class) + private function lbry_autoload_register( $class ) { $file_name = LBRY_ABSPATH . 'classes/' . $class . '.php'; - if (file_exists($file_name)) { + if ( file_exists( $file_name ) ) { require $file_name; return; } @@ -149,7 +149,7 @@ class LBRYPress $this->speech = new LBRY_Speech(); // Admin request - if (is_admin()) { + if ( is_admin() ) { $this->admin = new LBRY_Admin(); $this->notice = new LBRY_Admin_Notice(); $this->network = new LBRY_Network(); @@ -161,15 +161,15 @@ class LBRYPress */ private function init_hooks() { - register_activation_hook(LBRY_PLUGIN_FILE, array($this, 'activate')); - register_deactivation_hook(LBRY_PLUGIN_FILE, array($this, 'deactivate')); + register_activation_hook( LBRY_PLUGIN_FILE, array( $this, 'activate' ) ); + register_deactivation_hook( LBRY_PLUGIN_FILE, array( $this, 'deactivate' ) ); // Banner output for published posts // NOTE: move this to its own class to reduce clutter? - add_action('the_content', array($this, 'published_on_lbry_banner'), 12, 1); + add_action( 'the_content', array( $this, 'published_on_lbry_banner' ), 12, 1 ); - add_action('wp_enqueue_scripts', function () { - wp_enqueue_style('lbry-css', plugins_url('/frontend/lbry.css', LBRY_PLUGIN_FILE)); + add_action( 'wp_enqueue_scripts', function () { + wp_enqueue_style( 'lbry-css', plugins_url( '/frontend/lbry.css', LBRY_PLUGIN_FILE ) ); }); } @@ -181,16 +181,16 @@ class LBRYPress // TODO: Make sure errors are thrown if daemon can't be contacted, stop activation // Add options to the options table we need - if (! get_option(LBRY_SETTINGS)) { + if (! get_option( LBRY_SETTINGS ) ) { - // Default options + //Default options $option_defaults = array( LBRY_LICENSE => $this->licenses[0], LBRY_LBC_PUBLISH => 1 ); - add_option(LBRY_SETTINGS, $option_defaults, false); + add_option( LBRY_SETTINGS, $option_defaults, false ); } if ( ! get_option( LBRY_SPEECH_SETTINGS ) ) { @@ -221,26 +221,26 @@ class LBRYPress public function deactivate() { // TODO: Stop the daemon - error_log('Deactivated LBRYPress'); + error_log( 'Deactivated LBRYPress' ); } public function published_on_lbry_banner($content) { - if (!is_single() || !in_the_loop() || !is_main_query()) { + if ( ! is_single() || ! in_the_loop() || ! is_main_query() ) { return $content; } global $post; - if ($post->post_type != 'post') { + if ( $post->post_type != 'post' ) { return $content; } - if (!get_post_meta($post->ID, LBRY_WILL_PUBLISH, true)) { + if ( ! get_post_meta( $post->ID, LBRY_WILL_PUBLISH, true ) ) { return $content; } ob_start(); - require(LBRY_ABSPATH . 'templates/published_on_lbry_banner.php'); + require( LBRY_ABSPATH . 'templates/published_on_lbry_banner.php' ); $banner = ob_get_clean(); return $content .= $banner; diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php index 3952e3b..8578b91 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -26,11 +26,11 @@ class LBRY_Admin public function create_options_page() { add_menu_page( - __('LBRYPress Settings', 'lbrypress'), - __('LBRYPress', 'lbrypress'), + __( 'LBRYPress Settings', 'lbrypress' ), + __( 'LBRYPress', 'lbrypress' ), 'manage_options', LBRY_ADMIN_PAGE, - array($this, 'options_page_html'), + array( $this, 'options_page_html' ), plugin_dir_url(LBRY_PLUGIN_FILE) . '/admin/images/lbry-logo.svg' ); @@ -246,7 +246,7 @@ class LBRY_Admin { // Get first available account address from Daemon $address = LBRY()->daemon->address_list(); - $address = is_array($address) && !empty($address) ? $address[0]->address : ''; + $address = is_array( $address ) && ! empty( $address ) ? $address[0]->address : ''; printf( '', LBRY_WALLET, @@ -264,11 +264,11 @@ class LBRY_Admin $options = ''; // Create options list, select current license // - foreach (LBRY()->licenses as $value => $name) { + foreach ( LBRY()->licenses as $value => $name ) { $selected = $this->options[LBRY_LICENSE] === $value; $options .= '