????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.55 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/www.astacus.se/wp-content/themes/storefront/inc/admin/ |
Upload File : |
<?php
/**
* Storefront Plugin Install Class
*
* @author WooThemes
* @package storefront
* @since 2.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Storefront_Plugin_Install' ) ) :
/**
* The Storefront plugin install class
*/
class Storefront_Plugin_Install {
/**
* Setup class.
*
* @since 1.0
*/
public function __construct() {
add_action( 'admin_enqueue_scripts', array( $this, 'plugin_install_scripts' ) );
}
/**
* Load plugin install scripts
*
* @param string $hook_suffix the current page hook suffix.
* @return void
* @since 1.4.4
*/
public function plugin_install_scripts( $hook_suffix ) {
global $storefront_version;
wp_enqueue_script( 'storefront-plugin-install', get_template_directory_uri() . '/assets/js/admin/plugin-install.min.js', array( 'jquery', 'updates' ), $storefront_version, 'all' );
wp_enqueue_style( 'storefront-plugin-install', get_template_directory_uri() . '/assets/sass/admin/plugin-install.css', array(), $storefront_version, 'all' );
}
/**
* Output a button that will install or activate a plugin if it doesn't exist, or display a disabled button if the
* plugin is already activated.
*
* @param string $plugin_slug The plugin slug.
* @param string $plugin_file The plugin file.
*/
public static function install_plugin_button( $plugin_slug, $plugin_file, $plugin_name, $classes = array(), $activated = '', $activate = '', $install = '' ) {
if ( current_user_can( 'install_plugins' ) && current_user_can( 'activate_plugins' ) ) {
if ( is_plugin_active( $plugin_slug . '/' . $plugin_file ) ) {
// The plugin is already active
$button = array(
'message' => esc_attr__( 'Activated', 'storefront' ),
'url' => '#',
'classes' => array( 'storefront-button', 'disabled' ),
);
if ( '' !== $activated ) {
$button['message'] = esc_attr( $activated );
}
} elseif ( $url = self::_is_plugin_installed( $plugin_slug ) ) {
// The plugin exists but isn't activated yet.
$button = array(
'message' => esc_attr__( 'Activate', 'storefront' ),
'url' => $url,
'classes' => array( 'storefront-button', 'activate-now' ),
);
if ( '' !== $activate ) {
$button['message'] = esc_attr( $activate );
}
} else {
// The plugin doesn't exist.
$url = wp_nonce_url( add_query_arg( array(
'action' => 'install-plugin',
'plugin' => $plugin_slug,
), self_admin_url( 'update.php' ) ), 'install-plugin_' . $plugin_slug );
$button = array(
'message' => esc_attr__( 'Install now', 'storefront' ),
'url' => $url,
'classes' => array( 'storefront-button', 'sf-install-now', 'install-now', 'install-' . $plugin_slug ),
);
if ( '' !== $install ) {
$button['message'] = esc_attr( $install );
}
}
if ( ! empty( $classes ) ) {
$button['classes'] = array_merge( $button['classes'], $classes );
}
$button['classes'] = implode( ' ', $button['classes'] );
?>
<span class="sf-plugin-card plugin-card-<?php echo esc_attr( $plugin_slug ); ?>">
<a href="<?php echo esc_url( $button['url'] ); ?>" class="<?php echo esc_attr( $button['classes'] ); ?>" data-originaltext="<?php echo esc_attr( $button['message'] ); ?>" data-name="<?php echo esc_attr( $plugin_name ); ?>" data-slug="<?php echo esc_attr( $plugin_slug ); ?>" aria-label="<?php echo esc_attr( $button['message'] ); ?>"><?php echo esc_attr( $button['message'] ); ?></a>
</span>
<a href="https://wordpress.org/plugins/<?php echo esc_attr( $plugin_slug ); ?>" target="_blank"><?php esc_attr_e( 'Learn more', 'storefront' ); ?></a>
<?php
}
}
/**
* Check if a plugin is installed and return the url to activate it if so.
*
* @param string $plugin_slug The plugin slug.
*/
private static function _is_plugin_installed( $plugin_slug ) {
if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ) {
$plugins = get_plugins( '/' . $plugin_slug );
if ( ! empty( $plugins ) ) {
$keys = array_keys( $plugins );
$plugin_file = $plugin_slug . '/' . $keys[0];
$url = wp_nonce_url( add_query_arg( array(
'action' => 'activate',
'plugin' => $plugin_file,
), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_file );
return $url;
}
}
return false;
}
}
endif;
return new Storefront_Plugin_Install();