| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -if( !function_exists( 'pollux_app' )) { | |
| 3 | +if( !function_exists( 'pollux_app' ) ) { | |
| 4 | 4 |  	function pollux_app() { | 
| 5 | 5 | return GeminiLabs\Pollux\Application::getInstance(); | 
| 6 | 6 | } | 
| @@ -4,8 +4,8 @@ | ||
| 4 | 4 | * Compatibility with Give WP plugin | 
| 5 | 5 | */ | 
| 6 | 6 |  add_filter( 'give_load_admin_scripts', function( $is_admin_page, $hook ) { | 
| 7 | - $needle = sprintf( '_page_%s', filter_input( INPUT_GET, 'page' )); | |
| 8 | - return substr( $hook, - strlen( $needle )) !== $needle | |
| 7 | + $needle = sprintf( '_page_%s', filter_input( INPUT_GET, 'page' ) ); | |
| 8 | + return substr( $hook, - strlen( $needle ) ) !== $needle | |
| 9 | 9 | ? $is_admin_page | 
| 10 | 10 | : true; | 
| 11 | 11 | }, 10, 2 ); | 
| @@ -30,7 +30,7 @@ discard block | ||
| 30 | 30 | $this->versions = wp_parse_args( $versions, array( | 
| 31 | 31 | 'php' => static::MIN_PHP_VERSION, | 
| 32 | 32 | 'wordpress' => static::MIN_WORDPRESS_VERSION, | 
| 33 | - )); | |
| 33 | + ) ); | |
| 34 | 34 | } | 
| 35 | 35 | |
| 36 | 36 | /** | 
| @@ -41,8 +41,8 @@ discard block | ||
| 41 | 41 |  		if( $this->isValid() ) { | 
| 42 | 42 | return true; | 
| 43 | 43 | } | 
| 44 | - add_action( 'activated_plugin', array( $this, 'deactivate' )); | |
| 45 | - add_action( 'admin_notices', array( $this, 'deactivate' )); | |
| 44 | + add_action( 'activated_plugin', array( $this, 'deactivate' ) ); | |
| 45 | + add_action( 'admin_notices', array( $this, 'deactivate' ) ); | |
| 46 | 46 | return false; | 
| 47 | 47 | } | 
| 48 | 48 | |
| @@ -137,7 +137,7 @@ discard block | ||
| 137 | 137 | filter_input( INPUT_GET, 'plugin_status' ), | 
| 138 | 138 | filter_input( INPUT_GET, 'paged' ), | 
| 139 | 139 | filter_input( INPUT_GET, 's' ) | 
| 140 | - ))); | |
| 140 | + ) ) ); | |
| 141 | 141 | exit; | 
| 142 | 142 | } | 
| 143 | 143 | } | 
| @@ -18,16 +18,16 @@ discard block | ||
| 18 | 18 | */ | 
| 19 | 19 | public function get( $metaKey, array $args = [] ) | 
| 20 | 20 |  	{ | 
| 21 | - if( empty( $metaKey ))return; | |
| 21 | + if( empty($metaKey) )return; | |
| 22 | 22 | |
| 23 | 23 | $args = $this->normalize( $args ); | 
| 24 | 24 | $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); | 
| 25 | 25 | $metaValue = get_post_meta( $args['id'], $metaKey, $args['single'] ); | 
| 26 | 26 | |
| 27 | -		if( is_string( $metaValue )) { | |
| 27 | +		if( is_string( $metaValue ) ) { | |
| 28 | 28 | $metaValue = trim( $metaValue ); | 
| 29 | 29 | } | 
| 30 | - return empty( $metaValue ) | |
| 30 | + return empty($metaValue) | |
| 31 | 31 | ? $args['fallback'] | 
| 32 | 32 | : $metaValue; | 
| 33 | 33 | } | 
| @@ -39,9 +39,9 @@ discard block | ||
| 39 | 39 | */ | 
| 40 | 40 | protected function buildMetaKey( $metaKey, $prefix ) | 
| 41 | 41 |  	{ | 
| 42 | - return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix )) | |
| 42 | + return (substr( $metaKey, 0, 1 ) == '_' && !empty($prefix)) | |
| 43 | 43 | ? sprintf( '_%s%s', rtrim( $prefix, '_' ), $metaKey ) | 
| 44 | - : $prefix . $metaKey; | |
| 44 | + : $prefix.$metaKey; | |
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | 47 | /** | 
| @@ -55,6 +55,6 @@ discard block | ||
| 55 | 55 | 'single' => true, | 
| 56 | 56 | 'prefix' => Application::prefix(), | 
| 57 | 57 | ]; | 
| 58 | - return shortcode_atts( $defaults, array_change_key_case( $args )); | |
| 58 | + return shortcode_atts( $defaults, array_change_key_case( $args ) ); | |
| 59 | 59 | } | 
| 60 | 60 | } | 
| @@ -30,7 +30,7 @@ discard block | ||
| 30 | 30 |  	{ | 
| 31 | 31 | $args = array_pad( $args, 2, null ); | 
| 32 | 32 | $group = $this->$group; | 
| 33 | -		if( is_object( $group )) { | |
| 33 | +		if( is_object( $group ) ) { | |
| 34 | 34 | return $group; | 
| 35 | 35 | } | 
| 36 | 36 | return $this->get( $group, $args[0], $args[1] ); | 
| @@ -43,15 +43,15 @@ discard block | ||
| 43 | 43 | public function __get( $group ) | 
| 44 | 44 |  	{ | 
| 45 | 45 |  		if( $group == 'all' ) { | 
| 46 | - return (object) $this->options; | |
| 46 | + return (object)$this->options; | |
| 47 | 47 | } | 
| 48 | -		if( empty( $group )) { | |
| 48 | +		if( empty($group) ) { | |
| 49 | 49 | $group = $this->getDefaultGroup(); | 
| 50 | 50 | } | 
| 51 | -		if( is_array( $group )) { | |
| 51 | +		if( is_array( $group ) ) { | |
| 52 | 52 | $group = reset( $group ); | 
| 53 | 53 | } | 
| 54 | - return isset( $this->options[$group] ) | |
| 54 | + return isset($this->options[$group]) | |
| 55 | 55 | ? $this->options[$group] | 
| 56 | 56 | : null; | 
| 57 | 57 | } | 
| @@ -67,13 +67,13 @@ discard block | ||
| 67 | 67 |  		if( func_num_args() < 1 ) { | 
| 68 | 68 | return $this->all; | 
| 69 | 69 | } | 
| 70 | -		if( is_string( $group )) { | |
| 70 | +		if( is_string( $group ) ) { | |
| 71 | 71 | $group = $this->$group; | 
| 72 | 72 | } | 
| 73 | -		if( !is_array( $group )) { | |
| 73 | +		if( !is_array( $group ) ) { | |
| 74 | 74 | return $fallback; | 
| 75 | 75 | } | 
| 76 | -		if( is_null( $key )) { | |
| 76 | +		if( is_null( $key ) ) { | |
| 77 | 77 | return $group; | 
| 78 | 78 | } | 
| 79 | 79 | return $this->getValue( $group, $key, $fallback ); | 
| @@ -94,10 +94,10 @@ discard block | ||
| 94 | 94 | */ | 
| 95 | 95 | protected function getValue( array $group, $key, $fallback ) | 
| 96 | 96 |  	{ | 
| 97 | -		if( !array_key_exists( $key, $group )) { | |
| 97 | +		if( !array_key_exists( $key, $group ) ) { | |
| 98 | 98 | return $fallback; | 
| 99 | 99 | } | 
| 100 | - return empty( $group[$key] ) && !is_null( $fallback ) | |
| 100 | + return empty($group[$key]) && !is_null( $fallback ) | |
| 101 | 101 | ? $fallback | 
| 102 | 102 | : $group[$key]; | 
| 103 | 103 | } | 
| @@ -22,15 +22,15 @@ discard block | ||
| 22 | 22 |  	{ | 
| 23 | 23 |  		$instructions = array_reduce( $this->getInstructionGroups(), function( $html, $metabox ) { | 
| 24 | 24 | $fields = $this->getInstructionFields( $metabox ); | 
| 25 | -			if( empty( $fields )) { | |
| 25 | +			if( empty($fields) ) { | |
| 26 | 26 | return $html; | 
| 27 | 27 | } | 
| 28 | - return $html . sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', | |
| 28 | + return $html.sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', | |
| 29 | 29 | $metabox['title'], | 
| 30 | 30 | $fields | 
| 31 | 31 | ); | 
| 32 | 32 | }); | 
| 33 | - return $this->filter( 'before/instructions', '' ) . $instructions . $this->filter( 'after/instructions', '' ); | |
| 33 | + return $this->filter( 'before/instructions', '' ).$instructions.$this->filter( 'after/instructions', '' ); | |
| 34 | 34 | } | 
| 35 | 35 | |
| 36 | 36 | /** | 
| @@ -39,9 +39,9 @@ discard block | ||
| 39 | 39 | protected function getInstructionFields( $metabox ) | 
| 40 | 40 |  	{ | 
| 41 | 41 | $skipFields = ['custom_html', 'divider', 'heading', 'taxonomy']; | 
| 42 | -		return array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox, $skipFields ) { | |
| 42 | +		return array_reduce( $metabox['fields'], function( $html, $field ) use($metabox, $skipFields) { | |
| 43 | 43 | return $this->validate( $field['condition'] ) && !in_array( $field['type'], $skipFields ) | 
| 44 | -				? $html . $this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ) . PHP_EOL | |
| 44 | +				? $html.$this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ).PHP_EOL | |
| 45 | 45 | : $html; | 
| 46 | 46 | }); | 
| 47 | 47 | } | 
| @@ -85,7 +85,7 @@ discard block | ||
| 85 | 85 |  	{ | 
| 86 | 86 |  		return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) { | 
| 87 | 87 | return $this->show( false, $metabox ); | 
| 88 | - })) > 0 ); | |
| 88 | + }) ) > 0 ); | |
| 89 | 89 | } | 
| 90 | 90 | |
| 91 | 91 | /** | 
| @@ -29,10 +29,10 @@ discard block | ||
| 29 | 29 |  	{ | 
| 30 | 30 | $method = strtolower( $name ); | 
| 31 | 31 | $status = substr( $method, 3 ); | 
| 32 | -		if( 'add' == substr( $method, 0, 3 ) && in_array( $status, ['error', 'info', 'success', 'warning'] )) { | |
| 33 | - return call_user_func_array( [$this, 'addNotice'], array_merge( [$status], $args )); | |
| 32 | +		if( 'add' == substr( $method, 0, 3 ) && in_array( $status, ['error', 'info', 'success', 'warning'] ) ) { | |
| 33 | + return call_user_func_array( [$this, 'addNotice'], array_merge( [$status], $args ) ); | |
| 34 | 34 | } | 
| 35 | - throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name )); | |
| 35 | + throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name ) ); | |
| 36 | 36 | } | 
| 37 | 37 | |
| 38 | 38 | public function __get( $property ) | 
| @@ -40,7 +40,7 @@ discard block | ||
| 40 | 40 |  		if( $property == 'all' ) { | 
| 41 | 41 | return $this->app->notices; | 
| 42 | 42 | } | 
| 43 | - throw new Exception( sprintf( 'Not a valid property: %s', $property )); | |
| 43 | + throw new Exception( sprintf( 'Not a valid property: %s', $property ) ); | |
| 44 | 44 | } | 
| 45 | 45 | |
| 46 | 46 | /** | 
| @@ -48,13 +48,13 @@ discard block | ||
| 48 | 48 | */ | 
| 49 | 49 | public function activateButton( array $plugin ) | 
| 50 | 50 |  	{ | 
| 51 | - $actionUrl = self_admin_url( sprintf( 'options-general.php?page=%s&action=activate&plugin=%s', $this->app->id, $plugin['plugin'] )); | |
| 51 | + $actionUrl = self_admin_url( sprintf( 'options-general.php?page=%s&action=activate&plugin=%s', $this->app->id, $plugin['plugin'] ) ); | |
| 52 | 52 | return $this->button( sprintf( '%s %s', __( 'Activate', 'pollux' ), $plugin['name'] ), [ | 
| 53 | 53 | 'data-name' => $plugin['name'], | 
| 54 | 54 | 'data-plugin' => $plugin['plugin'], | 
| 55 | 55 | 'data-slug' => $plugin['slug'], | 
| 56 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'activate-plugin_%s', $plugin['plugin'] )), | |
| 57 | - ]); | |
| 56 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'activate-plugin_%s', $plugin['plugin'] ) ), | |
| 57 | + ] ); | |
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | 60 | /** | 
| @@ -66,10 +66,10 @@ discard block | ||
| 66 | 66 | $atts = wp_parse_args( $atts, [ | 
| 67 | 67 | 'class' => '', | 
| 68 | 68 | 'href' => '', | 
| 69 | - ]); | |
| 70 | - $atts['class'] = trim( $atts['class'] . ' button button-small' ); | |
| 71 | -		$attributes = array_reduce( array_keys( $atts ), function( $carry, $key ) use( $atts ) { | |
| 72 | - return $carry . sprintf( ' %s="%s"', $key, $atts[$key] ); | |
| 69 | + ] ); | |
| 70 | + $atts['class'] = trim( $atts['class'].' button button-small' ); | |
| 71 | +		$attributes = array_reduce( array_keys( $atts ), function( $carry, $key ) use($atts) { | |
| 72 | + return $carry.sprintf( ' %s="%s"', $key, $atts[$key] ); | |
| 73 | 73 | }); | 
| 74 | 74 | return sprintf( '<a%s>%s</a>', $attributes, $title ); | 
| 75 | 75 | } | 
| @@ -82,7 +82,7 @@ discard block | ||
| 82 | 82 |  		if( $unset ) { | 
| 83 | 83 | $index = array_search( $notice, $this->app->notices ); | 
| 84 | 84 |  			if( $index !== false ) { | 
| 85 | - unset( $this->app->notices[$index] ); | |
| 85 | + unset($this->app->notices[$index]); | |
| 86 | 86 | } | 
| 87 | 87 | } | 
| 88 | 88 | return $this->buildNotice( $notice ); | 
| @@ -93,13 +93,13 @@ discard block | ||
| 93 | 93 | */ | 
| 94 | 94 | public function installButton( array $plugin ) | 
| 95 | 95 |  	{ | 
| 96 | - $actionUrl = self_admin_url( sprintf( 'update.php?action=install-plugin&plugin=%s', $plugin['slug'] )); | |
| 96 | + $actionUrl = self_admin_url( sprintf( 'update.php?action=install-plugin&plugin=%s', $plugin['slug'] ) ); | |
| 97 | 97 | return $this->button( sprintf( '%s %s', __( 'Install', 'pollux' ), $plugin['name'] ), [ | 
| 98 | 98 | 'data-name' => $plugin['name'], | 
| 99 | 99 | 'data-plugin' => $plugin['plugin'], | 
| 100 | 100 | 'data-slug' => $plugin['slug'], | 
| 101 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'install-plugin_%s', $plugin['slug'] )), | |
| 102 | - ]); | |
| 101 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'install-plugin_%s', $plugin['slug'] ) ), | |
| 102 | + ] ); | |
| 103 | 103 | } | 
| 104 | 104 | |
| 105 | 105 | /** | 
| @@ -107,13 +107,13 @@ discard block | ||
| 107 | 107 | */ | 
| 108 | 108 | public function updateButton( array $plugin ) | 
| 109 | 109 |  	{ | 
| 110 | - $actionUrl = self_admin_url( sprintf( 'update.php?action=upgrade-plugin&plugin=%s', $plugin['plugin'] )); | |
| 110 | + $actionUrl = self_admin_url( sprintf( 'update.php?action=upgrade-plugin&plugin=%s', $plugin['plugin'] ) ); | |
| 111 | 111 | return $this->button( sprintf( '%s %s', __( 'Update', 'pollux' ), $plugin['name'] ), [ | 
| 112 | 112 | 'data-name' => $plugin['name'], | 
| 113 | 113 | 'data-plugin' => $plugin['plugin'], | 
| 114 | 114 | 'data-slug' => $plugin['slug'], | 
| 115 | - 'href' => wp_nonce_url( $actionUrl, sprintf( 'upgrade-plugin_%s', $plugin['plugin'] )), | |
| 116 | - ]); | |
| 115 | + 'href' => wp_nonce_url( $actionUrl, sprintf( 'upgrade-plugin_%s', $plugin['plugin'] ) ), | |
| 116 | + ] ); | |
| 117 | 117 | } | 
| 118 | 118 | |
| 119 | 119 | /** | 
| @@ -135,7 +135,7 @@ discard block | ||
| 135 | 135 |  	{ | 
| 136 | 136 | $this->app->notices[] = [ | 
| 137 | 137 | 'dismissible' => $dismissible, | 
| 138 | - 'message' => $this->buildMessage( array_filter( (array) $messages )), | |
| 138 | + 'message' => $this->buildMessage( array_filter( (array)$messages ) ), | |
| 139 | 139 | 'type' => $type, | 
| 140 | 140 | ]; | 
| 141 | 141 | $this->app->notices = array_unique( $this->app->notices, SORT_REGULAR ); | 
| @@ -147,10 +147,10 @@ discard block | ||
| 147 | 147 | protected function buildMessage( array $messages ) | 
| 148 | 148 |  	{ | 
| 149 | 149 |  		foreach( $messages as $key => &$message ) { | 
| 150 | - if( !is_wp_error( $message ))continue; | |
| 150 | + if( !is_wp_error( $message ) )continue; | |
| 151 | 151 | $message = $message->get_error_message(); | 
| 152 | 152 | } | 
| 153 | - return wpautop( implode( PHP_EOL . PHP_EOL, $messages )); | |
| 153 | + return wpautop( implode( PHP_EOL.PHP_EOL, $messages ) ); | |
| 154 | 154 | } | 
| 155 | 155 | |
| 156 | 156 | /** | 
| @@ -40,8 +40,8 @@ discard block | ||
| 40 | 40 | */ | 
| 41 | 41 | public static function getInstance( array $aliases = [] ) | 
| 42 | 42 |  	{ | 
| 43 | -		if( is_null( static::$instance )) { | |
| 44 | - return static::$instance = new static( $aliases ); | |
| 43 | +		if( is_null( static::$instance ) ) { | |
| 44 | + return static::$instance = new static($aliases); | |
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | 47 | $aliases = array_merge( static::$instance->aliases, $aliases ); | 
| @@ -60,7 +60,7 @@ discard block | ||
| 60 | 60 | */ | 
| 61 | 61 | public function load( $alias ) | 
| 62 | 62 |  	{ | 
| 63 | -		if( isset( $this->aliases[$alias] )) { | |
| 63 | +		if( isset($this->aliases[$alias]) ) { | |
| 64 | 64 | return class_alias( $this->aliases[$alias], $alias ); | 
| 65 | 65 | } | 
| 66 | 66 | } | 
| @@ -24,7 +24,7 @@ discard block | ||
| 24 | 24 | */ | 
| 25 | 25 | public static function id() | 
| 26 | 26 |  	{ | 
| 27 | - return Application::PREFIX . static::ID; | |
| 27 | + return Application::PREFIX.static::ID; | |
| 28 | 28 | } | 
| 29 | 29 | |
| 30 | 30 | public function __construct( Application $app ) | 
| @@ -39,8 +39,8 @@ discard block | ||
| 39 | 39 |  	{ | 
| 40 | 40 | if( $this->app->config->disable_config )return; | 
| 41 | 41 | |
| 42 | - add_action( 'admin_menu', [$this, 'registerPage'] ); | |
| 43 | - add_action( 'admin_menu', [$this, 'registerSetting'] ); | |
| 42 | + add_action( 'admin_menu', [$this, 'registerPage'] ); | |
| 43 | + add_action( 'admin_menu', [$this, 'registerSetting'] ); | |
| 44 | 44 | add_action( 'current_screen', [$this, 'resetPage'] ); | 
| 45 | 45 | } | 
| 46 | 46 | |
| @@ -94,9 +94,9 @@ discard block | ||
| 94 | 94 | 'config' => $this->app->make( ConfigManager::class ), | 
| 95 | 95 | 'heading' => __( 'Pollux Settings', 'pollux' ), | 
| 96 | 96 | 'id' => static::id(), | 
| 97 | - 'reset_url' => esc_url( add_query_arg( $query, admin_url( 'options-general.php' ))), | |
| 97 | + 'reset_url' => esc_url( add_query_arg( $query, admin_url( 'options-general.php' ) ) ), | |
| 98 | 98 | 'has_meta_box' => $this->app->gatekeeper->hasDependency( 'meta-box/meta-box.php' ), | 
| 99 | - ]); | |
| 99 | + ] ); | |
| 100 | 100 | } | 
| 101 | 101 | |
| 102 | 102 | /** | 
| @@ -108,16 +108,16 @@ discard block | ||
| 108 | 108 | if( filter_input( INPUT_GET, 'page' ) !== $this->app->id | 
| 109 | 109 | || filter_input( INPUT_GET, 'action' ) !== 'reset' | 
| 110 | 110 | )return; | 
| 111 | -		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), static::id() )) { | |
| 111 | +		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), static::id() ) ) { | |
| 112 | 112 | delete_option( static::id() ); | 
| 113 | 113 | $this->app->make( ConfigManager::class )->compile( true ); | 
| 114 | 114 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); | 
| 115 | 115 | } | 
| 116 | 116 |  		else { | 
| 117 | - add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' )); | |
| 117 | + add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' ) ); | |
| 118 | 118 | } | 
| 119 | 119 | set_transient( 'settings_errors', get_settings_errors(), 30 ); | 
| 120 | - wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() )); | |
| 120 | + wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() ) ); | |
| 121 | 121 | exit; | 
| 122 | 122 | } | 
| 123 | 123 | } |