tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); /* * Enable support for Post Thumbnails on posts and pages. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support( 'post-thumbnails' ); // This theme uses wp_nav_menu() in two locations. register_nav_menus( array( 'primary' => __( 'Primary Menu', 'popularfx' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script', ) ); // Add theme support for selective refresh for widgets. add_theme_support( 'customize-selective-refresh-widgets' ); /** * Add support for core custom logo. * * @link https://codex.wordpress.org/Theme_Logo */ add_theme_support( 'custom-logo', array( 'height' => 250, 'width' => 250, 'flex-width' => true, 'flex-height' => true, ) ); global $pagelayer, $popularfx; if(!empty($pagelayer->settings)){ $pagelayer->template_call_sidebar = 1; } // Show promos popularfx_promos(); $template = get_theme_mod('popularfx_template'); if(empty($template)){ // Set up the WordPress core custom background feature. add_theme_support('custom-background', apply_filters( 'popularfx_custom_background_args', array( 'default-color' => 'ffffff', 'default-image' => '', ) ) ); add_theme_support( 'custom-header', apply_filters( 'popularfx_custom_header_args', array( 'default-image' => '', 'default-text-color' => '000000', 'width' => 1000, 'height' => 250, 'flex-height' => true, 'wp-head-callback' => 'popularfx_header_style', ) ) ); } } } add_action( 'after_setup_theme', 'popularfx_setup' ); /** * Set the content width in pixels, based on the theme's design and stylesheet. * * Priority 0 to make it available to lower priority callbacks. * * @global int $content_width */ function popularfx_content_width() { // This variable is intended to be overruled from themes. // Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}. // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound $GLOBALS['content_width'] = apply_filters( 'popularfx_content_width', 640 ); } // Backward compat function popularfx_copyright(){ return popularfx_theme_credits(); } // Show credit of our theme function popularfx_theme_credits(){ return ''.__('PopularFX Theme', 'popularfx').''; } // Shows the promos function popularfx_promos(){ if(is_admin() && current_user_can('install_themes')){ // Show the promo popularfx_maybe_promo([ 'after' => 1,// In days 'interval' => 30,// In days 'pro_url' => esc_url(POPULARFX_PRO_URL), 'rating' => esc_url('https://wordpress.org/themes/popularfx/#reviews'), 'twitter' => esc_url('https://twitter.com/PopularFXthemes?status=').rawurlencode('I love #PopularFX Theme by @pagelayer team for my #WordPress site - '.esc_url(home_url())), 'facebook' => esc_url('https://facebook.com/popularfx'), 'website' => esc_url(POPULARFX_WWW_URL), 'image' => POPULARFX_URL.'/images/popularfx-logo.png', 'name' => 'popularfx_show_promo' ]); $template = get_theme_mod('popularfx_template'); if(empty($template)){ // Show the image promo popularfx_maybe_promo([ 'after' => 0,// In days 'interval' => 30,// In days 'pro_url' => esc_url(POPULARFX_PRO_URL), 'rating' => esc_url('https://wordpress.org/themes/popularfx/#reviews'), 'twitter' => esc_url('https://twitter.com/PopularFXthemes?status=').rawurlencode('I love #PopularFX Theme by @pagelayer team for my #WordPress site - '.esc_url(home_url())), 'facebook' => esc_url('https://facebook.com/popularfx'), 'website' => esc_url(POPULARFX_WWW_URL), 'image' => POPULARFX_URL.'/images/popularfx-logo.png', 'name' => 'popularfx_templates_promo' ]); } //delete_option('popularfx_templates_promo'); } } add_action( 'after_switch_theme', 'popularfx_promos', 10 ); /** * Register widget area. * * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar */ function popularfx_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Sidebar', 'popularfx' ), 'id' => 'sidebar-1', 'description' => esc_html__( 'Add widgets here.', 'popularfx' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'popularfx_widgets_init' ); /** * Enqueue scripts and styles. */ function popularfx_scripts() { $template = get_theme_mod('popularfx_template'); if(!empty($template)){ wp_enqueue_style( 'popularfx-style', get_stylesheet_directory_uri().'/templates/'.$template.'/style.css', array(), POPULARFX_VERSION ); wp_enqueue_style( 'popularfx-sidebar', get_stylesheet_directory_uri().'/sidebar.css', array(), POPULARFX_VERSION ); }else{ wp_enqueue_style( 'popularfx-style', get_stylesheet_uri(), array(), POPULARFX_VERSION ); wp_style_add_data( 'popularfx-style', 'rtl', 'replace' ); } wp_enqueue_script( 'popularfx-navigation', get_stylesheet_directory_uri() . '/js/navigation.js', array(), POPULARFX_VERSION, true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'popularfx_scripts' ); function popularfx_the_title($before = '', $after = '', $echo = true){ if(is_page()){ return; } the_title($before, $after, $echo); } // Show the templates promo function popularfx_templates_promo(){ global $popularfx_promo_opts, $popularfx; $opts = $popularfx_promo_opts['popularfx_templates_promo']; echo '
Dismiss
'.__('Did you know PopularFX comes with 500+ Templates to design your website. Click to choose your template !', 'popularfx').'

'.(empty($opts['pro_url']) || !empty($popularfx['license']) ? '' : ''.__('Buy PopularFX Pro', 'popularfx').'').' '.(empty($opts['rating']) ? '' : ''.__('Rate it 5★\'s', 'popularfx').'').' '.(empty($opts['facebook']) ? '' : ' '.__('Facebook', 'popularfx').'').' '.(empty($opts['twitter']) ? '' : ' '.__('Tweet', 'popularfx').'').' '.(empty($opts['website']) ? '' : ''.__('Visit our website', 'popularfx').'').'

'; } // Show promo notice on dashboard function popularfx_show_promo($opts = []){ global $popularfx_promo_opts, $popularfx; $opts = $popularfx_promo_opts['popularfx_show_promo']; echo '
'; if(!empty($opts['image'])){ echo ''; } echo '

'.sprintf( __('We are glad you are using %1$s to build your website. We really appreciate it !
We would like to request you to give us a 5 Star rating on %2$s.
It will greatly boost our motivation !', 'popularfx'), 'PopularFX', 'WordPress.org').'

'.(empty($opts['pro_url']) || !empty($popularfx['license']) ? '' : ''.__('Buy PopularFX Pro', 'popularfx').'').' '.(empty($opts['rating']) ? '' : ''.__('Rate it 5★\'s', 'popularfx').'').' '.(empty($opts['facebook']) ? '' : ' '.__('Facebook', 'popularfx').'').' '.(empty($opts['twitter']) ? '' : ' '.__('Tweet', 'popularfx').'').' '.(empty($opts['website']) ? '' : ''.__('Visit our website', 'popularfx').'').'

'.(empty($opts['pro_url']) || !empty($popularfx['license']) ? '' : '

'.sprintf( __('%1$s has many more features like 500+ Website %2$s Templates %3$s, 90+ widgets, 500+ sections, Theme Builder, WooCommerce Builder, Theme Creator and Exporter, Form Builder, Popup Builder, etc. You get a Pagelayer Pro license with the PopularFX Pro version.', 'popularfx'), 'PopularFX Pro', '', '').'

').'
'; echo '
'.__('Dismiss', 'popularfx').'


'.__('Install from 500+ Website Templates', 'popularfx').'
'; } // Are we to show a promo ? function popularfx_maybe_promo($opts){ global $popularfx_promo_opts; // There must be an interval if(empty($opts['interval'])){ return false; } // Are we to show a promo $opt_name = empty($opts['name']) ? 'popularfx_show_promo' : $opts['name']; $func = empty($opts['name']) ? $opt_name : $opts['name']; $promo_time = get_theme_mod($opt_name); //echo $opt_name.' - '.$func.' - '.date('Ymd', $promo_time).'
'; // First time access if(empty($promo_time)){ set_theme_mod($opt_name, time() + (!empty($opts['after']) ? $opts['after'] * 86400 : 0)); $promo_time = get_theme_mod($opt_name); } // Is there interval elapsed if(time() >= $promo_time){ $popularfx_promo_opts[$opt_name] = $opts; add_action('admin_notices', $func); } // Are we to disable the promo if(isset($_GET[$opt_name]) && (int)$_GET[$opt_name] == 0){ set_theme_mod($opt_name, time() + ($opts['interval'] * 86400)); die('DONE'); } } // Check if a field is posted via POST else return default value function popularfx_optpost($name, $default = ''){ if(!empty($_POST[$name])){ return popularfx_inputsec(popularfx_htmlizer(trim($_POST[$name]))); } return $default; } function popularfx_inputsec($string){ $string = addslashes($string); // This is to replace ` which can cause the command to be executed in exec() $string = str_replace('`', '\`', $string); return $string; } function popularfx_htmlizer($string){ $string = htmlentities($string, ENT_QUOTES, 'UTF-8'); preg_match_all('/(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)/', $string, $matches);//r_print($matches); foreach($matches[1] as $mk => $mv){ $tmp_m = popularfx_entity_check($matches[2][$mk]); $string = str_replace($matches[1][$mk], $tmp_m, $string); } return $string; } function popularfx_entity_check($string){ //Convert Hexadecimal to Decimal $num = ((substr($string, 0, 1) === 'x') ? hexdec(substr($string, 1)) : (int) $string); //Squares and Spaces - return nothing $string = (($num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num < 0x20) ? '' : '&#'.$num.';'); return $string; } if ( ! function_exists( 'popularfx_header_style' ) ) : /** * Styles the header image and text displayed on the blog. * * @see popularfx_custom_header_setup(). */ function popularfx_header_style() { $header_text_color = get_header_textcolor(); /* * If no custom options for text are set, let's bail. * get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: add_theme_support( 'custom-header' ). */ if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) { return; } // If we get this far, we have custom styles. Let's do this. ?>