| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | <h2 class="nav-tab-wrapper"> | 
| 2 | 2 | @foreach( $tabs as $tab => $name ) | 
| 3 | - <?php $class = ( $tab == $current_tab ) ? ' nav-tab-active' : '';?> | |
| 3 | + <?php $class = ($tab == $current_tab) ? ' nav-tab-active' : ''; ?> | |
| 4 | 4 |          <a class='nav-tab{{ $class }}' href='?page=wpdfi-settings.php&tab={{ $tab }}'>{{ $name }}</a> | 
| 5 | 5 | @endforeach | 
| 6 | 6 | </h2> | 
| 7 | 7 | \ No newline at end of file | 
| @@ -47,13 +47,13 @@ discard block | ||
| 47 | 47 | |
| 48 | 48 | $data = []; | 
| 49 | 49 | // Default size | 
| 50 | -		if ( in_array( $size_name, ['thumbnail', 'medium', 'medium_large', 'large'] ) ) { | |
| 51 | -			$data['width']  = get_option( "{$size_name}_size_w" ); | |
| 52 | -			$data['height'] = get_option( "{$size_name}_size_h" ); | |
| 50 | +		if (in_array($size_name, ['thumbnail', 'medium', 'medium_large', 'large'])) { | |
| 51 | +			$data['width']  = get_option("{$size_name}_size_w"); | |
| 52 | +			$data['height'] = get_option("{$size_name}_size_h"); | |
| 53 | 53 | // Additional size | 
| 54 | -		} elseif ( isset( $_wp_additional_image_sizes[ $size_name ] ) ) { | |
| 55 | - $data['width'] = $_wp_additional_image_sizes[ $size_name ]['width']; | |
| 56 | - $data['height'] = $_wp_additional_image_sizes[ $size_name ]['height']; | |
| 54 | +		} elseif (isset($_wp_additional_image_sizes[$size_name])) { | |
| 55 | + $data['width'] = $_wp_additional_image_sizes[$size_name]['width']; | |
| 56 | + $data['height'] = $_wp_additional_image_sizes[$size_name]['height']; | |
| 57 | 57 | } | 
| 58 | 58 | |
| 59 | 59 | return $data; | 
| @@ -68,7 +68,7 @@ discard block | ||
| 68 | 68 |  	public function get_size_names_and_dimensions() { | 
| 69 | 69 | $data = []; | 
| 70 | 70 | |
| 71 | -		foreach($this->get_size_names() as $size_name) { | |
| 71 | +		foreach ($this->get_size_names() as $size_name) { | |
| 72 | 72 | $data[$size_name] = $this->get_size_dimensions($size_name); | 
| 73 | 73 | } | 
| 74 | 74 | |
| @@ -37,7 +37,7 @@ discard block | ||
| 37 | 37 | */ | 
| 38 | 38 | public function __get($name) | 
| 39 | 39 |  	{ | 
| 40 | -		switch($name) { | |
| 40 | +		switch ($name) { | |
| 41 | 41 | // Load sub-module first | 
| 42 | 42 | case isset($this->modules[$name]): | 
| 43 | 43 | return $this->modules[$name]; | 
| @@ -55,8 +55,8 @@ discard block | ||
| 55 | 55 | * @return void | 
| 56 | 56 | */ | 
| 57 | 57 |  	public function moduleHooks() { | 
| 58 | -		foreach($this->modules as $module) { | |
| 59 | -			if(method_exists($module, 'hooks')) { | |
| 58 | +		foreach ($this->modules as $module) { | |
| 59 | +			if (method_exists($module, 'hooks')) { | |
| 60 | 60 | $module->hooks(); | 
| 61 | 61 | } | 
| 62 | 62 | } | 
| @@ -71,7 +71,7 @@ discard block | ||
| 71 | 71 | * @return mixed $handle | 
| 72 | 72 | */ | 
| 73 | 73 |  	public function module($name, $handle = null) { | 
| 74 | - if(!isset($this->modules[$name])) | |
| 74 | + if (!isset($this->modules[$name])) | |
| 75 | 75 | $this->modules[$name] = $handle; | 
| 76 | 76 | return $this->modules[$name]; | 
| 77 | 77 | } | 
| @@ -71,8 +71,9 @@ | ||
| 71 | 71 | * @return mixed $handle | 
| 72 | 72 | */ | 
| 73 | 73 |  	public function module($name, $handle = null) { | 
| 74 | - if(!isset($this->modules[$name])) | |
| 75 | - $this->modules[$name] = $handle; | |
| 74 | +		if(!isset($this->modules[$name])) { | |
| 75 | + $this->modules[$name] = $handle; | |
| 76 | + } | |
| 76 | 77 | return $this->modules[$name]; | 
| 77 | 78 | } | 
| 78 | 79 | } | 
| 79 | 80 | \ No newline at end of file | 
| @@ -36,7 +36,7 @@ | ||
| 36 | 36 | * @return WPDFI\Traits\Singleton A single instance of this class. | 
| 37 | 37 | */ | 
| 38 | 38 |  	public static function instance() { | 
| 39 | -		if ( null === self::$instance ) { | |
| 39 | +		if (null === self::$instance) { | |
| 40 | 40 | self::$instance = new self(); | 
| 41 | 41 | } | 
| 42 | 42 | return self::$instance; | 
| @@ -33,11 +33,11 @@ | ||
| 33 | 33 |  	public function get($post_type) { | 
| 34 | 34 | $data = []; | 
| 35 | 35 | |
| 36 | -		if($post_type) { | |
| 36 | +		if ($post_type) { | |
| 37 | 37 | |
| 38 | -			foreach(\get_object_taxonomies($post_type, 'objects') as $index => $taxonomy) { | |
| 38 | +			foreach (\get_object_taxonomies($post_type, 'objects') as $index => $taxonomy) { | |
| 39 | 39 | // Only accept taxonomies which visible to admin and reader | 
| 40 | -				if($taxonomy->show_ui and $taxonomy->show_in_menu) { | |
| 40 | +				if ($taxonomy->show_ui and $taxonomy->show_in_menu) { | |
| 41 | 41 | |
| 42 | 42 | $data[$index]['name'] = $taxonomy->name; | 
| 43 | 43 | $data[$index]['label'] = $taxonomy->label; | 
| @@ -54,7 +54,6 @@ | ||
| 54 | 54 | /** | 
| 55 | 55 | * Get taxonomy label from taxonomy name | 
| 56 | 56 | * | 
| 57 | - * @param string $taxonomy_name | |
| 58 | 57 | * @since 1.0.0 | 
| 59 | 58 | * @return string | 
| 60 | 59 | */ | 
| @@ -33,14 +33,14 @@ discard block | ||
| 33 | 33 |  	public function get($taxonomy) { | 
| 34 | 34 | $names = []; | 
| 35 | 35 | |
| 36 | -		if($taxonomy) { | |
| 36 | +		if ($taxonomy) { | |
| 37 | 37 | |
| 38 | 38 | $terms = \get_terms([ | 
| 39 | 39 | 'taxonomy' => $taxonomy, | 
| 40 | 40 | 'hide_empty' => false | 
| 41 | 41 | ]); | 
| 42 | 42 | |
| 43 | -			foreach($terms as $index => $term) { | |
| 43 | +			foreach ($terms as $index => $term) { | |
| 44 | 44 | |
| 45 | 45 | $names[$index]['id'] = $term->term_id; | 
| 46 | 46 | $names[$index]['text'] = $term->name; | 
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 | |
| 64 | 64 | $terms_array = []; | 
| 65 | 65 | |
| 66 | -		foreach($terms as $term) { | |
| 66 | +		foreach ($terms as $term) { | |
| 67 | 67 | |
| 68 | 68 | $terms_array[$term->taxonomy][] = $term->term_id; | 
| 69 | 69 | |
| @@ -43,7 +43,7 @@ discard block | ||
| 43 | 43 | $this->message = $noticeMessage; | 
| 44 | 44 | $this->type = $noticeType; | 
| 45 | 45 | |
| 46 | - \add_action( 'admin_notices', [$this, 'display']); | |
| 46 | +        \add_action('admin_notices', [$this, 'display']); | |
| 47 | 47 | } | 
| 48 | 48 | |
| 49 | 49 | /** | 
| @@ -54,7 +54,7 @@ discard block | ||
| 54 | 54 | */ | 
| 55 | 55 | public function display() | 
| 56 | 56 |      { | 
| 57 | - if(!$this->message) return; | |
| 57 | + if (!$this->message) return; | |
| 58 | 58 | |
| 59 | 59 |          echo \wpdfi()->templater->render('admin/notice', [ | 
| 60 | 60 | 'classes' => $this->get_classes(), | 
| @@ -54,7 +54,9 @@ | ||
| 54 | 54 | */ | 
| 55 | 55 | public function display() | 
| 56 | 56 |      { | 
| 57 | - if(!$this->message) return; | |
| 57 | +        if(!$this->message) { | |
| 58 | + return; | |
| 59 | + } | |
| 58 | 60 | |
| 59 | 61 |          echo \wpdfi()->templater->render('admin/notice', [ | 
| 60 | 62 | 'classes' => $this->get_classes(), | 
| @@ -10,88 +10,88 @@ | ||
| 10 | 10 | |
| 11 | 11 | final class Notice | 
| 12 | 12 |  { | 
| 13 | - use Singleton; | |
| 13 | + use Singleton; | |
| 14 | 14 | |
| 15 | - /** | |
| 16 | - * @traitDoc | |
| 17 | - */ | |
| 18 | - public function initializes() | |
| 19 | -    {    | |
| 20 | - // | |
| 21 | - } | |
| 15 | + /** | |
| 16 | + * @traitDoc | |
| 17 | + */ | |
| 18 | + public function initializes() | |
| 19 | +	{    | |
| 20 | + // | |
| 21 | + } | |
| 22 | 22 | |
| 23 | - /** | |
| 24 | - * Type of notice, it can be 'success', 'error', 'warning', 'info'. | |
| 25 | - */ | |
| 26 | - private $type; | |
| 23 | + /** | |
| 24 | + * Type of notice, it can be 'success', 'error', 'warning', 'info'. | |
| 25 | + */ | |
| 26 | + private $type; | |
| 27 | 27 | |
| 28 | - /** | |
| 29 | - * Message of the notice | |
| 30 | - */ | |
| 31 | - private $message; | |
| 28 | + /** | |
| 29 | + * Message of the notice | |
| 30 | + */ | |
| 31 | + private $message; | |
| 32 | 32 | |
| 33 | - /** | |
| 34 | - * Add new notice to the admin dashboard. | |
| 35 | - * | |
| 36 | - * @param string $noticeMessage | |
| 37 | - * @param string $noticeType | |
| 38 | - * @since 1.0.0 | |
| 39 | - * @return void | |
| 40 | - */ | |
| 41 | - public function add($noticeMessage, $noticeType = 'info') | |
| 42 | -    { | |
| 43 | - $this->message = $noticeMessage; | |
| 44 | - $this->type = $noticeType; | |
| 33 | + /** | |
| 34 | + * Add new notice to the admin dashboard. | |
| 35 | + * | |
| 36 | + * @param string $noticeMessage | |
| 37 | + * @param string $noticeType | |
| 38 | + * @since 1.0.0 | |
| 39 | + * @return void | |
| 40 | + */ | |
| 41 | + public function add($noticeMessage, $noticeType = 'info') | |
| 42 | +	{ | |
| 43 | + $this->message = $noticeMessage; | |
| 44 | + $this->type = $noticeType; | |
| 45 | 45 | |
| 46 | - \add_action( 'admin_notices', [$this, 'display']); | |
| 47 | - } | |
| 46 | + \add_action( 'admin_notices', [$this, 'display']); | |
| 47 | + } | |
| 48 | 48 | |
| 49 | - /** | |
| 50 | - * Display notice template to the admin dashboard. | |
| 51 | - * | |
| 52 | - * @since 1.0.0 | |
| 53 | - * @return \VA\Templater | |
| 54 | - */ | |
| 55 | - public function display() | |
| 56 | -    { | |
| 57 | - if(!$this->message) return; | |
| 49 | + /** | |
| 50 | + * Display notice template to the admin dashboard. | |
| 51 | + * | |
| 52 | + * @since 1.0.0 | |
| 53 | + * @return \VA\Templater | |
| 54 | + */ | |
| 55 | + public function display() | |
| 56 | +	{ | |
| 57 | + if(!$this->message) return; | |
| 58 | 58 | |
| 59 | -        echo \wpdfi()->templater->render('admin/notice', [ | |
| 60 | - 'classes' => $this->get_classes(), | |
| 61 | - 'message' => __($this->message, 'wpdfi') | |
| 62 | - ]); | |
| 63 | - } | |
| 59 | +		echo \wpdfi()->templater->render('admin/notice', [ | |
| 60 | + 'classes' => $this->get_classes(), | |
| 61 | + 'message' => __($this->message, 'wpdfi') | |
| 62 | + ]); | |
| 63 | + } | |
| 64 | 64 | |
| 65 | - /** | |
| 66 | - * Get all the classes of the notice | |
| 67 | - * | |
| 68 | - * @since 1.0.0 | |
| 69 | - * @return string | |
| 70 | - */ | |
| 71 | - private function get_classes() | |
| 72 | -    { | |
| 73 | -        return "notice notice-{$this->get_type()} is-dismissible"; | |
| 74 | - } | |
| 65 | + /** | |
| 66 | + * Get all the classes of the notice | |
| 67 | + * | |
| 68 | + * @since 1.0.0 | |
| 69 | + * @return string | |
| 70 | + */ | |
| 71 | + private function get_classes() | |
| 72 | +	{ | |
| 73 | +		return "notice notice-{$this->get_type()} is-dismissible"; | |
| 74 | + } | |
| 75 | 75 | |
| 76 | - /** | |
| 77 | - * Get the type of the notice | |
| 78 | - * | |
| 79 | - * @since 1.0.0 | |
| 80 | - * @return string | |
| 81 | - */ | |
| 82 | - private function get_type() | |
| 83 | -    { | |
| 84 | - return $this->type ? $this->type : $this->get_default_type(); | |
| 85 | - } | |
| 76 | + /** | |
| 77 | + * Get the type of the notice | |
| 78 | + * | |
| 79 | + * @since 1.0.0 | |
| 80 | + * @return string | |
| 81 | + */ | |
| 82 | + private function get_type() | |
| 83 | +	{ | |
| 84 | + return $this->type ? $this->type : $this->get_default_type(); | |
| 85 | + } | |
| 86 | 86 | |
| 87 | - /** | |
| 88 | - * Get default type of the notice | |
| 89 | - * | |
| 90 | - * @since 1.0.0 | |
| 91 | - * @return string | |
| 92 | - */ | |
| 93 | - private function get_default_type() | |
| 94 | -    { | |
| 95 | - return 'info'; | |
| 96 | - } | |
| 87 | + /** | |
| 88 | + * Get default type of the notice | |
| 89 | + * | |
| 90 | + * @since 1.0.0 | |
| 91 | + * @return string | |
| 92 | + */ | |
| 93 | + private function get_default_type() | |
| 94 | +	{ | |
| 95 | + return 'info'; | |
| 96 | + } | |
| 97 | 97 | } | 
| 98 | 98 | \ No newline at end of file | 
| @@ -43,12 +43,12 @@ discard block | ||
| 43 | 43 | \wp_enqueue_media(); | 
| 44 | 44 | } | 
| 45 | 45 | |
| 46 | - /** | |
| 47 | - * Add new setting menu | |
| 48 | - * | |
| 49 | - * @since 1.0.0 | |
| 50 | - * @return void | |
| 51 | - */ | |
| 46 | + /** | |
| 47 | + * Add new setting menu | |
| 48 | + * | |
| 49 | + * @since 1.0.0 | |
| 50 | + * @return void | |
| 51 | + */ | |
| 52 | 52 |  	public function setting_menu() { | 
| 53 | 53 | \add_options_page( 'WPDFI', 'WPDFI', 'manage_options', 'wpdfi-settings.php', [$this, 'render_layout']); | 
| 54 | 54 | } | 
| @@ -141,28 +141,28 @@ discard block | ||
| 141 | 141 | */ | 
| 142 | 142 |  	public function update_settings() { | 
| 143 | 143 |  		if(isset($_GET['page']) and $_GET['page'] == 'wpdfi-settings.php' and isset($_POST['_wpnonce'])) { | 
| 144 | - $nonce = $_POST['_wpnonce']; | |
| 145 | -            if ( ! \wp_verify_nonce( $nonce, 'wpdfi-settings-page' ) ) { | |
| 146 | - // This nonce is not valid. | |
| 147 | - return; | |
| 148 | -            } else { | |
| 149 | - // Dont need to store wp_nonce value | |
| 150 | - unset($_POST['_wpnonce']); | |
| 151 | - unset($_POST['_wp_http_referer']); | |
| 144 | + $nonce = $_POST['_wpnonce']; | |
| 145 | +			if ( ! \wp_verify_nonce( $nonce, 'wpdfi-settings-page' ) ) { | |
| 146 | + // This nonce is not valid. | |
| 147 | + return; | |
| 148 | +			} else { | |
| 149 | + // Dont need to store wp_nonce value | |
| 150 | + unset($_POST['_wpnonce']); | |
| 151 | + unset($_POST['_wp_http_referer']); | |
| 152 | 152 | |
| 153 | - $options = $this->_get_options(); | |
| 154 | -                foreach($_POST as $key => $value) { | |
| 155 | - $options[$key] = $value; | |
| 156 | - } | |
| 153 | + $options = $this->_get_options(); | |
| 154 | +				foreach($_POST as $key => $value) { | |
| 155 | + $options[$key] = $value; | |
| 156 | + } | |
| 157 | 157 | |
| 158 | -                if($this->_update_options($options)) { | |
| 159 | -                	\wpdfi()->admin_notice->add('Settings Saved.', 'success'); | |
| 160 | -                } else { | |
| 161 | -                	\wpdfi()->admin_notice->add('Your options are still the same.', 'warning'); | |
| 162 | - } | |
| 158 | +				if($this->_update_options($options)) { | |
| 159 | +					\wpdfi()->admin_notice->add('Settings Saved.', 'success'); | |
| 160 | +				} else { | |
| 161 | +					\wpdfi()->admin_notice->add('Your options are still the same.', 'warning'); | |
| 162 | + } | |
| 163 | 163 | |
| 164 | - } | |
| 165 | - } | |
| 164 | + } | |
| 165 | + } | |
| 166 | 166 | } | 
| 167 | 167 | |
| 168 | 168 | /** | 
| @@ -28,9 +28,9 @@ discard block | ||
| 28 | 28 | * @return void | 
| 29 | 29 | */ | 
| 30 | 30 |  	public function hooks() { | 
| 31 | - \add_action( 'admin_enqueue_scripts', [$this, 'wpdfi_enqueue_scripts']); | |
| 32 | - \add_action( 'admin_menu', [$this, 'setting_menu'] ); | |
| 33 | - \add_action( 'init', [$this, 'update_settings']); | |
| 31 | +		\add_action('admin_enqueue_scripts', [$this, 'wpdfi_enqueue_scripts']); | |
| 32 | +		\add_action('admin_menu', [$this, 'setting_menu']); | |
| 33 | +		\add_action('init', [$this, 'update_settings']);	 | |
| 34 | 34 | } | 
| 35 | 35 | |
| 36 | 36 | /** | 
| @@ -50,7 +50,7 @@ discard block | ||
| 50 | 50 | * @return void | 
| 51 | 51 | */ | 
| 52 | 52 |  	public function setting_menu() { | 
| 53 | - \add_options_page( 'WPDFI', 'WPDFI', 'manage_options', 'wpdfi-settings.php', [$this, 'render_layout']); | |
| 53 | +		\add_options_page('WPDFI', 'WPDFI', 'manage_options', 'wpdfi-settings.php', [$this, 'render_layout']); | |
| 54 | 54 | } | 
| 55 | 55 | |
| 56 | 56 | /** | 
| @@ -62,7 +62,7 @@ discard block | ||
| 62 | 62 |  	public function render_layout() { | 
| 63 | 63 | global $pagenow; | 
| 64 | 64 | // Exit if this is not options and WP Default Thumbnail settings page | 
| 65 | - if($pagenow != 'options-general.php' or $_GET['page'] != 'wpdfi-settings.php') return; | |
| 65 | + if ($pagenow != 'options-general.php' or $_GET['page'] != 'wpdfi-settings.php') return; | |
| 66 | 66 | |
| 67 | 67 | echo \wpdfi()->layout->get_admin_layout( | 
| 68 | 68 | $this->_get_tabs(), $this->_get_current_tab(), $this->_get_options(), $this->_get_layout_name() | 
| @@ -140,9 +140,9 @@ discard block | ||
| 140 | 140 | * @return void | 
| 141 | 141 | */ | 
| 142 | 142 |  	public function update_settings() { | 
| 143 | -		if(isset($_GET['page']) and $_GET['page'] == 'wpdfi-settings.php' and isset($_POST['_wpnonce'])) { | |
| 143 | +		if (isset($_GET['page']) and $_GET['page'] == 'wpdfi-settings.php' and isset($_POST['_wpnonce'])) { | |
| 144 | 144 | $nonce = $_POST['_wpnonce']; | 
| 145 | -            if ( ! \wp_verify_nonce( $nonce, 'wpdfi-settings-page' ) ) { | |
| 145 | +            if (!\wp_verify_nonce($nonce, 'wpdfi-settings-page')) { | |
| 146 | 146 | // This nonce is not valid. | 
| 147 | 147 | return; | 
| 148 | 148 |              } else { | 
| @@ -151,11 +151,11 @@ discard block | ||
| 151 | 151 | unset($_POST['_wp_http_referer']); | 
| 152 | 152 | |
| 153 | 153 | $options = $this->_get_options(); | 
| 154 | -                foreach($_POST as $key => $value) { | |
| 154 | +                foreach ($_POST as $key => $value) { | |
| 155 | 155 | $options[$key] = $value; | 
| 156 | 156 | } | 
| 157 | 157 | |
| 158 | -                if($this->_update_options($options)) { | |
| 158 | +                if ($this->_update_options($options)) { | |
| 159 | 159 |                  	\wpdfi()->admin_notice->add('Settings Saved.', 'success'); | 
| 160 | 160 |                  } else { | 
| 161 | 161 |                  	\wpdfi()->admin_notice->add('Your options are still the same.', 'warning'); | 
| @@ -174,7 +174,7 @@ discard block | ||
| 174 | 174 | * @return mixed(string/array) | 
| 175 | 175 | */ | 
| 176 | 176 |  	public function get_option($option_key, $option_detail = null) { | 
| 177 | - if($option_detail) return $this->_get_options()[$option_key][$option_detail]; | |
| 177 | + if ($option_detail) return $this->_get_options()[$option_key][$option_detail]; | |
| 178 | 178 | return $this->_get_options()[$option_key]; | 
| 179 | 179 | } | 
| 180 | 180 | |
| @@ -62,7 +62,9 @@ discard block | ||
| 62 | 62 |  	public function render_layout() { | 
| 63 | 63 | global $pagenow; | 
| 64 | 64 | // Exit if this is not options and WP Default Thumbnail settings page | 
| 65 | - if($pagenow != 'options-general.php' or $_GET['page'] != 'wpdfi-settings.php') return; | |
| 65 | +		if($pagenow != 'options-general.php' or $_GET['page'] != 'wpdfi-settings.php') { | |
| 66 | + return; | |
| 67 | + } | |
| 66 | 68 | |
| 67 | 69 | echo \wpdfi()->layout->get_admin_layout( | 
| 68 | 70 | $this->_get_tabs(), $this->_get_current_tab(), $this->_get_options(), $this->_get_layout_name() | 
| @@ -174,7 +176,9 @@ discard block | ||
| 174 | 176 | * @return mixed(string/array) | 
| 175 | 177 | */ | 
| 176 | 178 |  	public function get_option($option_key, $option_detail = null) { | 
| 177 | - if($option_detail) return $this->_get_options()[$option_key][$option_detail]; | |
| 179 | +		if($option_detail) { | |
| 180 | + return $this->_get_options()[$option_key][$option_detail]; | |
| 181 | + } | |
| 178 | 182 | return $this->_get_options()[$option_key]; | 
| 179 | 183 | } | 
| 180 | 184 | |
| @@ -2,7 +2,7 @@ | ||
| 2 | 2 | /* All uninstall actions of this plugin come here */ | 
| 3 | 3 | |
| 4 | 4 | |
| 5 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { | |
| 5 | +if (!defined('WP_UNINSTALL_PLUGIN')) { | |
| 6 | 6 | exit(); | 
| 7 | 7 | } | 
| 8 | 8 | |