',
];
}
} elseif ( $item['premium'] && ! Avada()->registration->is_registered() ) {
$disable_class = ' disabled avada-no-token';
}
// We need to display the 'Install' hover link.
if ( ! isset( $installed_plugins[ $item['file_path'] ] ) ) {
if ( ! $disable_class ) {
$url = esc_url(
wp_nonce_url(
add_query_arg(
[
'page' => rawurlencode( Avada_TGM_Plugin_Activation::$instance->menu ),
'plugin' => rawurlencode( $item['slug'] ),
'plugin_name' => rawurlencode( $item['sanitized_plugin'] ),
'tgmpa-install' => 'install-plugin',
'return_url' => 'fusion_plugins',
],
Avada_TGM_Plugin_Activation::$instance->get_tgmpa_url()
),
'tgmpa-install',
'tgmpa-nonce'
)
);
} else {
$url = '#';
}
if ( $fusion_builder_action ) {
$actions = $fusion_builder_action;
} else {
$actions = [
/* translators: Plugin name. */
'install' => '' . esc_attr__( 'Install', 'Avada' ) . '',
];
}
} elseif ( is_plugin_inactive( $item['file_path'] ) ) {
// We need to display the 'Activate' hover link.
$url = esc_url(
add_query_arg(
[
'plugin' => rawurlencode( $item['slug'] ),
'plugin_name' => rawurlencode( $item['sanitized_plugin'] ),
'avada-activate' => 'activate-plugin',
'avada-activate-nonce' => wp_create_nonce( 'avada-activate' ),
],
admin_url( 'admin.php?page=avada-plugins' )
)
);
$actions = [
/* translators: Plugin Name. */
'activate' => '' . esc_attr__( 'Activate', 'Avada' ) . '',
];
} elseif ( version_compare( $installed_plugins[ $item['file_path'] ]['Version'], $item['version'], '<' ) ) {
$disable_class = '';
// We need to display the 'Update' hover link.
$url = wp_nonce_url(
add_query_arg(
[
'page' => rawurlencode( Avada_TGM_Plugin_Activation::$instance->menu ),
'plugin' => rawurlencode( $item['slug'] ),
'tgmpa-update' => 'update-plugin',
'version' => rawurlencode( $item['version'] ),
'return_url' => 'fusion_plugins',
],
Avada_TGM_Plugin_Activation::$instance->get_tgmpa_url()
),
'tgmpa-update',
'tgmpa-nonce'
);
if ( 'fusion-core' !== $item['slug'] && 'fusion-builder' !== $item['slug'] && $item['premium'] && ! Avada()->registration->is_registered() ) {
$disable_class = ' disabled avada-no-token';
}
$actions = [
/* translators: Plugin Name. */
'update' => '' . esc_attr__( 'Update', 'Avada' ) . '',
];
} elseif ( fusion_is_plugin_activated( $item['file_path'] ) ) {
$url = esc_url(
add_query_arg(
[
'plugin' => rawurlencode( $item['slug'] ),
'plugin_name' => rawurlencode( $item['sanitized_plugin'] ),
'avada-deactivate' => 'deactivate-plugin',
'avada-deactivate-nonce' => wp_create_nonce( 'avada-deactivate' ),
],
admin_url( 'admin.php?page=avada-plugins' )
)
);
$actions = [
/* translators: Plugin name. */
'deactivate' => '' . esc_attr__( 'Deactivate', 'Avada' ) . '',
];
}
return $actions;
}
/**
* Needed in order to enable TGMP in AJAX call.
*
* @access public
* @since 5.0
* @param bool $load Whether TGMP should be inited or not.
* @return bool
*/
public function enable_tgmpa( $load ) {
return true;
}
/**
* Removes install link for Avada Builder, if Avada Core was not updated to 3.0
*
* @since 5.0.0
* @param array $action_links The action link(s) for a required plugin.
* @param string $item_slug The slug of a required plugin.
* @param array $item Data belonging to a required plugin.
* @param string $view_context Specifying the kind of action (install, activate, update).
* @return array The action link(s) for a required plugin.
*/
public function edit_tgmpa_action_links( $action_links, $item_slug, $item, $view_context ) {
if ( 'fusion-builder' === $item_slug && 'install' === $view_context ) {
$fusion_core_version = Avada_TGM_Plugin_Activation::$instance->get_installed_version( Avada_TGM_Plugin_Activation::$instance->plugins['fusion-core']['slug'] );
if ( version_compare( $fusion_core_version, '3.0', '<' ) ) {
$action_links['install'] = '' . esc_attr__( 'Avada Builder will be installable, once Avada Core plugin is updated.', 'Avada' ) . '' . esc_attr__( 'Avada Builder', 'Avada' ) . '';
}
}
return $action_links;
}
/**
* Removes install link for Avada Builder, if Avada Core was not updated to 3.0
*
* @since 5.0.0
* @param array $action_links The action link(s) for a required plugin.
* @return array The action link(s) for a required plugin.
*/
public function edit_tgmpa_notice_action_links( $action_links ) {
$fusion_core_version = Avada_TGM_Plugin_Activation::$instance->get_installed_version( Avada_TGM_Plugin_Activation::$instance->plugins['fusion-core']['slug'] );
$current_screen = get_current_screen();
if ( 'avada_page_avada-plugins' === $current_screen->id ) {
$link_template = '' . esc_attr__( 'Manage Plugins Below', 'Avada' ) . '';
$action_links = [
'install' => $link_template,
];
} elseif ( version_compare( $fusion_core_version, '3.0', '<' ) ) {
$link_template = '' . esc_attr__( 'Go Manage Plugins', 'Avada' ) . '';
$action_links = [
'install' => $link_template,
];
}
return $action_links;
}
/**
* Initialize the permalink settings.
*
* @since 3.9.2
*/
public function init_permalink_settings() {
add_settings_field(
'avada_portfolio_category_slug', // ID.
esc_attr__( 'Avada portfolio category base', 'Avada' ), // Setting title.
[ $this, 'permalink_slug_input' ], // Display callback.
'permalink', // Settings page.
'optional', // Settings section.
[
'taxonomy' => 'portfolio_category',
] // Args.
);
add_settings_field(
'avada_portfolio_skills_slug',
esc_attr__( 'Avada portfolio skill base', 'Avada' ),
[ $this, 'permalink_slug_input' ],
'permalink',
'optional',
[
'taxonomy' => 'portfolio_skills',
]
);
add_settings_field(
'avada_portfolio_tag_slug',
esc_attr__( 'Avada portfolio tag base', 'Avada' ),
[ $this, 'permalink_slug_input' ],
'permalink',
'optional',
[
'taxonomy' => 'portfolio_tags',
]
);
}
/**
* Show a slug input box.
*
* @since 3.9.2
* @access public
* @param array $args The argument.
*/
public function permalink_slug_input( $args ) {
$permalinks = get_option( 'avada_permalinks' );
$permalink_base = $args['taxonomy'] . '_base';
$input_name = 'avada_' . $args['taxonomy'] . '_slug';
$placeholder = $args['taxonomy'];
?>
registration->is_registered() ) {
$license_status = Avada()->remote_install->validate_envato_hosted_subscription_code();
$registration_args = Avada()->registration->get_args();
$product_id = sanitize_key( $registration_args['name'] );
$registration_array = [
$product_id => $license_status,
'scopes' => [],
];
update_option( 'fusion_registered', $registration_array );
$registration_array = [
$product_id => [
'token' => SUBSCRIPTION_CODE,
],
];
update_option( 'fusion_registration', $registration_array );
}
}
/**
* Sets the theme version.
*
* @since 5.0.0
*
* @access public
* @return void
*/
public function set_theme_version() {
$this->theme_version = Avada()->get_normalized_theme_version();
}
/**
* Sets the WP_Object for the theme.
*
* @since 5.0.0
*
* @access public
* @return void
*/
public function set_theme_object() {
$theme_object = wp_get_theme();
if ( $theme_object->parent_theme ) {
$template_dir = basename( Avada::$template_dir_path );
$theme_object = wp_get_theme( $template_dir );
}
$this->theme_object = $theme_object;
}
/**
* Override some LayerSlider data.
*
* @since 5.0.5
* @access public
* @return void
*/
public function layerslider_overrides() {
// Disable auto-updates.
$GLOBALS['lsAutoUpdateBox'] = false;
}
/**
* Add custom rules to Facebook instant articles plugin.
*
* @since 5.1
* @access public
* @param object $transformers The transformers object from the Facebook Instant Articles plugin.
* @return object
*/
public function add_instant_article_rules( $transformers ) {
$selectors_pass = [ 'fusion-fullwidth', 'fusion-builder-row', 'fusion-layout-column', 'fusion-column-wrapper', 'fusion-title', 'fusion-imageframe', 'imageframe-align-center', 'fusion-checklist', 'fusion-li-item', 'fusion-li-item-content' ];
$selectors_ignore = [ 'fusion-column-inner-bg-image', 'fusion-clearfix', 'title-sep-container', 'fusion-sep-clear', 'fusion-separator' ];
$avada_rules = '{ "rules" : [';
foreach ( $selectors_pass as $selector ) {
$avada_rules .= '{ "class": "PassThroughRule", "selector" : "div.' . $selector . '" },';
}
foreach ( $selectors_ignore as $selector ) {
$avada_rules .= '{ "class": "IgnoreRule", "selector" : "div.' . $selector . '" },';
}
$avada_rules = trim( $avada_rules, ',' ) . ']}';
$transformers->loadRules( $avada_rules );
return $transformers;
}
/**
* Returns an array of strings that will be used by avada-admin.js for translations.
*
* @access private
* @since 5.2
* @return array
*/
private function get_admin_script_l10n_strings() {
return [
'content' => esc_attr__( 'Content', 'Avada' ),
'modify' => esc_attr__( 'Modify', 'Avada' ),
'full_import' => esc_attr__( 'Full Import', 'Avada' ),
'partial_import' => esc_attr__( 'Partial Import', 'Avada' ),
'import' => esc_attr__( 'Import', 'Avada' ),
'download' => esc_attr__( 'Download', 'Avada' ),
'classic' => __( 'Importing demo content will give you sliders, pages, posts, theme options, widgets, sidebars and other settings. This will replicate the live demo. Clicking this option will replace your current theme options and widgets. It can also take a minute to complete.
REQUIREMENTS:
• Memory Limit of 256 MB and max execution time (php time limit) of 300 seconds.
• Slider Revolution and LayerSlider must be activated for sliders to import.
• Avada Core must be activated for Avada Slider, portfolio and FAQs to be imported.
• Avada Builder must be activated for page content to display as intended.', 'Avada' ),
'caffe' => __( 'Importing demo content will give you sliders, pages, posts, theme options, widgets, sidebars and other settings. This will replicate the live demo. Clicking this option will replace your current theme options and widgets. It can also take a minute to complete.
REQUIREMENTS:
• Memory Limit of 128 MB and max execution time (php time limit) of 180 seconds.
• Avada Core must be activated for sliders, portfolios and FAQs to import.
• Contact Form 7 plugin must be activated for the form to import.
• Avada Builder must be activated for page content to display as intended.', 'Avada' ),
'church' => __( 'Importing demo content will give you sliders, pages, posts, theme options, widgets, sidebars and other settings. This will replicate the live demo. Clicking this option will replace your current theme options and widgets. It can also take a minute to complete.
REQUIREMENTS:
• Memory Limit of 128 MB and max execution time (php time limit) of 180 seconds.
• Avada Core must be activated for sliders, portfolios and FAQs to import.
• The Events Calendar Plugin must be activated for all event data to import.
• Contact Form 7 plugin must be activated for the form to import.
• Avada Builder must be activated for page content to display as intended.', 'Avada' ),
'modern_shop' => __( 'Importing demo content will give you sliders, pages, posts, theme options, widgets, sidebars and other settings. This will replicate the live demo. Clicking this option will replace your current theme options and widgets. It can also take a minute to complete.
REQUIREMENTS:
• Memory Limit of 128 MB and max execution time (php time limit) of 180 seconds.
• Avada Core must be activated for sliders, portfolios and FAQs to import.
• WooCommerce must be activated for all shop data to import.
• Contact Form 7 plugin must be activated for the form to import.
• Avada Builder must be activated for page content to display as intended.', 'Avada' ),
'classic_shop' => __( 'Importing demo content will give you sliders, pages, posts, theme options, widgets, sidebars and other settings. This will replicate the live demo. Clicking this option will replace your current theme options and widgets. It can also take a minute to complete.
REQUIREMENTS:
• Memory Limit of 128 MB and max execution time (php time limit) of 180 seconds.
• Slider Revolution must be activated for sliders to import.
• Avada Core must be activated for Avada Slider, portfolio and FAQs to be imported.
• WooCommerce must be activated for all shop data to import.
• Contact Form 7 plugin must be activated for the form to import.
• Avada Builder must be activated for page content to display as intended.', 'Avada' ),
'landing_product' => __( 'Importing demo content will give you sliders, pages, posts, theme options, widgets, sidebars and other settings. This will replicate the live demo. Clicking this option will replace your current theme options and widgets. It can also take a minute to complete.
REQUIREMENTS:
• Memory Limit of 128 MB and max execution time (php time limit) of 180 seconds.
• Slider Revolution must be activated for sliders to import.
• Avada Core must be activated for Avada Slider, portfolio and FAQs to be imported.
• WooCommerce must be activated for all shop data to import.
• Avada Builder must be activated for page content to display as intended.', 'Avada' ),
'forum' => __( 'Importing demo content will give you sliders, pages, posts, theme options, widgets, sidebars and other settings. This will replicate the live demo. Clicking this option will replace your current theme options and widgets. It can also take a minute to complete.
REQUIREMENTS:
• Memory Limit of 128 MB and max execution time (php time limit) of 180 seconds.
• Avada Core must be activated for sliders, portfolios and FAQs to import.
• bbPress must be activated for all forum data to import.
• Contact Form 7 plugin must be activated for the form to import.
• Avada Builder must be activated for page content to display as intended.', 'Avada' ),
'technology' => __( 'Importing demo content will give you sliders, pages, posts, theme options, widgets, sidebars and other settings. This will replicate the live demo. Clicking this option will replace your current theme options and widgets. It can also take a minute to complete.
REQUIREMENTS:
• Memory Limit of 256 MB and max execution time (php time limit) of 300 seconds.
• Avada Core and LayerSlider must be activated for sliders to import.
• Contact Form 7 plugin must be activated for the form to import.
• Avada Builder must be activated for page content to display as intended.', 'Avada' ),
'creative' => __( 'Importing demo content will give you sliders, pages, posts, theme options, widgets, sidebars and other settings. This will replicate the live demo. Clicking this option will replace your current theme options and widgets. It can also take a minute to complete.
REQUIREMENTS:
• Memory Limit of 128 MB and max execution time (php time limit) of 180 seconds.
• Slider Revolution must be activated for sliders to import.
• Contact Form 7 plugin must be activated for the form to import.
• Avada Core must be activated for Avada Slider, portfolio and FAQs to be imported.
• Avada Builder must be activated for page content to display as intended.', 'Avada' ),
'default' => __( 'Importing demo content will give you sliders, pages, posts, theme options, widgets, sidebars and other settings. This will replicate the live demo. Clicking this option will replace your current theme options and widgets. It can also take a minute to complete.
REQUIREMENTS:
• Memory Limit of 128 MB and max execution time (php time limit) of 180 seconds.
• Avada Core must be activated for sliders, portfolios and FAQs to import.
• Contact Form 7 plugin must be activated for the form to import.
• Avada Builder must be activated for page content to display as intended.', 'Avada' ),
/* translators: The current step label. */
'currently_processing' => esc_attr__( 'Currently Processing: %s', 'Avada' ),
/* translators: The current step label. */
'currently_removing' => esc_attr__( 'Currently Removing: %s', 'Avada' ),
'file_does_not_exist' => esc_attr__( 'The file does not exist', 'Avada' ),
/* translators: URL. */
'error_timeout' => wp_kses_post( sprintf( __( 'Demo server couldn\'t be reached. Please check for wp_remote_get on the Status page.', 'Avada' ), admin_url( 'admin.php?page=avada-status' ) ) ),
/* translators: URL. */
'error_php_limits' => wp_kses_post( sprintf( __( 'Demo import failed. Please check for PHP limits in red on the Status page. Change those to the recommended value and try again.', 'Avada' ), admin_url( 'admin.php?page=avada-status' ) ) ),
'remove_demo' => esc_attr__( 'Removing demo content will remove ALL previously imported demo content from this demo and restore your site to the previous state it was in before this demo content was imported.', 'Avada' ),
'update_fc' => __( 'Avada Builder Plugin can only be installed and activated if Avada Core plugin is at version 3.0 or higher. Please update Avada Core first.', 'Avada' ),
/* translators: URL. */
'register_first' => sprintf( __( 'This plugin can only be installed or updated, after you have successfully completed the Avada product registration on the Dashboard Welcome tab.', 'Avada' ), admin_url( 'admin.php?page=avada#avada-db-registration' ) ),
'plugin_install_failed' => __( 'Plugin install failed. Please try Again.', 'Avada' ),
'plugin_active' => __( 'Active', 'Avada' ),
'please_wait' => esc_html__( 'Please wait, this may take a minute...', 'Avada' ),
];
}
/**
* Add meta boxes to taxonomies
*
* @access public
* @since 3.1.1
* @return void
*/
public function avada_taxonomy_meta() {
global $pagenow;
if ( ! ( 'term.php' === $pagenow || 'edit-tags.php' === $pagenow || ( fusion_doing_ajax() && ! empty( $_REQUEST['action'] ) && 'add-tag' === $_REQUEST['action'] ) ) ) { // phpcs:ignore WordPress.Security
return;
}
// Get array of available sliders.
$sliders_array = avada_get_available_sliders_array();
// Include Tax meta class.
include_once Avada::$template_dir_path . '/includes/class-avada-taxonomy-meta.php';
// Where to add meta fields.
$args = [
'screens' => apply_filters( 'fusion_tax_meta_allowed_screens', [ 'category', 'portfolio_category', 'faq_category', 'product_cat', 'tribe_events_cat', 'post_tag', 'portfolio_tags', 'product_tag', 'topic-tag', 'portfolio_skills' ] ),
];
// Init taxonomy meta boxes.
$avada_meta = new Avada_Taxonomy_Meta( $args );
$options = $avada_meta::avada_taxonomy_map();
if ( isset( $options['taxonomy_options']['fields'] ) ) {
foreach ( $options['taxonomy_options']['fields'] as $field ) {
// Defaults.
$field['id'] = isset( $field['id'] ) ? $field['id'] : '';
$field['label'] = isset( $field['label'] ) ? $field['label'] : '';
$field['choices'] = isset( $field['choices'] ) ? $field['choices'] : [];
$field['description'] = isset( $field['description'] ) ? $field['description'] : '';
$field['default'] = isset( $field['default'] ) ? $field['default'] : '';
$field['dependency'] = isset( $field['dependency'] ) ? $field['dependency'] : [];
$field['class'] = isset( $field['class'] ) ? $field['class'] : '';
switch ( $field['type'] ) {
case 'header':
$args = [
'value' => $field['label'],
'class' => $field['class'],
];
$avada_meta->header( $field['id'], $args );
break;
case 'select':
$args = [
'name' => $field['label'],
'default' => $field['default'],
'class' => $field['class'],
'desc' => $field['description'],
'dependency' => $field['dependency'],
];
$avada_meta->select( $field['id'], $field['choices'], $args );
break;
case 'radio-buttonset':
$args = [
'name' => $field['label'],
'default' => $field['default'],
'class' => $field['class'],
'desc' => $field['description'],
'dependency' => $field['dependency'],
];
$avada_meta->buttonset( $field['id'], $field['choices'], $args );
break;
case 'text':
$args = [
'name' => $field['label'],
'class' => $field['class'],
'desc' => $field['description'],
'dependency' => $field['dependency'],
];
$avada_meta->text( $field['id'], $args );
break;
case 'dimensions':
$args = [
'name' => $field['label'],
'class' => $field['class'],
'desc' => $field['description'],
'dependency' => $field['dependency'],
'default' => $field['value'],
];
$avada_meta->dimensions( $field['id'], $args );
break;
case 'color-alpha':
$args = [
'name' => $field['label'],
'class' => $field['class'],
'desc' => $field['description'],
'default' => $field['default'],
'dependency' => $field['dependency'],
];
$avada_meta->colorpicker( $field['id'], $args );
break;
case 'media_url':
case 'media':
$args = [
'name' => $field['label'],
'class' => $field['class'],
'desc' => $field['description'],
'dependency' => $field['dependency'],
];
$avada_meta->image( $field['id'], $args );
break;
}
}
}
}
/**
* Handles an ajax request for the plugins page.
*
* @access public
* @since 6.1
* @return void
*/
public function ajax_plugins_manager() {
// These are not the droids you're looking for.
if ( ! isset( $_POST['action'] ) || 'avada_ajax_plugin_manager' !== $_POST['action'] || ! isset( $_POST['actionToDo'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
return;
}
/**
* There's no reason for security checks here.
* This method simply pings a URL and gets the result,
* so it's the same as entering the URL in the browser.
*
* All we need is the sanity check below to make sure the user can activate plugins.
* More checks are performed in the native WP functions.
*/
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
switch ( $_POST['actionToDo'] ) { // phpcs:ignore WordPress.Security.NonceVerification
/**
* Plugin install.
*
* @uses wp_ajax_install_plugin function.
* @uses plugins_api_result filter.
*/
case 'install-plugin':
// Set nonce.
$_REQUEST['_ajax_nonce'] = wp_create_nonce( 'updates' );
// Add a filter to hijack the URL.
add_filter( 'plugins_api_result', [ $this, 'hijack_plugins_api' ], 10, 3 );
// Perform the installation. This will automatically return the correct JSON response.
wp_ajax_install_plugin();
break;
/**
* Plugin Update.
*
* @uses wp_ajax_update_plugin function.
*/
case 'update-plugin':
// Set nonce.
$_REQUEST['_ajax_nonce'] = wp_create_nonce( 'updates' );
// Add a filter to hijack the URL.
add_filter( 'site_transient_update_plugins', [ $this, 'hijack_plugins_transient_api' ] );
// Perform the update. This will automatically return the correct JSON response.
wp_ajax_update_plugin();
break;
/**
* Refresh the template.
*/
case 'refresh-container':
// Get the contents of the plugins page wrapper.
ob_start();
include get_template_directory() . '/includes/admin-screens/plugins.php';
wp_send_json_success( ob_get_clean() );
break;
}
wp_die();
}
/**
* Hijack the plugins API to provide our own custom response for AJAX installers.
*
* @access public
* @since 6.1
* @param object $value The transient value.
* @return object
*/
public function hijack_plugins_transient_api( $value ) {
// Sanity check: make sure response exists.
if ( ! is_object( $value ) || ! isset( $value->response ) ) {
return $value;
}
// These are not the droids you're looking for.
if ( isset( $_POST['pluginPath'] ) && isset( $_POST['slug'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
$plugin_path = sanitize_text_field( wp_unslash( $_POST['pluginPath'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
$plugin_slug = sanitize_text_field( wp_unslash( $_POST['slug'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
// Get the plugin name.
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_path );
$plugin_name = $plugin_data['Name'];
if ( ! isset( $value->response[ $plugin_path ] ) ) {
$value->response[ $plugin_path ] = new stdClass();
$value->response[ $plugin_path ]->slug = $plugin_slug;
$value->response[ $plugin_path ]->plugin = $plugin_path;
}
// Set the package URL.
$value->response[ $plugin_path ]->package = Avada()->remote_install->get_package( $plugin_name );
}
// Return the value.
return $value;
}
/**
* Hijack the plugins API to provide our own custom response for AJAX installers.
*
* @access public
* @since 6.1
* @param object|WP_Error $res Response object or WP_Error.
* @param string $action The type of information being requested from the Plugin Installation API.
* @param object $args Plugin API arguments.
* @return object
*/
public function hijack_plugins_api( $res, $action, $args ) {
// Sanity check: Only hijack relevant responses IF they err.
if ( 'plugin_information' !== $action || ! is_wp_error( $res ) ) {
return $res;
}
// Make sure arguments is an array.
$args = (array) $args;
// Get the plugin info.
$custom_plugins = Avada_TGM_Plugin_Activation::$instance->plugins;
$plugin_located = false;
foreach ( $custom_plugins as $slug => $plugin ) {
$plugin = (array) $plugin;
if ( ! isset( $plugin['slug'] ) || ! isset( $args['slug'] ) ) {
continue;
}
if ( strtolower( $slug ) === strtolower( $args['slug'] ) || strtolower( $plugin['slug'] ) === strtolower( $args['slug'] ) ) {
$plugin_located = $plugin;
break;
}
}
// If we successfully got the plugin info, change the response object.
if ( $plugin_located ) {
$res = new stdClass();
$res->name = $plugin_located['name'];
$res->slug = $plugin_located['slug'];
$res->version = $plugin_located['version'];
$res->download_link = Avada()->remote_install->get_package( $plugin_located['name'] );
}
// Return response.
return $res;
}
/**
* Set data from updates server.
*
* @static
* @since 7.0.2
* @param bool $is_update Set to true to get the update video. Defaults to false.
* @return void
*/
public static function set_dashboard_data( $is_update ) {
$api_url = 'https://updates.theme-fusion.com/?action=get-data';
if ( $is_update ) {
$api_url .= '&version=' . AVADA_VERSION;
}
$transient_name = 'avada_dashboard_data';
$cached = get_site_transient( $transient_name );
if ( $cached ) {
self::$dashboard_data = $cached;
} else {
// Get remote server response.
$response = wp_remote_get(
$api_url,
[
'user-agent' => 'avada-user-agent',
]
);
// Check for error.
if ( ! is_wp_error( $response ) ) {
// Parse response.
$data = wp_remote_retrieve_body( $response );
// Check for error.
if ( ! is_wp_error( $data ) ) {
self::$dashboard_data = json_decode( $data, true );
}
}
set_site_transient( $transient_name, self::$dashboard_data, HOUR_IN_SECONDS );
}
}
/**
* Get data from updates server.
*
* @static
* @since 7.0.2
* @return array The data from server.
*/
public static function get_dashboard_data() {
return self::$dashboard_data;
}
/**
* Gets the dashboard-screen video URL.
*
* @static
* @access public
* @since 6.2.0
* @return string Returns a URL.
*/
public static function get_dashboard_screen_video_url() {
// Fallback values.
$video_url = 'https://www.youtube.com/watch?v=Y5k5UMgOpXs?rel=0';
if ( isset( self::$dashboard_data['video-url'] ) ) {
$video_url = self::$dashboard_data['video-url'];
}
if ( false !== strpos( $video_url, 'https://www.youtube.com/watch?v=' ) ) {
$video_url = str_replace( [ 'https://www.youtube.com/watch?v=', '?rel=0' ], [ 'https://www.youtube.com/embed/', '' ], $video_url ) . '?rel=0';
}
return $video_url;
}
/**
* Get plugin info from plugins with plugin name.
*
* @since 7.0
* @param string $plugin_name Plugin name to search for.
* @param array $plugins Plugins array containing all plugins data.
* @return array
*/
public function fusion_get_plugin_info( $plugin_name, $plugins ) {
$plugin_info_return = null;
foreach ( $plugins as $plugin_file => $plugin_info ) {
if ( $plugin_info['Name'] === $plugin_name ) {
$plugin_info['plugin_file'] = $plugin_file;
$plugin_info['is_active'] = fusion_is_plugin_activated( $plugin_file );
$plugin_info_return = $plugin_info;
}
}
return apply_filters( 'fusion_get_plugin_info', $plugin_info_return, $plugin_name, $plugins );
}
}
/* Omit closing PHP tag to avoid "Headers already sent" issues. */