updated plugin GP Premium version 1.11.2

This commit is contained in:
2020-08-13 14:53:39 +00:00
committed by Gitium
parent 3f0f8d3ac9
commit 885bbdd113
151 changed files with 11329 additions and 6954 deletions

View File

@ -1,16 +1,32 @@
<?php
defined( 'WPINC' ) or die;
/**
* This file handles the widget imports.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* Widget importer class.
*/
class GeneratePress_Sites_Widget_Importer {
/**
* Instance.
*
* @var $_instance
*/
private static $_instance = null;
private static $_instance = null; // phpcs:ignore -- Want the underscore.
/**
* Get our instance.
*/
public static function instance() {
if ( ! isset( self::$_instance ) ) {
self::$_instance = new self;
self::$_instance = new self();
}
return self::$_instance;
}
@ -25,7 +41,7 @@ class GeneratePress_Sites_Widget_Importer {
* @global array $wp_registered_widget_updates
* @return array Widget information
*/
function wie_available_widgets() {
public function wie_available_widgets() {
global $wp_registered_widget_controls;
$widget_controls = $wp_registered_widget_controls;
@ -39,7 +55,7 @@ class GeneratePress_Sites_Widget_Importer {
}
}
return apply_filters( 'wie_available_widgets', $available_widgets );
return apply_filters( 'wie_available_widgets', $available_widgets ); // phpcs:ignore -- Keep the plugin prefix.
}
/**
@ -50,7 +66,7 @@ class GeneratePress_Sites_Widget_Importer {
* @param object $data JSON widget data from .wie file.
* @return array Results array
*/
function wie_import_data( $data ) {
public function wie_import_data( $data ) {
global $wp_registered_sidebars;
// Have valid data?
@ -66,9 +82,9 @@ class GeneratePress_Sites_Widget_Importer {
}
// Hook before import.
do_action( 'wie_before_import' );
do_action( 'wie_before_import' ); // phpcs:ignore -- Keep the plugin prefix.
$data = apply_filters( 'wie_import_data', $data );
$data = apply_filters( 'wie_import_data', $data ); // phpcs:ignore -- Keep the plugin prefix.
// Get all available widgets site supports.
$available_widgets = $this->wie_available_widgets();
@ -129,7 +145,7 @@ class GeneratePress_Sites_Widget_Importer {
// Filter to modify settings object before conversion to array and import
// Leave this filter here for backwards compatibility with manipulating objects (before conversion to array below)
// Ideally the newer wie_widget_settings_array below will be used instead of this.
$widget = apply_filters( 'wie_widget_settings', $widget );
$widget = apply_filters( 'wie_widget_settings', $widget ); // phpcs:ignore -- Keep the plugin prefix.
// Convert multidimensional objects to multidimensional arrays
// Some plugins like Jetpack Widget Visibility store settings as multidimensional arrays
@ -141,7 +157,7 @@ class GeneratePress_Sites_Widget_Importer {
// Filter to modify settings array
// This is preferred over the older wie_widget_settings filter above
// Do before identical check because changes may make it identical to end result (such as URL replacements).
$widget = apply_filters( 'wie_widget_settings_array', $widget );
$widget = apply_filters( 'wie_widget_settings_array', $widget ); // phpcs:ignore -- Keep the plugin prefix.
// Does widget with identical settings already exist in same sidebar?
if ( ! $fail && isset( $widget_instances[ $id_base ] ) ) {
@ -166,7 +182,7 @@ class GeneratePress_Sites_Widget_Importer {
// No failure.
if ( ! $fail ) {
// Add widget instance
// Add widget instance.
$single_widget_instances = get_option( 'widget_' . $id_base ); // All instances for that widget ID base, get fresh every time.
$single_widget_instances = ! empty( $single_widget_instances ) ? $single_widget_instances : array(
@ -230,7 +246,7 @@ class GeneratePress_Sites_Widget_Importer {
'widget_id_num_old' => $instance_id_number,
);
do_action( 'wie_after_widget_import', $after_widget_import );
do_action( 'wie_after_widget_import', $after_widget_import ); // phpcs:ignore -- Keep the plugin prefix.
// Success message.
if ( $sidebar_available ) {
@ -242,7 +258,7 @@ class GeneratePress_Sites_Widget_Importer {
}
}
// Result for widget instance
// Result for widget instance.
$results[ $sidebar_id ]['widgets'][ $widget_instance_id ]['name'] = isset( $available_widgets[ $id_base ]['name'] ) ? $available_widgets[ $id_base ]['name'] : $id_base; // Widget name or ID if name not available (not supported by site).
$results[ $sidebar_id ]['widgets'][ $widget_instance_id ]['title'] = ! empty( $widget['title'] ) ? $widget['title'] : esc_html__( 'No Title', 'widget-importer-exporter' ); // Show "No Title" if widget instance is untitled.
$results[ $sidebar_id ]['widgets'][ $widget_instance_id ]['message_type'] = $widget_message_type;
@ -251,9 +267,9 @@ class GeneratePress_Sites_Widget_Importer {
}
// Hook after import.
do_action( 'wie_after_import' );
do_action( 'wie_after_import' ); // phpcs:ignore -- Keep the plugin prefix.
// Return results.
return apply_filters( 'wie_import_results', $results );
return apply_filters( 'wie_import_results', $results ); // phpcs:ignore -- Keep the plugin prefix.
}
}