← All changes
|
admin/views/sp-framework/classes/setup.class.php
+32
-145
2.3.6
→
2.2.10
View file →
| @@ -1,66 +1,25 @@ | ||
| 1 | 1 | <?php if ( ! defined( 'ABSPATH' ) ) { |
| 2 | 2 | die; } // Cannot a cess directly. |
| 3 | 3 | |
| 4 | +/** | |
| 5 | + * | |
| 6 | + * Setup Class | |
| 7 | + * | |
| 8 | + * @since 1.0.0 | |
| 9 | + * @version 1.0.0 | |
| 10 | + */ | |
| 4 | 11 | if ( ! class_exists( 'SP_PC' ) ) { |
| 5 | - | |
| 6 | - /** | |
| 7 | - * | |
| 8 | - * Setup Class | |
| 9 | - * | |
| 10 | - * @since 1.0.0 | |
| 11 | - * @version 1.0.0 | |
| 12 | - */ | |
| 13 | 12 | class SP_PC { |
| 14 | 13 | |
| 15 | - /** | |
| 16 | - * Constants. | |
| 17 | - * | |
| 18 | - * @var string | |
| 19 | - */ | |
| 14 | + // constants. | |
| 20 | 15 | public static $version = '2.0.6'; |
| 21 | - | |
| 22 | - /** | |
| 23 | - * Premium or not. | |
| 24 | - * | |
| 25 | - * @var boolean | |
| 26 | - */ | |
| 27 | 16 | public static $premium = true; |
| 28 | - | |
| 29 | - /** | |
| 30 | - * Directory. | |
| 31 | - * | |
| 32 | - * @var string | |
| 33 | - */ | |
| 34 | - public static $dir = null; | |
| 35 | - | |
| 36 | - /** | |
| 37 | - * URL | |
| 38 | - * | |
| 39 | - * @var string | |
| 40 | - */ | |
| 41 | - public static $url = null; | |
| 42 | - | |
| 43 | - /** | |
| 44 | - * Initiated. | |
| 45 | - * | |
| 46 | - * @var array | |
| 47 | - */ | |
| 48 | - public static $inited = array(); | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * The fields array. | |
| 52 | - * | |
| 53 | - * @var array | |
| 54 | - */ | |
| 55 | - public static $fields = array(); | |
| 56 | - | |
| 57 | - /** | |
| 58 | - * The arguments. | |
| 59 | - * | |
| 60 | - * @var array | |
| 61 | - */ | |
| 62 | - public static $args = array( | |
| 17 | + public static $dir = null; | |
| 18 | + public static $url = null; | |
| 19 | + public static $inited = array(); | |
| 20 | + public static $fields = array(); | |
| 21 | + public static $args = array( | |
| 63 | 22 | 'options' => array(), |
| 64 | 23 | 'customize_options' => array(), |
| 65 | 24 | 'metaboxes' => array(), |
| 66 | 25 | 'shortcoders' => array(), |
| @@ -67,20 +26,12 @@ | ||
| 67 | 26 | 'taxonomy_options' => array(), |
| 68 | 27 | 'widgets' => array(), |
| 69 | 28 | ); |
| 70 | 29 | |
| 71 | - /** | |
| 72 | - * Shortcode instances. | |
| 73 | - * | |
| 74 | - * @var array | |
| 75 | - */ | |
| 30 | + // shortcode instances. | |
| 76 | 31 | public static $shortcode_instances = array(); |
| 77 | 32 | |
| 78 | - /** | |
| 79 | - * Init. | |
| 80 | - * | |
| 81 | - * @return void | |
| 82 | - */ | |
| 33 | + // init. | |
| 83 | 34 | public static function init() { |
| 84 | 35 | |
| 85 | 36 | // init action. |
| 86 | 37 | do_action( 'spf_init' ); |
| @@ -97,13 +48,9 @@ | ||
| 97 | 48 | add_action( 'admin_enqueue_scripts', array( 'SP_PC', 'add_admin_enqueue_scripts' ), 20 ); |
| 98 | 49 | |
| 99 | 50 | } |
| 100 | 51 | |
| 101 | - /** | |
| 102 | - * Setup. | |
| 103 | - * | |
| 104 | - * @return void | |
| 105 | - */ | |
| 52 | + // setup. | |
| 106 | 53 | public static function setup() { |
| 107 | 54 | |
| 108 | 55 | // setup options. |
| 109 | 56 | $params = array(); |
| @@ -139,9 +86,9 @@ | ||
| 139 | 86 | } |
| 140 | 87 | } |
| 141 | 88 | } |
| 142 | 89 | |
| 143 | - // create widgets. | |
| 90 | + // create widgets | |
| 144 | 91 | if ( ! empty( self::$args['widgets'] ) && class_exists( 'WP_Widget_Factory' ) ) { |
| 145 | 92 | |
| 146 | 93 | $wp_widget_factory = new WP_Widget_Factory(); |
| 147 | 94 | |
| @@ -156,59 +103,31 @@ | ||
| 156 | 103 | do_action( 'spf_loaded' ); |
| 157 | 104 | |
| 158 | 105 | } |
| 159 | 106 | |
| 160 | - /** | |
| 161 | - * Create options. | |
| 162 | - * | |
| 163 | - * @param string $id The option ID. | |
| 164 | - * @param array $args The arguments array. | |
| 165 | - * @return void | |
| 166 | - */ | |
| 107 | + // create options. | |
| 167 | 108 | public static function createOptions( $id, $args = array() ) { |
| 168 | 109 | self::$args['options'][ $id ] = $args; |
| 169 | 110 | } |
| 170 | 111 | |
| 171 | - /** | |
| 172 | - * Create metabox options. | |
| 173 | - * | |
| 174 | - * @param string $id The option ID. | |
| 175 | - * @param array $args The arguments array. | |
| 176 | - * @return void | |
| 177 | - */ | |
| 112 | + // create metabox options. | |
| 178 | 113 | public static function createMetabox( $id, $args = array() ) { |
| 179 | 114 | self::$args['metaboxes'][ $id ] = $args; |
| 180 | 115 | } |
| 181 | 116 | |
| 182 | - /** | |
| 183 | - * Create widget. | |
| 184 | - * | |
| 185 | - * @param string $id The option ID. | |
| 186 | - * @param array $args The arguments array. | |
| 187 | - * @return void | |
| 188 | - */ | |
| 117 | + // create widget. | |
| 189 | 118 | public static function createWidget( $id, $args = array() ) { |
| 190 | 119 | self::$args['widgets'][ $id ] = $args; |
| 191 | 120 | self::set_used_fields( $args ); |
| 192 | 121 | } |
| 193 | 122 | |
| 194 | - /** | |
| 195 | - * Create sections. | |
| 196 | - * | |
| 197 | - * @param string $id The option ID. | |
| 198 | - * @param array $sections The sections array. | |
| 199 | - * @return void | |
| 200 | - */ | |
| 123 | + // create section. | |
| 201 | 124 | public static function createSection( $id, $sections ) { |
| 202 | 125 | self::$args['sections'][ $id ][] = $sections; |
| 203 | 126 | self::set_used_fields( $sections ); |
| 204 | 127 | } |
| 205 | 128 | |
| 206 | - /** | |
| 207 | - * Constants. | |
| 208 | - * | |
| 209 | - * @return void | |
| 210 | - */ | |
| 129 | + // constants. | |
| 211 | 130 | public static function constants() { |
| 212 | 131 | |
| 213 | 132 | // we need this path-finder code for set URL of framework. |
| 214 | 133 | $dirname = wp_normalize_path( dirname( dirname( __FILE__ ) ) ); |
| @@ -225,16 +144,8 @@ | ||
| 225 | 144 | self::$url = $directory_uri . $foldername; |
| 226 | 145 | |
| 227 | 146 | } |
| 228 | 147 | |
| 229 | - /** | |
| 230 | - * Include plugin files. | |
| 231 | - * | |
| 232 | - * @param string $file Plugin files. | |
| 233 | - * @param boolean $load Load files. | |
| 234 | - * | |
| 235 | - * @return mixed | |
| 236 | - */ | |
| 237 | 148 | public static function include_plugin_file( $file, $load = true ) { |
| 238 | 149 | |
| 239 | 150 | $path = ''; |
| 240 | 151 | $file = ltrim( $file, '/' ); |
| @@ -270,37 +181,23 @@ | ||
| 270 | 181 | } |
| 271 | 182 | |
| 272 | 183 | } |
| 273 | 184 | |
| 274 | - /** | |
| 275 | - * Is plugin active. | |
| 276 | - * | |
| 277 | - * @param string $file The plugin file. | |
| 278 | - * @return boolean | |
| 279 | - */ | |
| 280 | 185 | public static function is_active_plugin( $file = '' ) { |
| 281 | 186 | return in_array( $file, (array) get_option( 'active_plugins', array() ) ); |
| 282 | 187 | } |
| 283 | 188 | |
| 284 | - /** | |
| 285 | - * Sanitize dirname. | |
| 286 | - * | |
| 287 | - * @param string $dirname The directory name. | |
| 288 | - * @return string | |
| 289 | - */ | |
| 189 | + // Sanitize dirname. | |
| 290 | 190 | public static function sanitize_dirname( $dirname ) { |
| 291 | 191 | return preg_replace( '/[^A-Za-z]/', '', $dirname ); |
| 292 | 192 | } |
| 293 | 193 | |
| 294 | - /** | |
| 295 | - * General includes. | |
| 296 | - * | |
| 297 | - * @return void | |
| 298 | - */ | |
| 194 | + // General includes. | |
| 299 | 195 | public static function includes() { |
| 300 | 196 | |
| 301 | 197 | // includes helpers. |
| 302 | 198 | self::include_plugin_file( 'functions/actions.php' ); |
| 199 | + self::include_plugin_file( 'functions/deprecated.php' ); | |
| 303 | 200 | self::include_plugin_file( 'functions/helpers.php' ); |
| 304 | 201 | self::include_plugin_file( 'functions/sanitize.php' ); |
| 305 | 202 | self::include_plugin_file( 'functions/validate.php' ); |
| 306 | 203 | |
| @@ -310,8 +207,9 @@ | ||
| 310 | 207 | self::include_plugin_file( 'classes/options.class.php' ); |
| 311 | 208 | |
| 312 | 209 | // includes premium version classes. |
| 313 | 210 | if ( self::$premium ) { |
| 211 | + //self::include_plugin_file( 'classes/customize-options.class.php' ); | |
| 314 | 212 | self::include_plugin_file( 'classes/metabox.class.php' ); |
| 315 | 213 | |
| 316 | 214 | self::include_plugin_file( 'classes/widgets.class.php' ); |
| 317 | 215 | } |
| @@ -361,13 +259,10 @@ | ||
| 361 | 259 | } |
| 362 | 260 | |
| 363 | 261 | } |
| 364 | 262 | |
| 365 | - /** | |
| 366 | - * Enqueue admin and fields styles and scripts. | |
| 367 | - * | |
| 368 | - * @return void | |
| 369 | - */ | |
| 263 | + // | |
| 264 | + // Enqueue admin and fields styles and scripts. | |
| 370 | 265 | public static function add_admin_enqueue_scripts() { |
| 371 | 266 | $current_screen = get_current_screen(); |
| 372 | 267 | $the_current_post_type = $current_screen->post_type; |
| 373 | 268 | if ( 'sp_post_carousel' === $the_current_post_type ) { |
| @@ -431,18 +326,10 @@ | ||
| 431 | 326 | } // Check screen ID. |
| 432 | 327 | |
| 433 | 328 | } |
| 434 | 329 | |
| 435 | - /** | |
| 436 | - * Add a new framework field. | |
| 437 | - * | |
| 438 | - * @param array $field The fields array. | |
| 439 | - * @param string $value The field value. | |
| 440 | - * @param string $unique The unique string. | |
| 441 | - * @param string $where The position to show the fields. | |
| 442 | - * @param string $parent If the fields has parent. | |
| 443 | - * @return void | |
| 444 | - */ | |
| 330 | + // | |
| 331 | + // Add a new framework field. | |
| 445 | 332 | public static function field( $field = array(), $value = '', $unique = '', $where = '', $parent = '' ) { |
| 446 | 333 | |
| 447 | 334 | // Check for unallow fields. |
| 448 | 335 | if ( ! empty( $field['_notice'] ) ) { |
| @@ -492,13 +379,13 @@ | ||
| 492 | 379 | } |
| 493 | 380 | |
| 494 | 381 | if ( ! empty( $field_type ) ) { |
| 495 | 382 | |
| 496 | - echo '<div class="spf-field spf-field-' . esc_attr( $field_type ) . esc_attr( $is_pseudo ) . esc_attr( $class ) . esc_attr( $hidden ) . '"' . wp_kses_post( $depend ) . '>'; | |
| 383 | + echo '<div class="spf-field spf-field-' . $field_type . $is_pseudo . $class . $hidden . '"' . $depend . '>'; | |
| 497 | 384 | |
| 498 | 385 | if ( ! empty( $field['title'] ) ) { |
| 499 | 386 | $subtitle = ( ! empty( $field['subtitle'] ) ) ? '<p class="spf-text-subtitle">' . $field['subtitle'] . '</p>' : ''; |
| 500 | - echo '<div class="spf-title"><h4>' . esc_html( $field['title'] ) . '</h4>' . wp_kses_post( $subtitle ) . '</div>'; | |
| 387 | + echo '<div class="spf-title"><h4>' . $field['title'] . '</h4>' . $subtitle . '</div>'; | |
| 501 | 388 | } |
| 502 | 389 | |
| 503 | 390 | echo ( ! empty( $field['title'] ) ) ? '<div class="spf-fieldset">' : ''; |
| 504 | 391 | |