@@ -71,7 +71,7 @@ |
||
71 | 71 | */ |
72 | 72 | public function scopeType(Builder $builder, $type) |
73 | 73 | { |
74 | - self::$type_scope = $type; |
|
74 | + self::$type_scope = $type; |
|
75 | 75 | return $builder->where('post_type', '=', $type); |
76 | 76 | } |
77 | 77 |
@@ -45,7 +45,7 @@ |
||
45 | 45 | // static::addGlobalScope(new PostTypeScope); |
46 | 46 | // static::addGlobalScope(new PostStatusScope); |
47 | 47 | // static::addGlobalScope(new PostAuthorScope); |
48 | - static::addGlobalScope('type', function (Builder $builder) { |
|
48 | + static::addGlobalScope('type', function(Builder $builder) { |
|
49 | 49 | $builder->where('post_type', '=', static::$type_scope); |
50 | 50 | }); |
51 | 51 | // static::addGlobalScope('scope', function (Builder $builder) { |
@@ -31,7 +31,7 @@ |
||
31 | 31 | !Schema::hasTable('oauth_clients') || |
32 | 32 | !Schema::hasTable('oauth_auth_codes') |
33 | 33 | ) { |
34 | - throw new \Exception("Please install OAuth2 Server Plugin (plugin link) or Implement OAuth2 Server from this link (https://github.com/Codexshaper/oauth2)", 1); |
|
34 | + throw new \Exception("Please install OAuth2 Server Plugin (plugin link) or Implement OAuth2 Server from this link (https://github.com/Codexshaper/oauth2)", 1); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $manager = new Manager; |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function handle(Request $request, Closure $next, ...$guards) |
24 | 24 | { |
25 | - foreach($guards as $guard) { |
|
26 | - if($guard == 'api') { |
|
27 | - if( |
|
25 | + foreach ($guards as $guard) { |
|
26 | + if ($guard == 'api') { |
|
27 | + if ( |
|
28 | 28 | !Schema::hasTable('oauth_access_tokens') || |
29 | 29 | !Schema::hasTable('oauth_refresh_tokens') || |
30 | 30 | !Schema::hasTable('oauth_personal_access_clients') || |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | $manager = new Manager; |
38 | 38 | $resourceServer = $manager->getResourceServer(); |
39 | - $psrRequest = ServerRequest::getPsrServerRequest(); |
|
39 | + $psrRequest = ServerRequest::getPsrServerRequest(); |
|
40 | 40 | |
41 | 41 | try { |
42 | 42 | $psr = $resourceServer->validateAuthenticatedRequest($psrRequest); |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | if ($user_id) { |
46 | 46 | $user = User::find($user_id); |
47 | 47 | |
48 | - $request->merge(['user' => $user ]); |
|
49 | - $request->merge(['scopes' => $psr->getAttribute('oauth_scopes') ]); |
|
48 | + $request->merge(['user' => $user]); |
|
49 | + $request->merge(['scopes' => $psr->getAttribute('oauth_scopes')]); |
|
50 | 50 | |
51 | - $request->setUserResolver(function () use ($user) { |
|
51 | + $request->setUserResolver(function() use ($user) { |
|
52 | 52 | return $user; |
53 | 53 | }); |
54 | 54 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | - if(\is_user_logged_in()) { |
|
67 | + if (\is_user_logged_in()) { |
|
68 | 68 | return $next($request); |
69 | 69 | } |
70 | 70 |
@@ -19,9 +19,9 @@ |
||
19 | 19 | $token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN'); |
20 | 20 | $action = $request->wpb_nonce ?: 'wpb_nonce'; |
21 | 21 | |
22 | - if ( !wp_verify_nonce( $token, $action ) ) { |
|
22 | + if (!wp_verify_nonce($token, $action)) { |
|
23 | 23 | if ($request->ajax()) { |
24 | - return wp_send_json(["message" => "CSRF Token mitchmatch"], 403 ); |
|
24 | + return wp_send_json(["message" => "CSRF Token mitchmatch"], 403); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | throw new \Exception("CSRF Token mismatch"); |
@@ -23,8 +23,8 @@ |
||
23 | 23 | public function handle(Request $request, Closure $next, ...$scopes) |
24 | 24 | { |
25 | 25 | foreach ($scopes as $scope) { |
26 | - if (! in_array($scope, $request->scopes)) { |
|
27 | - wp_send_json( ["msg" => "You don't have enough permission"], 400 ); |
|
26 | + if (!in_array($scope, $request->scopes)) { |
|
27 | + wp_send_json(["msg" => "You don't have enough permission"], 400); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 |
@@ -6,32 +6,32 @@ |
||
6 | 6 | |
7 | 7 | class User extends Model |
8 | 8 | { |
9 | - protected $primaryKey = 'ID'; |
|
9 | + protected $primaryKey = 'ID'; |
|
10 | 10 | |
11 | - /** |
|
12 | - * The attributes that are mass assignable. |
|
13 | - * |
|
14 | - * @var array |
|
15 | - */ |
|
16 | - protected $fillable = [ |
|
17 | - 'name', 'email', 'password', |
|
18 | - ]; |
|
11 | + /** |
|
12 | + * The attributes that are mass assignable. |
|
13 | + * |
|
14 | + * @var array |
|
15 | + */ |
|
16 | + protected $fillable = [ |
|
17 | + 'name', 'email', 'password', |
|
18 | + ]; |
|
19 | 19 | |
20 | - /** |
|
21 | - * The attributes that should be hidden for arrays. |
|
22 | - * |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - protected $hidden = [ |
|
26 | - 'password', 'remember_token', |
|
27 | - ]; |
|
20 | + /** |
|
21 | + * The attributes that should be hidden for arrays. |
|
22 | + * |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + protected $hidden = [ |
|
26 | + 'password', 'remember_token', |
|
27 | + ]; |
|
28 | 28 | |
29 | - /** |
|
30 | - * The attributes that should be cast to native types. |
|
31 | - * |
|
32 | - * @var array |
|
33 | - */ |
|
34 | - protected $casts = [ |
|
35 | - 'email_verified_at' => 'datetime', |
|
36 | - ]; |
|
29 | + /** |
|
30 | + * The attributes that should be cast to native types. |
|
31 | + * |
|
32 | + * @var array |
|
33 | + */ |
|
34 | + protected $casts = [ |
|
35 | + 'email_verified_at' => 'datetime', |
|
36 | + ]; |
|
37 | 37 | } |
38 | 38 | \ No newline at end of file |
@@ -2,37 +2,37 @@ |
||
2 | 2 | |
3 | 3 | class Install_Composer |
4 | 4 | { |
5 | - public function __construct() |
|
6 | - { |
|
7 | - if (! file_exists(__DIR__.'/vendor/autoload.php')) { |
|
5 | + public function __construct() |
|
6 | + { |
|
7 | + if (! file_exists(__DIR__.'/vendor/autoload.php')) { |
|
8 | 8 | |
9 | - require_once __DIR__.'/install/vendor/autoload.php'; |
|
9 | + require_once __DIR__.'/install/vendor/autoload.php'; |
|
10 | 10 | |
11 | - if(file_exists(__DIR__ . '/install/vendor/bin/composer')) { |
|
12 | - echo "composer file exists"; |
|
13 | - } |
|
11 | + if(file_exists(__DIR__ . '/install/vendor/bin/composer')) { |
|
12 | + echo "composer file exists"; |
|
13 | + } |
|
14 | 14 | |
15 | - // Composer\Factory::getHomeDir() method |
|
16 | - // needs COMPOSER_HOME environment variable set |
|
17 | - putenv('COMPOSER_HOME=' . __DIR__ . '/install/vendor/bin/composer'); |
|
15 | + // Composer\Factory::getHomeDir() method |
|
16 | + // needs COMPOSER_HOME environment variable set |
|
17 | + putenv('COMPOSER_HOME=' . __DIR__ . '/install/vendor/bin/composer'); |
|
18 | 18 | |
19 | - // call `composer install` command programmatically |
|
20 | - // if (file_exists(getcwd().'/composer.phar')) { |
|
21 | - // $composer = '"'.PHP_BINARY.'" '.getcwd().'/composer.phar'; |
|
22 | - // } |
|
19 | + // call `composer install` command programmatically |
|
20 | + // if (file_exists(getcwd().'/composer.phar')) { |
|
21 | + // $composer = '"'.PHP_BINARY.'" '.getcwd().'/composer.phar'; |
|
22 | + // } |
|
23 | 23 | |
24 | - $composer = 'composer'; |
|
24 | + $composer = 'composer'; |
|
25 | 25 | |
26 | - try { |
|
27 | - $process = \Symfony\Component\Process\Process::fromShellCommandline($composer.' install'); |
|
28 | - $process->setEnv([ |
|
29 | - 'COMPOSER_HOME' => __DIR__ . '/install/vendor/bin/composer', |
|
30 | - ]); |
|
31 | - $process->setTimeout(null); // Setting timeout to null to prevent installation from stopping at a certain point in time |
|
32 | - $process->setWorkingDirectory(__DIR__)->mustRun(); |
|
33 | - } catch (\Exception $ex) { |
|
34 | - echo $ex->getMessage(); |
|
35 | - } |
|
36 | - } |
|
37 | - } |
|
26 | + try { |
|
27 | + $process = \Symfony\Component\Process\Process::fromShellCommandline($composer.' install'); |
|
28 | + $process->setEnv([ |
|
29 | + 'COMPOSER_HOME' => __DIR__ . '/install/vendor/bin/composer', |
|
30 | + ]); |
|
31 | + $process->setTimeout(null); // Setting timeout to null to prevent installation from stopping at a certain point in time |
|
32 | + $process->setWorkingDirectory(__DIR__)->mustRun(); |
|
33 | + } catch (\Exception $ex) { |
|
34 | + echo $ex->getMessage(); |
|
35 | + } |
|
36 | + } |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -4,17 +4,17 @@ discard block |
||
4 | 4 | { |
5 | 5 | public function __construct() |
6 | 6 | { |
7 | - if (! file_exists(__DIR__.'/vendor/autoload.php')) { |
|
7 | + if (!file_exists(__DIR__.'/vendor/autoload.php')) { |
|
8 | 8 | |
9 | 9 | require_once __DIR__.'/install/vendor/autoload.php'; |
10 | 10 | |
11 | - if(file_exists(__DIR__ . '/install/vendor/bin/composer')) { |
|
11 | + if (file_exists(__DIR__.'/install/vendor/bin/composer')) { |
|
12 | 12 | echo "composer file exists"; |
13 | 13 | } |
14 | 14 | |
15 | 15 | // Composer\Factory::getHomeDir() method |
16 | 16 | // needs COMPOSER_HOME environment variable set |
17 | - putenv('COMPOSER_HOME=' . __DIR__ . '/install/vendor/bin/composer'); |
|
17 | + putenv('COMPOSER_HOME='.__DIR__.'/install/vendor/bin/composer'); |
|
18 | 18 | |
19 | 19 | // call `composer install` command programmatically |
20 | 20 | // if (file_exists(getcwd().'/composer.phar')) { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | try { |
27 | 27 | $process = \Symfony\Component\Process\Process::fromShellCommandline($composer.' install'); |
28 | 28 | $process->setEnv([ |
29 | - 'COMPOSER_HOME' => __DIR__ . '/install/vendor/bin/composer', |
|
29 | + 'COMPOSER_HOME' => __DIR__.'/install/vendor/bin/composer', |
|
30 | 30 | ]); |
31 | 31 | $process->setTimeout(null); // Setting timeout to null to prevent installation from stopping at a certain point in time |
32 | 32 | $process->setWorkingDirectory(__DIR__)->mustRun(); |
@@ -21,82 +21,82 @@ |
||
21 | 21 | */ |
22 | 22 | class WPB_Admin { |
23 | 23 | |
24 | - /** |
|
25 | - * The ID of this plugin. |
|
26 | - * |
|
27 | - * @since 1.0.0 |
|
28 | - * @access private |
|
29 | - * @var string $plugin_name The ID of this plugin. |
|
30 | - */ |
|
31 | - private $plugin_name; |
|
24 | + /** |
|
25 | + * The ID of this plugin. |
|
26 | + * |
|
27 | + * @since 1.0.0 |
|
28 | + * @access private |
|
29 | + * @var string $plugin_name The ID of this plugin. |
|
30 | + */ |
|
31 | + private $plugin_name; |
|
32 | 32 | |
33 | - /** |
|
34 | - * The version of this plugin. |
|
35 | - * |
|
36 | - * @since 1.0.0 |
|
37 | - * @access private |
|
38 | - * @var string $version The current version of this plugin. |
|
39 | - */ |
|
40 | - private $version; |
|
33 | + /** |
|
34 | + * The version of this plugin. |
|
35 | + * |
|
36 | + * @since 1.0.0 |
|
37 | + * @access private |
|
38 | + * @var string $version The current version of this plugin. |
|
39 | + */ |
|
40 | + private $version; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Initialize the class and set its properties. |
|
44 | - * |
|
45 | - * @since 1.0.0 |
|
46 | - * @param string $plugin_name The name of this plugin. |
|
47 | - * @param string $version The version of this plugin. |
|
48 | - */ |
|
49 | - public function __construct( $plugin_name, $version ) { |
|
42 | + /** |
|
43 | + * Initialize the class and set its properties. |
|
44 | + * |
|
45 | + * @since 1.0.0 |
|
46 | + * @param string $plugin_name The name of this plugin. |
|
47 | + * @param string $version The version of this plugin. |
|
48 | + */ |
|
49 | + public function __construct( $plugin_name, $version ) { |
|
50 | 50 | |
51 | - $this->plugin_name = $plugin_name; |
|
52 | - $this->version = $version; |
|
51 | + $this->plugin_name = $plugin_name; |
|
52 | + $this->version = $version; |
|
53 | 53 | |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Register the stylesheets for the admin area. |
|
58 | - * |
|
59 | - * @since 1.0.0 |
|
60 | - */ |
|
61 | - public function enqueue_styles() { |
|
56 | + /** |
|
57 | + * Register the stylesheets for the admin area. |
|
58 | + * |
|
59 | + * @since 1.0.0 |
|
60 | + */ |
|
61 | + public function enqueue_styles() { |
|
62 | 62 | |
63 | - /** |
|
64 | - * This function is provided for demonstration purposes only. |
|
65 | - * |
|
66 | - * An instance of this class should be passed to the run() function |
|
67 | - * defined in WPB_Loader as all of the hooks are defined |
|
68 | - * in that particular class. |
|
69 | - * |
|
70 | - * The WPB_Loader will then create the relationship |
|
71 | - * between the defined hooks and the functions defined in this |
|
72 | - * class. |
|
73 | - */ |
|
63 | + /** |
|
64 | + * This function is provided for demonstration purposes only. |
|
65 | + * |
|
66 | + * An instance of this class should be passed to the run() function |
|
67 | + * defined in WPB_Loader as all of the hooks are defined |
|
68 | + * in that particular class. |
|
69 | + * |
|
70 | + * The WPB_Loader will then create the relationship |
|
71 | + * between the defined hooks and the functions defined in this |
|
72 | + * class. |
|
73 | + */ |
|
74 | 74 | |
75 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpb-admin.css', array(), $this->version, 'all' ); |
|
75 | + wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpb-admin.css', array(), $this->version, 'all' ); |
|
76 | 76 | |
77 | - } |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Register the JavaScript for the admin area. |
|
81 | - * |
|
82 | - * @since 1.0.0 |
|
83 | - */ |
|
84 | - public function enqueue_scripts() { |
|
79 | + /** |
|
80 | + * Register the JavaScript for the admin area. |
|
81 | + * |
|
82 | + * @since 1.0.0 |
|
83 | + */ |
|
84 | + public function enqueue_scripts() { |
|
85 | 85 | |
86 | - /** |
|
87 | - * This function is provided for demonstration purposes only. |
|
88 | - * |
|
89 | - * An instance of this class should be passed to the run() function |
|
90 | - * defined in WPB_Loader as all of the hooks are defined |
|
91 | - * in that particular class. |
|
92 | - * |
|
93 | - * The WPB_Loader will then create the relationship |
|
94 | - * between the defined hooks and the functions defined in this |
|
95 | - * class. |
|
96 | - */ |
|
86 | + /** |
|
87 | + * This function is provided for demonstration purposes only. |
|
88 | + * |
|
89 | + * An instance of this class should be passed to the run() function |
|
90 | + * defined in WPB_Loader as all of the hooks are defined |
|
91 | + * in that particular class. |
|
92 | + * |
|
93 | + * The WPB_Loader will then create the relationship |
|
94 | + * between the defined hooks and the functions defined in this |
|
95 | + * class. |
|
96 | + */ |
|
97 | 97 | |
98 | - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wpb-admin.js', array( 'jquery' ), $this->version, false ); |
|
98 | + wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wpb-admin.js', array( 'jquery' ), $this->version, false ); |
|
99 | 99 | |
100 | - } |
|
100 | + } |
|
101 | 101 | |
102 | 102 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param string $plugin_name The name of this plugin. |
47 | 47 | * @param string $version The version of this plugin. |
48 | 48 | */ |
49 | - public function __construct( $plugin_name, $version ) { |
|
49 | + public function __construct($plugin_name, $version) { |
|
50 | 50 | |
51 | 51 | $this->plugin_name = $plugin_name; |
52 | 52 | $this->version = $version; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * class. |
73 | 73 | */ |
74 | 74 | |
75 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpb-admin.css', array(), $this->version, 'all' ); |
|
75 | + wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/wpb-admin.css', array(), $this->version, 'all'); |
|
76 | 76 | |
77 | 77 | } |
78 | 78 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * class. |
96 | 96 | */ |
97 | 97 | |
98 | - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wpb-admin.js', array( 'jquery' ), $this->version, false ); |
|
98 | + wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/wpb-admin.js', array('jquery'), $this->version, false); |
|
99 | 99 | |
100 | 100 | } |
101 | 101 |
@@ -22,142 +22,142 @@ |
||
22 | 22 | */ |
23 | 23 | class WPB_Admin_SubMenu { |
24 | 24 | |
25 | - /** |
|
26 | - * The menu page title. |
|
27 | - * |
|
28 | - * @since 1.0.0 |
|
29 | - * @access protected |
|
30 | - * @var string $page_title The string used to set menu page title. |
|
31 | - */ |
|
32 | - public $page_title; |
|
33 | - |
|
34 | - /** |
|
35 | - * The menu title. |
|
36 | - * |
|
37 | - * @since 1.0.0 |
|
38 | - * @access protected |
|
39 | - * @var string $menu_title The string used to set menu title. |
|
40 | - */ |
|
41 | - public $menu_title; |
|
42 | - |
|
43 | - /** |
|
44 | - * The menu capability. |
|
45 | - * |
|
46 | - * @since 1.0.0 |
|
47 | - * @access protected |
|
48 | - * @var string $capability The string used to set menu capability. |
|
49 | - */ |
|
50 | - public $capability; |
|
51 | - |
|
52 | - /** |
|
53 | - * The menu slug. |
|
54 | - * |
|
55 | - * @since 1.0.0 |
|
56 | - * @access protected |
|
57 | - * @var string $slug The string used to set menu slug. |
|
58 | - */ |
|
59 | - public $slug; |
|
60 | - |
|
61 | - /** |
|
62 | - * The callback to render content. |
|
63 | - * |
|
64 | - * @since 1.0.0 |
|
65 | - * @access protected |
|
66 | - * @var callback $callback The callback used to render content. |
|
67 | - */ |
|
68 | - public $callback; |
|
69 | - |
|
70 | - /** |
|
71 | - * The menu icon. |
|
72 | - * |
|
73 | - * @since 1.0.0 |
|
74 | - * @access protected |
|
75 | - * @var string $icon The string used to set menu icon. |
|
76 | - */ |
|
77 | - public $icon; |
|
78 | - |
|
79 | - /** |
|
80 | - * The menu position. |
|
81 | - * |
|
82 | - * @since 1.0.0 |
|
83 | - * @access protected |
|
84 | - * @var int $position The string used to set menu position. |
|
85 | - */ |
|
86 | - public $position; |
|
87 | - |
|
88 | - /** |
|
89 | - * The menu plugin name. |
|
90 | - * |
|
91 | - * @since 1.0.0 |
|
92 | - * @access protected |
|
93 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
94 | - */ |
|
95 | - public $plugin_name; |
|
96 | - |
|
97 | - /** |
|
98 | - * Create a new menu page. |
|
99 | - * |
|
100 | - * @since 1.0.0 |
|
101 | - * @access public |
|
102 | - */ |
|
103 | - public function save() { |
|
104 | - add_action( 'admin_menu', array( $this, 'create_submenu' ) ); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Create a new submenu page. |
|
109 | - * |
|
110 | - * @since 1.0.0 |
|
111 | - * @param array $options Pass proprties as an array. |
|
112 | - * @access public |
|
113 | - */ |
|
114 | - public function make( $options = array() ) { |
|
115 | - foreach ( $options as $property => $value ) { |
|
116 | - if ( property_exists( $this, $property ) ) { |
|
117 | - $this->{$property} = $value; |
|
118 | - } |
|
119 | - } |
|
120 | - add_action( 'admin_menu', array( $this, 'create_submenu' ) ); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Register new submenu page. |
|
125 | - * |
|
126 | - * @return void |
|
127 | - */ |
|
128 | - public function create_submenu() { |
|
129 | - if ( current_user_can( $this->capability ) ) { |
|
130 | - $hook = add_submenu_page( |
|
131 | - $this->parent_slug, |
|
132 | - $this->page_title, |
|
133 | - $this->menu_title, |
|
134 | - $this->capability, |
|
135 | - $this->slug, |
|
136 | - $this->callback, |
|
137 | - $this->icon |
|
138 | - ); |
|
139 | - } |
|
140 | - |
|
141 | - add_action( 'load-' . $hook, array( $this, 'init_hooks' ) ); |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * Initialize hooks for the admin page. |
|
146 | - * |
|
147 | - * @return void |
|
148 | - */ |
|
149 | - public function init_hooks() { |
|
150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * Load scripts and styles for the submenu page. |
|
155 | - * |
|
156 | - * @return void |
|
157 | - */ |
|
158 | - public function enqueue_scripts() { |
|
159 | - wp_enqueue_style( $this->plugin_name . '-vendors' ); |
|
160 | - wp_enqueue_style( $this->plugin_name . '-admin' ); |
|
161 | - wp_enqueue_script( $this->plugin_name . '-admin' ); |
|
162 | - } |
|
25 | + /** |
|
26 | + * The menu page title. |
|
27 | + * |
|
28 | + * @since 1.0.0 |
|
29 | + * @access protected |
|
30 | + * @var string $page_title The string used to set menu page title. |
|
31 | + */ |
|
32 | + public $page_title; |
|
33 | + |
|
34 | + /** |
|
35 | + * The menu title. |
|
36 | + * |
|
37 | + * @since 1.0.0 |
|
38 | + * @access protected |
|
39 | + * @var string $menu_title The string used to set menu title. |
|
40 | + */ |
|
41 | + public $menu_title; |
|
42 | + |
|
43 | + /** |
|
44 | + * The menu capability. |
|
45 | + * |
|
46 | + * @since 1.0.0 |
|
47 | + * @access protected |
|
48 | + * @var string $capability The string used to set menu capability. |
|
49 | + */ |
|
50 | + public $capability; |
|
51 | + |
|
52 | + /** |
|
53 | + * The menu slug. |
|
54 | + * |
|
55 | + * @since 1.0.0 |
|
56 | + * @access protected |
|
57 | + * @var string $slug The string used to set menu slug. |
|
58 | + */ |
|
59 | + public $slug; |
|
60 | + |
|
61 | + /** |
|
62 | + * The callback to render content. |
|
63 | + * |
|
64 | + * @since 1.0.0 |
|
65 | + * @access protected |
|
66 | + * @var callback $callback The callback used to render content. |
|
67 | + */ |
|
68 | + public $callback; |
|
69 | + |
|
70 | + /** |
|
71 | + * The menu icon. |
|
72 | + * |
|
73 | + * @since 1.0.0 |
|
74 | + * @access protected |
|
75 | + * @var string $icon The string used to set menu icon. |
|
76 | + */ |
|
77 | + public $icon; |
|
78 | + |
|
79 | + /** |
|
80 | + * The menu position. |
|
81 | + * |
|
82 | + * @since 1.0.0 |
|
83 | + * @access protected |
|
84 | + * @var int $position The string used to set menu position. |
|
85 | + */ |
|
86 | + public $position; |
|
87 | + |
|
88 | + /** |
|
89 | + * The menu plugin name. |
|
90 | + * |
|
91 | + * @since 1.0.0 |
|
92 | + * @access protected |
|
93 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
94 | + */ |
|
95 | + public $plugin_name; |
|
96 | + |
|
97 | + /** |
|
98 | + * Create a new menu page. |
|
99 | + * |
|
100 | + * @since 1.0.0 |
|
101 | + * @access public |
|
102 | + */ |
|
103 | + public function save() { |
|
104 | + add_action( 'admin_menu', array( $this, 'create_submenu' ) ); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Create a new submenu page. |
|
109 | + * |
|
110 | + * @since 1.0.0 |
|
111 | + * @param array $options Pass proprties as an array. |
|
112 | + * @access public |
|
113 | + */ |
|
114 | + public function make( $options = array() ) { |
|
115 | + foreach ( $options as $property => $value ) { |
|
116 | + if ( property_exists( $this, $property ) ) { |
|
117 | + $this->{$property} = $value; |
|
118 | + } |
|
119 | + } |
|
120 | + add_action( 'admin_menu', array( $this, 'create_submenu' ) ); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Register new submenu page. |
|
125 | + * |
|
126 | + * @return void |
|
127 | + */ |
|
128 | + public function create_submenu() { |
|
129 | + if ( current_user_can( $this->capability ) ) { |
|
130 | + $hook = add_submenu_page( |
|
131 | + $this->parent_slug, |
|
132 | + $this->page_title, |
|
133 | + $this->menu_title, |
|
134 | + $this->capability, |
|
135 | + $this->slug, |
|
136 | + $this->callback, |
|
137 | + $this->icon |
|
138 | + ); |
|
139 | + } |
|
140 | + |
|
141 | + add_action( 'load-' . $hook, array( $this, 'init_hooks' ) ); |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * Initialize hooks for the admin page. |
|
146 | + * |
|
147 | + * @return void |
|
148 | + */ |
|
149 | + public function init_hooks() { |
|
150 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * Load scripts and styles for the submenu page. |
|
155 | + * |
|
156 | + * @return void |
|
157 | + */ |
|
158 | + public function enqueue_scripts() { |
|
159 | + wp_enqueue_style( $this->plugin_name . '-vendors' ); |
|
160 | + wp_enqueue_style( $this->plugin_name . '-admin' ); |
|
161 | + wp_enqueue_script( $this->plugin_name . '-admin' ); |
|
162 | + } |
|
163 | 163 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @access public |
102 | 102 | */ |
103 | 103 | public function save() { |
104 | - add_action( 'admin_menu', array( $this, 'create_submenu' ) ); |
|
104 | + add_action('admin_menu', array($this, 'create_submenu')); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | * @param array $options Pass proprties as an array. |
112 | 112 | * @access public |
113 | 113 | */ |
114 | - public function make( $options = array() ) { |
|
115 | - foreach ( $options as $property => $value ) { |
|
116 | - if ( property_exists( $this, $property ) ) { |
|
114 | + public function make($options = array()) { |
|
115 | + foreach ($options as $property => $value) { |
|
116 | + if (property_exists($this, $property)) { |
|
117 | 117 | $this->{$property} = $value; |
118 | 118 | } |
119 | 119 | } |
120 | - add_action( 'admin_menu', array( $this, 'create_submenu' ) ); |
|
120 | + add_action('admin_menu', array($this, 'create_submenu')); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return void |
127 | 127 | */ |
128 | 128 | public function create_submenu() { |
129 | - if ( current_user_can( $this->capability ) ) { |
|
129 | + if (current_user_can($this->capability)) { |
|
130 | 130 | $hook = add_submenu_page( |
131 | 131 | $this->parent_slug, |
132 | 132 | $this->page_title, |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | ); |
139 | 139 | } |
140 | 140 | |
141 | - add_action( 'load-' . $hook, array( $this, 'init_hooks' ) ); |
|
141 | + add_action('load-'.$hook, array($this, 'init_hooks')); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @return void |
148 | 148 | */ |
149 | 149 | public function init_hooks() { |
150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
150 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * @return void |
157 | 157 | */ |
158 | 158 | public function enqueue_scripts() { |
159 | - wp_enqueue_style( $this->plugin_name . '-vendors' ); |
|
160 | - wp_enqueue_style( $this->plugin_name . '-admin' ); |
|
161 | - wp_enqueue_script( $this->plugin_name . '-admin' ); |
|
159 | + wp_enqueue_style($this->plugin_name.'-vendors'); |
|
160 | + wp_enqueue_style($this->plugin_name.'-admin'); |
|
161 | + wp_enqueue_script($this->plugin_name.'-admin'); |
|
162 | 162 | } |
163 | 163 | } |
@@ -21,139 +21,139 @@ |
||
21 | 21 | */ |
22 | 22 | class WPB_Admin_Menu { |
23 | 23 | |
24 | - /** |
|
25 | - * The menu page title. |
|
26 | - * |
|
27 | - * @since 1.0.0 |
|
28 | - * @access protected |
|
29 | - * @var string $page_title The string used to set menu page title. |
|
30 | - */ |
|
31 | - public $page_title; |
|
24 | + /** |
|
25 | + * The menu page title. |
|
26 | + * |
|
27 | + * @since 1.0.0 |
|
28 | + * @access protected |
|
29 | + * @var string $page_title The string used to set menu page title. |
|
30 | + */ |
|
31 | + public $page_title; |
|
32 | 32 | |
33 | - /** |
|
34 | - * The menu title. |
|
35 | - * |
|
36 | - * @since 1.0.0 |
|
37 | - * @access protected |
|
38 | - * @var string $menu_title The string used to set menu title. |
|
39 | - */ |
|
40 | - public $menu_title; |
|
33 | + /** |
|
34 | + * The menu title. |
|
35 | + * |
|
36 | + * @since 1.0.0 |
|
37 | + * @access protected |
|
38 | + * @var string $menu_title The string used to set menu title. |
|
39 | + */ |
|
40 | + public $menu_title; |
|
41 | 41 | |
42 | - /** |
|
43 | - * The menu capability. |
|
44 | - * |
|
45 | - * @since 1.0.0 |
|
46 | - * @access protected |
|
47 | - * @var string $capability The string used to set menu capability. |
|
48 | - */ |
|
49 | - public $capability; |
|
42 | + /** |
|
43 | + * The menu capability. |
|
44 | + * |
|
45 | + * @since 1.0.0 |
|
46 | + * @access protected |
|
47 | + * @var string $capability The string used to set menu capability. |
|
48 | + */ |
|
49 | + public $capability; |
|
50 | 50 | |
51 | - /** |
|
52 | - * The menu slug. |
|
53 | - * |
|
54 | - * @since 1.0.0 |
|
55 | - * @access protected |
|
56 | - * @var string $slug The string used to set menu slug. |
|
57 | - */ |
|
58 | - public $slug; |
|
51 | + /** |
|
52 | + * The menu slug. |
|
53 | + * |
|
54 | + * @since 1.0.0 |
|
55 | + * @access protected |
|
56 | + * @var string $slug The string used to set menu slug. |
|
57 | + */ |
|
58 | + public $slug; |
|
59 | 59 | |
60 | - /** |
|
61 | - * The callback to render content. |
|
62 | - * |
|
63 | - * @since 1.0.0 |
|
64 | - * @access protected |
|
65 | - * @var callback $callback The callback used to render content. |
|
66 | - */ |
|
67 | - public $callback; |
|
60 | + /** |
|
61 | + * The callback to render content. |
|
62 | + * |
|
63 | + * @since 1.0.0 |
|
64 | + * @access protected |
|
65 | + * @var callback $callback The callback used to render content. |
|
66 | + */ |
|
67 | + public $callback; |
|
68 | 68 | |
69 | - /** |
|
70 | - * The menu icon. |
|
71 | - * |
|
72 | - * @since 1.0.0 |
|
73 | - * @access protected |
|
74 | - * @var string $icon The string used to set menu icon. |
|
75 | - */ |
|
76 | - public $icon; |
|
69 | + /** |
|
70 | + * The menu icon. |
|
71 | + * |
|
72 | + * @since 1.0.0 |
|
73 | + * @access protected |
|
74 | + * @var string $icon The string used to set menu icon. |
|
75 | + */ |
|
76 | + public $icon; |
|
77 | 77 | |
78 | - /** |
|
79 | - * The menu position. |
|
80 | - * |
|
81 | - * @since 1.0.0 |
|
82 | - * @access protected |
|
83 | - * @var int $position The string used to set menu position. |
|
84 | - */ |
|
85 | - public $position; |
|
78 | + /** |
|
79 | + * The menu position. |
|
80 | + * |
|
81 | + * @since 1.0.0 |
|
82 | + * @access protected |
|
83 | + * @var int $position The string used to set menu position. |
|
84 | + */ |
|
85 | + public $position; |
|
86 | 86 | |
87 | - /** |
|
88 | - * The menu plugin name. |
|
89 | - * |
|
90 | - * @since 1.0.0 |
|
91 | - * @access protected |
|
92 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
93 | - */ |
|
94 | - public $plugin_name; |
|
87 | + /** |
|
88 | + * The menu plugin name. |
|
89 | + * |
|
90 | + * @since 1.0.0 |
|
91 | + * @access protected |
|
92 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
93 | + */ |
|
94 | + public $plugin_name; |
|
95 | 95 | |
96 | - /** |
|
97 | - * Create a new menu page. |
|
98 | - * |
|
99 | - * @since 1.0.0 |
|
100 | - * @access public |
|
101 | - */ |
|
102 | - public function save() { |
|
103 | - add_action( 'admin_menu', array( $this, 'create_menu' ) ); |
|
104 | - } |
|
96 | + /** |
|
97 | + * Create a new menu page. |
|
98 | + * |
|
99 | + * @since 1.0.0 |
|
100 | + * @access public |
|
101 | + */ |
|
102 | + public function save() { |
|
103 | + add_action( 'admin_menu', array( $this, 'create_menu' ) ); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Create a new menu page. |
|
108 | - * |
|
109 | - * @since 1.0.0 |
|
110 | - * @param array $options Pass proprties as an array. |
|
111 | - * @access public |
|
112 | - */ |
|
113 | - public function make( $options = array() ) { |
|
114 | - foreach ( $options as $property => $value ) { |
|
115 | - if ( property_exists( get_called_class(), $property ) ) { |
|
116 | - $this->{$property} = $value; |
|
117 | - } |
|
118 | - } |
|
119 | - add_action( 'admin_menu', array( $this, 'create_menu' ) ); |
|
120 | - } |
|
106 | + /** |
|
107 | + * Create a new menu page. |
|
108 | + * |
|
109 | + * @since 1.0.0 |
|
110 | + * @param array $options Pass proprties as an array. |
|
111 | + * @access public |
|
112 | + */ |
|
113 | + public function make( $options = array() ) { |
|
114 | + foreach ( $options as $property => $value ) { |
|
115 | + if ( property_exists( get_called_class(), $property ) ) { |
|
116 | + $this->{$property} = $value; |
|
117 | + } |
|
118 | + } |
|
119 | + add_action( 'admin_menu', array( $this, 'create_menu' ) ); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Register new menu page. |
|
124 | - * |
|
125 | - * @return void |
|
126 | - */ |
|
127 | - public function create_menu() { |
|
128 | - $hook = add_menu_page( |
|
129 | - $this->page_title, |
|
130 | - $this->menu_title, |
|
131 | - $this->capability, |
|
132 | - $this->slug, |
|
133 | - $this->callback, |
|
134 | - $this->icon |
|
135 | - ); |
|
122 | + /** |
|
123 | + * Register new menu page. |
|
124 | + * |
|
125 | + * @return void |
|
126 | + */ |
|
127 | + public function create_menu() { |
|
128 | + $hook = add_menu_page( |
|
129 | + $this->page_title, |
|
130 | + $this->menu_title, |
|
131 | + $this->capability, |
|
132 | + $this->slug, |
|
133 | + $this->callback, |
|
134 | + $this->icon |
|
135 | + ); |
|
136 | 136 | |
137 | - add_action( 'load-' . $hook, array( $this, 'init_hooks' ) ); |
|
138 | - } |
|
137 | + add_action( 'load-' . $hook, array( $this, 'init_hooks' ) ); |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * Initialize hooks for the admin page. |
|
142 | - * |
|
143 | - * @return void |
|
144 | - */ |
|
145 | - public function init_hooks() { |
|
146 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
147 | - } |
|
140 | + /** |
|
141 | + * Initialize hooks for the admin page. |
|
142 | + * |
|
143 | + * @return void |
|
144 | + */ |
|
145 | + public function init_hooks() { |
|
146 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * Load scripts and styles for the current menu page. |
|
151 | - * |
|
152 | - * @return void |
|
153 | - */ |
|
154 | - public function enqueue_scripts() { |
|
155 | - wp_enqueue_style( $this->plugin_name . '-vendors' ); |
|
156 | - wp_enqueue_style( $this->plugin_name . '-admin' ); |
|
157 | - wp_enqueue_script( $this->plugin_name . '-admin' ); |
|
158 | - } |
|
149 | + /** |
|
150 | + * Load scripts and styles for the current menu page. |
|
151 | + * |
|
152 | + * @return void |
|
153 | + */ |
|
154 | + public function enqueue_scripts() { |
|
155 | + wp_enqueue_style( $this->plugin_name . '-vendors' ); |
|
156 | + wp_enqueue_style( $this->plugin_name . '-admin' ); |
|
157 | + wp_enqueue_script( $this->plugin_name . '-admin' ); |
|
158 | + } |
|
159 | 159 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @access public |
101 | 101 | */ |
102 | 102 | public function save() { |
103 | - add_action( 'admin_menu', array( $this, 'create_menu' ) ); |
|
103 | + add_action('admin_menu', array($this, 'create_menu')); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | * @param array $options Pass proprties as an array. |
111 | 111 | * @access public |
112 | 112 | */ |
113 | - public function make( $options = array() ) { |
|
114 | - foreach ( $options as $property => $value ) { |
|
115 | - if ( property_exists( get_called_class(), $property ) ) { |
|
113 | + public function make($options = array()) { |
|
114 | + foreach ($options as $property => $value) { |
|
115 | + if (property_exists(get_called_class(), $property)) { |
|
116 | 116 | $this->{$property} = $value; |
117 | 117 | } |
118 | 118 | } |
119 | - add_action( 'admin_menu', array( $this, 'create_menu' ) ); |
|
119 | + add_action('admin_menu', array($this, 'create_menu')); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $this->icon |
135 | 135 | ); |
136 | 136 | |
137 | - add_action( 'load-' . $hook, array( $this, 'init_hooks' ) ); |
|
137 | + add_action('load-'.$hook, array($this, 'init_hooks')); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @return void |
144 | 144 | */ |
145 | 145 | public function init_hooks() { |
146 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
146 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @return void |
153 | 153 | */ |
154 | 154 | public function enqueue_scripts() { |
155 | - wp_enqueue_style( $this->plugin_name . '-vendors' ); |
|
156 | - wp_enqueue_style( $this->plugin_name . '-admin' ); |
|
157 | - wp_enqueue_script( $this->plugin_name . '-admin' ); |
|
155 | + wp_enqueue_style($this->plugin_name.'-vendors'); |
|
156 | + wp_enqueue_style($this->plugin_name.'-admin'); |
|
157 | + wp_enqueue_script($this->plugin_name.'-admin'); |
|
158 | 158 | } |
159 | 159 | } |