Modularización de GKACHELE SaaS
This commit is contained in:
@@ -0,0 +1,298 @@
|
||||
<?php
|
||||
class abiz_Customizer_Notify_Section extends WP_Customize_Section {
|
||||
|
||||
public $type = 'abiz-customizer-notify-section';
|
||||
|
||||
public $recommended_actions = '';
|
||||
|
||||
public $recommended_plugins = '';
|
||||
|
||||
public $total_actions = '';
|
||||
|
||||
public $plugin_text = '';
|
||||
|
||||
public $dismiss_button = '';
|
||||
|
||||
|
||||
public function check_active( $slug ) {
|
||||
if ( file_exists( ABSPATH . 'wp-content/plugins/' . $slug . '/' . $slug . '.php' ) ) {
|
||||
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
|
||||
$needs = is_plugin_active( $slug . '/' . $slug . '.php' ) ? 'deactivate' : 'activate';
|
||||
|
||||
return array(
|
||||
'status' => is_plugin_active( $slug . '/' . $slug . '.php' ),
|
||||
'needs' => $needs,
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'status' => false,
|
||||
'needs' => 'install',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function create_action_link( $state, $slug ) {
|
||||
switch ( $state ) {
|
||||
case 'install':
|
||||
return wp_nonce_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'action' => 'install-plugin',
|
||||
'plugin' => $slug,
|
||||
),
|
||||
network_admin_url( 'update.php' )
|
||||
),
|
||||
'install-plugin_' . $slug
|
||||
);
|
||||
break;
|
||||
case 'deactivate':
|
||||
return add_query_arg(
|
||||
array(
|
||||
'action' => 'deactivate',
|
||||
'plugin' => rawurlencode( $slug . '/' . $slug . '.php' ),
|
||||
'plugin_status' => 'all',
|
||||
'paged' => '1',
|
||||
'_wpnonce' => wp_create_nonce( 'deactivate-plugin_' . $slug . '/' . $slug . '.php' ),
|
||||
), network_admin_url( 'plugins.php' )
|
||||
);
|
||||
break;
|
||||
case 'activate':
|
||||
return add_query_arg(
|
||||
array(
|
||||
'action' => 'activate',
|
||||
'plugin' => rawurlencode( $slug . '/' . $slug . '.php' ),
|
||||
'plugin_status' => 'all',
|
||||
'paged' => '1',
|
||||
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $slug . '/' . $slug . '.php' ),
|
||||
), network_admin_url( 'plugins.php' )
|
||||
);
|
||||
break;
|
||||
}// End switch().
|
||||
}
|
||||
|
||||
|
||||
public function call_plugin_api( $slug ) {
|
||||
include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
|
||||
$call_api = get_transient( 'abiz_cust_notify_plugin_info_' . $slug );
|
||||
if ( false === $call_api ) {
|
||||
$call_api = plugins_api(
|
||||
'plugin_information', array(
|
||||
'slug' => $slug,
|
||||
'fields' => array(
|
||||
'downloaded' => false,
|
||||
'rating' => false,
|
||||
'description' => false,
|
||||
'short_description' => true,
|
||||
'donate_link' => false,
|
||||
'tags' => false,
|
||||
'sections' => false,
|
||||
'homepage' => false,
|
||||
'added' => false,
|
||||
'last_updated' => false,
|
||||
'compatibility' => false,
|
||||
'tested' => false,
|
||||
'requires' => false,
|
||||
'downloadlink' => false,
|
||||
'icons' => false,
|
||||
),
|
||||
)
|
||||
);
|
||||
set_transient( 'abiz_cust_notify_plugin_info_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS );
|
||||
}
|
||||
|
||||
return $call_api;
|
||||
}
|
||||
|
||||
|
||||
public function json() {
|
||||
$json = parent::json();
|
||||
global $abiz_customizer_notify_recommended_actions;
|
||||
global $abiz_customizer_notify_recommended_plugins;
|
||||
|
||||
global $install_button_label;
|
||||
global $activate_button_label;
|
||||
global $abiz_deactivate_button_label;
|
||||
|
||||
$formatted_array = array();
|
||||
$abiz_customizer_notify_show_recommended_actions = get_option( 'abiz_customizer_notify_show' );
|
||||
foreach ( $abiz_customizer_notify_recommended_actions as $key => $abiz_lite_customizer_notify_recommended_action ) {
|
||||
if ( $abiz_customizer_notify_show_recommended_actions[ $abiz_lite_customizer_notify_recommended_action['id'] ] === false ) {
|
||||
continue;
|
||||
}
|
||||
if ( $abiz_lite_customizer_notify_recommended_action['check'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$abiz_lite_customizer_notify_recommended_action['index'] = $key + 1;
|
||||
|
||||
if ( isset( $abiz_lite_customizer_notify_recommended_action['plugin_slug'] ) ) {
|
||||
$active = $this->check_active( $abiz_customizer_notify_recommended_action['plugin_slug'] );
|
||||
$abiz_lite_customizer_notify_recommended_action['url'] = $this->create_action_link( $active['needs'], $abiz_lite_customizer_notify_recommended_action['plugin_slug'] );
|
||||
if ( $active['needs'] !== 'install' && $active['status'] ) {
|
||||
$abiz_lite_customizer_notify_recommended_action['class'] = 'active';
|
||||
} else {
|
||||
$abiz_lite_customizer_notify_recommended_action['class'] = '';
|
||||
}
|
||||
|
||||
switch ( $active['needs'] ) {
|
||||
case 'install':
|
||||
$abiz_lite_customizer_notify_recommended_action['button_class'] = 'install-now button';
|
||||
$abiz_lite_customizer_notify_recommended_action['button_label'] = $install_button_label;
|
||||
break;
|
||||
case 'activate':
|
||||
$abiz_lite_customizer_notify_recommended_action['button_class'] = 'activate-now button button-primary';
|
||||
$abiz_lite_customizer_notify_recommended_action['button_label'] = $activate_button_label;
|
||||
break;
|
||||
case 'deactivate':
|
||||
$abiz_lite_customizer_notify_recommended_action['button_class'] = 'deactivate-now button';
|
||||
$abiz_lite_customizer_notify_recommended_action['button_label'] = $abiz_deactivate_button_label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$formatted_array[] = $abiz_lite_customizer_notify_recommended_action;
|
||||
}// End foreach().
|
||||
|
||||
$customize_plugins = array();
|
||||
|
||||
$abiz_lite_customizer_notify_show_recommended_plugins = get_option( 'abiz_customizer_notify_show_recommended_plugins' );
|
||||
|
||||
foreach ( $abiz_customizer_notify_recommended_plugins as $slug => $abiz_plugin_opt ) {
|
||||
|
||||
if ( ! $abiz_plugin_opt['recommended'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $abiz_lite_customizer_notify_show_recommended_plugins[ $slug ] ) && $abiz_lite_customizer_notify_show_recommended_plugins[ $slug ] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$active = $this->check_active( $slug );
|
||||
|
||||
if ( ! empty( $active['needs'] ) && ( $active['needs'] == 'deactivate' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ti_customizer_notify_recommended_plugin['url'] = $this->create_action_link( $active['needs'], $slug );
|
||||
if ( $active['needs'] !== 'install' && $active['status'] ) {
|
||||
$ti_customizer_notify_recommended_plugin['class'] = 'active';
|
||||
} else {
|
||||
$ti_customizer_notify_recommended_plugin['class'] = '';
|
||||
}
|
||||
|
||||
switch ( $active['needs'] ) {
|
||||
case 'install':
|
||||
$ti_customizer_notify_recommended_plugin['button_class'] = 'install-now button';
|
||||
$ti_customizer_notify_recommended_plugin['button_label'] = $install_button_label;
|
||||
break;
|
||||
case 'activate':
|
||||
$ti_customizer_notify_recommended_plugin['button_class'] = 'activate-now button button-primary';
|
||||
$ti_customizer_notify_recommended_plugin['button_label'] = $activate_button_label;
|
||||
break;
|
||||
case 'deactivate':
|
||||
$ti_customizer_notify_recommended_plugin['button_class'] = 'deactivate-now button';
|
||||
$ti_customizer_notify_recommended_plugin['button_label'] = $abiz_deactivate_button_label;
|
||||
break;
|
||||
}
|
||||
$abiz_info = $this->call_plugin_api( $slug );
|
||||
$ti_customizer_notify_recommended_plugin['id'] = $slug;
|
||||
$ti_customizer_notify_recommended_plugin['plugin_slug'] = $slug;
|
||||
|
||||
if ( ! empty( $abiz_plugin_opt['description'] ) ) {
|
||||
$ti_customizer_notify_recommended_plugin['description'] = $abiz_plugin_opt['description'];
|
||||
} else {
|
||||
$ti_customizer_notify_recommended_plugin['description'] = $abiz_info->short_description;
|
||||
}
|
||||
|
||||
$ti_customizer_notify_recommended_plugin['title'] = $abiz_info->name;
|
||||
|
||||
$customize_plugins[] = $ti_customizer_notify_recommended_plugin;
|
||||
|
||||
}// End foreach().
|
||||
|
||||
$json['recommended_actions'] = $formatted_array;
|
||||
$json['recommended_plugins'] = $customize_plugins;
|
||||
$json['total_actions'] = count( $abiz_customizer_notify_recommended_actions );
|
||||
$json['plugin_text'] = $this->plugin_text;
|
||||
$json['dismiss_button'] = $this->dismiss_button;
|
||||
return $json;
|
||||
|
||||
}
|
||||
|
||||
protected function render_template() {
|
||||
?>
|
||||
<# if( data.recommended_actions.length > 0 || data.recommended_plugins.length > 0 ){ #>
|
||||
<li id="accordion-section-{{ data.id }}" class="accordion-section control-section control-section-{{ data.type }} cannot-expand">
|
||||
|
||||
<h3 class="accordion-section-title">
|
||||
<span class="section-title" data-plugin_text="{{ data.plugin_text }}">
|
||||
<# if( data.recommended_actions.length > 0 ){ #>
|
||||
{{ data.title }}
|
||||
<# }else{ #>
|
||||
<# if( data.recommended_plugins.length > 0 ){ #>
|
||||
{{ data.plugin_text }}
|
||||
<# }#>
|
||||
<# } #>
|
||||
</span>
|
||||
<# if( data.recommended_actions.length > 0 ){ #>
|
||||
<span class="abiz-customizer-plugin-notify-actions-count">
|
||||
<span class="current-index">{{ data.recommended_actions[0].index }}</span>
|
||||
{{ data.total_actions }}
|
||||
</span>
|
||||
<# } #>
|
||||
</h3>
|
||||
<div class="abiz-theme-recomended-actions_container" id="plugin-filter">
|
||||
<# if( data.recommended_actions.length > 0 ){ #>
|
||||
<# for (action in data.recommended_actions) { #>
|
||||
<div class="abiz-recommeded-actions-container epsilon-required-actions" data-index="{{ data.recommended_actions[action].index }}">
|
||||
<# if( !data.recommended_actions[action].check ){ #>
|
||||
<div class="abiz-epsilon-recommeded-actions">
|
||||
<p class="title">{{ data.recommended_actions[action].title }}</p>
|
||||
<span data-action="dismiss" class="dashicons dashicons-no abiz-customizer-notify-dismiss-recommended-action" id="{{ data.recommended_actions[action].id }}"></span>
|
||||
<div class="description">{{{ data.recommended_actions[action].description }}}</div>
|
||||
<# if( data.recommended_actions[action].plugin_slug ){ #>
|
||||
<div class="custom-action">
|
||||
<p class="plugin-card-{{ data.recommended_actions[action].plugin_slug }} action_button {{ data.recommended_actions[action].class }}">
|
||||
<a data-slug="{{ data.recommended_actions[action].plugin_slug }}" class="{{ data.recommended_actions[action].button_class }}" href="{{ data.recommended_actions[action].url }}">{{ data.recommended_actions[action].button_label }}</a>
|
||||
</p>
|
||||
</div>
|
||||
<# } #>
|
||||
<# if( data.recommended_actions[action].help ){ #>
|
||||
<div class="custom-action">{{{ data.recommended_actions[action].help }}}</div>
|
||||
<# } #>
|
||||
</div>
|
||||
<# } #>
|
||||
</div>
|
||||
<# } #>
|
||||
<# } #>
|
||||
|
||||
<# if( data.recommended_plugins.length > 0 ){ #>
|
||||
<# for (action in data.recommended_plugins) { #>
|
||||
<div class="abiz-recommeded-actions-container epsilon-recommended-plugins" data-index="{{ data.recommended_plugins[action].index }}">
|
||||
<# if( !data.recommended_plugins[action].check ){ #>
|
||||
<div class="abiz-epsilon-recommeded-actions">
|
||||
<p class="title">{{ data.recommended_plugins[action].title }}</p>
|
||||
<span data-action="dismiss" class="dashicons dashicons-no abiz-customizer-notify-dismiss-button-recommended-plugin" id="{{ data.recommended_plugins[action].id }}"></span>
|
||||
<div class="description">{{{ data.recommended_plugins[action].description }}}</div>
|
||||
<# if( data.recommended_plugins[action].plugin_slug ){ #>
|
||||
<div class="custom-action">
|
||||
<p class="plugin-card-{{ data.recommended_plugins[action].plugin_slug }} action_button {{ data.recommended_plugins[action].class }}">
|
||||
<a data-slug="{{ data.recommended_plugins[action].plugin_slug }}" class="{{ data.recommended_plugins[action].button_class }}" href="{{ data.recommended_plugins[action].url }}">{{ data.recommended_plugins[action].button_label }}</a>
|
||||
</p>
|
||||
</div>
|
||||
<# } #>
|
||||
<# if( data.recommended_plugins[action].help ){ #>
|
||||
<div class="custom-action">{{{ data.recommended_plugins[action].help }}}</div>
|
||||
<# } #>
|
||||
</div>
|
||||
<# } #>
|
||||
</div>
|
||||
<# } #>
|
||||
<# } #>
|
||||
</div>
|
||||
</li>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
class abiz_Customizer_Notify {
|
||||
|
||||
private $recommended_actions;
|
||||
|
||||
|
||||
private $recommended_plugins;
|
||||
|
||||
|
||||
private static $instance;
|
||||
|
||||
|
||||
private $recommended_actions_title;
|
||||
|
||||
|
||||
private $recommended_plugins_title;
|
||||
|
||||
|
||||
private $dismiss_button;
|
||||
|
||||
|
||||
private $install_button_label;
|
||||
|
||||
|
||||
private $activate_button_label;
|
||||
|
||||
|
||||
private $abiz_deactivate_button_label;
|
||||
|
||||
private $config;
|
||||
|
||||
public static function init( $config ) {
|
||||
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof abiz_Customizer_Notify ) ) {
|
||||
self::$instance = new abiz_Customizer_Notify();
|
||||
if ( ! empty( $config ) && is_array( $config ) ) {
|
||||
self::$instance->config = $config;
|
||||
self::$instance->setup_config();
|
||||
self::$instance->setup_actions();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function setup_config() {
|
||||
|
||||
global $abiz_customizer_notify_recommended_plugins;
|
||||
global $abiz_customizer_notify_recommended_actions;
|
||||
|
||||
global $install_button_label;
|
||||
global $activate_button_label;
|
||||
global $abiz_deactivate_button_label;
|
||||
|
||||
$this->recommended_actions = isset( $this->config['recommended_actions'] ) ? $this->config['recommended_actions'] : array();
|
||||
$this->recommended_plugins = isset( $this->config['recommended_plugins'] ) ? $this->config['recommended_plugins'] : array();
|
||||
|
||||
$this->recommended_actions_title = isset( $this->config['recommended_actions_title'] ) ? $this->config['recommended_actions_title'] : '';
|
||||
$this->recommended_plugins_title = isset( $this->config['recommended_plugins_title'] ) ? $this->config['recommended_plugins_title'] : '';
|
||||
$this->dismiss_button = isset( $this->config['dismiss_button'] ) ? $this->config['dismiss_button'] : '';
|
||||
|
||||
$abiz_customizer_notify_recommended_plugins = array();
|
||||
$abiz_customizer_notify_recommended_actions = array();
|
||||
|
||||
if ( isset( $this->recommended_plugins ) ) {
|
||||
$abiz_customizer_notify_recommended_plugins = $this->recommended_plugins;
|
||||
}
|
||||
|
||||
if ( isset( $this->recommended_actions ) ) {
|
||||
$abiz_customizer_notify_recommended_actions = $this->recommended_actions;
|
||||
}
|
||||
|
||||
$install_button_label = isset( $this->config['install_button_label'] ) ? $this->config['install_button_label'] : '';
|
||||
$activate_button_label = isset( $this->config['activate_button_label'] ) ? $this->config['activate_button_label'] : '';
|
||||
$abiz_deactivate_button_label = isset( $this->config['abiz_deactivate_button_label'] ) ? $this->config['abiz_deactivate_button_label'] : '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function setup_actions() {
|
||||
|
||||
// Register the section.
|
||||
add_action( 'customize_register', array( $this, 'abiz_plugin_notification_customize_register' ) );
|
||||
|
||||
// Enqueue scripts and styles.
|
||||
add_action( 'customize_controls_enqueue_scripts', array( $this, 'abiz_customizer_notify_scripts_for_customizer' ), 0 );
|
||||
|
||||
/* ajax callback for dismissable recommended actions */
|
||||
add_action( 'wp_ajax_abiz_customizer_notify_dismiss_action', array( $this, 'abiz_customizer_notify_dismiss_recommended_action_callback' ) );
|
||||
|
||||
add_action( 'wp_ajax_abiz_customizer_notify_dismiss_recommended_plugins', array( $this, 'abiz_customizer_notify_dismiss_recommended_plugins_callback' ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function abiz_customizer_notify_scripts_for_customizer() {
|
||||
|
||||
wp_enqueue_style( 'abiz-customizer-notify-css', get_template_directory_uri() . '/core/customizer/customizer-notice/css/abiz-customizer-notify.css', array() );
|
||||
|
||||
wp_enqueue_style( 'plugin-install' );
|
||||
wp_enqueue_script( 'plugin-install' );
|
||||
wp_add_inline_script( 'plugin-install', 'var pagenow = "customizer";' );
|
||||
|
||||
wp_enqueue_script( 'updates' );
|
||||
|
||||
wp_enqueue_script( 'abiz-customizer-notify-js', get_template_directory_uri() . '/core/customizer/customizer-notice/js/abiz-customizer-notify.js', array( 'customize-controls' ) );
|
||||
wp_localize_script(
|
||||
'abiz-customizer-notify-js',
|
||||
'abizCustomizercompanionObject',
|
||||
array(
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||
'template_directory' => get_template_directory_uri(),
|
||||
'base_path' => admin_url(),
|
||||
'activating_string' => __( 'Activating', 'abiz' ),
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function abiz_plugin_notification_customize_register( $wp_customize ) {
|
||||
|
||||
require_once get_template_directory() . '/core/customizer/customizer-notice/abiz-customizer-notify-section.php';
|
||||
|
||||
$wp_customize->register_section_type( 'abiz_Customizer_Notify_Section' );
|
||||
|
||||
$wp_customize->add_section(
|
||||
new abiz_Customizer_Notify_Section(
|
||||
$wp_customize,
|
||||
'abiz-customizer-notify-section',
|
||||
array(
|
||||
'title' => $this->recommended_actions_title,
|
||||
'plugin_text' => $this->recommended_plugins_title,
|
||||
'dismiss_button' => $this->dismiss_button,
|
||||
'priority' => 0,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function abiz_customizer_notify_dismiss_recommended_action_callback() {
|
||||
|
||||
global $abiz_customizer_notify_recommended_actions;
|
||||
|
||||
$action_id = ( isset( $_GET['id'] ) ) ? $_GET['id'] : 0;
|
||||
|
||||
echo esc_html($action_id);
|
||||
|
||||
if ( ! empty( $action_id ) ) {
|
||||
|
||||
if ( get_option( 'abiz_customizer_notify_show' ) ) {
|
||||
|
||||
$abiz_customizer_notify_show_recommended_actions = get_option( 'abiz_customizer_notify_show' );
|
||||
switch ( $_GET['todo'] ) {
|
||||
case 'add':
|
||||
$abiz_customizer_notify_show_recommended_actions[ $action_id ] = true;
|
||||
break;
|
||||
case 'dismiss':
|
||||
$abiz_customizer_notify_show_recommended_actions[ $action_id ] = false;
|
||||
break;
|
||||
}
|
||||
update_option( 'abiz_customizer_notify_show', $abiz_customizer_notify_show_recommended_actions );
|
||||
|
||||
} else {
|
||||
$abiz_customizer_notify_show_recommended_actions = array();
|
||||
if ( ! empty( $abiz_customizer_notify_recommended_actions ) ) {
|
||||
foreach ( $abiz_customizer_notify_recommended_actions as $abiz_lite_customizer_notify_recommended_action ) {
|
||||
if ( $abiz_lite_customizer_notify_recommended_action['id'] == $action_id ) {
|
||||
$abiz_customizer_notify_show_recommended_actions[ $abiz_lite_customizer_notify_recommended_action['id'] ] = false;
|
||||
} else {
|
||||
$abiz_customizer_notify_show_recommended_actions[ $abiz_lite_customizer_notify_recommended_action['id'] ] = true;
|
||||
}
|
||||
}
|
||||
update_option( 'abiz_customizer_notify_show', $abiz_customizer_notify_show_recommended_actions );
|
||||
}
|
||||
}
|
||||
}
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
public function abiz_customizer_notify_dismiss_recommended_plugins_callback() {
|
||||
|
||||
$action_id = ( isset( $_GET['id'] ) ) ? $_GET['id'] : 0;
|
||||
|
||||
echo esc_html($action_id);
|
||||
|
||||
if ( ! empty( $action_id ) ) {
|
||||
|
||||
$abiz_lite_customizer_notify_show_recommended_plugins = get_option( 'abiz_customizer_notify_show_recommended_plugins' );
|
||||
|
||||
switch ( $_GET['todo'] ) {
|
||||
case 'add':
|
||||
$abiz_lite_customizer_notify_show_recommended_plugins[ $action_id ] = false;
|
||||
break;
|
||||
case 'dismiss':
|
||||
$abiz_lite_customizer_notify_show_recommended_plugins[ $action_id ] = true;
|
||||
break;
|
||||
}
|
||||
update_option( 'abiz_customizer_notify_show_recommended_plugins', $abiz_lite_customizer_notify_show_recommended_plugins );
|
||||
}
|
||||
die();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
.abiz-customizer-plugin-notify-actions-count {
|
||||
display: inline-block;
|
||||
z-index: 26;
|
||||
margin: 1px 0 0 2px;
|
||||
padding: 0 6px;
|
||||
border-radius: 10px;
|
||||
color: #fff;
|
||||
background-color: #d54e21;
|
||||
font-size: 9px;
|
||||
font-weight: 600;
|
||||
line-height: 17px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
div.abiz-theme-recomended-actions_container {
|
||||
margin-bottom: 2em;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.abiz-theme-recomended-actions_container p.succes {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.abiz-epsilon-recommeded-actions p.title {
|
||||
margin-bottom: 0;
|
||||
color: #555d66;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.abiz-epsilon-recommeded-actions div.description {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.abiz-epsilon-recommeded-actions .custom-action {
|
||||
margin-top: 1em;
|
||||
padding-top: 1em;
|
||||
border-top: 1px solid #fafafa;
|
||||
}
|
||||
|
||||
.abiz-epsilon-recommeded-actions .custom-action p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.abiz-theme-recomended-actions_container .abiz-recommeded-actions-container:not(:first-child) {
|
||||
overflow: hidden;
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.abiz-theme-recomended-actions_container .abiz-recommeded-actions-container:first-child {
|
||||
height: auto;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.abiz-theme-recomended-actions_container .abiz-recommeded-actions-container {
|
||||
-webkit-transition: opacity 2s;
|
||||
/* Safari */
|
||||
transition: opacity 2s;
|
||||
}
|
||||
|
||||
.abiz-theme-recomended-actions_container .hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.abiz-customizer-plugin-notify-actions-count.complete {
|
||||
background-color: #79ba49;
|
||||
}
|
||||
|
||||
.abiz-theme-recomended-actions_container #demo_content .button {
|
||||
display: block;
|
||||
margin-bottom: 1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.abiz-theme-recomended-actions_container .succes a {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.abiz-theme-recomended-actions_container .succes a.social {
|
||||
width: 49%;
|
||||
margin-bottom: 1em;
|
||||
padding-top: 4px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.abiz-theme-recomended-actions_container .succes a.social span,
|
||||
.abiz-theme-recomended-actions_container .succes span {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.abiz-theme-recomended-actions_container .succes {
|
||||
padding-top: 4px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.abiz-customizer-notify-dismiss-button-recommended-plugin,
|
||||
.abiz-customizer-notify-dismiss-recommended-action {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
border-radius: 50%;
|
||||
color: #d54e21;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.abiz-epsilon-recommeded-actions {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.abiz-customizer-notify-dismiss-recommended-action,
|
||||
.abiz-epsilon-recommeded-actions .abiz-customizer-notify-dismiss-button-recommended-plugin {
|
||||
top: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.abiz-epsilon-recommeded-actions #temp_load {
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
-webkit-align-items: center;
|
||||
align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
}
|
||||
|
||||
.abiz-epsilon-recommeded-actions #temp_load img {
|
||||
margin: 0 auto;
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* Customizer notification system
|
||||
*/
|
||||
(function (api) {
|
||||
|
||||
api.sectionConstructor['abiz-customizer-notify-section'] = api.Section.extend(
|
||||
{
|
||||
|
||||
// No events for this type of section.
|
||||
attachEvents: function () {
|
||||
},
|
||||
|
||||
// Always make the section active.
|
||||
isContextuallyActive: function () {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
})( wp.customize );
|
||||
|
||||
jQuery( document ).ready(
|
||||
function () {
|
||||
|
||||
jQuery( '.abiz-customizer-notify-dismiss-recommended-action' ).click(
|
||||
function () {
|
||||
|
||||
var id = jQuery( this ).attr( 'id' ),
|
||||
action = jQuery( this ).attr( 'data-action' );
|
||||
jQuery.ajax(
|
||||
{
|
||||
type: 'GET',
|
||||
data: {action: 'abiz_customizer_notify_dismiss_action', id: id, todo: action},
|
||||
dataType: 'html',
|
||||
url: abizCustomizercompanionObject.ajaxurl,
|
||||
beforeSend: function () {
|
||||
jQuery( '#' + id ).parent().append( '<div id="temp_load" style="text-align:center"><img src="' + abizCustomizercompanionObject.base_path + '/images/spinner-2x.gif" /></div>' );
|
||||
},
|
||||
success: function (data) {
|
||||
var container = jQuery( '#' + data ).parent().parent();
|
||||
var index = container.next().data( 'index' );
|
||||
var recommended_sction = jQuery( '#accordion-section-ti_customizer_notify_recomended_actions' );
|
||||
var actions_count = recommended_sction.find( '.abiz-customizer-plugin-notify-actions-count' );
|
||||
var section_title = recommended_sction.find( '.section-title' );
|
||||
jQuery( '.abiz-customizer-plugin-notify-actions-count .current-index' ).text( index );
|
||||
container.slideToggle().remove();
|
||||
if (jQuery( '.abiz-theme-recomended-actions_container > .epsilon-recommended-actions' ).length === 0) {
|
||||
|
||||
actions_count.remove();
|
||||
|
||||
if (jQuery( '.abiz-theme-recomended-actions_container > .epsilon-recommended-plugins' ).length === 0) {
|
||||
jQuery( '.control-section-ti-customizer-notify-recomended-actions' ).remove();
|
||||
} else {
|
||||
section_title.text( section_title.data( 'plugin_text' ) );
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
console.log( jqXHR + ' :: ' + textStatus + ' :: ' + errorThrown );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
jQuery( '.abiz-customizer-notify-dismiss-button-recommended-plugin' ).click(
|
||||
function () {
|
||||
var id = jQuery( this ).attr( 'id' ),
|
||||
action = jQuery( this ).attr( 'data-action' );
|
||||
jQuery.ajax(
|
||||
{
|
||||
type: 'GET',
|
||||
data: {action: 'abiz_customizer_notify_dismiss_recommended_plugins', id: id, todo: action},
|
||||
dataType: 'html',
|
||||
url: abizCustomizercompanionObject.ajaxurl,
|
||||
beforeSend: function () {
|
||||
jQuery( '#' + id ).parent().append( '<div id="temp_load" style="text-align:center"><img src="' + abizCustomizercompanionObject.base_path + '/images/spinner-2x.gif" /></div>' );
|
||||
},
|
||||
success: function (data) {
|
||||
var container = jQuery( '#' + data ).parent().parent();
|
||||
var index = container.next().data( 'index' );
|
||||
jQuery( '.abiz-customizer-plugin-notify-actions-count .current-index' ).text( index );
|
||||
container.slideToggle().remove();
|
||||
|
||||
if (jQuery( '.abiz-theme-recomended-actions_container > .epsilon-recommended-plugins' ).length === 0) {
|
||||
jQuery( '.control-section-ti-customizer-notify-recomended-section' ).remove();
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
console.log( jqXHR + ' :: ' + textStatus + ' :: ' + errorThrown );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
// Remove activate button and replace with activation in progress button.
|
||||
jQuery( document ).on(
|
||||
'DOMNodeInserted','.activate-now', function () {
|
||||
var activateButton = jQuery( '.activate-now' );
|
||||
if (activateButton.length) {
|
||||
var url = jQuery( activateButton ).attr( 'href' );
|
||||
if (typeof url !== 'undefined') {
|
||||
// Request plugin activation.
|
||||
jQuery.ajax(
|
||||
{
|
||||
beforeSend: function () {
|
||||
jQuery( activateButton ).replaceWith( '<a class="button updating-message">' + abizCustomizercompanionObject.activating_string + '...</a>' );
|
||||
},
|
||||
async: true,
|
||||
type: 'GET',
|
||||
url: url,
|
||||
success: function () {
|
||||
// Reload the page.
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Remove activate button and replace with activation in progress button.
|
||||
*
|
||||
* @package abiz
|
||||
*/
|
||||
|
||||
|
||||
jQuery( document ).ready(
|
||||
function ($) {
|
||||
$( 'body' ).on(
|
||||
'click', ' .abiz-install-plugin ', function () {
|
||||
var slug = $( this ).attr( 'data-slug' );
|
||||
|
||||
wp.updates.installPlugin(
|
||||
{
|
||||
slug: slug
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
$( '.activate-now' ).on(
|
||||
'click', function (e) {
|
||||
|
||||
var activateButton = $( this );
|
||||
e.preventDefault();
|
||||
if ($( activateButton ).length) {
|
||||
var url = $( activateButton ).attr( 'href' );
|
||||
|
||||
if (typeof url !== 'undefined') {
|
||||
// Request plugin activation.
|
||||
$.ajax(
|
||||
{
|
||||
beforeSend: function () {
|
||||
$( activateButton ).replaceWith( '<a class="button updating-message">'+"activating"+'...</a>' );
|
||||
},
|
||||
async: true,
|
||||
type: 'GET',
|
||||
url: url,
|
||||
success: function () {
|
||||
// Reload the page.
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user