@@ -11,7 +11,7 @@ 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')) exit; |
|
15 | 15 | |
16 | 16 | |
17 | 17 | //Define basic names |
@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | defined('PLUGIN_PATH') or define('PLUGIN_PATH', plugin_dir_path(__FILE__)); |
22 | 22 | defined('PLUGIN_FILE') or define('PLUGIN_FILE', plugin_basename(__FILE__)); |
23 | 23 | |
24 | -defined('PLUGIN_EXECUTE') or define('PLUGIN_EXECUTE', plugin_dir_path(__FILE__).'src/'); |
|
25 | -defined('PLUGIN_HELPER') or define('PLUGIN_HELPER', plugin_dir_path(__FILE__).'helper/'); |
|
26 | -defined('PLUGIN_TRANSLATE') or define('PLUGIN_TRANSLATE', plugin_basename( plugin_dir_path(__FILE__).'asset/ln/')); |
|
24 | +defined('PLUGIN_EXECUTE') or define('PLUGIN_EXECUTE', plugin_dir_path(__FILE__) . 'src/'); |
|
25 | +defined('PLUGIN_HELPER') or define('PLUGIN_HELPER', plugin_dir_path(__FILE__) . 'helper/'); |
|
26 | +defined('PLUGIN_TRANSLATE') or define('PLUGIN_TRANSLATE', plugin_basename(plugin_dir_path(__FILE__) . 'asset/ln/')); |
|
27 | 27 | |
28 | 28 | //change /wp-plugin-framework/ with your /plugin-name/ |
29 | 29 | $plugin_file_parts = explode('/', PLUGIN_FILE); |
30 | -defined('PLUGIN_JS') or define('PLUGIN_JS', plugins_url().'/' . $plugin_file_parts[0] . '/asset/js/'); |
|
31 | -defined('PLUGIN_CSS') or define('PLUGIN_CSS', plugins_url().'/' . $plugin_file_parts[0] . '/asset/css/'); |
|
32 | -defined('PLUGIN_IMAGE') or define('PLUGIN_IMAGE', plugins_url().'/' . $plugin_file_parts[0] . '/asset/img/'); |
|
30 | +defined('PLUGIN_JS') or define('PLUGIN_JS', plugins_url() . '/' . $plugin_file_parts[0] . '/asset/js/'); |
|
31 | +defined('PLUGIN_CSS') or define('PLUGIN_CSS', plugins_url() . '/' . $plugin_file_parts[0] . '/asset/css/'); |
|
32 | +defined('PLUGIN_IMAGE') or define('PLUGIN_IMAGE', plugins_url() . '/' . $plugin_file_parts[0] . '/asset/img/'); |
|
33 | 33 | |
34 | 34 | |
35 | 35 | //The Plugin |
36 | 36 | require_once('autoload.php'); |
37 | -if ( class_exists( 'PLUGIN_BUILD' ) ) new PLUGIN_BUILD(); ?> |
|
37 | +if (class_exists('PLUGIN_BUILD')) new PLUGIN_BUILD(); ?> |
@@ -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 |
@@ -34,4 +36,7 @@ discard block |
||
34 | 36 | |
35 | 37 | //The Plugin |
36 | 38 | require_once('autoload.php'); |
37 | -if ( class_exists( 'PLUGIN_BUILD' ) ) new PLUGIN_BUILD(); ?> |
|
39 | +if ( class_exists( 'PLUGIN_BUILD' ) ) { |
|
40 | + new PLUGIN_BUILD(); |
|
41 | +} |
|
42 | +?> |
@@ -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 | * 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 . 'textdomain-' . $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; |