芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/www/lupusm.pulsehost.co.uk/wp-content/themes/outgrid/inc/plugin-activation.php
1, 'message' => esc_html__( 'No Slug Found', 'outgrid' ) ) ); } $json = array(); // send back some json we use to hit up TGM $plugins = uicore_get_plugins(); foreach ( $plugins as $plugin ) { if ( $_POST['slug'] == $plugin['slug'] ) { $json = array( 'url' => admin_url( 'themes.php?page=tgmpa-install-plugins' ), 'plugin' => array( $plugin['slug'] ), 'tgmpa-page' => 'tgmpa-install-plugins', 'plugin_status' => 'all', '_wpnonce' => wp_create_nonce( 'bulk-plugins' ), 'action' => 'tgmpa-bulk-install', 'action2' => - 1, 'message' => esc_html__( 'Installing...', 'outgrid' ), ); break; } } if ( $json ) { wp_send_json( $json ); } exit; } add_action( 'wp_ajax_uicore_plugins', 'uicore_ajax_plugins' ); function uicore_get_plugins(){ return array( // This is an example of how to include a plugin bundled with a theme. array( 'name' => 'UiCore Framework', // The plugin name. 'slug' => 'uicore-framework', // The plugin slug (typically the folder name). 'source' => 'uicore-framework.zip', // The plugin source. 'required' => true, // If false, the plugin is only 'recommended' instead of required. 'version' => UICORE_FRAMEWORK_VERSION, // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. '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. 'is_callable' => '', // If set, this callable will be be checked for availability to determine if a plugin is active. ), array( 'name' => 'UiCore Elements', // The plugin name. 'slug' => 'uicore-elements', // The plugin slug (typically the folder name). 'required' => true, // If false, the plugin is only 'recommended' instead of required.// E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. ), // This is an example of how to include a plugin bundled with a theme. array( 'name' => 'Elementor', // The plugin name. 'slug' => 'elementor', // The plugin slug (typically the folder name). 'required' => true, // If false, the plugin is only 'recommended' instead of required. ), array( 'name' => 'UiCore Animate', // The plugin name. 'slug' => 'uicore-animate', // The plugin slug (typically the folder name). 'required' => true, // If false, the plugin is only 'recommended' instead of required. ), // This is an example of how to include a plugin bundled with a theme. array( 'name' => 'Element Pack', // The plugin name. 'slug' => 'bdthemes-element-pack', // The plugin slug (typically the folder name). 'required' => true, // If false, the plugin is only 'recommended' instead of required. 'version' => '5.7.4', 'source' => 'bdthemes-element-pack.zip' // The plugin source. ), ); } require_once get_template_directory() . '/inc/class-tgm-plugin-activation.php'; if (!function_exists('uicore_plugins_activation')) : function uicore_plugins_activation() { $plugins = uicore_get_plugins(); $config = array( 'id' => 'outgrid', // Unique ID for hashing notices for multiple instances of TGMPA. 'default_path' => get_template_directory() . "/inc/plugins/", // Default absolute path to bundled plugins. 'menu' => 'tgmpa-install-plugins', // Menu slug. 'has_notices' => true, // Show admin notices or not. 'dismissable' => true, // If false, a user cannot dismiss the nag message. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. 'is_automatic' => true, // Automatically activate plugins after installation or not. 'message' => '', // Message to output right before the plugins table. 'strings' => array( 'page_title' => esc_attr__( 'Install Recommended Plugins', 'outgrid' ), 'menu_title' => esc_attr__( 'Install Plugins', 'outgrid' ) ) ); tgmpa($plugins, $config); } endif; add_action('tgmpa_register', 'uicore_plugins_activation'); /** * Get plugin activate link * * @return string Activate plugin link */ function uicore_get_plugin_activation_link( $plugin_base_name, $slug, $plugin_filename ) { $activate_nonce = wp_create_nonce( 'activate-plugin_' . $slug .'/'. $plugin_filename ); return self_admin_url( 'plugins.php?_wpnonce=' . $activate_nonce . '&action=activate&plugin='. str_replace( '/', '%2F', $plugin_base_name ) ); } /** * Get install link * * @param string $plugin_slug The plugin slug * * @return string Install plugin link */ function uicore_get_plugin_install_link( $plugin_slug ){ // sanitize the plugin slug $plugin_slug = esc_attr( $plugin_slug ); $install_link = wp_nonce_url( add_query_arg( array( 'action' => 'install-plugin', 'plugin' => $plugin_slug, ), network_admin_url( 'update.php' ) ), 'install-plugin_' . $plugin_slug ); return $install_link; } /** * Creates and returns attributes for a dom * * @param array $attrs List of attributes and their values * * @return string HTML attribute string */ function uicore_make_html_attributes( $attrs = array() ){ if( ! is_array( $attrs ) ){ return ''; } $attributes_string = ''; foreach ( $attrs as $attr => $value ) { $value = is_array( $value ) ? join( ' ', array_unique( $value ) ) : $value; $attributes_string .= sprintf( '%s="%s" ', $attr, esc_attr( trim( $value ) ) ); } return $attributes_string; } /** * Display a notice for installing theme core plugin * * @return void */ function uicore_plugin_notice(){ if ( get_transient( 'uicore-fw-notice_' . UICORE_THEME_NAME ) ) { return; } if( class_exists( '\Elementor\Plugin' ) && class_exists( '\UiCore\Core' ) && class_exists( '\ElementPack\Admin' ) ){ return; } $plugins_base_name = array( 'uicore-elements/plugin.php', 'uicore-animate/plugin.php', 'uicore-framework/plugin.php', 'elementor/elementor.php', 'bdthemes-element-pack/bdthemes-element-pack.php' ); $plugins_slug = array( 'uicore-elements', 'uicore-animate', 'uicore-framework', 'elementor', 'bdthemes-element-pack' ); $plugins_filename = array( 'plugin.php', 'plugin.php', 'plugin.php', 'elementor.php', 'bdthemes-element-pack.php' ); $plugins_title = array( __('UiCore Elements', 'outgrid'), __('UiCore Animate', 'outgrid'), __('UiCore Framework', 'outgrid'), __('Elementor','outgrid'), __('Element Pack','outgrid') ); // Classess to check if plugins are active or not $class_check = array( '\UiCoreElements\Base', '\UiCoreAnimate\Base', '\UiCore\Core', '\Elementor\Plugin', '\ElementPack\Admin' ); $installed_plugins = get_plugins(); // find required plugins which is not installed or active $not_installed_or_activated_plugins_id = array(); foreach ( $plugins_base_name as $key => $plugin_base_name ) { if( ! isset( $installed_plugins[ $plugin_base_name ] ) || ! class_exists( $class_check[$key] ) ){ $not_installed_or_activated_plugins_id[] = $key; } } // get information of required plugins which is not installed or not activated foreach ( $not_installed_or_activated_plugins_id as $key => $value ) { $not_installed_plugins_number = count( $not_installed_or_activated_plugins_id ); $progress_text = $not_installed_plugins_number > 1 ? ( $key + 1 ). " / {$not_installed_plugins_number}" : ""; $progress_text_and_title = $progress_text . ' - ' .$plugins_title[ $value ]; $links_attrs[$key] = array( 'data-plugin-slug' => $plugins_slug[$value], 'data-activating-label' => sprintf( esc_attr__( 'Activating %s', 'outgrid' ), $progress_text_and_title ), 'data-installing-label' => sprintf( esc_attr__( 'Installing %s', 'outgrid' ), $progress_text_and_title ), 'data-activate-label' => sprintf( esc_attr__( 'Activate %s' , 'outgrid' ), $progress_text_and_title ), 'data-install-label' => sprintf( esc_attr__( 'Install %s' , 'outgrid' ), $progress_text_and_title ), 'data-activate-url' => uicore_get_plugin_activation_link( $plugins_base_name[$value], $plugins_slug[$value], $plugins_filename[$value] ), 'data-install-url' => uicore_get_plugin_install_link( $plugins_slug[$value] ), 'data-redirect-url' => self_admin_url('admin.php?page=uicore#/'), 'data-num-of-required-plugins' => $not_installed_plugins_number, 'data-plugin-order' => $key + 1, 'data-wpnonce' => wp_create_nonce( 'uicore_setup_nonce' ) ); if( ! isset( $installed_plugins[ $plugins_base_name[$value] ] ) ){ $links_attrs[$key]['data-action'] = 'install'; $links_attrs[$key]['href'] = $links_attrs[ $key ]['data-install-url']; $links_attrs[$key]['button_label'] = sprintf( esc_html__( 'Install %s', 'outgrid' ), $progress_text_and_title ); } elseif( ! class_exists( $class_check[ $value ] ) ) { $links_attrs[$key]['data-action'] = 'activate'; $links_attrs[$key]['href'] = $links_attrs[ $key ]['data-activate-url']; $links_attrs[$key]['button_label'] = sprintf( esc_html__( 'Activate %s', 'outgrid' ), $progress_text_and_title ); } } ?>
Install Required Plugins