Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Sage includes
- *
- * The $sage_includes array determines the code library included in your theme.
- * Add or remove files to the array as needed. Supports child theme overrides.
- *
- * Please note that missing files will produce a fatal error.
- *
- * @link https://github.com/roots/sage/pull/1042
- */
- $sage_includes = [
- 'lib/assets.php', // Scripts and stylesheets
- 'lib/extras.php', // Custom functions
- 'lib/setup.php', // Theme setup
- 'lib/titles.php', // Page titles
- 'lib/wrapper.php', // Theme wrapper class
- 'lib/customizer.php' // Theme customizer
- ];
- foreach ($sage_includes as $file) {
- if (!$filepath = locate_template($file)) {
- trigger_error(sprintf(__('Error locating %s for inclusion', 'sage'), $file), E_USER_ERROR);
- }
- require_once $filepath;
- }
- unset($file, $filepath);
- //
- add_action('template_redirect', function () {
- if (is_user_logged_in() && !is_user_member_of_blog())
- die('Please ask the network administrator to get access to this blog.');
- });
- // Menus
- function register_my_menus_2()
- {
- register_nav_menus(
- array(
- 'pre-header-menu' => __('Pre Header Menu'),
- 'footer-menu-1' => __('Footer Menu 1'),
- 'footer-menu-2' => __('Footer Menu 2')
- )
- );
- }
- add_action('init', 'register_my_menus_2');
- // Function Includes
- require_once('faq-type.php');
- include_once 'function-invoice-packing-slips.php';
- include_once 'function-custom-search-filter.php';
- include_once 'function-acf-fields.php';
- //include_once 'function-woo-endpoints.php';
- include_once 'function-woo-general.php';
- function delete_warning_scripts()
- {
- global $wp;
- $current_url = explode("/", home_url(add_query_arg(array(), $wp->request)));
- if ($current_url[count($current_url) - 1] == 'edit.php' && $_GET['post_type'] == 'product') {
- // register your script location, dependencies and version
- wp_register_script('custom_script', get_template_directory_uri() . '/custom_js/delete_duplicate_warn_script.js', array('jquery'), '1.0');
- // enqueue the script
- wp_enqueue_script('custom_script');
- }
- }
- function add_my_custom_menu()
- {
- //add an item to the menu
- add_menu_page(
- 'Data Report',
- 'Data Report',
- 'manage_options',
- 'data_report.php',
- '',
- '',
- '105'
- );
- add_menu_page(
- 'Product Search',
- 'Product Search',
- 'manage_options',
- 'custom-search.php',
- '',
- '',
- '106'
- );
- add_menu_page(
- 'Clone Site',
- 'Clone Site',
- 'manage_options',
- 'clone_site.php',
- '',
- '',
- '104'
- );
- //add_menu_page('Data Report', 'Data Report', string $capability, string $menu_slug, callable $function = '', string $icon_url = '', int $position = null );
- //add submenu page for signup listings
- }
- add_action('admin_menu', 'add_my_custom_menu');
- add_action('admin_enqueue_scripts', 'delete_warning_scripts');
- add_action('wp_enqueue_scripts', 'bulk_discount_alert');
- function bulk_discount_alert()
- {
- if (is_product()) {
- $ss_url = get_stylesheet_directory_uri();
- wp_register_script('bulk_discount_alert', get_template_directory_uri() . '/custom_js/bulk_discount_alert.js', array('jquery'), '1.0');
- wp_enqueue_script('bulk_discount_alert', "{$ss_url}/custom_js/bulk_discount_alert.js");
- }
- }
- function v_forcelogin()
- {
- // Exceptions for AJAX, Cron, or WP-CLI requests
- if ((defined('DOING_AJAX') && DOING_AJAX) || (defined('DOING_CRON') && DOING_CRON) || (defined('WP_CLI') && WP_CLI)) {
- return;
- }
- // Redirect unauthorized visitors
- if (!is_user_logged_in()) {
- // Get URL
- $url = isset($_SERVER['HTTPS']) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http';
- $url .= '://' . $_SERVER['HTTP_HOST'];
- // port is prepopulated here sometimes
- if (strpos($_SERVER['HTTP_HOST'], ':') === false) {
- $url .= in_array($_SERVER['SERVER_PORT'], array('80', '443')) ? '' : ':' . $_SERVER['SERVER_PORT'];
- }
- $url .= $_SERVER['REQUEST_URI'];
- // Apply filters
- $bypass = apply_filters('v_forcelogin_bypass', false);
- $whitelist = apply_filters('v_forcelogin_whitelist', array());
- $redirect_url = apply_filters('v_forcelogin_redirect', $url);
- // Redirect
- if (preg_replace('/\?.*/', '', $url) != preg_replace('/\?.*/', '', wp_login_url()) && !in_array($url, $whitelist) && !$bypass) {
- wp_safe_redirect(wp_login_url($redirect_url), 302);
- exit();
- }
- } else {
- // Only allow Multisite users access to their assigned sites
- if (function_exists('is_multisite') && is_multisite()) {
- $current_user = wp_get_current_user();
- if (!is_user_member_of_blog($current_user->ID) && !is_super_admin())
- wp_die(__("You're not authorized to access this site.", 'wp-force-login'), get_option('blogname') . ' › ' . __("Error", 'wp-force-login'));
- }
- }
- }
- add_action('template_redirect', 'v_forcelogin');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement