@@ -1,5 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 3 | 5 | |
| 4 | 6 | /** |
| 5 | 7 | * WP Query class for querying WP database |
@@ -29,12 +29,12 @@ |
||
| 29 | 29 | /** |
| 30 | 30 | $user_args = $this->user_args($paged); |
| 31 | 31 | $the_query = new WP_User_Query( $user_args ); |
| 32 | - */ |
|
| 32 | + */ |
|
| 33 | 33 | |
| 34 | 34 | // The Loop |
| 35 | 35 | if ( $the_query->have_posts() ) { |
| 36 | 36 | while ( $the_query->have_posts() ) { |
| 37 | - $the_query->the_post(); |
|
| 37 | + $the_query->the_post(); |
|
| 38 | 38 | // Do Stuff |
| 39 | 39 | } // end while |
| 40 | 40 | } // endif |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 2 | +if ( ! defined('ABSPATH')) exit; |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * WP Query class for querying WP database |
| 6 | 6 | * For more reference of arguments visit: https://gist.github.com/nirjharlo/5c6f8ac4cc5271f88376788e599c287b |
| 7 | 7 | * This class depends on WP pagenavi plugin: https://wordpress.org/plugins/wp-pagenavi/ |
| 8 | 8 | */ |
| 9 | -if ( ! class_exists( 'PLUGIN_QUERY' ) ) { |
|
| 9 | +if ( ! class_exists('PLUGIN_QUERY')) { |
|
| 10 | 10 | |
| 11 | 11 | class PLUGIN_QUERY { |
| 12 | 12 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | get_query_var('page') : 1); |
| 25 | 25 | |
| 26 | 26 | $post_args = $this->post_args($paged); |
| 27 | - $the_query = new WP_Query( $post_args ); |
|
| 27 | + $the_query = new WP_Query($post_args); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | $user_args = $this->user_args($paged); |
@@ -32,15 +32,15 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | |
| 34 | 34 | // The Loop |
| 35 | - if ( $the_query->have_posts() ) { |
|
| 36 | - while ( $the_query->have_posts() ) { |
|
| 35 | + if ($the_query->have_posts()) { |
|
| 36 | + while ($the_query->have_posts()) { |
|
| 37 | 37 | $the_query->the_post(); |
| 38 | 38 | // Do Stuff |
| 39 | 39 | } // end while |
| 40 | 40 | } // endif |
| 41 | 41 | |
| 42 | - if (function_exists('wp_pagenavi')) { |
|
| 43 | - wp_pagenavi( array( 'query' => $the_query, 'echo' => true ) );//For user query add param 'type' => 'users' |
|
| 42 | + if (function_exists('wp_pagenavi')) { |
|
| 43 | + wp_pagenavi(array('query' => $the_query, 'echo' => true)); //For user query add param 'type' => 'users' |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | // Reset Post Data |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function user_args($paged) { |
| 55 | 55 | |
| 56 | - $offset = ( $paged - 1 ) * $this->display_count; |
|
| 56 | + $offset = ($paged - 1) * $this->display_count; |
|
| 57 | 57 | |
| 58 | - $args = array ( |
|
| 58 | + $args = array( |
|
| 59 | 59 | 'role' => '', // user role |
| 60 | 60 | 'order' => '', //ASC or DESC |
| 61 | 61 | 'fields' => '', // |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | 'count_total' => true, |
| 72 | 72 | 'paged' => $paged, |
| 73 | 73 | 'offset' => $offset, |
| 74 | - 'search' => '*'.esc_attr( $_GET['search'] ).'*', |
|
| 74 | + 'search' => '*' . esc_attr($_GET['search']) . '*', |
|
| 75 | 75 | 'meta_query' => array( // It supports nested meta query |
| 76 | 76 | 'relation' => 'AND', //or 'OR' |
| 77 | 77 | array( |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function post_args($paged) { |
| 98 | 98 | |
| 99 | - $offset = ( $paged - 1 ) * $this->display_count; |
|
| 99 | + $offset = ($paged - 1) * $this->display_count; |
|
| 100 | 100 | |
| 101 | - $args = array ( |
|
| 101 | + $args = array( |
|
| 102 | 102 | 'post_type' => '', // array of type slugs |
| 103 | 103 | 'order' => 'ASC', |
| 104 | 104 | 'fields' => '', // |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | 'count_total' => true, |
| 113 | 113 | 'paged' => $paged, |
| 114 | 114 | 'offset' => $offset, |
| 115 | - 'search' => '*'.esc_attr( $_GET['search'] ).'*', |
|
| 115 | + 'search' => '*' . esc_attr($_GET['search']) . '*', |
|
| 116 | 116 | 'meta_query' => array( // It supports nested meta query |
| 117 | 117 | 'relation' => 'AND', //or 'OR' |
| 118 | 118 | array( |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | add_action( 'admin_menu', array( $this, 'menu_page' ) ); |
| 54 | 54 | add_action( 'admin_menu', array( $this, 'sub_menu_page' ) ); |
| 55 | 55 | add_filter( 'set-screen-option', array( $this, 'set_screen' ), 10, 3 ); |
| 56 | - * |
|
| 57 | - */ |
|
| 56 | + * |
|
| 57 | + */ |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | //Set screen option |
| 104 | 104 | public function set_screen($status, $option, $value) { |
| 105 | 105 | |
| 106 | - if ( 'option_name_per_page' == $option ) return $value; // Related to PLUGIN_TABLE() |
|
| 107 | - //return $status; |
|
| 106 | + if ( 'option_name_per_page' == $option ) return $value; // Related to PLUGIN_TABLE() |
|
| 107 | + //return $status; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | echo '<textarea name="settings_field_name" id="settings_field_name" value="' . get_option('settings_field_name') . '>'. __( 'Enter Value', 'textdomain' ) . '</textarea>'; |
| 202 | 202 | echo '<select name="settings_field_name" id="settings_field_name"><option value="value" ' . selected( 'value', get_option('settings_field_name'), false) . '>Value</option></select>'; |
| 203 | 203 | echo '<input type="checkbox" id="settings_field_name" name="settings_field_name" value="1"' . checked( 1, get_option('settings_field_name'), false ) . '/>'; |
| 204 | - */ |
|
| 204 | + */ |
|
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | } ?> |
@@ -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 | * Backend settings page class, can have settings fields or data table |
@@ -103,7 +105,10 @@ discard block |
||
| 103 | 105 | //Set screen option |
| 104 | 106 | public function set_screen($status, $option, $value) { |
| 105 | 107 | |
| 106 | - if ( 'option_name_per_page' == $option ) return $value; // Related to PLUGIN_TABLE() |
|
| 108 | + if ( 'option_name_per_page' == $option ) { |
|
| 109 | + return $value; |
|
| 110 | + } |
|
| 111 | + // Related to PLUGIN_TABLE() |
|
| 107 | 112 | //return $status; |
| 108 | 113 | } |
| 109 | 114 | |
@@ -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 | * Backend settings page class, can have settings fields or data table |
| 6 | 6 | */ |
| 7 | -if ( ! class_exists( 'PLUGIN_SETTINGS' ) ) { |
|
| 7 | +if ( ! class_exists('PLUGIN_SETTINGS')) { |
|
| 8 | 8 | |
| 9 | 9 | final class PLUGIN_SETTINGS { |
| 10 | 10 | |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | public function __construct() { |
| 21 | 21 | |
| 22 | 22 | $this->capability = 'manage_options'; |
| 23 | - $this->menuPage = array( 'name' => '', 'heading' => '', 'slug' => '' ); |
|
| 23 | + $this->menuPage = array('name' => '', 'heading' => '', 'slug' => ''); |
|
| 24 | 24 | $this->subMenuPage = array( |
| 25 | 25 | 'name' => '', |
| 26 | 26 | 'heading' => '', |
| 27 | 27 | 'slug' => '', |
| 28 | 28 | 'parent_slug' => '', |
| 29 | - 'help' => '',//true/false, |
|
| 30 | - 'screen' => '',//true/false |
|
| 29 | + 'help' => '', //true/false, |
|
| 30 | + 'screen' => '', //true/false |
|
| 31 | 31 | ); |
| 32 | 32 | $this->helpData = array( |
| 33 | 33 | array( |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | 'info' => array( |
| 37 | 37 | array( |
| 38 | 38 | 'id' => 'helpId', |
| 39 | - 'title' => __( 'Title', 'textdomain' ), |
|
| 40 | - 'content' => __( 'Description', 'textdomain' ), |
|
| 39 | + 'title' => __('Title', 'textdomain'), |
|
| 40 | + 'content' => __('Description', 'textdomain'), |
|
| 41 | 41 | ), |
| 42 | 42 | ), |
| 43 | - 'link' => '<p><a href="#">' . __( 'helpLink', 'textdomain' ) . '</a></p>', |
|
| 43 | + 'link' => '<p><a href="#">' . __('helpLink', 'textdomain') . '</a></p>', |
|
| 44 | 44 | ) |
| 45 | 45 | ) |
| 46 | 46 | ); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $this->menuPage['heading'], |
| 69 | 69 | $this->capability, |
| 70 | 70 | $this->menuPage['slug'], |
| 71 | - array( $this, 'menu_page_callback' ) |
|
| 71 | + array($this, 'menu_page_callback') |
|
| 72 | 72 | ); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -87,13 +87,13 @@ discard block |
||
| 87 | 87 | // For the first submenu page, slug should be same as menupage. |
| 88 | 88 | $this->subMenuPage['slug'], |
| 89 | 89 | // For the first submenu page, callback should be same as menupage. |
| 90 | - array( $this, 'menu_page_callback' ) |
|
| 90 | + array($this, 'menu_page_callback') |
|
| 91 | 91 | ); |
| 92 | 92 | if ($this->subMenuPage['help']) { |
| 93 | - add_action( 'load-' . $hook, array( $this, 'help_tabs' ) ); |
|
| 93 | + add_action('load-' . $hook, array($this, 'help_tabs')); |
|
| 94 | 94 | } |
| 95 | 95 | if ($this->subMenuPage['screen']) { |
| 96 | - add_action( 'load-' . $hook, array( $this, 'screen_option' ) ); |
|
| 96 | + add_action('load-' . $hook, array($this, 'screen_option')); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | //Set screen option |
| 104 | 104 | public function set_screen($status, $option, $value) { |
| 105 | 105 | |
| 106 | - if ( 'option_name_per_page' == $option ) return $value; // Related to PLUGIN_TABLE() |
|
| 106 | + if ('option_name_per_page' == $option) return $value; // Related to PLUGIN_TABLE() |
|
| 107 | 107 | //return $status; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | $option = 'per_page'; |
| 116 | 116 | $args = array( |
| 117 | - 'label' => __( 'Show per page', '' ), |
|
| 117 | + 'label' => __('Show per page', ''), |
|
| 118 | 118 | 'default' => 10, |
| 119 | 119 | 'option' => 'option_name_per_page' // Related to PLUGIN_TABLE() |
| 120 | 120 | ); |
| 121 | - add_screen_option( $option, $args ); |
|
| 121 | + add_screen_option($option, $args); |
|
| 122 | 122 | $this->Table = new PLUGIN_TABLE(); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | <form method="post" action=""> |
| 139 | 139 | <?php settings_fields("settings_id"); |
| 140 | 140 | do_settings_sections("settings_name"); |
| 141 | - submit_button( __( 'Save', 'textdomain' ), 'primary', 'id' ); ?> |
|
| 141 | + submit_button(__('Save', 'textdomain'), 'primary', 'id'); ?> |
|
| 142 | 142 | </form> |
| 143 | 143 | |
| 144 | 144 | <?php |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | foreach ($this->helpData as $value) { |
| 165 | 165 | if ($_GET['page'] == $value['slug']) { |
| 166 | 166 | $this->screen = get_current_screen(); |
| 167 | - foreach( $value['info'] as $key ) { |
|
| 168 | - $this->screen->add_help_tab( $key ); |
|
| 167 | + foreach ($value['info'] as $key) { |
|
| 168 | + $this->screen->add_help_tab($key); |
|
| 169 | 169 | } |
| 170 | - $this->screen->set_help_sidebar( $value['link'] ); |
|
| 170 | + $this->screen->set_help_sidebar($value['link']); |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | //Add different types of settings and corrosponding sections |
| 178 | 178 | public function add_settings() { |
| 179 | 179 | |
| 180 | - add_settings_section( 'settings_id', __( 'Section Name', 'textdomain' ), array( $this,'section_cb' ), 'settings_name' ); |
|
| 180 | + add_settings_section('settings_id', __('Section Name', 'textdomain'), array($this, 'section_cb'), 'settings_name'); |
|
| 181 | 181 | |
| 182 | - register_setting( 'settings_id', 'settings_field_name' ); |
|
| 183 | - add_settings_field( 'settings_field_name', __( 'Field Name', 'textdomain' ), array( $this, 'settings_field_cb' ), 'settings_name', 'settings_id' ); |
|
| 182 | + register_setting('settings_id', 'settings_field_name'); |
|
| 183 | + add_settings_field('settings_field_name', __('Field Name', 'textdomain'), array($this, 'settings_field_cb'), 'settings_name', 'settings_id'); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | //Section description |
| 189 | 189 | public function section_cb() { |
| 190 | 190 | |
| 191 | - echo '<p class="description">' . __( 'Set up settings', 'textdomain' ) . '</p>'; |
|
| 191 | + echo '<p class="description">' . __('Set up settings', 'textdomain') . '</p>'; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | |
@@ -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']) ); |
@@ -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 | * Main plugin object to define the plugin |
@@ -165,7 +167,9 @@ discard block |
||
| 165 | 167 | */ |
| 166 | 168 | public function scripts() { |
| 167 | 169 | |
| 168 | - if ( class_exists( 'PLUGIN_SCRIPT' ) ) new PLUGIN_SCRIPT(); |
|
| 170 | + if ( class_exists( 'PLUGIN_SCRIPT' ) ) { |
|
| 171 | + new PLUGIN_SCRIPT(); |
|
| 172 | + } |
|
| 169 | 173 | } |
| 170 | 174 | |
| 171 | 175 | |
@@ -176,7 +180,9 @@ discard block |
||
| 176 | 180 | */ |
| 177 | 181 | public function settings() { |
| 178 | 182 | |
| 179 | - if ( class_exists( 'PLUGIN_SETTINGS' ) ) new PLUGIN_SETTINGS(); |
|
| 183 | + if ( class_exists( 'PLUGIN_SETTINGS' ) ) { |
|
| 184 | + new PLUGIN_SETTINGS(); |
|
| 185 | + } |
|
| 180 | 186 | } |
| 181 | 187 | |
| 182 | 188 | |
@@ -187,7 +193,9 @@ discard block |
||
| 187 | 193 | */ |
| 188 | 194 | public function widgets() { |
| 189 | 195 | |
| 190 | - if ( class_exists( 'PLUGIN_WIDGET' ) ) new PLUGIN_WIDGET(); |
|
| 196 | + if ( class_exists( 'PLUGIN_WIDGET' ) ) { |
|
| 197 | + new PLUGIN_WIDGET(); |
|
| 198 | + } |
|
| 191 | 199 | } |
| 192 | 200 | |
| 193 | 201 | |
@@ -198,7 +206,9 @@ discard block |
||
| 198 | 206 | */ |
| 199 | 207 | public function metabox() { |
| 200 | 208 | |
| 201 | - if ( class_exists( 'PLUGIN_METABOX' ) ) new PLUGIN_METABOX(); |
|
| 209 | + if ( class_exists( 'PLUGIN_METABOX' ) ) { |
|
| 210 | + new PLUGIN_METABOX(); |
|
| 211 | + } |
|
| 202 | 212 | } |
| 203 | 213 | |
| 204 | 214 | |
@@ -209,7 +219,9 @@ discard block |
||
| 209 | 219 | */ |
| 210 | 220 | public function shortcode() { |
| 211 | 221 | |
| 212 | - if ( class_exists( 'PLUGIN_SHORTCODE' ) ) new PLUGIN_SHORTCODE(); |
|
| 222 | + if ( class_exists( 'PLUGIN_SHORTCODE' ) ) { |
|
| 223 | + new PLUGIN_SHORTCODE(); |
|
| 224 | + } |
|
| 213 | 225 | } |
| 214 | 226 | |
| 215 | 227 | |
@@ -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 | * Main plugin object to define the plugin |
| 6 | 6 | */ |
| 7 | -if ( ! class_exists( 'PLUGIN_BUILD' ) ) { |
|
| 7 | +if ( ! class_exists('PLUGIN_BUILD')) { |
|
| 8 | 8 | |
| 9 | 9 | final class PLUGIN_BUILD { |
| 10 | 10 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public static function instance() { |
| 67 | 67 | |
| 68 | - if ( is_null( self::$_instance ) ) { |
|
| 68 | + if (is_null(self::$_instance)) { |
|
| 69 | 69 | self::$_instance = new self(); |
| 70 | 70 | self::$_instance->init(); |
| 71 | 71 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function cron_activation() { |
| 101 | 101 | |
| 102 | - if ( class_exists( 'PLUGIN_CRON' ) ) { |
|
| 102 | + if (class_exists('PLUGIN_CRON')) { |
|
| 103 | 103 | |
| 104 | 104 | $cron = new PLUGIN_CRON(); |
| 105 | 105 | $schedule = $cron->schedule_task( |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function db_install() { |
| 124 | 124 | |
| 125 | - if ( class_exists( 'PLUGIN_DB' ) ) { |
|
| 125 | + if (class_exists('PLUGIN_DB')) { |
|
| 126 | 126 | |
| 127 | 127 | $db = new PLUGIN_DB(); |
| 128 | 128 | $db->table = self::$plugin_table; |
@@ -132,15 +132,15 @@ discard block |
||
| 132 | 132 | $db->build(); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if (get_option( '_plugin_db_exist') == '0' ) { |
|
| 136 | - add_action( 'admin_notices', array( $this, 'db_error_msg' ) ); |
|
| 135 | + if (get_option('_plugin_db_exist') == '0') { |
|
| 136 | + add_action('admin_notices', array($this, 'db_error_msg')); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $options = array( |
| 140 | - array( 'option_name', '__value__' ), |
|
| 140 | + array('option_name', '__value__'), |
|
| 141 | 141 | ); |
| 142 | - foreach ( $options as $value ) { |
|
| 143 | - update_option( $value[0], $value[1] ); |
|
| 142 | + foreach ($options as $value) { |
|
| 143 | + update_option($value[0], $value[1]); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | public function db_error_msg() { ?> |
| 154 | 154 | |
| 155 | 155 | <div class="notice notice-error is-dismissible"> |
| 156 | - <p><?php _e( 'Database table Not installed correctly.', 'textdomain' ); ?></p> |
|
| 156 | + <p><?php _e('Database table Not installed correctly.', 'textdomain'); ?></p> |
|
| 157 | 157 | </div> |
| 158 | 158 | <?php |
| 159 | 159 | } |
@@ -169,13 +169,13 @@ discard block |
||
| 169 | 169 | $table_name = self::$plugin_table; |
| 170 | 170 | |
| 171 | 171 | global $wpdb; |
| 172 | - $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}$table_name" ); |
|
| 172 | + $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}$table_name"); |
|
| 173 | 173 | |
| 174 | 174 | $options = array( |
| 175 | 175 | '_plugin_db_exist' |
| 176 | 176 | ); |
| 177 | - foreach ( $options as $value ) { |
|
| 178 | - delete_option( $value ); |
|
| 177 | + foreach ($options as $value) { |
|
| 178 | + delete_option($value); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function custom_cron_hook_cb() { |
| 200 | 200 | |
| 201 | - add_action( 'custom_cron_hook', array( $this, 'do_cron_job_function' ) ); |
|
| 201 | + add_action('custom_cron_hook', array($this, 'do_cron_job_function')); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | public function cron_uninstall() { |
| 211 | 211 | |
| 212 | - wp_clear_scheduled_hook( 'custom_cron_hook' ); |
|
| 212 | + wp_clear_scheduled_hook('custom_cron_hook'); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | public function scripts() { |
| 222 | 222 | |
| 223 | - if ( class_exists( 'PLUGIN_SCRIPT' ) ) new PLUGIN_SCRIPT(); |
|
| 223 | + if (class_exists('PLUGIN_SCRIPT')) new PLUGIN_SCRIPT(); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public function settings() { |
| 233 | 233 | |
| 234 | - if ( class_exists( 'PLUGIN_SETTINGS' ) ) new PLUGIN_SETTINGS(); |
|
| 234 | + if (class_exists('PLUGIN_SETTINGS')) new PLUGIN_SETTINGS(); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | public function widgets() { |
| 244 | 244 | |
| 245 | - if ( class_exists( 'PLUGIN_WIDGET' ) ) new PLUGIN_WIDGET(); |
|
| 245 | + if (class_exists('PLUGIN_WIDGET')) new PLUGIN_WIDGET(); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | public function metabox() { |
| 255 | 255 | |
| 256 | - if ( class_exists( 'PLUGIN_METABOX' ) ) new PLUGIN_METABOX(); |
|
| 256 | + if (class_exists('PLUGIN_METABOX')) new PLUGIN_METABOX(); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | public function shortcode() { |
| 266 | 266 | |
| 267 | - if ( class_exists( 'PLUGIN_SHORTCODE' ) ) new PLUGIN_SHORTCODE(); |
|
| 267 | + if (class_exists('PLUGIN_SHORTCODE')) new PLUGIN_SHORTCODE(); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | |
@@ -276,13 +276,13 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | public function functionality() { |
| 278 | 278 | |
| 279 | - require_once( 'src/install.php' ); |
|
| 280 | - require_once( 'src/db.php' ); |
|
| 281 | - require_once( 'src/query.php' ); |
|
| 282 | - require_once( 'src/settings.php' ); |
|
| 283 | - require_once( 'src/widget.php' ); |
|
| 284 | - require_once( 'src/metabox.php' ); |
|
| 285 | - require_once( 'src/shortcode.php' ); |
|
| 279 | + require_once('src/install.php'); |
|
| 280 | + require_once('src/db.php'); |
|
| 281 | + require_once('src/query.php'); |
|
| 282 | + require_once('src/settings.php'); |
|
| 283 | + require_once('src/widget.php'); |
|
| 284 | + require_once('src/metabox.php'); |
|
| 285 | + require_once('src/shortcode.php'); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | |
@@ -294,12 +294,12 @@ discard block |
||
| 294 | 294 | */ |
| 295 | 295 | public function helpers() { |
| 296 | 296 | |
| 297 | - require_once( 'lib/cron.php' ); |
|
| 298 | - require_once( 'lib/api.php' ); |
|
| 299 | - require_once( 'lib/table.php' ); |
|
| 300 | - require_once( 'lib/ajax.php' ); |
|
| 301 | - require_once( 'lib/upload.php' ); |
|
| 302 | - require_once( 'lib/script.php' ); |
|
| 297 | + require_once('lib/cron.php'); |
|
| 298 | + require_once('lib/api.php'); |
|
| 299 | + require_once('lib/table.php'); |
|
| 300 | + require_once('lib/ajax.php'); |
|
| 301 | + require_once('lib/upload.php'); |
|
| 302 | + require_once('lib/script.php'); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | |
@@ -313,16 +313,16 @@ discard block |
||
| 313 | 313 | $this->helpers(); |
| 314 | 314 | $this->functionality(); |
| 315 | 315 | |
| 316 | - register_activation_hook( PLUGIN_FILE, array( $this, 'db_install' ) ); |
|
| 317 | - register_activation_hook( PLUGIN_FILE, array($this, 'cron_activation' ) ); |
|
| 316 | + register_activation_hook(PLUGIN_FILE, array($this, 'db_install')); |
|
| 317 | + register_activation_hook(PLUGIN_FILE, array($this, 'cron_activation')); |
|
| 318 | 318 | |
| 319 | 319 | //remove the DB and CORN upon uninstallation |
| 320 | 320 | //$this won't work here. |
| 321 | - register_uninstall_hook( PLUGIN_FILE, array( 'PLUGIN_BUILD', 'db_uninstall' ) ); |
|
| 322 | - register_uninstall_hook( PLUGIN_FILE, array( 'PLUGIN_BUILD', 'cron_uninstall' ) ); |
|
| 321 | + register_uninstall_hook(PLUGIN_FILE, array('PLUGIN_BUILD', 'db_uninstall')); |
|
| 322 | + register_uninstall_hook(PLUGIN_FILE, array('PLUGIN_BUILD', 'cron_uninstall')); |
|
| 323 | 323 | |
| 324 | - add_action( 'init', array( $this, 'installation' ) ); |
|
| 325 | - add_action( 'init', array( $this, 'custom_cron_hook_cb' ) ); |
|
| 324 | + add_action('init', array($this, 'installation')); |
|
| 325 | + add_action('init', array($this, 'custom_cron_hook_cb')); |
|
| 326 | 326 | |
| 327 | 327 | $this->scripts(); |
| 328 | 328 | $this->widgets(); |
@@ -11,27 +11,27 @@ |
||
| 11 | 11 | License: GPLv2 |
| 12 | 12 | License URI: http://www.gnu.org/licenses/gpl-3.0.html |
| 13 | 13 | */ |
| 14 | -if ( !defined( 'ABSPATH' ) ) exit; |
|
| 14 | +if ( ! defined('ABSPATH')) exit; |
|
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | //Define basic names |
| 18 | 18 | //Edit the "_PLUGIN" in following namespaces for compatibility with your desired name. |
| 19 | -defined( 'PLUGIN_DEBUG' ) or define( 'PLUGIN_DEBUG', false ); |
|
| 19 | +defined('PLUGIN_DEBUG') or define('PLUGIN_DEBUG', false); |
|
| 20 | 20 | |
| 21 | -defined( 'PLUGIN_PATH' ) or define( 'PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
|
| 22 | -defined( 'PLUGIN_FILE' ) or define( 'PLUGIN_FILE', plugin_basename( __FILE__ ) ); |
|
| 21 | +defined('PLUGIN_PATH') or define('PLUGIN_PATH', plugin_dir_path(__FILE__)); |
|
| 22 | +defined('PLUGIN_FILE') or define('PLUGIN_FILE', plugin_basename(__FILE__)); |
|
| 23 | 23 | |
| 24 | -defined( 'PLUGIN_TRANSLATE' ) or define( 'PLUGIN_TRANSLATE', plugin_basename( plugin_dir_path( __FILE__ ) . 'asset/ln/' ) ); |
|
| 24 | +defined('PLUGIN_TRANSLATE') or define('PLUGIN_TRANSLATE', plugin_basename(plugin_dir_path(__FILE__) . 'asset/ln/')); |
|
| 25 | 25 | |
| 26 | -defined( 'PLUGIN_JS' ) or define( 'PLUGIN_JS', plugins_url( '/asset/js/', __FILE__ ) ); |
|
| 27 | -defined( 'PLUGIN_CSS' ) or define( 'PLUGIN_CSS', plugins_url( '/asset/css/', __FILE__ ) ); |
|
| 28 | -defined( 'PLUGIN_IMAGE' ) or define( 'PLUGIN_IMAGE', plugins_url( '/asset/img/', __FILE__ ) ); |
|
| 26 | +defined('PLUGIN_JS') or define('PLUGIN_JS', plugins_url('/asset/js/', __FILE__)); |
|
| 27 | +defined('PLUGIN_CSS') or define('PLUGIN_CSS', plugins_url('/asset/css/', __FILE__)); |
|
| 28 | +defined('PLUGIN_IMAGE') or define('PLUGIN_IMAGE', plugins_url('/asset/img/', __FILE__)); |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | //The Plugin |
| 32 | -require_once( 'autoload.php' ); |
|
| 32 | +require_once('autoload.php'); |
|
| 33 | 33 | function plugin() { |
| 34 | - if ( class_exists( 'PLUGIN_BUILD' ) ) return PLUGIN_BUILD::instance(); |
|
| 34 | + if (class_exists('PLUGIN_BUILD')) return PLUGIN_BUILD::instance(); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | global $plugin; |
@@ -11,7 +11,9 @@ discard block |
||
| 11 | 11 | License: GPLv2 |
| 12 | 12 | License URI: http://www.gnu.org/licenses/gpl-3.0.html |
| 13 | 13 | */ |
| 14 | -if ( !defined( 'ABSPATH' ) ) exit; |
|
| 14 | +if ( !defined( 'ABSPATH' ) ) { |
|
| 15 | + exit; |
|
| 16 | +} |
|
| 15 | 17 | |
| 16 | 18 | |
| 17 | 19 | //Define basic names |
@@ -31,8 +33,10 @@ discard block |
||
| 31 | 33 | //The Plugin |
| 32 | 34 | require_once( 'autoload.php' ); |
| 33 | 35 | function plugin() { |
| 34 | - if ( class_exists( 'PLUGIN_BUILD' ) ) return PLUGIN_BUILD::instance(); |
|
| 35 | -} |
|
| 36 | + if ( class_exists( 'PLUGIN_BUILD' ) ) { |
|
| 37 | + return PLUGIN_BUILD::instance(); |
|
| 38 | + } |
|
| 39 | + } |
|
| 36 | 40 | |
| 37 | 41 | global $plugin; |
| 38 | 42 | $plugin = plugin(); ?> |