Skip to content

Commit abf7830

Browse files
Major code clean up done and added vsp_force_load_libs
1 parent 4344ede commit abf7830

18 files changed

+94
-359
lines changed

includes/class-ajax.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,12 @@ final class Ajax extends Ajaxer {
1919
/**
2020
* Ajax Action Prefix
2121
*
22-
* @example for wordpress_show_popup WordPress is the prefix
23-
*
2422
* @var string
2523
*/
2624
protected $action_prefix = 'vsp';
2725

2826
/**
29-
* Array of ajax actions
30-
*
31-
* @example array('ajax_action_1' => true,'ajax_action_2' => false)
32-
* if value set to true then it runs for both loggedout / logged in users
33-
* if value set to false then it runs only for the logged in user
27+
* Ajax actions
3428
*
3529
* @var array
3630
*/
@@ -48,7 +42,6 @@ public function addon_action() {
4842
$this->validate_request( 'addon', __( 'Unable To Process Your Request', 'vsp-framework' ) );
4943
do_action( $_REQUEST['hook_slug'] . '_handle_addon_request', $this );
5044
}
51-
5245
$this->json_error();
5346
}
5447

includes/class-base.php

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,25 @@ class Base extends Core\Instance_Handler {
3030

3131
/**
3232
* Class Clone.
33-
*
34-
* @throws \Exception
3533
*/
3634
public function __clone() {
37-
vsp_doing_it_wrong( __FUNCTION__, __( 'Cloning instances of the class is forbidden.', 'vsp-framework' ), $this->option( 'version' ) );
35+
vsp_doing_it_wrong( __FUNCTION__, __( 'Cloning instances of the class is forbidden.', 'vsp-framework' ), $this->plugin()
36+
->version() );
3837
}
3938

4039
/**
41-
* Class WakeUP.
42-
*
43-
* @throws \Exception
40+
* Class Wakeup.
4441
*/
4542
public function __wakeup() {
46-
vsp_doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of the class is forbidden.', 'vsp-framework' ), $this->option( 'version' ) );
43+
vsp_doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of the class is forbidden.', 'vsp-framework' ), $this->plugin()
44+
->version() );
4745
}
4846

4947
/**
5048
* Merges And sets the given args
5149
*
52-
* @param array $options .
53-
* @param array $defaults .
50+
* @param array $options
51+
* @param array $defaults
5452
*/
5553
protected function set_args( $options = array(), $defaults = array() ) {
5654
$defaults = empty( $defaults ) ? $this->default_options : $defaults;
@@ -61,8 +59,8 @@ protected function set_args( $options = array(), $defaults = array() ) {
6159
/**
6260
* Merges given array
6361
*
64-
* @param array $new .
65-
* @param array $defaults .
62+
* @param array $new
63+
* @param array $defaults
6664
*
6765
* @return array
6866
*/
@@ -74,8 +72,8 @@ protected function parse_args( $new = array(), $defaults = array() ) {
7472
/**
7573
* Returns value from options array
7674
*
77-
* @param string $key .
78-
* @param bool $default .
75+
* @param string $key
76+
* @param bool $default
7977
*
8078
* @return bool|mixed
8179
*/
@@ -86,18 +84,18 @@ protected function option( $key = '', $default = false ) {
8684
/**
8785
* Sets given value for the option
8886
*
89-
* @param string $key .
90-
* @param string|object|array|int|integer $value .
87+
* @param string $key
88+
* @param mixed $value
9189
*/
9290
protected function set_option( $key, $value ) {
9391
$this->options[ $key ] = $value;
9492
}
9593

9694
/**
97-
* @return \VSP\Framework|\VSP\Base
95+
* @return \VSP\Framework
9896
*/
9997
public function plugin() {
100-
return ( $this instanceof \VSP\Framework ) ? $this : $this->get_instance( self::$framework_instance[ static::class ] );
98+
return ( $this instanceof Framework ) ? $this : $this->get_instance( self::$framework_instance[ static::class ] );
10199
}
102100

103101
/**
@@ -106,8 +104,6 @@ public function plugin() {
106104
* @param string $ex_path
107105
*
108106
* @return string
109-
* @see \plugins_url()
110-
*
111107
*/
112108
public function plugin_url( $ex_path = '/' ) {
113109
$file = $this->plugin()
@@ -121,8 +117,6 @@ public function plugin_url( $ex_path = '/' ) {
121117
* @param string $ex_path
122118
*
123119
* @return string
124-
* @see \plugin_dir_path()
125-
*
126120
*/
127121
public function plugin_path( $ex_path = '' ) {
128122
$file = $this->plugin()

includes/class-error.php

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -29,55 +29,17 @@ public function has() {
2929
/**
3030
* Add an error or append additional message to an existing error.
3131
*
32-
* @since 2.1.0
33-
*
34-
* @param string|int $code Error code.
35-
* @param string $message Error message.
36-
* @param mixed $data Optional. Error data.
37-
*
38-
* @return $this|self
39-
*/
40-
public function add( $code, $message, $data = '' ) {
41-
if ( ! is_array( $message ) ) {
42-
$message = array( $message );
43-
}
44-
foreach ( $message as $m ) {
45-
parent::add( $code, $m, $data );
46-
}
47-
return $this;
48-
}
49-
50-
/**
51-
* Add data for error code.
52-
*
53-
* The error code can only contain one error data.
54-
*
55-
* @since 2.1.0
56-
*
57-
* @param mixed $data Error data.
5832
* @param string|int $code Error code.
33+
* @param string $msg Error message.
34+
* @param mixed $arg Optional. Error data.
5935
*
6036
* @return $this
6137
*/
62-
public function add_data( $data, $code = '' ) {
63-
parent::add_data( $data, $code );
64-
return $this;
65-
}
66-
67-
/**
68-
* Removes the specified error.
69-
*
70-
* This function removes all error messages associated with the specified
71-
* error code, along with any error data for that code.
72-
*
73-
* @since 4.1.0
74-
*
75-
* @param string|int $code Error code.
76-
*
77-
* @return $this
78-
*/
79-
public function remove( $code ) {
80-
parent::remove( $code );
38+
public function add( $code, $msg, $arg = '' ) {
39+
$msg = ( ! is_array( $msg ) ) ? array( $msg ) : $msg;
40+
foreach ( $msg as $m ) {
41+
parent::add( $code, $m, $arg );
42+
}
8143
return $this;
8244
}
8345
}

includes/class-framework-base.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function __construct( $options = array() ) {
8989
}
9090

9191
/**
92-
* Sets Core Values like (plugin_slug,db_slug,hook_slug) and more
92+
* Sets Core Values like
9393
*
9494
* @param string $key .
9595
* @param string $default .
@@ -106,8 +106,8 @@ protected function _set_core( $key = '', $default = '' ) {
106106
/**
107107
* Merges And sets the given args
108108
*
109-
* @param array $options .
110-
* @param array $defaults .
109+
* @param array $options
110+
* @param array $defaults
111111
*/
112112
public function set_args( $options = array(), $defaults = array() ) {
113113
$defaults = empty( $defaults ) ? $this->default_options : $defaults;
@@ -149,11 +149,8 @@ public function version() {
149149
* @return string|bool
150150
*/
151151
public function slug( $type = 'slug' ) {
152-
$return = false;
152+
$return = $this->slug;
153153
switch ( $type ) {
154-
case 'slug':
155-
$return = $this->slug;
156-
break;
157154
case 'db':
158155
$return = $this->db_slug;
159156
break;
@@ -176,8 +173,8 @@ public function plugin_name() {
176173
/**
177174
* Triggers Given function
178175
*
179-
* @param string $type .
180-
* @param array $args .
176+
* @param string $type
177+
* @param array $args
181178
*
182179
* @return mixed
183180
*/

includes/class-framework-modules.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ abstract class Framework_Modules extends Framework_Admin {
2121
/**
2222
* Logging
2323
*
24-
* @var null|\VSP\Modules\Logger
24+
* @var \VSP\Modules\Logger
2525
*/
2626
private $logging = null;
2727

2828
/**
2929
* Stores Autoloader
3030
*
31-
* @var null
31+
* @var \Varunsridharan\PHP\Autoloader
3232
* @access
3333
*/
3434
private $autoloader = null;
@@ -47,8 +47,6 @@ protected function _init_system_tools() {
4747
/**
4848
* Function Used to init Addons Module
4949
*
50-
* @uses VSP_Framework::addons_init_before
51-
* @uses VSP_Framework::addons_init
5250
* @hook addons_init_before
5351
* @hook addons_inti
5452
*/

includes/class-framework.php

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
if ( ! class_exists( '\VSP\Framework' ) ) {
1010
/**
11-
* Class VSP_Framework
11+
* Class VSP\Framework
1212
* This class should be extened and used in a plugins class
1313
*
1414
* @package VSP
@@ -22,29 +22,16 @@ abstract class Framework extends Framework_Modules {
2222
* @var array
2323
*/
2424
protected $default_options = array(
25-
/**
26-
* @see https://docs.wponion.com/modules/settings
27-
*/
25+
/* @see https://docs.wponion.com/modules/settings */
2826
'settings_page' => false,
29-
/**
30-
* @see http://github.com/varunsridharan/php-autoloader
31-
*/
27+
/* @see http://github.com/varunsridharan/php-autoloader */
3228
'autoloader' => false,
33-
/**
34-
* True / False
35-
*/
3629
'logging' => false,
37-
/**
38-
* @see https://github.com/varunsridharan/vsp-framework/blob/master/includes/modules/class-addons.php#L43-L51
39-
*/
30+
/* @see https://github.com/varunsridharan/vsp-framework/blob/master/includes/modules/class-addons.php#L43-L51 */
4031
'addons' => false,
41-
/**
42-
* @see https://github.com/varunsridharan/vsp-framework/blob/master/includes/modules/class-system-tools.php#L38-L41
43-
*/
32+
/* @see https://github.com/varunsridharan/vsp-framework/blob/master/includes/modules/class-system-tools.php#L38-L41 */
4433
'system_tools' => false,
45-
/**
46-
* @see https://github.com/varunsridharan/wp-localizer
47-
*/
34+
/* @see https://github.com/varunsridharan/wp-localizer */
4835
'localizer' => false,
4936
'plugin_file' => __FILE__,
5037
);
@@ -67,9 +54,8 @@ public function __construct( $options = array() ) {
6754
* Function Called When vsp_framework_init hook is fired
6855
*
6956
* @hook vsp_framework_init
70-
* @uses \VSP_Framework::_admin_init()
71-
* @uses VSP_Framework::plugin_init_before
72-
* @uses VSP_Framework::plugin_init
57+
* @uses \VSP\Framework::plugin_init_before
58+
* @uses \VSP\Framework::plugin_init
7359
*/
7460
public function _init_plugin() {
7561
$this->plugin_init_before();
@@ -101,8 +87,8 @@ private function _init_class() {
10187
/**
10288
* Function used to register common plugin hooks
10389
*
104-
* @uses \VSP_Framework_Admin::_register_admin_hooks()
105-
* @uses \VSP_Framework::register_hooks()
90+
* @uses \VSP\Framework_Admin::_register_admin_hooks()
91+
* @uses \VSP\Framework::register_hooks()
10692
*/
10793
private function _register_hooks() {
10894
add_action( 'init', array( $this, '_wp_init' ), 20 );
@@ -118,7 +104,7 @@ private function _register_hooks() {
118104
/**
119105
* Function used to load all framework required files
120106
*
121-
* @uses \VSP_Framework::load_files
107+
* @uses \VSP\Framework::load_files
122108
* @hook loaded
123109
*/
124110
private function _load_required_files() {
@@ -129,20 +115,20 @@ private function _load_required_files() {
129115
/**
130116
* Function Calls When wp_inited
131117
*
132-
* @uses \VSP_Framework::wp_init
118+
* @uses \VSP\Framework::wp_init
133119
*/
134120
public function _wp_init() {
135121
$this->wp_init();
136122
}
137123

138124
/**
139-
* @see VSP_Framework::__register_hooks
125+
* @see \VSP\Framework->__register_hooks
140126
*/
141127
protected function register_hooks() {
142128
}
143129

144130
/**
145-
* @see \VSP_Framework::__load_required_files
131+
* @see \VSP\Framework::__load_required_files
146132
*/
147133
protected function load_files() {
148134
}

includes/core/class-instance-handler.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,6 @@ protected function get_instance( $key ) {
7373
return ( isset( $this->instances[ $key ] ) ) ? $this->instances[ $key ] : false;
7474
}
7575

76-
/**
77-
* Returns all instance
78-
*
79-
* @return array
80-
*/
81-
protected function get_all_instances() {
82-
return $this->instances;
83-
}
84-
8576
/**
8677
* Creats a new instance for a given class
8778
*

0 commit comments

Comments
 (0)