@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Implimentation of WordPress inbuilt functions for plugin activation. |
6 | 6 | */ |
7 | -if ( ! class_exists( 'PLUGIN_INSTALL' ) ) { |
|
7 | +if ( ! class_exists('PLUGIN_INSTALL')) { |
|
8 | 8 | |
9 | 9 | final class PLUGIN_INSTALL { |
10 | 10 | |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | |
27 | 27 | public function execute() { |
28 | - add_action( 'plugins_loaded', array( $this, 'text_domain_cb' ) ); |
|
29 | - add_action( 'admin_notices', array( $this, 'php_ver_incompatible' ) ); |
|
30 | - add_filter( 'plugin_action_links', array( $this, 'menu_page_link' ), 10, 2 ); |
|
28 | + add_action('plugins_loaded', array($this, 'text_domain_cb')); |
|
29 | + add_action('admin_notices', array($this, 'php_ver_incompatible')); |
|
30 | + add_filter('plugin_action_links', array($this, 'menu_page_link'), 10, 2); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | unload_textdomain($this->textDomin); |
42 | 42 | load_textdomain($this->textDomin, PLUGIN_LN . 'quize-custom-ads-' . $locale . '.mo'); |
43 | - load_plugin_textdomain( $this->textDomin, false, PLUGIN_LN ); |
|
43 | + load_plugin_textdomain($this->textDomin, false, PLUGIN_LN); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | //Define low php verson errors |
49 | 49 | public function php_ver_incompatible() { |
50 | 50 | |
51 | - if ( version_compare( phpversion(), $this->phpVerAllowed, '<' ) ) : |
|
52 | - $text = __( 'The Plugin can\'t be activated because your PHP version', 'textdomain' ); |
|
53 | - $text_last = __( 'is less than required '.$this->phpVerAllowed.'. See more information', 'textdomain' ); |
|
51 | + if (version_compare(phpversion(), $this->phpVerAllowed, '<')) : |
|
52 | + $text = __('The Plugin can\'t be activated because your PHP version', 'textdomain'); |
|
53 | + $text_last = __('is less than required ' . $this->phpVerAllowed . '. See more information', 'textdomain'); |
|
54 | 54 | $text_link = 'php.net/eol.php'; ?> |
55 | 55 | |
56 | 56 | <div id="message" class="updated notice notice-success is-dismissible"><p><?php echo $text . ' ' . phpversion() . ' ' . $text_last . ': '; ?><a href="http://php.net/eol.php/" target="_blank"><?php echo $text_link; ?></a></p></div> |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | |
61 | 61 | |
62 | 62 | // Add settings link to plugin page |
63 | - public function menu_page_link( $links, $file ) { |
|
63 | + public function menu_page_link($links, $file) { |
|
64 | 64 | |
65 | 65 | if ($this->pluginPageLinks) { |
66 | 66 | static $this_plugin; |
67 | - if ( ! $this_plugin ) { |
|
67 | + if ( ! $this_plugin) { |
|
68 | 68 | $this_plugin = PLUGIN_FILE; |
69 | 69 | } |
70 | - if ( $file == $this_plugin ) { |
|
70 | + if ($file == $this_plugin) { |
|
71 | 71 | $shift_link = array(); |
72 | 72 | foreach ($this->pluginPageLinks as $value) { |
73 | - $shift_link[] = '<a href="'.$value['slug'].'">'.$value['label'].'</a>'; |
|
73 | + $shift_link[] = '<a href="' . $value['slug'] . '">' . $value['label'] . '</a>'; |
|
74 | 74 | } |
75 | - foreach( $shift_link as $val ) { |
|
76 | - array_unshift( $links, $val ); |
|
75 | + foreach ($shift_link as $val) { |
|
76 | + array_unshift($links, $val); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | return $links; |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Build a sample metabox in editor screen |
6 | 6 | */ |
7 | -if ( ! class_exists( 'PLUGIN_METABOX' ) ) { |
|
7 | +if ( ! class_exists('PLUGIN_METABOX')) { |
|
8 | 8 | |
9 | 9 | final class PLUGIN_METABOX { |
10 | 10 | |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | public function __construct() { |
14 | 14 | |
15 | 15 | //Adding the metabox. For custom post type use "add_meta_boxes_posttype" action |
16 | - add_action( 'add_meta_boxes', array( $this, 'register' ) ); |
|
17 | - add_action( 'save_post', array( $this, 'save' ), 10, 2 ); |
|
16 | + add_action('add_meta_boxes', array($this, 'register')); |
|
17 | + add_action('save_post', array($this, 'save'), 10, 2); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | |
24 | 24 | add_meta_box( |
25 | 25 | 'meta-box-id', |
26 | - esc_html__( 'MetaBox Title', 'textdomain' ), |
|
27 | - array( $this, 'render' ), |
|
26 | + esc_html__('MetaBox Title', 'textdomain'), |
|
27 | + array($this, 'render'), |
|
28 | 28 | // Declare the post type to show meta box |
29 | 29 | 'post_type', |
30 | 30 | 'normal', |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | |
37 | 37 | public function render() { |
38 | 38 | |
39 | - wp_nonce_field( basename( __FILE__ ), 'metabox_name_nonce' ); ?> |
|
39 | + wp_nonce_field(basename(__FILE__), 'metabox_name_nonce'); ?> |
|
40 | 40 | |
41 | 41 | <p> |
42 | - <label for="metabox_name"><?php _e( "Custom Text", 'textdomain' ); ?></label> |
|
42 | + <label for="metabox_name"><?php _e("Custom Text", 'textdomain'); ?></label> |
|
43 | 43 | <br /> |
44 | - <input class="widefat" type="text" name="metabox_field_name" id="metabox_field_name" value="<?php echo esc_attr( get_post_meta( $object->ID, 'metabox_name', true ) ); ?>" /> |
|
44 | + <input class="widefat" type="text" name="metabox_field_name" id="metabox_field_name" value="<?php echo esc_attr(get_post_meta($object->ID, 'metabox_name', true)); ?>" /> |
|
45 | 45 | </p> |
46 | 46 | <?php |
47 | 47 | } |
@@ -49,22 +49,22 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | //Save the post data |
52 | - function save( $post_id, $post ) { |
|
52 | + function save($post_id, $post) { |
|
53 | 53 | |
54 | 54 | //Check if doing autosave |
55 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; |
|
55 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; |
|
56 | 56 | |
57 | 57 | //Verify the nonce before proceeding. |
58 | - if ( !isset( $_POST['metabox_name_nonce'] ) || !wp_verify_nonce( $_POST['metabox_name_nonce'], basename( __FILE__ ) ) ) return; |
|
58 | + if ( ! isset($_POST['metabox_name_nonce']) || ! wp_verify_nonce($_POST['metabox_name_nonce'], basename(__FILE__))) return; |
|
59 | 59 | |
60 | 60 | //Get the post type object. |
61 | - $post_type = get_post_type_object( $post->post_type ); |
|
61 | + $post_type = get_post_type_object($post->post_type); |
|
62 | 62 | |
63 | 63 | //Check if the current user has permission to edit the post. |
64 | - if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id; |
|
64 | + if ( ! current_user_can($post_type->cap->edit_post, $post_id)) return $post_id; |
|
65 | 65 | |
66 | - if ( isset( $_POST['metabox_field_name'] ) ) { |
|
67 | - update_post_meta( $post_id, 'metabox_field_name', esc_attr($_POST['metabox_field_name']) ); |
|
66 | + if (isset($_POST['metabox_field_name'])) { |
|
67 | + update_post_meta($post_id, 'metabox_field_name', esc_attr($_POST['metabox_field_name'])); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | } |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
3 | 5 | |
4 | 6 | /** |
5 | 7 | * Build a sample metabox in editor screen |
@@ -52,16 +54,22 @@ discard block |
||
52 | 54 | function save( $post_id, $post ) { |
53 | 55 | |
54 | 56 | //Check if doing autosave |
55 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; |
|
57 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
58 | + return; |
|
59 | + } |
|
56 | 60 | |
57 | 61 | //Verify the nonce before proceeding. |
58 | - if ( !isset( $_POST['metabox_name_nonce'] ) || !wp_verify_nonce( $_POST['metabox_name_nonce'], basename( __FILE__ ) ) ) return; |
|
62 | + if ( !isset( $_POST['metabox_name_nonce'] ) || !wp_verify_nonce( $_POST['metabox_name_nonce'], basename( __FILE__ ) ) ) { |
|
63 | + return; |
|
64 | + } |
|
59 | 65 | |
60 | 66 | //Get the post type object. |
61 | 67 | $post_type = get_post_type_object( $post->post_type ); |
62 | 68 | |
63 | 69 | //Check if the current user has permission to edit the post. |
64 | - if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id; |
|
70 | + if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) { |
|
71 | + return $post_id; |
|
72 | + } |
|
65 | 73 | |
66 | 74 | if ( isset( $_POST['metabox_field_name'] ) ) { |
67 | 75 | update_post_meta( $post_id, 'metabox_field_name', esc_attr($_POST['metabox_field_name']) ); |