← All changes
|
admin/views/sp-framework/classes/setup.class.php
+41
-163
2.4.21
→
2.2.10
View file →
| @@ -1,74 +1,25 @@ | ||
| 1 | -<?php | |
| 1 | +<?php if ( ! defined( 'ABSPATH' ) ) { | |
| 2 | + die; } // Cannot a cess directly. | |
| 3 | + | |
| 2 | 4 | /** |
| 3 | - * The setup class of the plugin. | |
| 4 | 5 | * |
| 5 | - * @package Smart_Post_Show | |
| 6 | - * @subpackage Smart_Post_Show/views/sp-framework/classes | |
| 6 | + * Setup Class | |
| 7 | + * | |
| 8 | + * @since 1.0.0 | |
| 9 | + * @version 1.0.0 | |
| 7 | 10 | */ |
| 8 | - | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | - die; } // Cannot a cess directly. | |
| 11 | - | |
| 12 | 11 | if ( ! class_exists( 'SP_PC' ) ) { |
| 13 | - | |
| 14 | - /** | |
| 15 | - * | |
| 16 | - * Setup Class | |
| 17 | - * | |
| 18 | - * @since 1.0.0 | |
| 19 | - * @version 1.0.0 | |
| 20 | - */ | |
| 21 | 12 | class SP_PC { |
| 22 | 13 | |
| 23 | - /** | |
| 24 | - * Constants. | |
| 25 | - * | |
| 26 | - * @var string | |
| 27 | - */ | |
| 14 | + // constants. | |
| 28 | 15 | public static $version = '2.0.6'; |
| 29 | - | |
| 30 | - /** | |
| 31 | - * Premium or not. | |
| 32 | - * | |
| 33 | - * @var boolean | |
| 34 | - */ | |
| 35 | 16 | public static $premium = true; |
| 36 | - | |
| 37 | - /** | |
| 38 | - * Directory. | |
| 39 | - * | |
| 40 | - * @var string | |
| 41 | - */ | |
| 42 | - public static $dir = null; | |
| 43 | - | |
| 44 | - /** | |
| 45 | - * URL | |
| 46 | - * | |
| 47 | - * @var string | |
| 48 | - */ | |
| 49 | - public static $url = null; | |
| 50 | - | |
| 51 | - /** | |
| 52 | - * Initiated. | |
| 53 | - * | |
| 54 | - * @var array | |
| 55 | - */ | |
| 56 | - public static $inited = array(); | |
| 57 | - | |
| 58 | - /** | |
| 59 | - * The fields array. | |
| 60 | - * | |
| 61 | - * @var array | |
| 62 | - */ | |
| 63 | - public static $fields = array(); | |
| 64 | - | |
| 65 | - /** | |
| 66 | - * The arguments. | |
| 67 | - * | |
| 68 | - * @var array | |
| 69 | - */ | |
| 70 | - 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( | |
| 71 | 22 | 'options' => array(), |
| 72 | 23 | 'customize_options' => array(), |
| 73 | 24 | 'metaboxes' => array(), |
| 74 | 25 | 'shortcoders' => array(), |
| @@ -75,20 +26,12 @@ | ||
| 75 | 26 | 'taxonomy_options' => array(), |
| 76 | 27 | 'widgets' => array(), |
| 77 | 28 | ); |
| 78 | 29 | |
| 79 | - /** | |
| 80 | - * Shortcode instances. | |
| 81 | - * | |
| 82 | - * @var array | |
| 83 | - */ | |
| 30 | + // shortcode instances. | |
| 84 | 31 | public static $shortcode_instances = array(); |
| 85 | 32 | |
| 86 | - /** | |
| 87 | - * Init. | |
| 88 | - * | |
| 89 | - * @return void | |
| 90 | - */ | |
| 33 | + // init. | |
| 91 | 34 | public static function init() { |
| 92 | 35 | |
| 93 | 36 | // init action. |
| 94 | 37 | do_action( 'spf_init' ); |
| @@ -105,13 +48,9 @@ | ||
| 105 | 48 | add_action( 'admin_enqueue_scripts', array( 'SP_PC', 'add_admin_enqueue_scripts' ), 20 ); |
| 106 | 49 | |
| 107 | 50 | } |
| 108 | 51 | |
| 109 | - /** | |
| 110 | - * Setup. | |
| 111 | - * | |
| 112 | - * @return void | |
| 113 | - */ | |
| 52 | + // setup. | |
| 114 | 53 | public static function setup() { |
| 115 | 54 | |
| 116 | 55 | // setup options. |
| 117 | 56 | $params = array(); |
| @@ -147,9 +86,9 @@ | ||
| 147 | 86 | } |
| 148 | 87 | } |
| 149 | 88 | } |
| 150 | 89 | |
| 151 | - // create widgets. | |
| 90 | + // create widgets | |
| 152 | 91 | if ( ! empty( self::$args['widgets'] ) && class_exists( 'WP_Widget_Factory' ) ) { |
| 153 | 92 | |
| 154 | 93 | $wp_widget_factory = new WP_Widget_Factory(); |
| 155 | 94 | |
| @@ -164,59 +103,31 @@ | ||
| 164 | 103 | do_action( 'spf_loaded' ); |
| 165 | 104 | |
| 166 | 105 | } |
| 167 | 106 | |
| 168 | - /** | |
| 169 | - * Create options. | |
| 170 | - * | |
| 171 | - * @param string $id The option ID. | |
| 172 | - * @param array $args The arguments array. | |
| 173 | - * @return void | |
| 174 | - */ | |
| 107 | + // create options. | |
| 175 | 108 | public static function createOptions( $id, $args = array() ) { |
| 176 | 109 | self::$args['options'][ $id ] = $args; |
| 177 | 110 | } |
| 178 | 111 | |
| 179 | - /** | |
| 180 | - * Create metabox options. | |
| 181 | - * | |
| 182 | - * @param string $id The option ID. | |
| 183 | - * @param array $args The arguments array. | |
| 184 | - * @return void | |
| 185 | - */ | |
| 112 | + // create metabox options. | |
| 186 | 113 | public static function createMetabox( $id, $args = array() ) { |
| 187 | 114 | self::$args['metaboxes'][ $id ] = $args; |
| 188 | 115 | } |
| 189 | 116 | |
| 190 | - /** | |
| 191 | - * Create widget. | |
| 192 | - * | |
| 193 | - * @param string $id The option ID. | |
| 194 | - * @param array $args The arguments array. | |
| 195 | - * @return void | |
| 196 | - */ | |
| 117 | + // create widget. | |
| 197 | 118 | public static function createWidget( $id, $args = array() ) { |
| 198 | 119 | self::$args['widgets'][ $id ] = $args; |
| 199 | 120 | self::set_used_fields( $args ); |
| 200 | 121 | } |
| 201 | 122 | |
| 202 | - /** | |
| 203 | - * Create sections. | |
| 204 | - * | |
| 205 | - * @param string $id The option ID. | |
| 206 | - * @param array $sections The sections array. | |
| 207 | - * @return void | |
| 208 | - */ | |
| 123 | + // create section. | |
| 209 | 124 | public static function createSection( $id, $sections ) { |
| 210 | 125 | self::$args['sections'][ $id ][] = $sections; |
| 211 | 126 | self::set_used_fields( $sections ); |
| 212 | 127 | } |
| 213 | 128 | |
| 214 | - /** | |
| 215 | - * Constants. | |
| 216 | - * | |
| 217 | - * @return void | |
| 218 | - */ | |
| 129 | + // constants. | |
| 219 | 130 | public static function constants() { |
| 220 | 131 | |
| 221 | 132 | // we need this path-finder code for set URL of framework. |
| 222 | 133 | $dirname = wp_normalize_path( dirname( dirname( __FILE__ ) ) ); |
| @@ -233,16 +144,8 @@ | ||
| 233 | 144 | self::$url = $directory_uri . $foldername; |
| 234 | 145 | |
| 235 | 146 | } |
| 236 | 147 | |
| 237 | - /** | |
| 238 | - * Include plugin files. | |
| 239 | - * | |
| 240 | - * @param string $file Plugin files. | |
| 241 | - * @param boolean $load Load files. | |
| 242 | - * | |
| 243 | - * @return mixed | |
| 244 | - */ | |
| 245 | 148 | public static function include_plugin_file( $file, $load = true ) { |
| 246 | 149 | |
| 247 | 150 | $path = ''; |
| 248 | 151 | $file = ltrim( $file, '/' ); |
| @@ -278,37 +181,23 @@ | ||
| 278 | 181 | } |
| 279 | 182 | |
| 280 | 183 | } |
| 281 | 184 | |
| 282 | - /** | |
| 283 | - * Is plugin active. | |
| 284 | - * | |
| 285 | - * @param string $file The plugin file. | |
| 286 | - * @return boolean | |
| 287 | - */ | |
| 288 | 185 | public static function is_active_plugin( $file = '' ) { |
| 289 | 186 | return in_array( $file, (array) get_option( 'active_plugins', array() ) ); |
| 290 | 187 | } |
| 291 | 188 | |
| 292 | - /** | |
| 293 | - * Sanitize dirname. | |
| 294 | - * | |
| 295 | - * @param string $dirname The directory name. | |
| 296 | - * @return string | |
| 297 | - */ | |
| 189 | + // Sanitize dirname. | |
| 298 | 190 | public static function sanitize_dirname( $dirname ) { |
| 299 | 191 | return preg_replace( '/[^A-Za-z]/', '', $dirname ); |
| 300 | 192 | } |
| 301 | 193 | |
| 302 | - /** | |
| 303 | - * General includes. | |
| 304 | - * | |
| 305 | - * @return void | |
| 306 | - */ | |
| 194 | + // General includes. | |
| 307 | 195 | public static function includes() { |
| 308 | 196 | |
| 309 | 197 | // includes helpers. |
| 310 | 198 | self::include_plugin_file( 'functions/actions.php' ); |
| 199 | + self::include_plugin_file( 'functions/deprecated.php' ); | |
| 311 | 200 | self::include_plugin_file( 'functions/helpers.php' ); |
| 312 | 201 | self::include_plugin_file( 'functions/sanitize.php' ); |
| 313 | 202 | self::include_plugin_file( 'functions/validate.php' ); |
| 314 | 203 | |
| @@ -318,8 +207,9 @@ | ||
| 318 | 207 | self::include_plugin_file( 'classes/options.class.php' ); |
| 319 | 208 | |
| 320 | 209 | // includes premium version classes. |
| 321 | 210 | if ( self::$premium ) { |
| 211 | + //self::include_plugin_file( 'classes/customize-options.class.php' ); | |
| 322 | 212 | self::include_plugin_file( 'classes/metabox.class.php' ); |
| 323 | 213 | |
| 324 | 214 | self::include_plugin_file( 'classes/widgets.class.php' ); |
| 325 | 215 | } |
| @@ -369,13 +259,10 @@ | ||
| 369 | 259 | } |
| 370 | 260 | |
| 371 | 261 | } |
| 372 | 262 | |
| 373 | - /** | |
| 374 | - * Enqueue admin and fields styles and scripts. | |
| 375 | - * | |
| 376 | - * @return void | |
| 377 | - */ | |
| 263 | + // | |
| 264 | + // Enqueue admin and fields styles and scripts. | |
| 378 | 265 | public static function add_admin_enqueue_scripts() { |
| 379 | 266 | $current_screen = get_current_screen(); |
| 380 | 267 | $the_current_post_type = $current_screen->post_type; |
| 381 | 268 | if ( 'sp_post_carousel' === $the_current_post_type ) { |
| @@ -400,20 +287,19 @@ | ||
| 400 | 287 | wp_localize_script( |
| 401 | 288 | 'spf', |
| 402 | 289 | 'spf_vars', |
| 403 | 290 | array( |
| 404 | - 'previewJS' => esc_url( SP_PC_URL . 'public/assets/js/scripts' . $min . '.js' ), | |
| 405 | 291 | 'color_palette' => apply_filters( 'spf_color_palette', array() ), |
| 406 | 292 | 'i18n' => array( |
| 407 | 293 | // global localize. |
| 408 | - 'confirm' => esc_html__( 'Are you sure?', 'post-carousel' ), | |
| 409 | - 'reset_notification' => esc_html__( 'Restoring options.', 'post-carousel' ), | |
| 410 | - 'import_notification' => esc_html__( 'Importing options.', 'post-carousel' ), | |
| 294 | + 'confirm' => esc_html__( 'Are you sure?', 'smart-post-show' ), | |
| 295 | + 'reset_notification' => esc_html__( 'Restoring options.', 'smart-post-show' ), | |
| 296 | + 'import_notification' => esc_html__( 'Importing options.', 'smart-post-show' ), | |
| 411 | 297 | |
| 412 | 298 | // chosen localize. |
| 413 | - 'typing_text' => esc_html__( 'Please enter %s or more characters', 'post-carousel' ), | |
| 414 | - 'searching_text' => esc_html__( 'Searching...', 'post-carousel' ), | |
| 415 | - 'no_results_text' => esc_html__( 'No results match', 'post-carousel' ), | |
| 299 | + 'typing_text' => esc_html__( 'Please enter %s or more characters', 'smart-post-show' ), | |
| 300 | + 'searching_text' => esc_html__( 'Searching...', 'smart-post-show' ), | |
| 301 | + 'no_results_text' => esc_html__( 'No results match', 'smart-post-show' ), | |
| 416 | 302 | ), |
| 417 | 303 | ) |
| 418 | 304 | ); |
| 419 | 305 | |
| @@ -440,18 +326,10 @@ | ||
| 440 | 326 | } // Check screen ID. |
| 441 | 327 | |
| 442 | 328 | } |
| 443 | 329 | |
| 444 | - /** | |
| 445 | - * Add a new framework field. | |
| 446 | - * | |
| 447 | - * @param array $field The fields array. | |
| 448 | - * @param string $value The field value. | |
| 449 | - * @param string $unique The unique string. | |
| 450 | - * @param string $where The position to show the fields. | |
| 451 | - * @param string $parent If the fields has parent. | |
| 452 | - * @return void | |
| 453 | - */ | |
| 330 | + // | |
| 331 | + // Add a new framework field. | |
| 454 | 332 | public static function field( $field = array(), $value = '', $unique = '', $where = '', $parent = '' ) { |
| 455 | 333 | |
| 456 | 334 | // Check for unallow fields. |
| 457 | 335 | if ( ! empty( $field['_notice'] ) ) { |
| @@ -458,9 +336,9 @@ | ||
| 458 | 336 | |
| 459 | 337 | $field_type = $field['type']; |
| 460 | 338 | |
| 461 | 339 | $field = array(); |
| 462 | - $field['content'] = sprintf( esc_html__( 'Ooops! This field type (%s) can not be used here, yet.', 'post-carousel' ), '<strong>' . $field_type . '</strong>' ); | |
| 340 | + $field['content'] = sprintf( esc_html__( 'Ooops! This field type (%s) can not be used here, yet.', 'smart-post-show' ), '<strong>' . $field_type . '</strong>' ); | |
| 463 | 341 | $field['type'] = 'notice'; |
| 464 | 342 | $field['style'] = 'danger'; |
| 465 | 343 | |
| 466 | 344 | } |
| @@ -501,13 +379,13 @@ | ||
| 501 | 379 | } |
| 502 | 380 | |
| 503 | 381 | if ( ! empty( $field_type ) ) { |
| 504 | 382 | |
| 505 | - 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 . '>'; | |
| 506 | 384 | |
| 507 | 385 | if ( ! empty( $field['title'] ) ) { |
| 508 | 386 | $subtitle = ( ! empty( $field['subtitle'] ) ) ? '<p class="spf-text-subtitle">' . $field['subtitle'] . '</p>' : ''; |
| 509 | - 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>'; | |
| 510 | 388 | } |
| 511 | 389 | |
| 512 | 390 | echo ( ! empty( $field['title'] ) ) ? '<div class="spf-fieldset">' : ''; |
| 513 | 391 | |
| @@ -521,12 +399,12 @@ | ||
| 521 | 399 | if ( class_exists( $classname ) ) { |
| 522 | 400 | $instance = new $classname( $field, $value, $unique, $where, $parent ); |
| 523 | 401 | $instance->render(); |
| 524 | 402 | } else { |
| 525 | - echo '<p>' . esc_html__( 'This field class is not available!', 'post-carousel' ) . '</p>'; | |
| 403 | + echo '<p>' . esc_html__( 'This field class is not available!', 'smart-post-show' ) . '</p>'; | |
| 526 | 404 | } |
| 527 | 405 | } else { |
| 528 | - echo '<p>' . esc_html__( 'This type is not found!', 'post-carousel' ) . '</p>'; | |
| 406 | + echo '<p>' . esc_html__( 'This type is not found!', 'smart-post-show' ) . '</p>'; | |
| 529 | 407 | } |
| 530 | 408 | |
| 531 | 409 | echo ( ! empty( $field['title'] ) ) ? '</div>' : ''; |
| 532 | 410 | echo '<div class="clear"></div>'; |