initial commit

This commit is contained in:
2024-04-29 13:12:44 +05:45
commit 34887303c5
19300 changed files with 5268802 additions and 0 deletions

View File

@@ -0,0 +1,238 @@
<?php
/**
* Load CSS logic.
*
* @package gutenberg-css
*/
namespace ReduxTemplates;
if ( ! class_exists( '\ReduxTemplates\Gutenberg_Custom_CSS' ) ) {
/**
* Class GutenbergCSS.
*/
class Gutenberg_Custom_CSS {
/**
* The main instance var.
*
* @var Gutenberg_Custom_CSS
*/
public static $instance = null;
/**
* Initialize the class
*/
public function init() {
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_assets' ) );
add_action( 'wp_head', array( $this, 'render_server_side_css' ) );
add_action( 'wp_loaded', array( $this, 'add_attributes_to_blocks' ) );
add_action( 'plugins_loaded', array( $this, 'remove_themeisle_css' ), 99 );
}
/**
* Remove ThemeIsle GutenbergCSS.
*
* @since 4.0.0
* @access public
*/
public function remove_themeisle_css() {
if ( class_exists( '\ThemeIsle\GutenbergCSS' ) ) {
$instance = \ThemeIsle\GutenbergCSS::instance();
remove_action(
'enqueue_block_editor_assets',
array(
$instance,
'enqueue_editor_assets',
)
);
remove_action( 'wp_head', array( $instance, 'render_server_side_css' ) );
remove_action( 'wp_loaded', array( $instance, 'add_attributes_to_blocks' ) );
}
}
/**
* Load Gutenberg assets.
*
* @since 1.0.0
* @access public
*/
public function enqueue_editor_assets() {
wp_enqueue_code_editor( array( 'type' => 'text/css' ) );
wp_add_inline_script(
'wp-codemirror',
'window.CodeMirror = wp.CodeMirror;'
);
wp_set_script_translations( 'redux-gutenberg-css', 'redux-framework' );
}
/**
* Parse Blocks for Gutenberg and WordPress 5.0
*
* @param string $content Content to parse.
*
* @since 1.0.0
* @access public
* @return string
*/
public function parse_blocks( $content ) {
if ( ! function_exists( 'parse_blocks' ) ) {
return gutenberg_parse_blocks( $content );
} else {
return parse_blocks( $content );
}
}
/**
* Render server-side CSS
*
* @since 1.0.0
* @access public
*/
public function render_server_side_css() {
if ( function_exists( 'has_blocks' ) && has_blocks( get_the_ID() ) ) {
global $post;
if ( ! is_object( $post ) ) {
return;
}
$blocks = $this->parse_blocks( $post->post_content );
if ( ! is_array( $blocks ) || empty( $blocks ) ) {
return;
}
$style = "\n" . '<style type="text/css" media="all">' . "\n";
$style .= $this->cycle_through_blocks( $blocks );
$style .= "\n" . '</style>' . "\n";
echo $style; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
/**
* Cycle thorugh Blocks
*
* @param array $inner_blocks Array of blocks.
* @since 1.0.0
* @access public
* @return string
*/
public function cycle_through_blocks( $inner_blocks ) {
$style = '';
foreach ( $inner_blocks as $block ) {
if ( isset( $block['attrs'] ) ) {
if ( isset( $block['attrs']['hasCustomCSS'] ) && isset( $block['attrs']['customCSS'] ) ) {
$style .= $block['attrs']['customCSS'];
}
}
if ( 'core/block' === $block['blockName'] && ! empty( $block['attrs']['ref'] ) ) {
$reusable_block = get_post( $block['attrs']['ref'] );
if ( ! $reusable_block || 'wp_block' !== $reusable_block->post_type ) {
return;
}
if ( 'publish' !== $reusable_block->post_status || ! empty( $reusable_block->post_password ) ) {
return;
}
$blocks = $this->parse_blocks( $reusable_block->post_content );
$style .= $this->cycle_through_blocks( $blocks );
}
if ( isset( $block['innerBlocks'] ) && ! empty( $block['innerBlocks'] ) && is_array( $block['innerBlocks'] ) ) {
$style .= $this->cycle_through_blocks( $block['innerBlocks'] );
}
}
return $style;
}
/**
* Adds the `hasCustomCSS` and `customCSS` attributes to all blocks, to avoid `Invalid parameter(s): attributes`
* error in Gutenberg.
*
* @since 1.0.3
* @access public
*/
public function add_attributes_to_blocks() {
$registered_blocks = \WP_Block_Type_Registry::get_instance()->get_all_registered();
foreach ( $registered_blocks as $name => $block ) {
$block->attributes['hasCustomCSS'] = array(
'type' => 'boolean',
'default' => false,
);
$block->attributes['customCSS'] = array(
'type' => 'string',
'default' => '',
);
}
}
/**
* Method to return path to child class in a Reflective Way.
*
* @since 1.0.0
* @access protected
* @return string
*/
protected function get_dir() {
return dirname( __FILE__ );
}
/**
* The instance method for the static class.
* Defines and returns the instance of the static class.
*
* @static
* @since 1.0.0
* @access public
* @return GutenbergCSS
*/
public static function instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
self::$instance->init();
}
return self::$instance;
}
/**
* Throw error on object clone
*
* The whole idea of the singleton design pattern is that there is a single
* object therefore, we don't want the object to be cloned.
*
* @access public
* @since 1.0.0
* @return void
*/
public function __clone() {
// Cloning instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'redux-framework' ), '1.0.0' );
}
/**
* Disable unserializing of the class
*
* @access public
* @since 1.0.0
* @return void
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'redux-framework' ), '1.0.0' );
}
}
}

View File

@@ -0,0 +1,236 @@
<?php // phpcs:ignore WordPress.Files.FileName
/**
* Initialize the Redux Template Library.
*
* @since 4.0.0
* @package Redux Framework
*/
namespace ReduxTemplates;
use Redux_Connection_Banner;
use Redux_Core;
use Redux_Filesystem;
use Redux_Functions;
use Redux_Functions_Ex;
use Redux_Helpers;
use ReduxTemplates;
use function base64_encode; // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Redux Templates Init Class
*
* @since 4.0.0
*/
class Init {
/**
* Default left value
*
* @var int
*/
public static $default_left = 5;
/**
* Init constructor.
*
* @access public
*/
public function __construct() {
global $pagenow;
if ( 'widgets.php' === $pagenow ) {
return;
}
add_action( 'init', array( $this, 'load' ) );
if ( did_action( 'init' ) ) { // In case the devs load it at the wrong place.
$this->load();
}
if ( false === Redux_Core::$redux_templates_enabled ) {
return;
}
// Editor Load.
add_action( 'enqueue_block_editor_assets', array( $this, 'editor_assets' ), 1 );
// Admin Load.
add_action( 'admin_enqueue_scripts', array( $this, 'admin_assets' ) );
// Initiate the custom css fields.
Gutenberg_Custom_CSS::instance();
}
/**
* Load everything up after init.
*
* @access public
* @since 4.0.0
*/
public static function load() {
new ReduxTemplates\API();
new ReduxTemplates\Templates();
new ReduxTemplates\Notice_Overrides();
}
/**
* Get local contents of a file.
*
* @param string $file_path File path.
*
* @access public
* @return string
* @since 4.0.0
*/
public static function get_local_file_contents( string $file_path ): string {
$fs = Redux_Filesystem::get_instance();
return $fs->get_contents( $file_path );
}
/**
* Load Editor Styles and Scripts.
*
* @access public
* @since 4.0.0
*/
public function editor_assets() {
$fs = Redux_Filesystem::get_instance();
$min = Redux_Functions::is_min();
// Little safety here for developers.
if ( ! $fs->file_exists( REDUXTEMPLATES_DIR_PATH . "assets/js/redux-templates$min.js" ) ) {
if ( '.min' === $min ) {
$min = '';
} else {
$min = '.min';
}
}
$version = REDUXTEMPLATES_VERSION;
// When doing local dev work. Otherwise, follow the check for dev_mode or not.
if ( defined( 'REDUX_PLUGIN_FILE' ) ) {
if ( $fs->file_exists( trailingslashit( dirname( REDUX_PLUGIN_FILE ) ) . 'local_developer.txt' ) ) {
$min = '';
}
$version = time();
}
$min = ''; // Fix since our min'd file isn't working.
wp_enqueue_script(
'redux-templates-js',
plugins_url( "assets/js/redux-templates$min.js", REDUXTEMPLATES_FILE ),
array( 'code-editor', 'csslint', 'wp-i18n', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-editor', 'wp-element', 'wp-hooks' ),
$version,
true
);
wp_set_script_translations( 'redux-templates-js', 'redux-templates' );
// Backend editor scripts: common vendor files.
wp_enqueue_script(
'redux-templates-js-vendor',
plugins_url( "assets/js/vendor$min.js", REDUXTEMPLATES_FILE ),
array(),
$version,
true
);
// We started using the CSS variables. This gives us the function before it's put in core.
if ( version_compare( get_bloginfo( 'version' ), '5.5', '<' ) ) {
if ( ! defined( 'GUTENBERG_VERSION' ) || ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '8.5.1', '<' ) ) ) {
wp_register_style( 'redux-templates-gutenberg-compatibility', false, array(), $version );
wp_enqueue_style( 'redux-templates-gutenberg-compatibility' );
wp_add_inline_style( 'redux-templates-gutenberg-compatibility', ':root {--wp-admin-theme-color: #007cba;}' );
}
}
$global_vars = array(
'i18n' => 'redux-framework',
'plugin' => REDUXTEMPLATES_DIR_URL,
'mokama' => Redux_Helpers::mokama(),
'key' => base64_encode( Redux_Functions::gs() ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
'version' => Redux_Core::$version,
'supported_plugins' => array(), // Load the supported plugins.
'tos' => Redux_Connection_Banner::tos_blurb( 'import_wizard' ),
);
if ( ! $global_vars['mokama'] ) {
// phpcs:disable Squiz.PHP.CommentedOutCode
// delete_user_meta( get_current_user_id(), '_redux_templates_counts'); // To test left.
$global_vars['left'] = self::left( get_current_user_id() );
// phpcs:ignore
// delete_user_meta( get_current_user_id(), '_redux_welcome_guide' ); // For testing.
if ( Redux_Helpers::is_gutenberg_page() && $global_vars['left'] === self::$default_left ) {
// We don't want to show unless Gutenberg is running, and they haven't tried the library yet.
$launched = get_user_meta( get_current_user_id(), '_redux_welcome_guide', true );
if ( '1' !== $launched ) {
$global_vars['welcome'] = 1;
}
}
}
if ( ! $global_vars['mokama'] ) {
$global_vars['u'] = rtrim( Redux_Functions_Ex::get_site_utm_url( '', 'library', true ), '1' );
}
wp_localize_script(
'redux-templates-js',
'redux_templates',
$global_vars
);
wp_enqueue_style(
'redux-fontawesome',
REDUXTEMPLATES_DIR_URL . 'assets/css/font-awesome.min.css',
false,
$version
);
$extra_css = ReduxTemplates\Templates::inline_editor_css();
if ( ! empty( $extra_css ) ) {
wp_add_inline_style( 'redux-fontawesome', $extra_css );
}
}
/**
* Admin Style & Script.
*
* @access public
* @since 4.0.0
*/
public function admin_assets() {
wp_enqueue_style(
'redux-templates-bundle',
REDUXTEMPLATES_DIR_URL . 'assets/css/admin.min.css',
false,
REDUXTEMPLATES_VERSION
);
}
/**
* Get the items left.
*
* @param int $uid User ID number.
* @access public
* @since 4.1.18
* @return int
*/
public static function left( int $uid ): int {
$count = get_user_meta( $uid, '_redux_templates_counts', true );
if ( empty( $count ) ) {
$count = self::$default_left;
}
if ( $count <= 0 ) {
$count = 0;
}
return $count;
}
}
new Init();

View File

@@ -0,0 +1,23 @@
<?php // phpcs:ignore WordPress.Files.FileName
namespace ReduxTemplates;
/**
* ReduxTemplates InstallerMuter.
*
* @since 4.0.0
*/
class Installer_Muter extends \WP_Upgrader_Skin {
/**
* Suppress feedback.
*
* @param string|null $string A string.
* @param array|null ...$args Passed args.
*
* @return void
* @since 4.0.0
*/
public function feedback( $string, ...$args ) {
/* no output */
}
}

View File

@@ -0,0 +1,156 @@
<?php // phpcs:ignore WordPress.Files.FileName
/**
* Installer class which installs and/or activates block plugins.
*
* @since 4.0.0
* @package Redux Framework
*/
namespace ReduxTemplates;
use ReduxTemplates;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
require_once ABSPATH . 'wp-admin/includes/file.php';
require_once ABSPATH . 'wp-admin/includes/misc.php';
require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
/**
* ReduxTemplates Installer.
*
* @since 4.0.0
*/
class Installer {
/**
* Run command.
*
* @param string $slug Plugin Slug.
* @param string $download_link Install URL if from a custom URL.
*
* @return array
* @since 4.0.0
*/
public static function run( $slug, $download_link = '' ) {
$plugin_dir = WP_PLUGIN_DIR . '/' . $slug;
/*
* Don't try installing plugins that already exist (wastes time downloading files that
* won't be used
*/
$status = array();
if ( ! is_dir( $plugin_dir ) ) {
if ( empty( $download_link ) ) {
$api = plugins_api(
'plugin_information',
array(
'slug' => $slug,
'fields' => array(
'short_description' => false,
'sections' => false,
'requires' => false,
'rating' => false,
'ratings' => false,
'downloaded' => false,
'last_updated' => false,
'added' => false,
'tags' => false,
'compatibility' => false,
'homepage' => false,
'donate_link' => false,
),
)
);
$download_link = $api->download_link;
}
if ( empty( $download_link ) ) {
$status['error'] = 'Install url for ' . $slug . ' could not be located.';
return $status;
}
ob_start();
$skin = new ReduxTemplates\Installer_Muter( array( 'api' => $api ) );
$upgrader = new \Plugin_Upgrader( $skin );
$install = $upgrader->install( $download_link );
ob_end_clean();
if ( true !== $install ) {
$status['error'] = 'Install process failed for ' . $slug . '.';
if ( ! empty( $install ) ) {
ob_start();
// phpcs:ignore WordPress.PHP.DevelopmentFunctions
\var_dump( $install );
$result = ob_get_clean();
$status['var_dump'] = $result;
} else {
$status['error'] .= ' ' . $upgrader->skin->options['api']->errors['plugins_api_failed'][0];
}
return $status;
}
// Stop UAGB redirect.
if ( 'ultimate-addons-for-gutenberg' === $slug ) {
update_option( '__uagb_do_redirect', false );
}
$status['install'] = 'success';
}
/*
* The install results don't indicate what the main plugin file is, so we just try to
* activate based on the slug. It may fail, in which case the plugin will have to be activated
* manually from the admin screen.
*/
$plugin_path = false;
$plugin_check = false;
if ( file_exists( $plugin_dir . '/' . $slug . '.php' ) ) {
$plugin_path = $plugin_dir . '/' . $slug . '.php';
$plugin_check = $slug . '/' . $slug . '.php';
} elseif ( file_exists( $plugin_dir . '/plugin.php' ) ) {
$plugin_path = $plugin_dir . '/plugin.php';
$plugin_check = $slug . '/plugin.php';
} else {
$split = explode( '-', $slug );
$new_filename = '';
foreach ( $split as $s ) {
if ( ! empty( $s ) ) {
$new_filename .= $s[0];
}
}
$plugin_path = $plugin_dir . '/' . $new_filename . '.php';
$plugin_check = $slug . '/' . $new_filename . '.php';
if ( ! file_exists( $plugin_path ) ) {
$plugin_path = $plugin_dir . '/index.php';
$plugin_check = $slug . '/index.php';
}
}
if ( ! empty( $plugin_path ) && file_exists( $plugin_path ) ) {
activate_plugin( $plugin_check );
$status['activate'] = 'success';
} else {
$status['error'] = sprintf(
'The block plugin `%s` could not be activated. Please try installing it manually.',
$slug
);
}
return $status;
}
}

View File

@@ -0,0 +1,79 @@
<?php // phpcs:ignore WordPress.Files.FileName
/**
* Notice overrides for Redux Pro block plugins.
*
* @since 4.0.0
* @package Redux Framework
*/
namespace ReduxTemplates;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Redux Templates Notice Overrides Class
*
* @since 4.1.19
*/
class Notice_Overrides {
/**
* ReduxTemplates Notice_Overrides.
*
* @since 4.1.19
*/
public function __construct() {
add_action( 'admin_notices', array( $this, 'filter_notices' ), 0 );
}
/**
* Filter out any notices before they're displayed.
*
* @since 4.0.0
*/
public function filter_notices() {
if ( \Redux_Helpers::mokama() ) {
$this->remove_filters_for_anonymous_class( 'admin_notices', 'QUBELY_PRO\Updater', 'show_invalid_license_notice' );
}
}
/**
* Allow to remove method for an hook when, it's a class method used and class don't have variable, but you know the class name.
*
* @since 1.6.0
*
* @param string $hook_name Hook/action name to remove.
* @param string $class_name Class name. `Colors::class` for example.
* @param string $method_name Class method name.
* @param int $priority Action priority.
*
* @return bool
*/
public static function remove_filters_for_anonymous_class( $hook_name = '', $class_name = '', $method_name = '', $priority = 10 ) {
global $wp_filter;
// Take only filters on right hook name and priority.
if ( ! isset( $wp_filter[ $hook_name ][ $priority ] ) || ! is_array( $wp_filter[ $hook_name ][ $priority ] ) ) {
return false;
}
// Loop on filters registered.
foreach ( $wp_filter[ $hook_name ][ $priority ] as $unique_id => $filter_array ) {
// Test if filter is an array ! (always for class/method).
// Test if object is a class, class and method is equal to param !
if ( isset( $filter_array['function'] ) && is_array( $filter_array['function'] ) && is_object( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) === $class_name && $filter_array['function'][1] === $method_name ) {
// Test for WordPress >= 4.7 WP_Hook class (https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/).
if ( $wp_filter[ $hook_name ] instanceof \WP_Hook ) {
unset( $wp_filter[ $hook_name ]->callbacks[ $priority ][ $unique_id ] );
} else {
unset( $wp_filter[ $hook_name ][ $priority ][ $unique_id ] );
}
}
}
return false;
}
}

View File

@@ -0,0 +1,54 @@
<?php // phpcs:ignore WordPress.Files.FileName
/**
* Notices class to ensure WP is the proper version (block editor exists).
*
* @since 4.0.0
* @package Redux Framework
*/
namespace ReduxTemplates;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* ReduxTemplates Notices.
*
* @since 4.0.0
*/
class Notices {
/**
* PHP Error Notice.
*
* @return void
* @since 4.0.0
*/
public static function php_error_notice() {
$message = sprintf( /* translators: %s: php version number */
esc_html__( 'ReduxTemplates requires PHP version %s or more.', 'redux-framework' ),
'7.1'
);
$html_message = sprintf( '<div class="notice notice-error is-dismissible">%s</div>', wpautop( $message ) );
echo wp_kses_post( $html_message );
}
/**
* WordPress version error notice.
*
* @return void
* @since 4.0.0
*/
public static function wordpress_error_notice() {
$message = sprintf( /* translators: %s: WordPress version number */
esc_html__( 'ReduxTemplates requires WordPress version %s or more.', 'redux-framework' ),
'4.7'
);
$html_message = sprintf( '<div class="notice notice-error is-dismissible">%s</div>', wpautop( $message ) );
echo wp_kses_post( $html_message );
}
}

View File

@@ -0,0 +1,173 @@
<?php // phpcs:ignore WordPress.Files.FileName
/**
* Detect supported plugins with the given instance.
*
* @since 4.0.0
* @package Redux Framework
*/
namespace ReduxTemplates;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Redux Templates Supported_Plugins Class
*
* @since 4.0.0
*/
class Supported_Plugins {
/**
* List of all supported plugins from the library.
*
* @var array|null
*/
protected static $plugins = array();
/**
* List of all supported plugins from the library.
*
* @var Supported_Plugins|null
*/
protected static $instance = null;
/**
* Return or generate instance, singleton.
*
* @return object Instance
* @since 4.0.0
*/
public static function instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Include the template
*
* @param array|null $plugins List of all possible plugins from the library.
*
* @return void
* @since 4.0.0
*/
public function init( $plugins = array() ) {
self::$plugins = $plugins;
self::detect_versions();
}
/**
* Detect all versions of plugins had in library and installed locally.
*
* @return void
* @since 4.0.0
*/
private static function detect_versions() {
$all_plugins = get_plugins();
$active_plugins = get_option( 'active_plugins' );
$data = array();
foreach ( $active_plugins as $plugin ) {
$slug = explode( '/', $plugin )[0];
if ( ! isset( $all_plugins[ $plugin ] ) ) {
$all_plugins[ $plugin ] = array();
}
$data[ $slug ] = $all_plugins[ $plugin ];
}
foreach ( self::$plugins as $key => $plugin ) {
$selector = false;
if ( isset( $data[ $key ] ) ) {
$selector = $key;
} else {
if ( isset( $plugin['slug'] ) && isset( $data[ $plugin['slug'] ] ) ) {
$selector = $plugin['slug'];
}
}
if ( isset( $plugin['detect'] ) ) {
if ( isset( $plugin['detect']['freemius'] ) && $plugin['detect']['freemius'] ) {
// Freemius Version Detection.
if ( isset( $GLOBALS[ $plugin['detect']['freemius'] ] ) && ! empty( $GLOBALS[ $plugin['detect']['freemius'] ] ) ) {
$freemius = $GLOBALS[ $plugin['detect']['freemius'] ];
$selector = $freemius->get_plugin_basename();
$true_slug = explode( '/', $selector )[0];
if ( $true_slug !== $key ) {
self::$plugins[ $key ]['true_slug'] = $true_slug;
}
if ( isset( self::$plugins[ $key ]['free_slug'] ) ) {
continue; // Let's only store the info on the free version.
}
$plugin_info = $freemius->get_plugin_data();
if ( $selector && ! isset( $data[ $selector ]['Version'] ) ) {
self::$plugins[ $key ]['version'] = $plugin_info['Version'];
}
if ( $freemius->can_use_premium_code() ) {
self::$plugins[ $key ]['is_pro'] = true;
}
unset( self::$plugins[ $key ]['detect']['freemius'] );
}
}
if ( isset( $plugin['detect']['defined'] ) ) {
if ( ! empty( $plugin['detect']['defined'] ) ) {
foreach ( $plugin['detect']['defined'] as $key_name => $defined_name ) {
if ( defined( $defined_name ) && ! empty( constant( $defined_name ) ) ) {
self::$plugins[ $key ][ $key_name ] = constant( $defined_name );
}
}
}
unset( self::$plugins[ $key ]['detect']['defined'] );
}
if ( empty( self::$plugins[ $key ]['detect'] ) ) {
unset( self::$plugins[ $key ]['detect'] );
}
} else {
if ( isset( $data[ $key ] ) ) {
if ( isset( $data[ $key ]['Version'] ) ) {
self::$plugins[ $key ]['version'] = $data[ $key ]['Version'];
}
}
}
}
foreach ( self::$plugins as $key => $plugin ) {
if ( ! isset( $plugin['url'] ) || ( isset( $plugin['url'] ) && empty( $plugin['url'] ) ) ) {
if ( isset( $plugin['free_slug'] ) ) {
if ( isset( $plugin['free_slug'] ) ) {
$free_plugin = self::$plugins[ $plugin['free_slug'] ];
if ( isset( $free_plugin['url'] ) ) {
self::$plugins[ $key ]['url'] = $free_plugin['url'];
} else {
self::$plugins[ $key ]['url'] = "https://wordpress.org/plugins/{$plugin['free_slug']}/";
}
}
} else {
self::$plugins[ $key ]['url'] = "https://wordpress.org/plugins/{$key}/";
}
}
}
self::$plugins['redux-framework']['plugin'] = defined( 'REDUX_PLUGIN_FILE' );
if ( isset( self::$plugins['redux-pro'] ) ) {
self::$plugins['redux-pro']['redux_pro'] = true;
}
}
/**
* Helper function to return all installed plugins.
*
* @return array Array of plugins and which are installed.
* @since 4.0.0
*/
public static function get_plugins() {
$instance = self::instance();
if ( empty( $instance::$plugins ) ) {
$instance->init();
}
return $instance::$plugins;
}
}

View File

@@ -0,0 +1,157 @@
<?php // phpcs:ignore WordPress.Files.FileName
/**
* CSS overrides for block plugins.
*
* @since 4.0.0
* @package Redux Framework
*/
namespace ReduxTemplates;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Redux Templates Templates Class
*
* @since 4.0.0
*/
class Template_Overrides {
/**
* ReduxTemplates Template_Overrides.
*
* @since 4.0.0
*/
public function __construct() {
}
/**
* Detects if the current page has blocks or not.
*
* @return bool
* @since 4.0.0
*/
public static function is_gutenberg() {
global $post;
if ( function_exists( 'has_blocks' ) && has_blocks( $post->ID ) ) {
return true;
}
return false;
}
/**
* Detects the current theme and provides overrides.
*
* @return string
* @since 4.0.0
*/
public static function get_overrides() {
if ( ! self::is_gutenberg() ) {
return;
}
$template = mb_strtolower( get_template() );
$css = '';
if ( method_exists( __CLASS__, $template ) ) {
$css = call_user_func( array( __CLASS__, $template ) );
$css = preg_replace( '/\s+/S', ' ', $css );
}
$css .= <<<'EOD'
#main {
padding: unset !important;
}
#content {
padding: unset !important;
}
#wrapper {
min-height: unset !important;
}
.alignfull, .alignwide {
margin: unset !important;
max-width: unset !important;
width: unset !important;
}
}
EOD;
// Remove comments.
$css = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css );
// Remove space after colons.
$css = str_replace( ': ', ':', $css );
// Remove space after commas.
$css = str_replace( ', ', ',', $css );
// Remove space after opening bracket.
$css = str_replace( ' {', '{', $css );
// Remove whitespace.
$css = str_replace( array( "\r\n", "\r", "\n", "\t", ' ', ' ', ' ' ), '', $css );
return $css;
}
/**
* Consulting theme overrides.
*
* @return string
* @since 4.0.0
*/
public static function consulting() {
return <<<'EOD'
#content-core {
max-width: 100%;
}
EOD;
}
/**
* Avada theme overrides.
*
* @return string
* @since 4.0.0
*/
public static function avada() {
return <<<'EOD'
#main .fusion-row {
max-width: unset;
}
EOD;
}
/**
* GeneratePress theme overrides.
*
* @return string
* @since 4.1.24
*/
public static function generatepress() {
return <<<'EOD'
.site-content {
display: block!important;
}
EOD;
}
/**
* TwentyTwenty theme overrides.
*
* @return string
* @since 4.0.0
*/
public static function twentytwenty() {
return <<<'EOD'
[class*="__inner-container"] > *:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.is-style-wide) {
max-width: unset !important;
}
.wp-block-archives:not(.alignwide):not(.alignfull), .wp-block-categories:not(.alignwide):not(.alignfull), .wp-block-code, .wp-block-columns:not(.alignwide):not(.alignfull), .wp-block-cover:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.aligncenter), .wp-block-embed:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.aligncenter), .wp-block-gallery:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.aligncenter), .wp-block-group:not(.has-background):not(.alignwide):not(.alignfull), .wp-block-image:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.aligncenter), .wp-block-latest-comments:not(.aligncenter):not(.alignleft):not(.alignright), .wp-block-latest-posts:not(.aligncenter):not(.alignleft):not(.alignright), .wp-block-media-text:not(.alignwide):not(.alignfull), .wp-block-preformatted, .wp-block-pullquote:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright), .wp-block-quote, .wp-block-quote.is-large, .wp-block-quote.is-style-large, .wp-block-verse, .wp-block-video:not(.alignwide):not(.alignfull) {
margin-top: unset;
margin-bottom: unset;
}
EOD;
}
}

View File

@@ -0,0 +1,181 @@
<?php // phpcs:ignore WordPress.Files.FileName
/**
* Templates overrides for pages.
*
* @since 4.0.0
* @package Redux Framework
*/
namespace ReduxTemplates;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Redux Templates Templates Class
*
* @since 4.0.0
*/
class Templates {
/**
* Default container width.
*
* @var int
*/
public static $content_width = 1200;
/**
* ReduxTemplates Template.
*
* @since 4.0.0
*/
public function __construct() {
global $pagenow;
if ( 'widgets.php' === $pagenow ) {
return;
}
if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && \Redux_Enable_Gutenberg::$is_disabled ) {
// We don't want to add templates unless it's a gutenberg page.
return;
}
// Include ReduxTemplates default template without wrapper.
add_filter( 'template_include', array( $this, 'template_include' ) );
// Override the default content-width when using Redux templates so the template doesn't look like crao.
add_action( 'wp', array( $this, 'modify_template_content_width' ) );
// Add ReduxTemplates supported Post types in page template.
$post_types = get_post_types( array(), 'object' );
if ( ! empty( $post_types ) ) {
foreach ( $post_types as $post_type ) {
if ( isset( $post_type->name ) && isset( $post_type->show_in_rest ) && true === $post_type->show_in_rest ) {
add_filter( "theme_{$post_type->name}_templates", array( $this, 'add_templates' ) );
}
}
}
add_filter( 'admin_body_class', array( $this, 'add_body_class' ), 999 );
}
/**
* Add the redux-template class to the admin body if a redux-templates page type is selected.
*
* @param string|null $classes Classes string for admin panel.
*
* @return string|null
* @since 4.1.19
*/
public function add_body_class( ?string $classes ): ?string {
global $post;
$screen = get_current_screen();
if ( 'post' === $screen->base && get_current_screen()->is_block_editor() ) {
$check = get_post_meta( $post->ID, '_wp_page_template', true );
if ( strpos( $check, 'redux-templates_' ) !== false ) {
$classes .= ' redux-template';
}
}
return $classes;
}
/**
* Override the $content_width variable for themes so our templates work properly and don't look squished.
*
* @param array $to_find Template keys to check against.
*
* @since 4.0.0
* @return bool
*/
public function check_template( $to_find = array() ) {
global $post;
if ( ! empty( $post ) ) {
$template = get_page_template_slug( $post->ID );
if ( false !== strpos( $template, 'redux' ) ) {
$test = mb_strtolower( preg_replace( '/[^A-Za-z0-9 ]/', '', $template ) );
foreach ( $to_find as $key ) {
if ( false !== strpos( $test, $key ) ) {
return true;
}
}
}
}
return false;
}
/**
* Override the $content_width variable for themes so our templates work properly and don't look squished.
*
* @since 4.0.0
*/
public function modify_template_content_width() {
$to_find = array( 'cover', 'canvas', 'fullwidth' );
if ( $this->check_template( $to_find ) ) {
global $content_width;
if ( $content_width < 1000 ) {
$content_width = get_option( '_redux_content_width', self::$content_width );
}
}
}
/**
* Override the $content_width variable for themes so our templates work properly and don't look squished.
*
* @since 4.0.0
*/
public static function inline_editor_css() {
global $content_width;
if ( $content_width < 1000 ) {
$content_width = get_option( '_redux_content_width', self::$content_width );
return ".redux-template .wp-block {max-width: {$content_width}px;}";
}
}
/**
* Include the template
*
* @param string $template Template type.
*
* @return string
* @since 4.0.0
*/
public function template_include( $template ) {
if ( is_singular() ) {
$page_template = get_post_meta( get_the_ID(), '_wp_page_template', true );
if ( 'redux-templates_full_width' === $page_template ) {
$template = REDUXTEMPLATES_DIR_PATH . 'classes/templates/template-full-width.php';
} elseif ( 'redux-templates_contained' === $page_template ) {
$template = REDUXTEMPLATES_DIR_PATH . 'classes/templates/template-contained.php';
} elseif ( 'redux-templates_canvas' === $page_template ) {
$template = REDUXTEMPLATES_DIR_PATH . 'classes/templates/template-canvas.php';
}
}
return $template;
}
/**
* Hook to add the templates to the dropdown
*
* @param array $post_templates Default post templates array.
*
* @return array
* @since 4.0.0
*/
public function add_templates( $post_templates ) {
$post_templates['redux-templates_contained'] = __( 'Redux Contained', 'redux-framework' );
$post_templates['redux-templates_full_width'] = __( 'Redux Full Width', 'redux-framework' );
$post_templates['redux-templates_canvas'] = __( 'Redux Canvas', 'redux-framework' );
return $post_templates;
}
}

View File

@@ -0,0 +1,8 @@
<?php
/**
* Silence is golden.
*
* @package Redux Framework
*/
echo null;

View File

@@ -0,0 +1,193 @@
[
{
"updated": "2020-02-21 03:30:58.045000+00:00",
"name": "AC Repair",
"source": "qubely",
"source_id": 21484,
"id": "mJh5ySG24on5VqUMlprz",
"categories": [
"Business"
]
},
{
"updated": "2020-02-21 03:30:58.608000+00:00",
"name": "Agency",
"source": "qubely",
"source_id": 19646,
"id": "ODBu76kDETR5E4n37cpH",
"categories": [
"Agency"
]
},
{
"updated": "2020-02-21 03:30:59.001000+00:00",
"name": "Asana",
"source": "qubely",
"source_id": 60,
"id": "CYdoUeYy1wGS1O0HYvtd",
"categories": [
"Business"
]
},
{
"updated": "2020-02-21 03:30:57.793000+00:00",
"name": "Barber Shop",
"source": "qubely",
"source_id": 21517,
"id": "vAIGGFj5y1ZtlbNH6BmN",
"categories": [
"Business"
]
},
{
"updated": "2020-02-21 03:30:58.840000+00:00",
"name": "Business",
"source": "qubely",
"source_id": 19631,
"id": "4mgpK6hv5lJbgEhXugtP",
"categories": [
"Business"
]
},
{
"updated": "2020-02-21 03:30:58.309000+00:00",
"name": "Charity",
"source": "qubely",
"source_id": 21465,
"id": "ksUkL3DuQ6980rdLNo55",
"categories": [
"Nonprofit"
]
},
{
"updated": "2020-02-21 03:30:57.390000+00:00",
"name": "Coffee Shop",
"source": "qubely",
"source_id": 21525,
"id": "HlHfaRBS7yPTBv6BrR5I",
"categories": [
"Restaurant"
]
},
{
"updated": "2020-02-21 03:30:58.483000+00:00",
"name": "Corporate",
"source": "qubely",
"source_id": 19686,
"id": "nKrKWZUJmhnJY6210Ope",
"categories": [
"Corporate"
]
},
{
"updated": "2020-02-21 03:30:56.577000+00:00",
"name": "Creative Agency",
"source": "qubely",
"source_id": 21728,
"id": "q8BizzfJ1pUnxNnKaN67",
"categories": [
"Agency"
]
},
{
"updated": "2020-02-21 03:30:56.992000+00:00",
"name": "Dentist",
"source": "qubely",
"source_id": 21531,
"id": "9h8lHaKWhTFeNAG6wCy1",
"categories": [
"Agency"
]
},
{
"updated": "2020-02-21 03:30:55.585000+00:00",
"name": "Design Agency",
"source": "qubely",
"source_id": 22673,
"id": "uyyQVLD0Oa6pP5WxBdE7",
"categories": [
"Agency"
]
},
{
"updated": "2020-02-21 03:30:56.002000+00:00",
"name": "Digital Agency",
"source": "qubely",
"source_id": 22409,
"id": "00wC7hKicdnUYkH5QRXc",
"categories": [
"Agency"
]
},
{
"updated": "2020-02-21 03:30:56.201000+00:00",
"name": "Food Truck",
"source": "qubely",
"source_id": 22199,
"id": "a2HJy0KQOKmXq3AkEfvY",
"categories": [
"Business",
"Restaurant"
]
},
{
"updated": "2020-02-21 03:30:57.137000+00:00",
"name": "Furniture",
"source": "qubely",
"source_id": 21532,
"id": "oh7glhYSa13x0iX8tS0z",
"categories": [
"Business"
]
},
{
"updated": "2020-02-21 03:30:57.950000+00:00",
"name": "GYM",
"source": "qubely",
"source_id": 21503,
"id": "LcDrsZAx2zwDDMPV0ecO",
"categories": [
"Business"
]
},
{
"updated": "2020-02-21 03:30:56.867000+00:00",
"name": "Hand-Craft",
"source": "qubely",
"source_id": 21550,
"id": "PNH120vtgC7VLlUaoWuM",
"categories": [
"Business"
]
},
{
"updated": "2020-02-21 03:30:56.435000+00:00",
"name": "Hotel & Resort",
"source": "qubely",
"source_id": 21977,
"id": "c6uD6NjhH6oLA6XNe0gX",
"categories": [
"Agency"
]
},
{
"updated": "2020-02-21 03:30:55.808000+00:00",
"name": "Kindergarten",
"source": "qubely",
"source_id": 22547,
"id": "1C3YMjjBgz73jxc4iGRH",
"categories": [
"Education"
]
},
{
"updated": "2020-02-21 03:30:57.536000+00:00",
"name": "Restaurant",
"source": "qubely",
"source_id": 21489,
"id": "XjFb4Ipxr44vkcA0lj6N",
"categories": [
"Restaurant"
]
}
]

View File

@@ -0,0 +1,8 @@
<?php
/**
* Silence is golden.
*
* @package Redux Framework
*/
echo null;

View File

@@ -0,0 +1,8 @@
<?php
/**
* Silence is golden.
*
* @package Redux Framework
*/
echo null;

View File

@@ -0,0 +1,44 @@
<?php
/**
* ReduxTemplates - Canvas / Theme Override
*
* @since 4.0.0
* @package redux-framework
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="profile" href="https://gmpg.org/xfn/11"/>
<?php if ( ! current_theme_supports( 'title-tag' ) ) : ?>
<title><?php echo esc_html( wp_get_document_title() ); ?></title>
<?php endif; ?>
<?php
wp_head();
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<style type="text/css" id="redux-template-overrides">' . ReduxTemplates\Template_Overrides::get_overrides() . '</style>';
?>
</head>
<body <?php echo body_class(); ?>>
<?php wp_body_open(); ?>
<?php
while ( have_posts() ) :
the_post();
the_content();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
?>
<?php endwhile; ?>
<?php wp_footer(); ?>
</body>
</html>

View File

@@ -0,0 +1,27 @@
<?php
/**
* ReduxTemplates - Full Width / Contained
*
* @since 4.0.0
* @package redux-framework
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
get_header();
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<style type="text/css" id="redux-template-overrides">' . ReduxTemplates\Template_Overrides::get_overrides() . '</style>';
while ( have_posts() ) :
the_post();
the_content();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
get_footer();

View File

@@ -0,0 +1,25 @@
<?php
/**
* ReduxTemplates - Full Width / Stretched
*
* @since 4.0.0
* @package redux-framework
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
get_header();
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<style type="text/css" id="redux-template-overrides">' . ReduxTemplates\Template_Overrides::get_overrides() . '</style>';
while ( have_posts() ) :
the_post();
the_content();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
get_footer();