/** * CommerceGurus functions and definitions * Maybe your best course would be to tread lightly. * * @package commercegurus */ function factorycommercegurus_getoption( $option, $fallback = false ) { global $factorycommercegurus_options; if ( $fallback == false ) { $fallback = ''; } $output = ( isset( $factorycommercegurus_options[$option] ) && $factorycommercegurus_options[$option] !== '' ) ? $factorycommercegurus_options[$option] : $fallback; return $output; } /** * Global Paths */ define( 'factorycommercegurus_FILEPATH', get_template_directory() ); define( 'factorycommercegurus_THEMEURI', get_template_directory_uri() ); define( 'factorycommercegurus_BOOTSTRAP_JS', get_template_directory_uri() . '/inc/core/bootstrap/dist/js' ); define( 'factorycommercegurus_JS', get_template_directory_uri() . '/js' ); define( 'factorycommercegurus_CORE', get_template_directory() . '/inc/core' ); /** * Constants for Plugins */ define( 'ULTIMATE_USE_BUILTIN', true ); /** * Load Globals */ require_once( factorycommercegurus_CORE . '/functions/javascript.php' ); require_once( factorycommercegurus_CORE . '/functions/get-the-image.php' ); require_once( factorycommercegurus_CORE . '/menus/wp_bootstrap_navwalker.php' ); require_once( factorycommercegurus_CORE . '/menus/megadropdown.php' ); /** * TGM Plugin Activation */ require_once ( factorycommercegurus_CORE . '/functions/class-tgm-plugin-activation.php' ); add_action( 'tgmpa_register', 'factorycommercegurus_register_required_plugins' ); function factorycommercegurus_register_required_plugins() { /** * Array of plugin arrays. Required keys are name and slug. * If the source is NOT from the .org repo, then source is also required. */ $plugins = array( array( 'name' => 'Advanced Custom Fields', // The plugin name 'slug' => 'advanced-custom-fields', // The plugin slug (typically the folder name) 'required' => true, // If false, the plugin is only 'recommended' instead of required ), array( 'name' => 'Advanced Sidebar Menu', // The plugin name 'slug' => 'advanced-sidebar-menu', // The plugin slug (typically the folder name) 'required' => false, // If false, the plugin is only 'recommended' instead of required ), array( 'name' => 'Redux Framework', // The plugin name 'slug' => 'redux-framework', // The plugin slug (typically the folder name) 'required' => true, // If false, the plugin is only 'recommended' instead of required ), array( 'name' => 'Layer Slider', // The plugin name 'slug' => 'LayerSlider', // The plugin slug (typically the folder name) 'source' => 'http://files.commercegurus.com/layersliderwp-6.2.2.installable.zip', // The plugin source 'required' => false, // If false, the plugin is only 'recommended' instead of required 'version' => '6.2.2', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins 'external_url' => '', // If set, overrides default API URL and points to an external URL ), array( 'name' => 'WPBakery Visual Composer', // The plugin name 'slug' => 'js_composer', // The plugin slug (typically the folder name) 'source' => 'http://files.commercegurus.com/js_composer_5.1/js_composer.zip', // The plugin source 'required' => false, // If false, the plugin is only 'recommended' instead of required 'version' => '5.1', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins 'external_url' => '', // If set, overrides default API URL and points to an external URL ), array( 'name' => 'CommerceGurus Toolkit', // The plugin name 'slug' => 'commercegurus-toolkit', // The plugin slug (typically the folder name) 'source' => get_template_directory_uri() . '/inc/plugins/commercegurus-toolkit.zip', // The plugin source 'required' => true, // If false, the plugin is only 'recommended' instead of required 'version' => '1.5', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins 'external_url' => '', // If set, overrides default API URL and points to an external URL ), array( 'name' => 'Contact Form 7', // The plugin name 'slug' => 'contact-form-7', // The plugin slug (typically the folder name) 'required' => false, // If false, the plugin is only 'recommended' instead of required ), array( 'name' => 'MailChimp for WordPress', // The plugin name 'slug' => 'mailchimp-for-wp', // The plugin slug (typically the folder name) 'required' => false, // If false, the plugin is only 'recommended' instead of required ), array( 'name' => 'Yoast SEO', // The plugin name 'slug' => 'wordpress-seo', // The plugin slug (typically the folder name) 'required' => false, // If false, the plugin is only 'recommended' instead of required ), array( 'name' => 'Widget CSS Classes', // The plugin name 'slug' => 'widget-css-classes', // The plugin slug (typically the folder name) 'required' => false, // If false, the plugin is only 'recommended' instead of required ), array( 'name' => 'WooSidebars', // The plugin name 'slug' => 'woosidebars', // The plugin slug (typically the folder name) 'required' => false, // If false, the plugin is only 'recommended' instead of required ) ); /** * Array of configuration settings. Amend each line as needed. * If you want the default strings to be available under your own theme domain, * leave the strings uncommented. * Some of the strings are added into a sprintf, so see the comments at the * end of each line for what each argument will be. */ $config = array( 'domain' => 'factory', // Text domain - likely want to be the same as your theme. 'default_path' => '', // Default absolute path to pre-packaged plugins 'parent_slug' => 'themes.php', // Default parent menu slug 'menu' => 'install-required-plugins', // Menu slug 'has_notices' => true, // Show admin notices or not 'is_automatic' => false, // Automatically activate plugins after installation or not 'message' => '', // Message to output right before the plugins table 'strings' => array( 'page_title' => esc_html__( 'Install Required Plugins', 'factory' ), 'menu_title' => esc_html__( 'Install Plugins', 'factory' ), 'installing' => esc_html__( 'Installing Plugin: %s', 'factory' ), // %1$s = plugin name 'oops' => esc_html__( 'Something went wrong with the plugin API.', 'factory' ), 'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.', 'factory' ), // %1$s = plugin name(s) 'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.', 'factory' ), // %1$s = plugin name(s) 'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.', 'factory' ), // %1$s = plugin name(s) 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.', 'factory' ), // %1$s = plugin name(s) 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'factory' ), // %1$s = plugin name(s) 'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.', 'factory' ), // %1$s = plugin name(s) 'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 'factory' ), // %1$s = plugin name(s) 'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.', 'factory' ), // %1$s = plugin name(s) 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'factory' ), 'activate_link' => _n_noop( 'Activate installed plugin', 'Activate installed plugins', 'factory' ), 'return' => esc_html__( 'Return to Required Plugins Installer', 'factory' ), 'plugin_activated' => esc_html__( 'Plugin activated successfully.', 'factory' ), 'complete' => esc_html__( 'All plugins installed and activated successfully. %s', 'factory' ), // %1$s = dashboard link 'nag_type' => 'updated' // Determines admin notice type - can only be 'updated' or 'error' ) ); tgmpa( $plugins, $config ); } /** * Demo Data Installer */ require get_template_directory() . '/inc/radium-one-click-demo-install/init.php'; /** * Live Preview */ if ( !defined( 'factorycommercegurus_LIVEDEMO' ) ) { define( 'factorycommercegurus_LIVEDEMO', false ); } function factorycommercegurus_is_live_demo() { if ( factorycommercegurus_LIVEDEMO ) { return true; } else { return false; } } if ( factorycommercegurus_is_live_demo() ) { add_action( 'after_setup_theme', 'factorycommercegurus_start_live_session', 1 ); add_action( 'wp_logout', 'factorycommercegurus_end_live_session' ); add_action( 'wp_login', 'factorycommercegurus_end_live_session' ); //start live session if ( !function_exists( 'factorycommercegurus_start_live_session' ) ) { function factorycommercegurus_start_live_session() { if ( !session_id() ) { session_start(); } } } //end live session if ( !function_exists( 'factorycommercegurus_end_live_session' ) ) { function factorycommercegurus_end_live_session() { session_destroy(); } } } /** * Load CSS */ function factorycommercegurus_load_styles() { $factorycommercegurus_responsive_status = ''; $factorycommercegurus_responsive_status = factorycommercegurus_getoption( 'factorycommercegurus_responsive' ); wp_register_style( 'bootstrap', get_template_directory_uri() . '/inc/core/bootstrap/dist/css/bootstrap.min.css' ); wp_register_style( 'cg-commercegurus', get_template_directory_uri() . '/css/commercegurus.css' ); if ( $factorycommercegurus_responsive_status !== 'disabled' ) { wp_register_style( 'cg-responsive', get_template_directory_uri() . '/css/responsive.css' ); } if ( $factorycommercegurus_responsive_status == 'disabled' ) { wp_register_style( 'cg-non-responsive', get_template_directory_uri() . '/css/non-responsive.css' ); } wp_enqueue_style( 'cg-style', get_stylesheet_uri() ); wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome/font-awesome.min.css' ); wp_enqueue_style( 'ionicons', get_template_directory_uri() . '/css/ionicons.css' ); wp_enqueue_style( 'animate', get_template_directory_uri() . '/css/animate.css' ); wp_enqueue_style( 'bootstrap' ); wp_enqueue_style( 'cg-commercegurus' ); if ( $factorycommercegurus_responsive_status !== 'disabled' ) { wp_enqueue_style( 'cg-responsive' ); } if ( $factorycommercegurus_responsive_status == 'disabled' ) { wp_enqueue_style( 'cg-non-responsive' ); } if ( factorycommercegurus_is_live_demo() ) { wp_enqueue_style( 'cg-livepreviewcss', get_template_directory_uri() . '/css/livepreview.css' ); } // skins $cg_skin_color = ''; $cg_skin_color = factorycommercegurus_getoption( 'factorycommercegurus_skin_color' ); if ( !empty( $_SESSION['factorycommercegurus_skin_color'] ) ) { $cg_skin_color = $_SESSION['factorycommercegurus_skin_color']; } if ( isset( $cg_skin_color ) ) { if ( $cg_skin_color !== 'none' ) { wp_enqueue_style( 'cg-cssskin', get_template_directory_uri() . '/css/skins/' . $cg_skin_color . '.css' ); } } } add_action( 'wp_enqueue_scripts', 'factorycommercegurus_load_styles' ); // Load css from theme options. require_once( factorycommercegurus_CORE . '/css/custom-css.php' ); /** * Maybe load js */ function factorycommercegurus_maybe_load_scripts() { $factorycommercegurus_sticky_menu = ''; $factorycommercegurus_display_search = ''; $factorycommercegurus_sticky_menu = factorycommercegurus_getoption( 'factorycommercegurus_sticky_menu' ); if ( $factorycommercegurus_sticky_menu == '1' ) { wp_enqueue_script( 'factorycommercegurus_scrollfix', factorycommercegurus_JS . '/src/cond/scrollfix.js', array( 'jquery' ), '', false ); } $factorycommercegurus_display_search = factorycommercegurus_getoption( 'factorycommercegurus_show_search' ); } add_action( 'wp_enqueue_scripts', 'factorycommercegurus_maybe_load_scripts' ); /** * Force Visual Composer to initialize as "built into the theme". This will hide certain tabs under the Settings->Visual Composer page */ if ( function_exists( 'vc_set_as_theme' ) ) { vc_set_as_theme( $disable_updater = true ); // Disable frontend editor by default - to re-enable just comment out the next line vc_disable_frontend(); } /* Disable VC auto-update */ function factorycommercegurus_vc_disable_update() { if (function_exists('vc_license') && function_exists('vc_updater') && ! vc_license()->isActivated()) { remove_filter( 'upgrader_pre_download', array( vc_updater(), 'preUpgradeFilter' ), 10); remove_filter( 'pre_set_site_transient_update_plugins', array( vc_updater()->updateManager(), 'check_update' ) ); } } add_action( 'admin_init', 'factorycommercegurus_vc_disable_update', 9 ); // Initialising Shortcodes if ( class_exists( 'WPBakeryVisualComposerAbstract' ) ) { function factorycommercegurus_requireVcExtend() { require_once locate_template( '/customvc/vc_extend.php' ); } add_action( 'init', 'factorycommercegurus_requireVcExtend', 2 ); // Set VC tpl override directory $vcdir = get_stylesheet_directory() . '/customvc/vc_templates/'; vc_set_shortcodes_templates_dir( $vcdir ); // Remove VC nag looking for key - CommerceGurus has an extended lic. if ( is_admin() ) { function factorycommercegurus_remove_vc_nag() { setcookie( 'vchideactivationmsg_vc11', ( defined( 'WPB_VC_VERSION' ) ? WPB_VC_VERSION : '1' ), strtotime( '+3 years' ), '/' ); } add_action( 'init', 'factorycommercegurus_remove_vc_nag' ); } add_action( 'vc_after_mapping', function(){ if( is_admin() ) $_COOKIE['vchideactivationmsg_vc11'] = 30; } ); } /** * Sets up theme defaults and registers support for various WordPress features. */ if ( !function_exists( 'factorycommercegurus_setup' ) ) : function factorycommercegurus_setup() { /** * Translations can be filed in the /languages/ directory * If you're building a theme based on a commercegurus theme, use a find and replace * to change 'factory' to the name of your theme in all the template files */ load_theme_textdomain( 'factory', get_template_directory() . '/languages' ); /** * Add default posts and comments RSS feed links to head */ add_theme_support( 'automatic-feed-links' ); /** * This theme uses wp_nav_menu() in one location. */ register_nav_menus( array( 'primary' => esc_html__( 'Primary Menu', 'factory' ), 'mobile' => esc_html__( 'Mobile Menu', 'factory' ), ) ); /** * Infinite Scroll Support via Jetpack */ function factorycommercegurus_infinite_scroll_supported() { return current_theme_supports( 'infinite-scroll' ) && ( is_home() || is_archive() || is_search() ) && ! ( is_post_type_archive( 'product' ) || is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ); } add_filter( 'infinite_scroll_archive_supported', 'factorycommercegurus_infinite_scroll_supported' ); add_theme_support( 'infinite-scroll', array( 'container' => 'primary', 'type' => 'click', 'footer' => 'page', ) ); /** * Custom Thumbnails */ if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); add_image_size( 'hp-latest-posts', 380, 250, true ); } /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded