wsp_localized_script(); wp_localize_script( 'wsp-main-script', 'wsp_obj', $localized_array ); } wp_register_style( 'wsp-style', SMART_PRELOADER_URL.'assets/css/wsp-smart-preload-style.css', false, SMART_PRELOADER_VERSION ); wp_enqueue_style( 'wsp-style' ); } /** * [wsp_add_class_body description] * @param [array] $classes [list of body classes] * @return [array] [list of body classes] */ public function wsp_add_class_body($classes){ $wsp = get_option( 'wsp-loader-opt' ); if( isset($wsp['homepage']) && $wsp['homepage'] == "1"){ if( is_home() || is_front_page() ) { $classes[] = 'wp-smart-body'; } } else { $classes[] = 'wp-smart-body'; } return $classes; } public function wsp_localized_script(){ $wsp = get_option( 'wsp-loader-opt' ); return $wsp; } public function wsp_custom_css_front(){ $wsp = get_option( 'wsp-loader-opt' ); $style = ''; echo $style; } public function wsp_add_submenu_option(){ add_submenu_page( 'options-general.php', // parent slug 'WP Smart Preloader', // page title 'WP Smart Preloader', // menu title 'manage_options', // capability 'wsp-loader', // menu slug array($this,'wsp_submenu_callback_fn') // Callback ); } /** * [wsp_submenu_callback_fn callback function of option page] */ public function wsp_submenu_callback_fn(){ // Set class property $this->options = get_option( 'wsp-loader-opt' ); ?>
"; $select .= ""; foreach($loader as $load){ $sel = ( isset( $this->options['loader'] ) && $this->options['loader'] == $load ) ? 'selected="selected"' : ''; $select .= ''; } $select .= "
Loading...
"; _e($select,"wp-smart-preloader"); } /** * setting function for home page */ public function wsp_preloader_homepage(){ printf(__('','wp-smart-preloader'),"wsp-loader-opt[homepage]",(isset($this->options['homepage']) && $this->options['homepage'] == "1")?'checked="checked"':'' ); } /** * setting function fadeout */ public function wsp_loader_fadeOut(){ printf(__('
%s
','wp-smart-preloader'),"wsp-loader-opt[fadeout]",(isset($this->options['fadeout']) )?$this->options['fadeout']:'',__('Default:2500
1 second => 1000',"wp-smart-preloader") ); } /** * setting function delay */ public function wsp_loader_delay(){ printf(__('
%s
','wp-smart-preloader'),"wsp-loader-opt[delay]",(isset($this->options['delay']) )?$this->options['delay']:'',__('Default:1500
1 second => 1000',"wp-smart-preloader") ); } /** * setting function custom css */ public function wsp_loader_custom_css(){ printf("Want to change Look and feel. Add your desired css here :)","wp-smart-preloader"); echo "
"; printf("Or add CSS for your Custom html5 animation :)","wp-smart-preloader"); echo "

"; printf(__('
','wp-smart-preloader'),"wsp-loader-opt[custom_css]",isset($this->options['custom_css'])? esc_attr( $this->options['custom_css'] ):'',"wsp-loader-opt[custom_css]" ); } public function wsp_custom_animation(){ printf("Want to add you own custom html5 animation? Enter your html code here.","wp-smart-preloader"); echo "

"; printf(__('
','wp-smart-preloader'),"wsp-loader-opt[custom_animation]",isset($this->options['custom_animation'])? esc_attr( $this->options['custom_animation'] ):'',"wsp-loader-opt[custom_animation]" ); } /** * [wsp_sanitize sanitize function for setting] */ public function wsp_sanitize( $input ){ foreach($input as $k => $v) { $newinput[$k] = trim($v); // Check the input is a letter or a number if(!preg_match('/^[A-Z0-9 _]*$/i', $v)) { $newinput[$k] = ''; } } return $input; } /** * [wsp_section_info function for section info] * @return [echo] [display info] */ public function wsp_section_info(){ _e('WP Smart Preloader Setting:','wp-smart-preloader'); } /** * [wsp_uninstall to delete options after uninstall] */ public function wsp_uninstall(){ delete_option( 'wsp-loader-opt' ); } } // if( is_admin() ){ $wp_smart_preloader = new WP_smart_preloader(); // }