load_upgrade(); $this->load_customize(); add_action('wp', array($this, 'load_front')); add_action('admin_menu', array($this, 'admin_menu')); add_filter('plugin_action_links_' . LOFTLOADER_NAME, array($this, 'plugin_action_links')); } /** * For LoftLoader customize, load the customize related functions */ function load_upgrade(){ require_once LOFTLOADER_ROOT . 'inc/class-loftloader-upgrade.php'; } /** * For LoftLoader upgrade, load the upgrade related functions */ function load_customize(){ require_once LOFTLOADER_ROOT . 'inc/class-loftloader-customize.php'; } /** * For LoftLoader front, load the front end related functions */ function load_front(){ require_once LOFTLOADER_ROOT . 'inc/class-loftloader-front.php'; } /** * Add new setting link to loftloader */ function plugin_action_links($links){ $customize_url = $this->get_customize_uri(); $action_links = array( 'settings' => '' . esc_html__('Settings', 'loftloader') . '' ); return array_merge($action_links, $links); } /** * Add an admin menu for loftloader */ function admin_menu(){ global $submenu; $customize_url = $this->get_customize_uri(); $submenu['options-general.php'][] = array(esc_html__('LoftLoader Lite', 'loftloader'), 'manage_options', $customize_url, 'hide-if-no-customize'); } /** * Helper function to get loftloader customize url * @return url loftloader customize uri */ function get_customize_uri(){ return add_query_arg(array('return' => urlencode(wp_unslash( $_SERVER['REQUEST_URI'])), 'plugin' => 'loftloader-lite'), 'customize.php'); } } // Init loftloader lite add_action('after_setup_theme', 'loftloader_init'); function loftloader_init(){ if(!class_exists('LoftLoaderPro')){ new LoftLoader(); } } add_action('plugins_loaded', 'loftloader_any_page'); function loftloader_any_page(){ $enable_any_page = get_option('loftloader_enable_any_page', ''); if($enable_any_page === 'on'){ require_once LOFTLOADER_ROOT . 'inc/class-loftloader-any-page.php'; } } // Remove widget panels add_filter('customize_loaded_components', 'loftloader_remove_widget_panels', 1000, 2); function loftloader_remove_widget_panels($components, $manager){ if(!class_exists('LoftLoaderPro') && loftloader_is_customize($manager)){ foreach($components as $i => $c){ if(false !== $i){ unset($components[$i]); } } } return $components; } /** * Helper function to test on loftloader customize page * * @return boolean */ function loftloader_is_customize($manager = false){ global $wp_customize; $customize = empty($manager) ? $wp_customize : $manager; return (($customize instanceof WP_Customize_Manager) && ((isset($_GET['plugin']) && ($_GET['plugin'] === 'loftloader-lite')) || ($customize->is_preview() && !is_admin()))) || defined('DOING_AJAX'); } }