@@ -22,107 +22,107 @@ |
||
22 | 22 | */ |
23 | 23 | class WPB_Loader { |
24 | 24 | |
25 | - /** |
|
26 | - * The array of actions registered with WordPress. |
|
27 | - * |
|
28 | - * @since 1.0.0 |
|
29 | - * @access protected |
|
30 | - * @var array $actions The actions registered with WordPress to fire when the plugin loads. |
|
31 | - */ |
|
32 | - protected $actions; |
|
33 | - |
|
34 | - /** |
|
35 | - * The array of filters registered with WordPress. |
|
36 | - * |
|
37 | - * @since 1.0.0 |
|
38 | - * @access protected |
|
39 | - * @var array $filters The filters registered with WordPress to fire when the plugin loads. |
|
40 | - */ |
|
41 | - protected $filters; |
|
42 | - |
|
43 | - /** |
|
44 | - * Initialize the collections used to maintain the actions and filters. |
|
45 | - * |
|
46 | - * @since 1.0.0 |
|
47 | - */ |
|
48 | - public function __construct() { |
|
49 | - |
|
50 | - $this->actions = array(); |
|
51 | - $this->filters = array(); |
|
52 | - |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Add a new action to the collection to be registered with WordPress. |
|
57 | - * |
|
58 | - * @since 1.0.0 |
|
59 | - * @param string $hook The name of the WordPress action that is being registered. |
|
60 | - * @param object $component A reference to the instance of the object on which the action is defined. |
|
61 | - * @param string $callback The name of the function definition on the $component. |
|
62 | - * @param int $priority Optional. The priority at which the function should be fired. Default is 10. |
|
63 | - * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
|
64 | - */ |
|
65 | - public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
66 | - $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * Add a new filter to the collection to be registered with WordPress. |
|
71 | - * |
|
72 | - * @since 1.0.0 |
|
73 | - * @param string $hook The name of the WordPress filter that is being registered. |
|
74 | - * @param object $component A reference to the instance of the object on which the filter is defined. |
|
75 | - * @param string $callback The name of the function definition on the $component. |
|
76 | - * @param int $priority Optional. The priority at which the function should be fired. Default is 10. |
|
77 | - * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
|
78 | - */ |
|
79 | - public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
80 | - $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * A utility function that is used to register the actions and hooks into a single |
|
85 | - * collection. |
|
86 | - * |
|
87 | - * @since 1.0.0 |
|
88 | - * @access private |
|
89 | - * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). |
|
90 | - * @param string $hook The name of the WordPress filter that is being registered. |
|
91 | - * @param object $component A reference to the instance of the object on which the filter is defined. |
|
92 | - * @param string $callback The name of the function definition on the $component. |
|
93 | - * @param int $priority The priority at which the function should be fired. |
|
94 | - * @param int $accepted_args The number of arguments that should be passed to the $callback. |
|
95 | - * @return array The collection of actions and filters registered with WordPress. |
|
96 | - */ |
|
97 | - private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { |
|
98 | - |
|
99 | - $hooks[] = array( |
|
100 | - 'hook' => $hook, |
|
101 | - 'component' => $component, |
|
102 | - 'callback' => $callback, |
|
103 | - 'priority' => $priority, |
|
104 | - 'accepted_args' => $accepted_args, |
|
105 | - ); |
|
106 | - |
|
107 | - return $hooks; |
|
108 | - |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Register the filters and actions with WordPress. |
|
113 | - * |
|
114 | - * @since 1.0.0 |
|
115 | - */ |
|
116 | - public function run() { |
|
117 | - |
|
118 | - foreach ( $this->filters as $hook ) { |
|
119 | - add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
120 | - } |
|
121 | - |
|
122 | - foreach ( $this->actions as $hook ) { |
|
123 | - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
124 | - } |
|
125 | - |
|
126 | - } |
|
25 | + /** |
|
26 | + * The array of actions registered with WordPress. |
|
27 | + * |
|
28 | + * @since 1.0.0 |
|
29 | + * @access protected |
|
30 | + * @var array $actions The actions registered with WordPress to fire when the plugin loads. |
|
31 | + */ |
|
32 | + protected $actions; |
|
33 | + |
|
34 | + /** |
|
35 | + * The array of filters registered with WordPress. |
|
36 | + * |
|
37 | + * @since 1.0.0 |
|
38 | + * @access protected |
|
39 | + * @var array $filters The filters registered with WordPress to fire when the plugin loads. |
|
40 | + */ |
|
41 | + protected $filters; |
|
42 | + |
|
43 | + /** |
|
44 | + * Initialize the collections used to maintain the actions and filters. |
|
45 | + * |
|
46 | + * @since 1.0.0 |
|
47 | + */ |
|
48 | + public function __construct() { |
|
49 | + |
|
50 | + $this->actions = array(); |
|
51 | + $this->filters = array(); |
|
52 | + |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Add a new action to the collection to be registered with WordPress. |
|
57 | + * |
|
58 | + * @since 1.0.0 |
|
59 | + * @param string $hook The name of the WordPress action that is being registered. |
|
60 | + * @param object $component A reference to the instance of the object on which the action is defined. |
|
61 | + * @param string $callback The name of the function definition on the $component. |
|
62 | + * @param int $priority Optional. The priority at which the function should be fired. Default is 10. |
|
63 | + * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
|
64 | + */ |
|
65 | + public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
66 | + $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * Add a new filter to the collection to be registered with WordPress. |
|
71 | + * |
|
72 | + * @since 1.0.0 |
|
73 | + * @param string $hook The name of the WordPress filter that is being registered. |
|
74 | + * @param object $component A reference to the instance of the object on which the filter is defined. |
|
75 | + * @param string $callback The name of the function definition on the $component. |
|
76 | + * @param int $priority Optional. The priority at which the function should be fired. Default is 10. |
|
77 | + * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
|
78 | + */ |
|
79 | + public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
80 | + $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * A utility function that is used to register the actions and hooks into a single |
|
85 | + * collection. |
|
86 | + * |
|
87 | + * @since 1.0.0 |
|
88 | + * @access private |
|
89 | + * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). |
|
90 | + * @param string $hook The name of the WordPress filter that is being registered. |
|
91 | + * @param object $component A reference to the instance of the object on which the filter is defined. |
|
92 | + * @param string $callback The name of the function definition on the $component. |
|
93 | + * @param int $priority The priority at which the function should be fired. |
|
94 | + * @param int $accepted_args The number of arguments that should be passed to the $callback. |
|
95 | + * @return array The collection of actions and filters registered with WordPress. |
|
96 | + */ |
|
97 | + private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { |
|
98 | + |
|
99 | + $hooks[] = array( |
|
100 | + 'hook' => $hook, |
|
101 | + 'component' => $component, |
|
102 | + 'callback' => $callback, |
|
103 | + 'priority' => $priority, |
|
104 | + 'accepted_args' => $accepted_args, |
|
105 | + ); |
|
106 | + |
|
107 | + return $hooks; |
|
108 | + |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Register the filters and actions with WordPress. |
|
113 | + * |
|
114 | + * @since 1.0.0 |
|
115 | + */ |
|
116 | + public function run() { |
|
117 | + |
|
118 | + foreach ( $this->filters as $hook ) { |
|
119 | + add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
120 | + } |
|
121 | + |
|
122 | + foreach ( $this->actions as $hook ) { |
|
123 | + add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
124 | + } |
|
125 | + |
|
126 | + } |
|
127 | 127 | |
128 | 128 | } |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @param int $priority Optional. The priority at which the function should be fired. Default is 10. |
63 | 63 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
64 | 64 | */ |
65 | - public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
66 | - $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); |
|
65 | + public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1) { |
|
66 | + $this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @param int $priority Optional. The priority at which the function should be fired. Default is 10. |
77 | 77 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
78 | 78 | */ |
79 | - public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
80 | - $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); |
|
79 | + public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1) { |
|
80 | + $this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param int $accepted_args The number of arguments that should be passed to the $callback. |
95 | 95 | * @return array The collection of actions and filters registered with WordPress. |
96 | 96 | */ |
97 | - private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { |
|
97 | + private function add($hooks, $hook, $component, $callback, $priority, $accepted_args) { |
|
98 | 98 | |
99 | 99 | $hooks[] = array( |
100 | 100 | 'hook' => $hook, |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function run() { |
117 | 117 | |
118 | - foreach ( $this->filters as $hook ) { |
|
119 | - add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
118 | + foreach ($this->filters as $hook) { |
|
119 | + add_filter($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']); |
|
120 | 120 | } |
121 | 121 | |
122 | - foreach ( $this->actions as $hook ) { |
|
123 | - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
122 | + foreach ($this->actions as $hook) { |
|
123 | + add_action($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | } |
@@ -21,82 +21,82 @@ |
||
21 | 21 | */ |
22 | 22 | class WPB_Public { |
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 the 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 the 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 public-facing side of the site. |
|
58 | - * |
|
59 | - * @since 1.0.0 |
|
60 | - */ |
|
61 | - public function enqueue_styles() { |
|
56 | + /** |
|
57 | + * Register the stylesheets for the public-facing side of the site. |
|
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-public.css', array(), $this->version, 'all' ); |
|
75 | + wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpb-public.css', array(), $this->version, 'all' ); |
|
76 | 76 | |
77 | - } |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Register the JavaScript for the public-facing side of the site. |
|
81 | - * |
|
82 | - * @since 1.0.0 |
|
83 | - */ |
|
84 | - public function enqueue_scripts() { |
|
79 | + /** |
|
80 | + * Register the JavaScript for the public-facing side of the site. |
|
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-public.js', array( 'jquery' ), $this->version, false ); |
|
98 | + wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wpb-public.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 the 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-public.css', array(), $this->version, 'all' ); |
|
75 | + wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/wpb-public.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-public.js', array( 'jquery' ), $this->version, false ); |
|
98 | + wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/wpb-public.js', array('jquery'), $this->version, false); |
|
99 | 99 | |
100 | 100 | } |
101 | 101 |
@@ -23,32 +23,32 @@ |
||
23 | 23 | */ |
24 | 24 | class Create_Customers_Table extends Migration { |
25 | 25 | |
26 | - /** |
|
27 | - * Run the migrations. |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function up() { |
|
32 | - Schema::create( |
|
33 | - 'customers', |
|
34 | - function ( Blueprint $table ) { |
|
35 | - $table->id(); |
|
36 | - $table->string( 'name' ); |
|
37 | - $table->string( 'email' )->unique(); |
|
38 | - $table->timestamp( 'email_verified_at' )->nullable(); |
|
39 | - $table->string( 'password' ); |
|
40 | - $table->rememberToken(); |
|
41 | - $table->timestamps(); |
|
42 | - } |
|
43 | - ); |
|
44 | - } |
|
26 | + /** |
|
27 | + * Run the migrations. |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function up() { |
|
32 | + Schema::create( |
|
33 | + 'customers', |
|
34 | + function ( Blueprint $table ) { |
|
35 | + $table->id(); |
|
36 | + $table->string( 'name' ); |
|
37 | + $table->string( 'email' )->unique(); |
|
38 | + $table->timestamp( 'email_verified_at' )->nullable(); |
|
39 | + $table->string( 'password' ); |
|
40 | + $table->rememberToken(); |
|
41 | + $table->timestamps(); |
|
42 | + } |
|
43 | + ); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Reverse the migrations. |
|
48 | - * |
|
49 | - * @return void |
|
50 | - */ |
|
51 | - public function down() { |
|
52 | - Schema::dropIfExists( 'customers' ); |
|
53 | - } |
|
46 | + /** |
|
47 | + * Reverse the migrations. |
|
48 | + * |
|
49 | + * @return void |
|
50 | + */ |
|
51 | + public function down() { |
|
52 | + Schema::dropIfExists( 'customers' ); |
|
53 | + } |
|
54 | 54 | } |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | public function up() { |
32 | 32 | Schema::create( |
33 | 33 | 'customers', |
34 | - function ( Blueprint $table ) { |
|
34 | + function(Blueprint $table) { |
|
35 | 35 | $table->id(); |
36 | - $table->string( 'name' ); |
|
37 | - $table->string( 'email' )->unique(); |
|
38 | - $table->timestamp( 'email_verified_at' )->nullable(); |
|
39 | - $table->string( 'password' ); |
|
36 | + $table->string('name'); |
|
37 | + $table->string('email')->unique(); |
|
38 | + $table->timestamp('email_verified_at')->nullable(); |
|
39 | + $table->string('password'); |
|
40 | 40 | $table->rememberToken(); |
41 | 41 | $table->timestamps(); |
42 | 42 | } |
@@ -49,6 +49,6 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public function down() { |
52 | - Schema::dropIfExists( 'customers' ); |
|
52 | + Schema::dropIfExists('customers'); |
|
53 | 53 | } |
54 | 54 | } |
@@ -25,15 +25,15 @@ |
||
25 | 25 | */ |
26 | 26 | class PostAuthorScope implements Scope { |
27 | 27 | |
28 | - /** |
|
29 | - * Apply the scope to a given Eloquent query builder. |
|
30 | - * |
|
31 | - * @param \Illuminate\Database\Eloquent\Builder $builder The eloquent builder. |
|
32 | - * @param \Illuminate\Database\Eloquent\Model $model The eloquent model. |
|
33 | - * |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function apply( Builder $builder, Model $model ) { |
|
37 | - $builder->whereNull( 'post_author' ); |
|
38 | - } |
|
28 | + /** |
|
29 | + * Apply the scope to a given Eloquent query builder. |
|
30 | + * |
|
31 | + * @param \Illuminate\Database\Eloquent\Builder $builder The eloquent builder. |
|
32 | + * @param \Illuminate\Database\Eloquent\Model $model The eloquent model. |
|
33 | + * |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function apply( Builder $builder, Model $model ) { |
|
37 | + $builder->whereNull( 'post_author' ); |
|
38 | + } |
|
39 | 39 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * |
34 | 34 | * @return void |
35 | 35 | */ |
36 | - public function apply( Builder $builder, Model $model ) { |
|
37 | - $builder->whereNull( 'post_author' ); |
|
36 | + public function apply(Builder $builder, Model $model) { |
|
37 | + $builder->whereNull('post_author'); |
|
38 | 38 | } |
39 | 39 | } |
@@ -25,15 +25,15 @@ |
||
25 | 25 | */ |
26 | 26 | class PostTypeScope implements Scope { |
27 | 27 | |
28 | - /** |
|
29 | - * Apply the scope to a given Eloquent query builder. |
|
30 | - * |
|
31 | - * @param \Illuminate\Database\Eloquent\Builder $builder $builder The eloquent builder. |
|
32 | - * @param \Illuminate\Database\Eloquent\Model $model $model The eloquent model. |
|
33 | - * |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function apply( Builder $builder, Model $model ) { |
|
37 | - $builder->where( 'post_type', '=', 'post' ); |
|
38 | - } |
|
28 | + /** |
|
29 | + * Apply the scope to a given Eloquent query builder. |
|
30 | + * |
|
31 | + * @param \Illuminate\Database\Eloquent\Builder $builder $builder The eloquent builder. |
|
32 | + * @param \Illuminate\Database\Eloquent\Model $model $model The eloquent model. |
|
33 | + * |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function apply( Builder $builder, Model $model ) { |
|
37 | + $builder->where( 'post_type', '=', 'post' ); |
|
38 | + } |
|
39 | 39 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * |
34 | 34 | * @return void |
35 | 35 | */ |
36 | - public function apply( Builder $builder, Model $model ) { |
|
37 | - $builder->where( 'post_type', '=', 'post' ); |
|
36 | + public function apply(Builder $builder, Model $model) { |
|
37 | + $builder->where('post_type', '=', 'post'); |
|
38 | 38 | } |
39 | 39 | } |
@@ -25,15 +25,15 @@ |
||
25 | 25 | */ |
26 | 26 | class PostStatusScope implements Scope { |
27 | 27 | |
28 | - /** |
|
29 | - * Apply the scope to a given Eloquent query builder. |
|
30 | - * |
|
31 | - * @param \Illuminate\Database\Eloquent\Builder $builder $builder The eloquent builder. |
|
32 | - * @param \Illuminate\Database\Eloquent\Model $model $model The eloquent model. |
|
33 | - * |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function apply( Builder $builder, Model $model ) { |
|
37 | - $builder->where( 'post_status', '=', 'publish' ); |
|
38 | - } |
|
28 | + /** |
|
29 | + * Apply the scope to a given Eloquent query builder. |
|
30 | + * |
|
31 | + * @param \Illuminate\Database\Eloquent\Builder $builder $builder The eloquent builder. |
|
32 | + * @param \Illuminate\Database\Eloquent\Model $model $model The eloquent model. |
|
33 | + * |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function apply( Builder $builder, Model $model ) { |
|
37 | + $builder->where( 'post_status', '=', 'publish' ); |
|
38 | + } |
|
39 | 39 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * |
34 | 34 | * @return void |
35 | 35 | */ |
36 | - public function apply( Builder $builder, Model $model ) { |
|
37 | - $builder->where( 'post_status', '=', 'publish' ); |
|
36 | + public function apply(Builder $builder, Model $model) { |
|
37 | + $builder->where('post_status', '=', 'publish'); |
|
38 | 38 | } |
39 | 39 | } |
@@ -23,61 +23,61 @@ |
||
23 | 23 | */ |
24 | 24 | class DB extends Capsule { |
25 | 25 | |
26 | - /** |
|
27 | - * The database instance. |
|
28 | - * |
|
29 | - * @since 1.0.0 |
|
30 | - * @access protected |
|
31 | - * @var \WPB\Database\DB $instance The database instance. |
|
32 | - */ |
|
33 | - protected static $instance = false; |
|
26 | + /** |
|
27 | + * The database instance. |
|
28 | + * |
|
29 | + * @since 1.0.0 |
|
30 | + * @access protected |
|
31 | + * @var \WPB\Database\DB $instance The database instance. |
|
32 | + */ |
|
33 | + protected static $instance = false; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Return database instance. |
|
37 | - * |
|
38 | - * @since 1.0.0 |
|
39 | - * @access public |
|
40 | - * |
|
41 | - * @return null|\WPB\Database\DB |
|
42 | - */ |
|
43 | - public static function instance() { |
|
44 | - if ( ! static::$instance ) { |
|
45 | - static::$instance = new self(); |
|
46 | - } |
|
35 | + /** |
|
36 | + * Return database instance. |
|
37 | + * |
|
38 | + * @since 1.0.0 |
|
39 | + * @access public |
|
40 | + * |
|
41 | + * @return null|\WPB\Database\DB |
|
42 | + */ |
|
43 | + public static function instance() { |
|
44 | + if ( ! static::$instance ) { |
|
45 | + static::$instance = new self(); |
|
46 | + } |
|
47 | 47 | |
48 | - return static::$instance; |
|
49 | - } |
|
48 | + return static::$instance; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * The database constructor. |
|
53 | - * |
|
54 | - * @since 1.0.0 |
|
55 | - * @access public |
|
56 | - * |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function __construct() { |
|
60 | - parent::__construct(); |
|
51 | + /** |
|
52 | + * The database constructor. |
|
53 | + * |
|
54 | + * @since 1.0.0 |
|
55 | + * @access public |
|
56 | + * |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function __construct() { |
|
60 | + parent::__construct(); |
|
61 | 61 | |
62 | - global $wpdb; |
|
62 | + global $wpdb; |
|
63 | 63 | |
64 | - $this->addConnection( |
|
65 | - array( |
|
64 | + $this->addConnection( |
|
65 | + array( |
|
66 | 66 | |
67 | - 'driver' => 'mysql', |
|
68 | - 'host' => $wpdb->dbhost, |
|
69 | - 'database' => $wpdb->dbname, |
|
70 | - 'username' => $wpdb->dbuser, |
|
71 | - 'password' => $wpdb->dbpassword, |
|
72 | - 'prefix' => $wpdb->prefix, |
|
73 | - 'charset' => $wpdb->charset, |
|
74 | - 'collation' => $wpdb->collate, |
|
75 | - ) |
|
76 | - ); |
|
67 | + 'driver' => 'mysql', |
|
68 | + 'host' => $wpdb->dbhost, |
|
69 | + 'database' => $wpdb->dbname, |
|
70 | + 'username' => $wpdb->dbuser, |
|
71 | + 'password' => $wpdb->dbpassword, |
|
72 | + 'prefix' => $wpdb->prefix, |
|
73 | + 'charset' => $wpdb->charset, |
|
74 | + 'collation' => $wpdb->collate, |
|
75 | + ) |
|
76 | + ); |
|
77 | 77 | |
78 | - // Make this Capsule instance available globally. |
|
79 | - $this->setAsGlobal(); |
|
80 | - // Setup the Eloquent ORM. |
|
81 | - $this->bootEloquent(); |
|
82 | - } |
|
78 | + // Make this Capsule instance available globally. |
|
79 | + $this->setAsGlobal(); |
|
80 | + // Setup the Eloquent ORM. |
|
81 | + $this->bootEloquent(); |
|
82 | + } |
|
83 | 83 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | * @return null|\WPB\Database\DB |
42 | 42 | */ |
43 | 43 | public static function instance() { |
44 | - if ( ! static::$instance ) { |
|
44 | + if (!static::$instance) { |
|
45 | 45 | static::$instance = new self(); |
46 | 46 | } |
47 | 47 |
@@ -22,153 +22,153 @@ |
||
22 | 22 | */ |
23 | 23 | class WPB_Admin_SubMenu { |
24 | 24 | |
25 | - /** |
|
26 | - * The menu page title. |
|
27 | - * |
|
28 | - * @since 1.0.0 |
|
29 | - * @access public |
|
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 public |
|
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 public |
|
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 public |
|
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 public |
|
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 public |
|
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 public |
|
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 private |
|
93 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
94 | - */ |
|
95 | - private $plugin_name; |
|
96 | - |
|
97 | - /** |
|
98 | - * Boot Menu. |
|
99 | - * |
|
100 | - * @param string $plugin_name The string used to uniquely identify this plugin. |
|
101 | - * @since 1.0.0 |
|
102 | - * @access public |
|
103 | - */ |
|
104 | - public function __construct( $plugin_name ) { |
|
105 | - $this->plugin_name = $plugin_name; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Create a new menu page. |
|
110 | - * |
|
111 | - * @since 1.0.0 |
|
112 | - * @access public |
|
113 | - */ |
|
114 | - public function save() { |
|
115 | - add_action( 'admin_menu', array( $this, 'create_submenu' ) ); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Create a new submenu page. |
|
120 | - * |
|
121 | - * @since 1.0.0 |
|
122 | - * @param array $options Pass proprties as an array. |
|
123 | - * @access public |
|
124 | - */ |
|
125 | - public function make( $options = array() ) { |
|
126 | - foreach ( $options as $property => $value ) { |
|
127 | - if ( property_exists( $this, $property ) ) { |
|
128 | - $this->{$property} = $value; |
|
129 | - } |
|
130 | - } |
|
131 | - add_action( 'admin_menu', array( $this, 'create_submenu' ) ); |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * Register new submenu page. |
|
136 | - * |
|
137 | - * @return void |
|
138 | - */ |
|
139 | - public function create_submenu() { |
|
140 | - if ( current_user_can( $this->capability ) ) { |
|
141 | - $hook = add_submenu_page( |
|
142 | - $this->parent_slug, |
|
143 | - $this->page_title, |
|
144 | - $this->menu_title, |
|
145 | - $this->capability, |
|
146 | - $this->slug, |
|
147 | - $this->callback, |
|
148 | - $this->icon |
|
149 | - ); |
|
150 | - } |
|
151 | - |
|
152 | - add_action( 'load-' . $hook, array( $this, 'init_hooks' ) ); |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Initialize hooks for the admin page. |
|
157 | - * |
|
158 | - * @return void |
|
159 | - */ |
|
160 | - public function init_hooks() { |
|
161 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Load scripts and styles for the submenu page. |
|
166 | - * |
|
167 | - * @return void |
|
168 | - */ |
|
169 | - public function enqueue_scripts() { |
|
170 | - wp_enqueue_style( $this->plugin_name . '-vendors' ); |
|
171 | - wp_enqueue_style( $this->plugin_name . '-admin' ); |
|
172 | - wp_enqueue_script( $this->plugin_name . '-admin' ); |
|
173 | - } |
|
25 | + /** |
|
26 | + * The menu page title. |
|
27 | + * |
|
28 | + * @since 1.0.0 |
|
29 | + * @access public |
|
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 public |
|
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 public |
|
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 public |
|
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 public |
|
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 public |
|
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 public |
|
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 private |
|
93 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
94 | + */ |
|
95 | + private $plugin_name; |
|
96 | + |
|
97 | + /** |
|
98 | + * Boot Menu. |
|
99 | + * |
|
100 | + * @param string $plugin_name The string used to uniquely identify this plugin. |
|
101 | + * @since 1.0.0 |
|
102 | + * @access public |
|
103 | + */ |
|
104 | + public function __construct( $plugin_name ) { |
|
105 | + $this->plugin_name = $plugin_name; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Create a new menu page. |
|
110 | + * |
|
111 | + * @since 1.0.0 |
|
112 | + * @access public |
|
113 | + */ |
|
114 | + public function save() { |
|
115 | + add_action( 'admin_menu', array( $this, 'create_submenu' ) ); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Create a new submenu page. |
|
120 | + * |
|
121 | + * @since 1.0.0 |
|
122 | + * @param array $options Pass proprties as an array. |
|
123 | + * @access public |
|
124 | + */ |
|
125 | + public function make( $options = array() ) { |
|
126 | + foreach ( $options as $property => $value ) { |
|
127 | + if ( property_exists( $this, $property ) ) { |
|
128 | + $this->{$property} = $value; |
|
129 | + } |
|
130 | + } |
|
131 | + add_action( 'admin_menu', array( $this, 'create_submenu' ) ); |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * Register new submenu page. |
|
136 | + * |
|
137 | + * @return void |
|
138 | + */ |
|
139 | + public function create_submenu() { |
|
140 | + if ( current_user_can( $this->capability ) ) { |
|
141 | + $hook = add_submenu_page( |
|
142 | + $this->parent_slug, |
|
143 | + $this->page_title, |
|
144 | + $this->menu_title, |
|
145 | + $this->capability, |
|
146 | + $this->slug, |
|
147 | + $this->callback, |
|
148 | + $this->icon |
|
149 | + ); |
|
150 | + } |
|
151 | + |
|
152 | + add_action( 'load-' . $hook, array( $this, 'init_hooks' ) ); |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Initialize hooks for the admin page. |
|
157 | + * |
|
158 | + * @return void |
|
159 | + */ |
|
160 | + public function init_hooks() { |
|
161 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Load scripts and styles for the submenu page. |
|
166 | + * |
|
167 | + * @return void |
|
168 | + */ |
|
169 | + public function enqueue_scripts() { |
|
170 | + wp_enqueue_style( $this->plugin_name . '-vendors' ); |
|
171 | + wp_enqueue_style( $this->plugin_name . '-admin' ); |
|
172 | + wp_enqueue_script( $this->plugin_name . '-admin' ); |
|
173 | + } |
|
174 | 174 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @since 1.0.0 |
102 | 102 | * @access public |
103 | 103 | */ |
104 | - public function __construct( $plugin_name ) { |
|
104 | + public function __construct($plugin_name) { |
|
105 | 105 | $this->plugin_name = $plugin_name; |
106 | 106 | } |
107 | 107 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @access public |
113 | 113 | */ |
114 | 114 | public function save() { |
115 | - add_action( 'admin_menu', array( $this, 'create_submenu' ) ); |
|
115 | + add_action('admin_menu', array($this, 'create_submenu')); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | * @param array $options Pass proprties as an array. |
123 | 123 | * @access public |
124 | 124 | */ |
125 | - public function make( $options = array() ) { |
|
126 | - foreach ( $options as $property => $value ) { |
|
127 | - if ( property_exists( $this, $property ) ) { |
|
125 | + public function make($options = array()) { |
|
126 | + foreach ($options as $property => $value) { |
|
127 | + if (property_exists($this, $property)) { |
|
128 | 128 | $this->{$property} = $value; |
129 | 129 | } |
130 | 130 | } |
131 | - add_action( 'admin_menu', array( $this, 'create_submenu' ) ); |
|
131 | + add_action('admin_menu', array($this, 'create_submenu')); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @return void |
138 | 138 | */ |
139 | 139 | public function create_submenu() { |
140 | - if ( current_user_can( $this->capability ) ) { |
|
140 | + if (current_user_can($this->capability)) { |
|
141 | 141 | $hook = add_submenu_page( |
142 | 142 | $this->parent_slug, |
143 | 143 | $this->page_title, |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | ); |
150 | 150 | } |
151 | 151 | |
152 | - add_action( 'load-' . $hook, array( $this, 'init_hooks' ) ); |
|
152 | + add_action('load-'.$hook, array($this, 'init_hooks')); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return void |
159 | 159 | */ |
160 | 160 | public function init_hooks() { |
161 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
161 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @return void |
168 | 168 | */ |
169 | 169 | public function enqueue_scripts() { |
170 | - wp_enqueue_style( $this->plugin_name . '-vendors' ); |
|
171 | - wp_enqueue_style( $this->plugin_name . '-admin' ); |
|
172 | - wp_enqueue_script( $this->plugin_name . '-admin' ); |
|
170 | + wp_enqueue_style($this->plugin_name.'-vendors'); |
|
171 | + wp_enqueue_style($this->plugin_name.'-admin'); |
|
172 | + wp_enqueue_script($this->plugin_name.'-admin'); |
|
173 | 173 | } |
174 | 174 | } |
@@ -24,108 +24,108 @@ |
||
24 | 24 | */ |
25 | 25 | class Post extends Model { |
26 | 26 | |
27 | - protected $primaryKey = 'ID'; |
|
27 | + protected $primaryKey = 'ID'; |
|
28 | 28 | |
29 | - /** |
|
30 | - * The post type scope. |
|
31 | - * |
|
32 | - * @since 1.0.0 |
|
33 | - * @access protected |
|
34 | - * @var string $plugin_name The post type scope. |
|
35 | - */ |
|
36 | - protected static $type_scope = 'post'; |
|
29 | + /** |
|
30 | + * The post type scope. |
|
31 | + * |
|
32 | + * @since 1.0.0 |
|
33 | + * @access protected |
|
34 | + * @var string $plugin_name The post type scope. |
|
35 | + */ |
|
36 | + protected static $type_scope = 'post'; |
|
37 | 37 | |
38 | - /** |
|
39 | - * The post status scope. |
|
40 | - * |
|
41 | - * @since 1.0.0 |
|
42 | - * @access protected |
|
43 | - * @var string $status_scope The post status scope. |
|
44 | - */ |
|
45 | - protected static $status_scope = 'publish'; |
|
38 | + /** |
|
39 | + * The post status scope. |
|
40 | + * |
|
41 | + * @since 1.0.0 |
|
42 | + * @access protected |
|
43 | + * @var string $status_scope The post status scope. |
|
44 | + */ |
|
45 | + protected static $status_scope = 'publish'; |
|
46 | 46 | |
47 | - /** |
|
48 | - * The unique identifier of this plugin. |
|
49 | - * |
|
50 | - * @since 1.0.0 |
|
51 | - * @access protected |
|
52 | - * @var string $author_scope The author scope.. |
|
53 | - */ |
|
54 | - protected static $author_scope = null; |
|
47 | + /** |
|
48 | + * The unique identifier of this plugin. |
|
49 | + * |
|
50 | + * @since 1.0.0 |
|
51 | + * @access protected |
|
52 | + * @var string $author_scope The author scope.. |
|
53 | + */ |
|
54 | + protected static $author_scope = null; |
|
55 | 55 | |
56 | - /** |
|
57 | - * The constant used to modify default created at fields. |
|
58 | - * |
|
59 | - * @since 1.0.0 |
|
60 | - * @access protected |
|
61 | - * @var string CREATED_AT The constant used to modify default created at fields. |
|
62 | - */ |
|
63 | - const CREATED_AT = 'post_date'; |
|
56 | + /** |
|
57 | + * The constant used to modify default created at fields. |
|
58 | + * |
|
59 | + * @since 1.0.0 |
|
60 | + * @access protected |
|
61 | + * @var string CREATED_AT The constant used to modify default created at fields. |
|
62 | + */ |
|
63 | + const CREATED_AT = 'post_date'; |
|
64 | 64 | |
65 | - /** |
|
66 | - * The constant used to modify default updated at fields. |
|
67 | - * |
|
68 | - * @since 1.0.0 |
|
69 | - * @access protected |
|
70 | - * @var string UPDATED_AT The constant used to modify default updated at fields. |
|
71 | - */ |
|
72 | - const UPDATED_AT = 'post_modified'; |
|
65 | + /** |
|
66 | + * The constant used to modify default updated at fields. |
|
67 | + * |
|
68 | + * @since 1.0.0 |
|
69 | + * @access protected |
|
70 | + * @var string UPDATED_AT The constant used to modify default updated at fields. |
|
71 | + */ |
|
72 | + const UPDATED_AT = 'post_modified'; |
|
73 | 73 | |
74 | - /** |
|
75 | - * Boot the model. |
|
76 | - * |
|
77 | - * @since 1.0.0 |
|
78 | - * @access protected |
|
79 | - * |
|
80 | - * @return void |
|
81 | - */ |
|
82 | - protected static function boot() { |
|
83 | - parent::boot(); |
|
84 | - static::addGlobalScope( |
|
85 | - 'type', |
|
86 | - function ( Builder $builder ) { |
|
87 | - $builder->where( 'post_type', '=', static::$type_scope ); |
|
88 | - } |
|
89 | - ); |
|
74 | + /** |
|
75 | + * Boot the model. |
|
76 | + * |
|
77 | + * @since 1.0.0 |
|
78 | + * @access protected |
|
79 | + * |
|
80 | + * @return void |
|
81 | + */ |
|
82 | + protected static function boot() { |
|
83 | + parent::boot(); |
|
84 | + static::addGlobalScope( |
|
85 | + 'type', |
|
86 | + function ( Builder $builder ) { |
|
87 | + $builder->where( 'post_type', '=', static::$type_scope ); |
|
88 | + } |
|
89 | + ); |
|
90 | 90 | |
91 | - } |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Filter by post type. |
|
95 | - * |
|
96 | - * @param \Illuminate\Database\Eloquent\Builder $builder The eloquent builder. |
|
97 | - * @param string $type The post type scope. |
|
98 | - * |
|
99 | - * @return mixed |
|
100 | - */ |
|
101 | - public function scopeType( Builder $builder, $type ) { |
|
102 | - self::$type_scope = $type; |
|
103 | - return $builder->where( 'post_type', '=', $type ); |
|
104 | - } |
|
93 | + /** |
|
94 | + * Filter by post type. |
|
95 | + * |
|
96 | + * @param \Illuminate\Database\Eloquent\Builder $builder The eloquent builder. |
|
97 | + * @param string $type The post type scope. |
|
98 | + * |
|
99 | + * @return mixed |
|
100 | + */ |
|
101 | + public function scopeType( Builder $builder, $type ) { |
|
102 | + self::$type_scope = $type; |
|
103 | + return $builder->where( 'post_type', '=', $type ); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Filter by post status |
|
108 | - * |
|
109 | - * @param \Illuminate\Database\Eloquent\Builder $builder The eloquent builder. |
|
110 | - * @param string $status The post status scope. |
|
111 | - * |
|
112 | - * @return mixed |
|
113 | - */ |
|
114 | - public function scopeStatus( Builder $builder, $status ) { |
|
115 | - return $builder->where( 'post_status', '=', $status ); |
|
116 | - } |
|
106 | + /** |
|
107 | + * Filter by post status |
|
108 | + * |
|
109 | + * @param \Illuminate\Database\Eloquent\Builder $builder The eloquent builder. |
|
110 | + * @param string $status The post status scope. |
|
111 | + * |
|
112 | + * @return mixed |
|
113 | + */ |
|
114 | + public function scopeStatus( Builder $builder, $status ) { |
|
115 | + return $builder->where( 'post_status', '=', $status ); |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * Filter by post author |
|
120 | - * |
|
121 | - * @param \Illuminate\Database\Eloquent\Builder $builder The eloquent builder. |
|
122 | - * @param string|null $author The post status scope. |
|
123 | - * |
|
124 | - * @return mixed |
|
125 | - */ |
|
126 | - public function scopeAuthor( Builder $builder, $author ) { |
|
127 | - if ( $author ) { |
|
128 | - return $builder->where( 'post_author', '=', $author ); |
|
129 | - } |
|
130 | - } |
|
118 | + /** |
|
119 | + * Filter by post author |
|
120 | + * |
|
121 | + * @param \Illuminate\Database\Eloquent\Builder $builder The eloquent builder. |
|
122 | + * @param string|null $author The post status scope. |
|
123 | + * |
|
124 | + * @return mixed |
|
125 | + */ |
|
126 | + public function scopeAuthor( Builder $builder, $author ) { |
|
127 | + if ( $author ) { |
|
128 | + return $builder->where( 'post_author', '=', $author ); |
|
129 | + } |
|
130 | + } |
|
131 | 131 | } |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | parent::boot(); |
84 | 84 | static::addGlobalScope( |
85 | 85 | 'type', |
86 | - function ( Builder $builder ) { |
|
87 | - $builder->where( 'post_type', '=', static::$type_scope ); |
|
86 | + function(Builder $builder) { |
|
87 | + $builder->where('post_type', '=', static::$type_scope); |
|
88 | 88 | } |
89 | 89 | ); |
90 | 90 | |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return mixed |
100 | 100 | */ |
101 | - public function scopeType( Builder $builder, $type ) { |
|
101 | + public function scopeType(Builder $builder, $type) { |
|
102 | 102 | self::$type_scope = $type; |
103 | - return $builder->where( 'post_type', '=', $type ); |
|
103 | + return $builder->where('post_type', '=', $type); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return mixed |
113 | 113 | */ |
114 | - public function scopeStatus( Builder $builder, $status ) { |
|
115 | - return $builder->where( 'post_status', '=', $status ); |
|
114 | + public function scopeStatus(Builder $builder, $status) { |
|
115 | + return $builder->where('post_status', '=', $status); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return mixed |
125 | 125 | */ |
126 | - public function scopeAuthor( Builder $builder, $author ) { |
|
127 | - if ( $author ) { |
|
128 | - return $builder->where( 'post_author', '=', $author ); |
|
126 | + public function scopeAuthor(Builder $builder, $author) { |
|
127 | + if ($author) { |
|
128 | + return $builder->where('post_author', '=', $author); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | } |