WP init
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Includes;
|
||||
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* WPR_Conditions_Manager setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class WPR_Conditions_Manager {
|
||||
|
||||
/**
|
||||
** Header & Footer Conditions
|
||||
*/
|
||||
public static function header_footer_display_conditions( $conditions ) {
|
||||
$template = NULL;
|
||||
|
||||
// Custom
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) {
|
||||
if ( !empty($conditions) ) {
|
||||
$conditions['caller-header-footer'] = ['true'];
|
||||
|
||||
// Archive Pages (includes search)
|
||||
if ( !is_null( \WprAddonsPro\Classes\Pro_Modules::archive_templates_conditions( $conditions ) ) ) {
|
||||
$template = \WprAddonsPro\Classes\Pro_Modules::archive_templates_conditions( $conditions );
|
||||
}
|
||||
|
||||
// Single Pages
|
||||
if ( !is_null( \WprAddonsPro\Classes\Pro_Modules::single_templates_conditions( $conditions ) ) ) {
|
||||
$template = \WprAddonsPro\Classes\Pro_Modules::single_templates_conditions( $conditions );
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
$template = Utilities::get_template_slug( $conditions, 'global' );
|
||||
}
|
||||
|
||||
if ( \Elementor\Plugin::$instance->preview->is_preview_mode() ) {
|
||||
$template_type = Utilities::get_wpr_template_type(get_the_ID());
|
||||
|
||||
if ( 'header' === $template_type || 'footer' === $template_type || is_singular('wpr_mega_menu') ) {
|
||||
$template = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'on' === get_option('wpr_hide_head_foot_on_maintenenace', 'on') ) {
|
||||
if ( !current_user_can('administrator') && ('maintenance' == get_option('elementor_maintenance_mode_mode') || 'coming_soon' == get_option('elementor_maintenance_mode_mode')) ) {
|
||||
$template = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
** Canvas Content Conditions
|
||||
*/
|
||||
public static function canvas_page_content_display_conditions() {
|
||||
$template = NULL;
|
||||
|
||||
// Get Conditions
|
||||
if ( class_exists( 'WooCommerce' ) && is_woocommerce() ) {
|
||||
$archives = json_decode( get_option( 'wpr_product_archive_conditions' ), true );
|
||||
$singles = json_decode( get_option( 'wpr_product_single_conditions' ), true );
|
||||
} else {
|
||||
$archives = json_decode( get_option( 'wpr_archive_conditions' ), true );
|
||||
$singles = json_decode( get_option( 'wpr_single_conditions' ), true );
|
||||
}
|
||||
|
||||
if ( empty($archives) && empty($singles) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Custom
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) {
|
||||
|
||||
// Archive Pages (includes search)
|
||||
if ( !is_null( \WprAddonsPro\Classes\Pro_Modules::archive_templates_conditions( $archives ) ) ) {
|
||||
$template = \WprAddonsPro\Classes\Pro_Modules::archive_templates_conditions( $archives );
|
||||
}
|
||||
|
||||
// Single Pages
|
||||
if ( !is_null( \WprAddonsPro\Classes\Pro_Modules::single_templates_conditions( $singles ) ) ) {
|
||||
$template = \WprAddonsPro\Classes\Pro_Modules::single_templates_conditions( $singles );
|
||||
}
|
||||
} else {
|
||||
// Archive Pages (includes search)
|
||||
if ( !is_null( WPR_Conditions_Manager::archive_templates_conditions_free($archives) ) ) {
|
||||
$template = WPR_Conditions_Manager::archive_templates_conditions_free($archives);
|
||||
}
|
||||
|
||||
// Single Pages
|
||||
if ( !is_null( WPR_Conditions_Manager::single_templates_conditions_free($singles) ) ) {
|
||||
$template = WPR_Conditions_Manager::single_templates_conditions_free($singles);
|
||||
}
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
** Archive Pages Templates Conditions Free
|
||||
*/
|
||||
public static function archive_templates_conditions_free( $conditions ) {
|
||||
$term_id = '';
|
||||
$term_name = '';
|
||||
$queried_object = get_queried_object();
|
||||
|
||||
// Get Terms
|
||||
if ( ! is_null( $queried_object ) ) {
|
||||
if ( isset( $queried_object->term_id ) && isset( $queried_object->taxonomy ) ) {
|
||||
$term_id = $queried_object->term_id;
|
||||
$term_name = $queried_object->taxonomy;
|
||||
}
|
||||
}
|
||||
|
||||
// Reset
|
||||
$template = NULL;
|
||||
|
||||
// Archive Pages (includes search)
|
||||
if ( is_archive() || is_search() ) {
|
||||
if ( ! is_search() ) {
|
||||
// Author
|
||||
if ( is_author() ) {
|
||||
$template = Utilities::get_template_slug( $conditions, 'archive/author' );
|
||||
// Date
|
||||
} elseif ( is_date() ) {
|
||||
$template = Utilities::get_template_slug( $conditions, 'archive/date' );
|
||||
// Category
|
||||
} elseif ( is_category() ) {
|
||||
$template = Utilities::get_template_slug( $conditions, 'archive/categories', $term_id );
|
||||
// Tag
|
||||
} elseif ( is_tag() ) {
|
||||
$template = Utilities::get_template_slug( $conditions, 'archive/tags', $term_id );
|
||||
// Products
|
||||
} elseif ( class_exists( 'WooCommerce' ) && is_woocommerce() ) {
|
||||
$template = Utilities::get_template_slug( $conditions, 'product_archive/products' );
|
||||
}
|
||||
|
||||
// Search Page
|
||||
} else {
|
||||
$template = Utilities::get_template_slug( $conditions, 'archive/search' );
|
||||
}
|
||||
|
||||
// Posts Page
|
||||
} elseif ( Utilities::is_blog_archive() ) {
|
||||
$template = Utilities::get_template_slug( $conditions, 'archive/posts' );
|
||||
}
|
||||
|
||||
// Global - For All Archives
|
||||
if ( is_null($template) ) {
|
||||
$all_archives = Utilities::get_template_slug( $conditions, 'archive/all_archives' );
|
||||
|
||||
if ( ! is_null($all_archives) ) {
|
||||
if ( class_exists( 'WooCommerce' ) && is_shop() ) {
|
||||
$template = null;
|
||||
} else {
|
||||
if ( is_archive() || is_search() || Utilities::is_blog_archive() ) {
|
||||
$template = $all_archives;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
** Single Pages Templates Conditions - Free
|
||||
*/
|
||||
public static function single_templates_conditions_free( $conditions ) {
|
||||
global $post;
|
||||
|
||||
// Get Posts
|
||||
$post_id = is_null($post) ? '' : $post->ID;
|
||||
$post_type = is_null($post) ? '' : $post->post_type;
|
||||
|
||||
// Reset
|
||||
$template = NULL;
|
||||
|
||||
// Single Pages
|
||||
if ( is_single() || is_front_page() || is_page() || is_404() ) {
|
||||
|
||||
if ( is_single() ) {
|
||||
// Blog Posts
|
||||
if ( 'post' == $post_type ) {
|
||||
$template = Utilities::get_template_slug( $conditions, 'single/posts', $post_id );
|
||||
} elseif ( 'product' == $post_type ) {
|
||||
$template = Utilities::get_template_slug( $conditions, 'product_single/product', $post_id );
|
||||
}
|
||||
} else {
|
||||
// Front page
|
||||
if ( is_front_page() && ! Utilities::is_blog_archive() ) {//TODO: is it a good check? - is_blog_archive()
|
||||
$template = Utilities::get_template_slug( $conditions, 'single/front_page' );
|
||||
// Error 404 Page
|
||||
} elseif ( is_404() ) {
|
||||
$template = Utilities::get_template_slug( $conditions, 'single/page_404' );
|
||||
// Single Page
|
||||
} elseif ( is_page() ) {
|
||||
$template = Utilities::get_template_slug( $conditions, 'single/pages', $post_id );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Includes;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* WPR_Editor_Hooks
|
||||
*
|
||||
* Handles Elementor editor hooks and modifications
|
||||
* Including removal of Elementor Pro promotion widgets
|
||||
*/
|
||||
class WPR_Editor_Hooks {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var WPR_Editor_Hooks
|
||||
*/
|
||||
private static $_instance = null;
|
||||
|
||||
/**
|
||||
* Get instance
|
||||
*
|
||||
* @return WPR_Editor_Hooks
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( is_null( self::$_instance ) ) {
|
||||
self::$_instance = new self();
|
||||
}
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
private function __construct() {
|
||||
$this->add_hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all hooks
|
||||
*/
|
||||
private function add_hooks() {
|
||||
// Remove Elementor Pro Promotion Widgets - Only in editor (not during import)
|
||||
if ( current_user_can('administrator') ) {
|
||||
add_action('elementor/editor/before_enqueue_scripts', [$this, 'conditional_remove_elementor_pro_promotions'], 1);
|
||||
// Detect widgets when page is saved
|
||||
add_action('elementor/editor/after_save', [$this, 'detect_widgets_on_save'], 10, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove pro widgets from Elementor transient
|
||||
*
|
||||
* @param mixed $transient Transient data
|
||||
* @return mixed Modified transient data
|
||||
*/
|
||||
public function remove_pro_widgets_from_transient($transient) {
|
||||
// Remove pro_widgets from the Elementor API data
|
||||
if ($transient && isset($transient['pro_widgets'])) {
|
||||
$transient['pro_widgets'] = [];
|
||||
}
|
||||
return $transient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditionally remove Elementor Pro promotions
|
||||
* Uses persistent flag for performance - once Royal widgets are used, always hide promotions
|
||||
*/
|
||||
public function conditional_remove_elementor_pro_promotions() {
|
||||
// Check persistent flag first (most efficient) - works everywhere
|
||||
$flag = get_option('wpr_has_used_royal_widgets');
|
||||
|
||||
if ($flag) {
|
||||
$this->remove_elementor_promotions();
|
||||
return;
|
||||
}
|
||||
|
||||
// Only continue for first-time detection in actual Elementor editor (not during imports)
|
||||
$is_editor = isset(\Elementor\Plugin::$instance->editor);
|
||||
$is_edit_mode = $is_editor && \Elementor\Plugin::$instance->editor->is_edit_mode();
|
||||
|
||||
if (!$is_editor || !$is_edit_mode) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback: Check current page for first-time detection
|
||||
$post_id = get_the_ID();
|
||||
|
||||
if (!$post_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if this page uses Royal widgets
|
||||
$has_widgets = $this->page_has_royal_widgets($post_id);
|
||||
|
||||
if ($has_widgets) {
|
||||
// Set persistent flag for future use
|
||||
update_option('wpr_has_used_royal_widgets', time());
|
||||
|
||||
// Remove promotions
|
||||
$this->remove_elementor_promotions();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Royal widgets when page is saved and set persistent flag
|
||||
*
|
||||
* @param int $post_id Post ID that was saved
|
||||
* @param array $data Elementor data being saved
|
||||
*/
|
||||
public function detect_widgets_on_save($post_id, $data) {
|
||||
// Skip if flag already set
|
||||
if (get_option('wpr_has_used_royal_widgets')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear cache to force fresh detection
|
||||
delete_transient('wpr_has_widgets_' . $post_id);
|
||||
|
||||
// Check if this page has Royal widgets
|
||||
if ($this->page_has_royal_widgets($post_id)) {
|
||||
update_option('wpr_has_used_royal_widgets', time());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply filters to remove Elementor promotions
|
||||
*/
|
||||
private function remove_elementor_promotions() {
|
||||
add_filter('pre_transient_elementor_remote_info_api_data_' . ELEMENTOR_VERSION,
|
||||
[$this, 'remove_pro_widgets_from_transient'], 999);
|
||||
add_filter('transient_elementor_remote_info_api_data_' . ELEMENTOR_VERSION,
|
||||
[$this, 'remove_pro_widgets_from_transient'], 999);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a page has Royal Addons widgets
|
||||
*
|
||||
* @param int $post_id Post ID to check
|
||||
* @return bool True if Royal widgets found
|
||||
*/
|
||||
private function page_has_royal_widgets($post_id) {
|
||||
// Check cache first
|
||||
$cache_key = 'wpr_has_widgets_' . $post_id;
|
||||
$cached = get_transient($cache_key);
|
||||
if (false !== $cached) {
|
||||
return $cached === 'yes';
|
||||
}
|
||||
|
||||
$has_widgets = false;
|
||||
|
||||
// Method 1: Check _elementor_controls_usage (fastest and most reliable)
|
||||
$controls_usage = get_post_meta($post_id, '_elementor_controls_usage', true);
|
||||
|
||||
if (is_array($controls_usage)) {
|
||||
foreach ($controls_usage as $widget_type => $data) {
|
||||
if (is_string($widget_type) && strpos($widget_type, 'wpr-') === 0) {
|
||||
$has_widgets = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Method 2: Fallback to _elementor_data for unsaved pages
|
||||
if (!$has_widgets) {
|
||||
$elementor_data = get_post_meta($post_id, '_elementor_data', true);
|
||||
|
||||
if (!empty($elementor_data)) {
|
||||
// Handle both array (during import) and string (normal) cases
|
||||
if (is_array($elementor_data)) {
|
||||
$elementor_data = wp_json_encode($elementor_data);
|
||||
}
|
||||
|
||||
if (is_string($elementor_data)) {
|
||||
if (strpos($elementor_data, '"widgetType":"wpr-') !== false) {
|
||||
$has_widgets = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cache result for 1 hour
|
||||
$cache_value = $has_widgets ? 'yes' : 'no';
|
||||
set_transient($cache_key, $cache_value, HOUR_IN_SECONDS);
|
||||
|
||||
return $has_widgets;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Initialize
|
||||
WPR_Editor_Hooks::instance();
|
||||
@@ -0,0 +1,306 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Includes;
|
||||
|
||||
use WprAddons\Classes\Utilities;
|
||||
use Elementor\Core\Base\Elements_Iteration_Actions\Assets;
|
||||
use Elementor\Core\Files\CSS\Post as Post_CSS;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* WPR_Render_Templates setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class WPR_Render_Templates {
|
||||
|
||||
/**
|
||||
** Instance of Elemenntor Frontend class.
|
||||
*
|
||||
** @var \Elementor\Frontend()
|
||||
*/
|
||||
private static $elementor_instance;
|
||||
|
||||
/**
|
||||
** Get Current Theme.
|
||||
*/
|
||||
public $current_theme;
|
||||
|
||||
/**
|
||||
** Royal Themes Array.
|
||||
*/
|
||||
public $royal_themes;
|
||||
|
||||
|
||||
/**
|
||||
** Constructor
|
||||
*/
|
||||
public function __construct( $only_hf = false ) {
|
||||
|
||||
// Elementor Frontend
|
||||
self::$elementor_instance = \Elementor\Plugin::instance();
|
||||
|
||||
// Ative Theme
|
||||
$this->current_theme = get_template();
|
||||
|
||||
// Royal Themes
|
||||
$this->royal_themes = ['ashe', 'ashe-pro', 'ashe-pro-premium', 'bard', 'bard-pro', 'bard-pro-premium'];
|
||||
|
||||
// Popular Themes
|
||||
if ( 'astra' === $this->current_theme ) {
|
||||
require_once(__DIR__ . '/../templates/views/astra/class-astra-compat.php');
|
||||
|
||||
} elseif ( 'generatepress' === $this->current_theme ) {
|
||||
require_once(__DIR__ . '/../templates/views/generatepress/class-generatepress-compat.php');
|
||||
|
||||
} elseif ( 'oceanwp' === $this->current_theme ) {
|
||||
require_once(__DIR__ . '/../templates/views/oceanwp/class-oceanwp-compat.php');
|
||||
|
||||
} elseif ( 'storefront' === $this->current_theme ) {
|
||||
require_once(__DIR__ . '/../templates/views/storefront/class-storefront-compat.php');
|
||||
|
||||
// Other Themes
|
||||
} else {
|
||||
add_action( 'wp', [ $this, 'global_compatibility' ] );
|
||||
}
|
||||
|
||||
// Scripts and Styles
|
||||
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
|
||||
|
||||
// Theme Builder
|
||||
if ( !$only_hf ) { // Prevent Loading in Header or Footer Templates
|
||||
add_filter( 'template_include', [ $this, 'convert_to_canvas' ], 12 ); // 12 after WP Pages and WooCommerce.
|
||||
add_action( 'elementor/page_templates/canvas/wpr_print_content', [ $this, 'canvas_page_content_display' ] );
|
||||
}
|
||||
}
|
||||
|
||||
public function global_compatibility() {
|
||||
add_action( 'get_header', [ $this, 'replace_header' ] );
|
||||
add_action( 'elementor/page_templates/canvas/before_content', [ $this, 'add_canvas_header' ] );
|
||||
|
||||
add_action( 'get_footer', [ $this, 'replace_footer' ] );
|
||||
add_action( 'elementor/page_templates/canvas/after_content', [ $this, 'add_canvas_footer' ], 9 );
|
||||
}
|
||||
|
||||
/**
|
||||
** Check if a Template has Conditions
|
||||
*/
|
||||
public function is_template_available( $type ) {
|
||||
if ( 'content' === $type ) {
|
||||
return !is_null(WPR_Conditions_Manager::canvas_page_content_display_conditions()) ? true : false;
|
||||
} else {
|
||||
$conditions = json_decode( get_option('wpr_'. $type .'_conditions', '[]'), true );
|
||||
$template = WPR_Conditions_Manager::header_footer_display_conditions( $conditions );
|
||||
|
||||
return (!empty( $conditions ) && !is_null($template)) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Header
|
||||
*/
|
||||
public function replace_header() {
|
||||
if ( $this->is_template_available('header') ) {
|
||||
if ( ! in_array($this->current_theme, $this->royal_themes) ) {
|
||||
require __DIR__ . '/../templates/views/theme-header.php';
|
||||
} else {
|
||||
require __DIR__ . '/../templates/views/royal/theme-header-royal.php';
|
||||
}
|
||||
|
||||
$templates = [];
|
||||
$templates[] = 'header.php';
|
||||
|
||||
remove_all_actions( 'wp_head' ); // Avoid running wp_head hooks again.
|
||||
|
||||
ob_start();
|
||||
locate_template( $templates, true );
|
||||
ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
||||
public function add_canvas_header() {
|
||||
if ( $this->is_template_available('header') ) {
|
||||
$conditions = json_decode( get_option('wpr_header_conditions', '[]'), true );
|
||||
$template_slug = WPR_Conditions_Manager::header_footer_display_conditions($conditions);
|
||||
$template_id = Utilities::get_template_id($template_slug);
|
||||
|
||||
if ( defined('ICL_LANGUAGE_CODE') ) {
|
||||
$default_language_code = apply_filters('wpml_default_language', null);
|
||||
$current_language_code = apply_filters( 'wpml_current_language', NULL );
|
||||
|
||||
IF ( ICL_LANGUAGE_CODE !== $default_language_code ) {
|
||||
$template_id = apply_filters('wpml_object_id', $template_id, 'wpr_templates', true, $default_language_code);
|
||||
}
|
||||
}
|
||||
|
||||
$show_on_canvas = get_post_meta($template_id, 'wpr_header_show_on_canvas', true);
|
||||
|
||||
// if ( !empty($show_on_canvas) && 'true' === $show_on_canvas && 0 === strpos($template_slug, 'user-header-') ) {
|
||||
if ( !empty($show_on_canvas) && 'true' === $show_on_canvas && !is_null($template_slug) ) {
|
||||
Utilities::render_elementor_template($template_slug);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Footer
|
||||
*/
|
||||
public function replace_footer() {
|
||||
if ( $this->is_template_available('footer') ) {
|
||||
if ( ! in_array($this->current_theme, $this->royal_themes) ) {
|
||||
require __DIR__ . '/../templates/views/theme-footer.php';
|
||||
} else {
|
||||
require __DIR__ . '/../templates/views/royal/theme-footer-royal.php';
|
||||
}
|
||||
|
||||
$templates = [];
|
||||
$templates[] = 'footer.php';
|
||||
|
||||
remove_all_actions( 'wp_footer' ); // Avoid running wp_footer hooks again.
|
||||
|
||||
ob_start();
|
||||
locate_template( $templates, true );
|
||||
ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
||||
public function add_canvas_footer() {
|
||||
if ( $this->is_template_available('footer') ) {
|
||||
$conditions = json_decode( get_option('wpr_footer_conditions', '[]'), true );
|
||||
$template_slug = WPR_Conditions_Manager::header_footer_display_conditions($conditions);
|
||||
$template_id = Utilities::get_template_id($template_slug);
|
||||
|
||||
if ( defined('ICL_LANGUAGE_CODE') ) {
|
||||
$default_language_code = apply_filters('wpml_default_language', null);
|
||||
$current_language_code = apply_filters( 'wpml_current_language', NULL );
|
||||
|
||||
IF ( ICL_LANGUAGE_CODE !== $default_language_code ) {
|
||||
$template_id = apply_filters('wpml_object_id', $template_id, 'wpr_templates', true, $default_language_code);
|
||||
}
|
||||
}
|
||||
|
||||
$show_on_canvas = get_post_meta($template_id, 'wpr_footer_show_on_canvas', true);
|
||||
|
||||
// if ( !empty($show_on_canvas) && 'true' === $show_on_canvas && 0 === strpos($template_slug, 'user-footer-') ) {
|
||||
if ( !empty($show_on_canvas) && 'true' === $show_on_canvas && !is_null($template_slug) ) {
|
||||
Utilities::render_elementor_template($template_slug);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function convert_to_canvas( $template ) {
|
||||
$is_theme_builder_edit = \Elementor\Plugin::$instance->preview->is_preview_mode() && Utilities::is_theme_builder_template() ? true : false;
|
||||
$_wp_page_template = get_post_meta(get_the_ID(), '_wp_page_template', true);
|
||||
|
||||
if ( $this->is_template_available('content') || $is_theme_builder_edit ) {
|
||||
if ( (is_page() || is_single()) && 'elementor_canvas' === $_wp_page_template && !$is_theme_builder_edit ) {
|
||||
return $template;
|
||||
} else {
|
||||
return WPR_ADDONS_PATH . 'admin/templates/wpr-canvas.php';
|
||||
}
|
||||
} else {
|
||||
return $template;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Theme Builder Content Display
|
||||
*/
|
||||
public function canvas_page_content_display() {
|
||||
// Get Template
|
||||
$template = WPR_Conditions_Manager::canvas_page_content_display_conditions();
|
||||
|
||||
// Display Template
|
||||
Utilities::render_elementor_template( $template );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue styles and scripts.
|
||||
*/
|
||||
public function enqueue_scripts() {
|
||||
|
||||
if ( !class_exists( '\Elementor\Plugin' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Elementor Frontend // Maybe we dont need this (should be extra, because we have everything below)
|
||||
// self::$elementor_instance->frontend->enqueue_styles();
|
||||
|
||||
// if ( class_exists( '\ElementorPro\Plugin' ) ) {
|
||||
// $elementor_pro = \ElementorPro\Plugin::instance();
|
||||
// $elementor_pro->enqueue_frontend_scripts();
|
||||
// }
|
||||
|
||||
// Load Header Template CSS File
|
||||
$heder_conditions = json_decode( get_option('wpr_header_conditions', '[]'), true );
|
||||
$heder_template = WPR_Conditions_Manager::header_footer_display_conditions($heder_conditions);
|
||||
$header_template_id = !is_null($heder_template) ? Utilities::get_template_id($heder_template) : false;
|
||||
|
||||
if ( false !== $header_template_id ) {
|
||||
|
||||
// Load Header Template Assets (Elementor Widget)
|
||||
if ( ! self::$elementor_instance->preview->is_preview_mode() ) {
|
||||
$page_assets = get_post_meta( $header_template_id, Assets::ASSETS_META_KEY, true );
|
||||
if ( ! empty( $page_assets ) ) {
|
||||
self::$elementor_instance->assets_loader->enable_assets( $page_assets );
|
||||
}
|
||||
|
||||
$css_file = Post_CSS::create( get_the_ID() );
|
||||
$css_file->enqueue();
|
||||
}
|
||||
|
||||
// Header Template CSS File
|
||||
if ( class_exists( '\Elementor\Core\Files\CSS\Post' ) ) {
|
||||
$header_css_file = new \Elementor\Core\Files\CSS\Post( $header_template_id );
|
||||
} elseif ( class_exists( '\Elementor\Post_CSS_File' ) ) {
|
||||
$header_css_file = new \Elementor\Post_CSS_File( $header_template_id );
|
||||
}
|
||||
|
||||
$header_css_file->enqueue();
|
||||
}
|
||||
|
||||
// Load Footer Template CSS File
|
||||
$footer_conditions = json_decode( get_option('wpr_footer_conditions', '[]'), true );
|
||||
$footer_template = WPR_Conditions_Manager::header_footer_display_conditions($footer_conditions);
|
||||
$footer_template_id = !is_null($footer_template) ? Utilities::get_template_id($footer_template) : false;
|
||||
|
||||
if ( false !== $footer_template_id ) {
|
||||
// Load Footer Template Assets (Elementor Widget)
|
||||
if ( ! self::$elementor_instance->preview->is_preview_mode() ) {
|
||||
$page_assets = get_post_meta( $footer_template_id, Assets::ASSETS_META_KEY, true );
|
||||
if ( ! empty( $page_assets ) ) {
|
||||
self::$elementor_instance->assets_loader->enable_assets( $page_assets );
|
||||
}
|
||||
|
||||
$css_file = Post_CSS::create( get_the_ID() );
|
||||
$css_file->enqueue();
|
||||
}
|
||||
|
||||
// Footer Template CSS File
|
||||
if ( class_exists( '\Elementor\Core\Files\CSS\Post' ) ) {
|
||||
$footer_css_file = new \Elementor\Core\Files\CSS\Post( $footer_template_id );
|
||||
} elseif ( class_exists( '\Elementor\Post_CSS_File' ) ) {
|
||||
$footer_css_file = new \Elementor\Post_CSS_File( $footer_template_id );
|
||||
}
|
||||
|
||||
$footer_css_file->enqueue();
|
||||
}
|
||||
|
||||
// Load Canvas Content Template CSS File
|
||||
$canvas_conditions = WPR_Conditions_Manager::canvas_page_content_display_conditions();
|
||||
$canvas_template_id = !empty($canvas_conditions) ? Utilities::get_template_id($canvas_conditions) : false;
|
||||
|
||||
if ( false !== $canvas_template_id ) {
|
||||
if ( class_exists( '\Elementor\Core\Files\CSS\Post' ) ) {
|
||||
$footer_css_file = new \Elementor\Core\Files\CSS\Post( $canvas_template_id );
|
||||
} elseif ( class_exists( '\Elementor\Post_CSS_File' ) ) {
|
||||
$footer_css_file = new \Elementor\Post_CSS_File( $canvas_template_id );
|
||||
}
|
||||
|
||||
$footer_css_file->enqueue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,569 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Includes;
|
||||
|
||||
use WprAddons\Plugin;
|
||||
use Elementor\TemplateLibrary\Source_Base;
|
||||
use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* WPR_Templates_Actions setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class WPR_Templates_Actions {
|
||||
|
||||
/**
|
||||
** Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// Save Conditions
|
||||
add_action( 'wp_ajax_wpr_save_template_conditions', [ $this, 'wpr_save_template_conditions' ] );
|
||||
|
||||
// Create Template
|
||||
add_action( 'wp_ajax_wpr_create_template', [ $this, 'wpr_create_template' ] );
|
||||
|
||||
// Import Library Template
|
||||
add_action( 'wp_ajax_wpr_import_library_template', [ $this, 'wpr_import_library_template' ] );
|
||||
|
||||
// Reset Template
|
||||
add_action( 'wp_ajax_wpr_delete_template', [ $this, 'wpr_delete_template' ] );
|
||||
|
||||
// Register Elementor AJAX Actions
|
||||
add_action( 'elementor/ajax/register_actions', [ $this, 'register_elementor_ajax_actions' ] );
|
||||
|
||||
// Enqueue Scripts
|
||||
add_action( 'admin_enqueue_scripts', [ $this, 'templates_library_scripts' ] );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
** Save Template Conditions
|
||||
*/
|
||||
public function wpr_save_template_conditions() {
|
||||
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-options-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
$template = isset($_POST['template']) ? sanitize_text_field(wp_unslash($_POST['template'])): false;
|
||||
|
||||
// Header
|
||||
if ( isset($_POST['wpr_header_conditions']) ) {
|
||||
update_option( 'wpr_header_conditions', $this->sanitize_conditions($_POST['wpr_header_conditions']) ); // phpcs:ignore
|
||||
|
||||
$wpr_header_show_on_canvas = isset($_POST['wpr_header_show_on_canvas']) ? sanitize_text_field(wp_unslash($_POST['wpr_header_show_on_canvas'])): false;
|
||||
if ( $wpr_header_show_on_canvas && $template ) {
|
||||
update_post_meta( Utilities::get_template_id($template), 'wpr_header_show_on_canvas', $wpr_header_show_on_canvas );
|
||||
}
|
||||
}
|
||||
|
||||
// Footer
|
||||
if ( isset($_POST['wpr_footer_conditions']) ) {
|
||||
update_option( 'wpr_footer_conditions', $this->sanitize_conditions($_POST['wpr_footer_conditions']) ); // phpcs:ignore
|
||||
|
||||
$wpr_footer_show_on_canvas = isset($_POST['wpr_footer_show_on_canvas']) ? sanitize_text_field(wp_unslash($_POST['wpr_footer_show_on_canvas'])): false;
|
||||
if ( $wpr_footer_show_on_canvas && $template ) {
|
||||
update_post_meta( Utilities::get_template_id($template), 'wpr_footer_show_on_canvas', $wpr_footer_show_on_canvas );
|
||||
}
|
||||
}
|
||||
|
||||
// Archive
|
||||
if ( isset($_POST['wpr_archive_conditions']) ) {
|
||||
update_option( 'wpr_archive_conditions', $this->sanitize_conditions($_POST['wpr_archive_conditions']) ); // phpcs:ignore
|
||||
}
|
||||
|
||||
// Single
|
||||
if ( isset($_POST['wpr_single_conditions']) ) {
|
||||
update_option( 'wpr_single_conditions', $this->sanitize_conditions($_POST['wpr_single_conditions']) ); // phpcs:ignore
|
||||
}
|
||||
|
||||
// Product Archive
|
||||
if ( isset($_POST['wpr_product_archive_conditions']) ) {
|
||||
update_option( 'wpr_product_archive_conditions', $this->sanitize_conditions($_POST['wpr_product_archive_conditions']) ); // phpcs:ignore
|
||||
}
|
||||
|
||||
// Product Single
|
||||
if ( isset($_POST['wpr_product_single_conditions']) ) {
|
||||
update_option( 'wpr_product_single_conditions', $this->sanitize_conditions($_POST['wpr_product_single_conditions']) ); // phpcs:ignore
|
||||
}
|
||||
|
||||
// Popup
|
||||
if ( isset($_POST['wpr_popup_conditions']) ) {
|
||||
update_option( 'wpr_popup_conditions', $this->sanitize_conditions($_POST['wpr_popup_conditions']) ); // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
public function sanitize_conditions( $data ) {
|
||||
return wp_unslash( json_encode( array_filter( json_decode(stripcslashes($data), true) ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
** Create Template
|
||||
*/
|
||||
public function wpr_create_template() {
|
||||
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-options-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
$user_template_type = isset($_POST['user_template_type']) ? sanitize_text_field(wp_unslash($_POST['user_template_type'])): false;
|
||||
$user_template_library = isset($_POST['user_template_library']) ? sanitize_text_field(wp_unslash($_POST['user_template_library'])): false;
|
||||
$user_template_title = isset($_POST['user_template_title']) ? sanitize_text_field(wp_unslash($_POST['user_template_title'])): false;
|
||||
$user_template_slug = isset($_POST['user_template_slug']) ? sanitize_text_field(wp_unslash($_POST['user_template_slug'])): false;
|
||||
|
||||
$check_post_type =( $user_template_library == 'wpr_templates' || $user_template_library == 'elementor_library' );
|
||||
|
||||
if ( $user_template_title && $check_post_type ) {
|
||||
// Create
|
||||
$template_id = wp_insert_post(array (
|
||||
'post_type' => $user_template_library,
|
||||
'post_title' => $user_template_title,
|
||||
'post_name' => $user_template_slug,
|
||||
'post_content' => '',
|
||||
'post_status' => 'publish'
|
||||
));
|
||||
|
||||
// Set Types
|
||||
if ( 'wpr_templates' === $_POST['user_template_library'] ) {
|
||||
|
||||
wp_set_object_terms( $template_id, [$user_template_type, 'user'], 'wpr_template_type' );
|
||||
|
||||
if ( 'popup' === $_POST['user_template_type'] ) {
|
||||
update_post_meta( $template_id, '_elementor_template_type', 'wpr-popups' );
|
||||
} else {
|
||||
if ( 'header' === $_POST['user_template_type'] ) {
|
||||
update_post_meta( $template_id, '_elementor_template_type', 'wpr-theme-builder-header' );
|
||||
} elseif ( 'footer' === $_POST['user_template_type'] ) {
|
||||
update_post_meta( $template_id, '_elementor_template_type', 'wpr-theme-builder-footer' );
|
||||
} else {
|
||||
update_post_meta( $template_id, '_elementor_template_type', 'wpr-theme-builder' );
|
||||
}
|
||||
|
||||
update_post_meta( $template_id, '_wpr_template_type', $user_template_type );
|
||||
}
|
||||
} else {
|
||||
update_post_meta( $template_id, '_elementor_template_type', 'page' );
|
||||
}
|
||||
|
||||
// Set Canvas Template
|
||||
update_post_meta( $template_id, '_wp_page_template', 'elementor_canvas' ); //tmp - maybe set for wpr_templates only
|
||||
|
||||
// Send ID to JS
|
||||
echo esc_html($template_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Import Library Template
|
||||
*/
|
||||
public function wpr_import_library_template() {
|
||||
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-addons-library-frontend-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
$source = new WPR_Library_Source();
|
||||
$slug = isset($_POST['slug']) ? sanitize_text_field(wp_unslash($_POST['slug'])) : '';
|
||||
$kit = isset($_POST['kit']) ? sanitize_text_field(wp_unslash($_POST['kit'])) : '';
|
||||
$section = isset($_POST['section']) ? sanitize_text_field(wp_unslash($_POST['section'])) : '';
|
||||
|
||||
$data = $source->get_data([
|
||||
'template_id' => $slug,
|
||||
'kit_id' => $kit,
|
||||
'section_id' => $section
|
||||
]);
|
||||
|
||||
$template = '' !== $kit ? $kit : $slug;
|
||||
if ( $this->vts($slug) ) {
|
||||
echo json_encode($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Validate Template
|
||||
*/
|
||||
public function vts( $template ) {
|
||||
// Avoid Cache
|
||||
$randomNum = substr(str_shuffle("0123456789abcdefghijklmnopqrstvwxyzABCDEFGHIJKLMNOPQRSTVWXYZ"), 0, 7);
|
||||
|
||||
$remote_file_url = 'https://royal-elementor-addons.com/library/vts.json?='. $randomNum;
|
||||
|
||||
$tmp_file = download_url( $remote_file_url );
|
||||
|
||||
$file_args = [
|
||||
'name' => 'vts.json',
|
||||
'tmp_name' => $tmp_file,
|
||||
'error' => 0,
|
||||
'size' => filesize( $tmp_file ),
|
||||
];
|
||||
|
||||
$defaults = array(
|
||||
'test_form' => false,
|
||||
'test_size' => true,
|
||||
'test_upload' => true,
|
||||
'mimes' => [
|
||||
'xml' => 'text/xml',
|
||||
'json' => 'text/plain',
|
||||
],
|
||||
'wp_handle_sideload' => 'upload',
|
||||
);
|
||||
|
||||
$local_file = wp_handle_sideload( $file_args, $defaults );
|
||||
|
||||
if ( isset( $local_file['error'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$tmps = json_decode(file_get_contents($local_file['file']));
|
||||
|
||||
// Delete Import File
|
||||
unlink( $local_file['file'] );
|
||||
|
||||
return in_array($template, $tmps) && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
** Reset Template
|
||||
*/
|
||||
public function wpr_delete_template() {
|
||||
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'delete_post-' . $_POST['template_slug'] ) || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
$template_slug = isset($_POST['template_slug']) ? sanitize_text_field(wp_unslash($_POST['template_slug'])): '';
|
||||
$template_library = isset($_POST['template_library']) ? sanitize_text_field(wp_unslash($_POST['template_library'])): '';
|
||||
|
||||
$post = get_page_by_path( $template_slug, OBJECT, $template_library );
|
||||
|
||||
if ( get_post_type($post->ID) == 'wpr_templates' || get_post_type($post->ID) == 'elementor_library' ) {
|
||||
wp_delete_post( $post->ID, true );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Enqueue Scripts and Styles
|
||||
*/
|
||||
public function templates_library_scripts( $hook ) {
|
||||
|
||||
// Get Plugin Version
|
||||
$version = Plugin::instance()->get_version();
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
|
||||
if ( $screen->id === 'edit-wpr_templates' ) {
|
||||
$custom_css = '
|
||||
.wpr-templates-cat-select,
|
||||
.wpr-templates-cat-select option,
|
||||
.wpr-templates-cat-select option:checked {
|
||||
text-transform: capitalize !important;
|
||||
}
|
||||
';
|
||||
|
||||
wp_add_inline_style( 'wp-admin', $custom_css );
|
||||
}
|
||||
|
||||
// Deny if NOT Plugin Page
|
||||
if ( 'toplevel_page_wpr-addons' == $hook || strpos($hook, 'wpr-theme-builder') || strpos($hook, 'wpr-popups') ) {
|
||||
|
||||
// Color Picker
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
wp_enqueue_script( 'wp-color-picker-alpha', WPR_ADDONS_URL .'assets/js/admin/lib/wp-color-picker-alpha.min.js', ['jquery', 'wp-color-picker'], $version, true );
|
||||
|
||||
// Media Upload
|
||||
if ( ! did_action( 'wp_enqueue_media' ) ) {
|
||||
wp_enqueue_media();
|
||||
}
|
||||
|
||||
// enqueue CSS
|
||||
wp_enqueue_style( 'wpr-plugin-options-css', WPR_ADDONS_URL .'assets/css/admin/plugin-options.css', [], $version );
|
||||
|
||||
// enqueue JS
|
||||
wp_enqueue_script( 'wpr-plugin-options-js', WPR_ADDONS_URL .'assets/js/admin/plugin-options.js', ['jquery'], $version );
|
||||
|
||||
wp_localize_script(
|
||||
'wpr-plugin-options-js',
|
||||
'WprPluginOptions', // This is used in the js file to group all of your scripts together
|
||||
[
|
||||
'nonce' => wp_create_nonce( 'wpr-plugin-options-js' ),
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if ( strpos($hook, 'wpr-templates-kit') ) {
|
||||
wp_enqueue_style( 'wpr-templates-kit-css', WPR_ADDONS_URL .'assets/css/admin/templates-kit.css', [], $version );
|
||||
wp_enqueue_script( 'wpr-templates-kit-js', WPR_ADDONS_URL .'assets/js/admin/templates-kit.js', ['jquery', 'updates'], $version );
|
||||
|
||||
wp_localize_script(
|
||||
'wpr-templates-kit-js',
|
||||
'WprTemplatesKitLoc', // This is used in the js file to group all of your scripts together
|
||||
[
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||
'resturl' => get_rest_url() . 'wpraddons/v1',
|
||||
'nonce' => wp_create_nonce( 'wpr-templates-kit-js' ),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if ( strpos($hook, 'wpr-premade-blocks') ) {
|
||||
wp_enqueue_style( 'wpr-premade-blocks-css', WPR_ADDONS_URL .'assets/css/admin/premade-blocks.css', [], $version );
|
||||
|
||||
wp_enqueue_script( 'wpr-macy-js', WPR_ADDONS_URL .'assets/js/lib/macy/macy.js', ['jquery'], $version );
|
||||
wp_enqueue_script( 'wpr-premade-blocks-js', WPR_ADDONS_URL .'assets/js/admin/premade-blocks.js', ['jquery'], $version );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Register Elementor AJAX Actions
|
||||
*/
|
||||
public function register_elementor_ajax_actions( Ajax $ajax ) {
|
||||
|
||||
// Elementor Search Data
|
||||
$ajax->register_ajax_action( 'wpr_elementor_search_data', function( $data ) {
|
||||
// Freemius OptIn
|
||||
if ( ! (wpr_fs()->is_registered() && wpr_fs()->is_tracking_allowed() || wpr_fs()->is_pending_activation() )) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( strlen($data['search_query']) > 25 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send Search Query
|
||||
wp_remote_post( 'https://reastats.kinsta.cloud/wp-json/elementor-search/data', [
|
||||
'body' => [
|
||||
'search_query' => $data['search_query']
|
||||
]
|
||||
] );
|
||||
} );
|
||||
|
||||
// Templates Library Pages Search Data
|
||||
$ajax->register_ajax_action( 'wpr_templates_library_search_data', function( $data ) {
|
||||
// Freemius OptIn
|
||||
if ( ! (wpr_fs()->is_registered() && wpr_fs()->is_tracking_allowed() || wpr_fs()->is_pending_activation() )) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( strlen($data['search_query']) > 25 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send Search Query
|
||||
wp_remote_post( 'https://reastats.kinsta.cloud/wp-json/templates-library-search/data', [
|
||||
'body' => [
|
||||
'search_query' => $data['search_query']
|
||||
]
|
||||
] );
|
||||
} );
|
||||
|
||||
// Templates Library Blocks Search Data
|
||||
$ajax->register_ajax_action( 'wpr_templates_library_blocks_search_data', function( $data ) {
|
||||
// Freemius OptIn
|
||||
if ( ! (wpr_fs()->is_registered() && wpr_fs()->is_tracking_allowed() || wpr_fs()->is_pending_activation() )) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( strlen($data['search_query']) > 25 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send Search Query
|
||||
wp_remote_post( 'https://reastats.kinsta.cloud/wp-json/templates-library-blocks-search/data', [
|
||||
'body' => [
|
||||
'search_query' => $data['search_query']
|
||||
]
|
||||
] );
|
||||
} );
|
||||
|
||||
// Templates Library Sections Search Data
|
||||
$ajax->register_ajax_action( 'wpr_templates_library_sections_search_data', function( $data ) {
|
||||
// Freemius OptIn
|
||||
if ( ! (wpr_fs()->is_registered() && wpr_fs()->is_tracking_allowed() || wpr_fs()->is_pending_activation() )) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( strlen($data['search_query']) > 25 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send Search Query
|
||||
wp_remote_post( 'https://reastats.kinsta.cloud/wp-json/templates-library-sections-search/data', [
|
||||
'body' => [
|
||||
'search_query' => $data['search_query']
|
||||
]
|
||||
] );
|
||||
} );
|
||||
|
||||
// Library Template Import Finished
|
||||
$ajax->register_ajax_action( 'wpr_library_template_import_finished', function( $data ) {
|
||||
Utilities::regenerate_extra_image_sizes();
|
||||
|
||||
// Freemius OptIn
|
||||
if ( ! (wpr_fs()->is_registered() && wpr_fs()->is_tracking_allowed() || wpr_fs()->is_pending_activation() )) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Templates Library Import Block
|
||||
if ( isset($data['block'])) {
|
||||
wp_remote_post( 'https://reastats.kinsta.cloud/wp-json/templates-library-blocks-import/data', [
|
||||
'body' => [
|
||||
'imported_block' => $data['block']
|
||||
]
|
||||
] );
|
||||
}
|
||||
|
||||
// Templates Library Import Section
|
||||
if ( isset($data['section'])) {
|
||||
wp_remote_post( 'https://reastats.kinsta.cloud/wp-json/templates-library-sections-import/data', [
|
||||
'body' => [
|
||||
'imported_section' => $data['section']
|
||||
]
|
||||
] );
|
||||
}
|
||||
|
||||
if ( ! isset($data['kit']) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Templates Library Import Template
|
||||
wp_remote_post( 'https://reastats.kinsta.cloud/wp-json/templates-library-import/data', [
|
||||
'body' => [
|
||||
'imported_template' => $data['kit'] .'-'. $data['template'] . ' *'. WPR_ADDONS_VERSION .'*'
|
||||
]
|
||||
] );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WPR_Templates_Actions setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class WPR_Library_Source extends \Elementor\TemplateLibrary\Source_Base {
|
||||
|
||||
public function get_id() {
|
||||
return 'wpr-layout-manager';
|
||||
}
|
||||
|
||||
public function get_title() {
|
||||
return 'WPR Layout Manager';
|
||||
}
|
||||
|
||||
public function register_data() {}
|
||||
|
||||
public function save_item( $template_data ) {
|
||||
return new \WP_Error( 'invalid_request', 'Cannot save template to a WPR layout manager' );
|
||||
}
|
||||
|
||||
public function update_item( $new_data ) {
|
||||
return new \WP_Error( 'invalid_request', 'Cannot update template to a WPR layout manager' );
|
||||
}
|
||||
|
||||
public function delete_template( $template_id ) {
|
||||
return new \WP_Error( 'invalid_request', 'Cannot delete template from a WPR layout manager' );
|
||||
}
|
||||
|
||||
public function export_template( $template_id ) {
|
||||
return new \WP_Error( 'invalid_request', 'Cannot export template from a WPR layout manager' );
|
||||
}
|
||||
|
||||
public function get_items( $args = [] ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
public function get_item( $template_id ) {
|
||||
$templates = $this->get_items();
|
||||
|
||||
return $templates[ $template_id ];
|
||||
}
|
||||
|
||||
public function request_template_data( $template_id, $kit_id, $section_id ) {
|
||||
if ( empty( $template_id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( '' !== $kit_id ) {
|
||||
$url = 'https://royal-elementor-addons.com/library/templates-kit/'. $kit_id .'/';
|
||||
} elseif ( '' !== $section_id ) {
|
||||
$url = 'https://royal-elementor-addons.com/library/premade-sections/';
|
||||
// $url = 'https://royal-elementor-addons.com/library/premade-sections/'. $kit_id .'/';
|
||||
} else {
|
||||
$url = 'https://royal-elementor-addons.com/library/premade-styles/';
|
||||
}
|
||||
|
||||
// Avoid Cache
|
||||
$randomNum = substr(str_shuffle("0123456789abcdefghijklmnopqrstvwxyzABCDEFGHIJKLMNOPQRSTVWXYZ"), 0, 7);
|
||||
|
||||
$response = wp_remote_get($url . $template_id .'.json?='. $randomNum, [
|
||||
'timeout' => 60,
|
||||
'sslverify' => false
|
||||
] );
|
||||
|
||||
return wp_remote_retrieve_body( $response );
|
||||
}
|
||||
|
||||
public function get_data( array $args ) {
|
||||
$data = $this->request_template_data( $args['template_id'], $args['kit_id'], $args['section_id'] );
|
||||
|
||||
$data = json_decode( $data, true );
|
||||
|
||||
if ( empty( $data ) || empty( $data['content'] ) ) {
|
||||
throw new \Exception( 'Template does not have any content' );
|
||||
}
|
||||
|
||||
add_filter( 'intermediate_image_sizes_advanced', [new Utilities, 'disable_extra_image_sizes'], 10, 3 );
|
||||
|
||||
// Remove Parallax Images from Import File
|
||||
foreach( $data['content'] as $key => $content ) {
|
||||
if ( isset($data['content'][$key]['settings']['bg_image']) ) {
|
||||
unset($data['content'][$key]['settings']['bg_image']);
|
||||
}
|
||||
if ( isset($data['content'][$key]['settings']['hover_parallax']) ) {
|
||||
unset($data['content'][$key]['settings']['hover_parallax']);
|
||||
}
|
||||
}
|
||||
|
||||
$parallax_bg = get_option('wpr-parallax-background', 'on');
|
||||
$parallax_multi = get_option('wpr-parallax-multi-layer', 'on');
|
||||
|
||||
// Disable Extensions during Import
|
||||
if ( 'on' === $parallax_bg ) {
|
||||
update_option('wpr-parallax-background', '');
|
||||
}
|
||||
if ( 'on' === $parallax_multi ) {
|
||||
update_option('wpr-parallax-multi-layer', '');
|
||||
}
|
||||
|
||||
$data['content'] = $this->replace_elements_ids( $data['content'] );
|
||||
$data['content'] = $this->process_export_import_content( $data['content'], 'on_import' );
|
||||
|
||||
// Enable Back
|
||||
if ( 'on' === $parallax_bg ) {
|
||||
update_option('wpr-parallax-background', 'on');
|
||||
}
|
||||
if ( 'on' === $parallax_multi ) {
|
||||
update_option('wpr-parallax-multi-layer', 'on');
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Includes;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* WPR_Templates_Category_Filter setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class WPR_Templates_Category_Filter {
|
||||
|
||||
/**
|
||||
** Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// $which (the position of the filters form) is either 'top' or 'bottom'
|
||||
add_action( 'restrict_manage_posts', function ( $post_type, $which ) {
|
||||
if ( 'top' === $which && 'wpr_templates' === $post_type ) {
|
||||
$taxonomy = 'wpr_template_type';
|
||||
$tax = get_taxonomy( $taxonomy ); // get the taxonomy object/data
|
||||
$cat = filter_input( INPUT_GET, $taxonomy ); // get the selected category slug
|
||||
|
||||
echo '<label class="screen-reader-text" for="wpr_template_type">Filter by ' .
|
||||
esc_html( $tax->labels->singular_name ) . '</label>';
|
||||
|
||||
wp_dropdown_categories( [
|
||||
'walker' => new WPR_Custom_Walker_CategoryDropdown(),
|
||||
'class' => 'wpr-templates-cat-select',
|
||||
'show_option_all' => $tax->labels->all_items,
|
||||
'hide_empty' => 0, // include categories that have no posts
|
||||
'hierarchical' => $tax->hierarchical,
|
||||
'show_count' => 0, // don't show the category's posts count
|
||||
'orderby' => 'name',
|
||||
'selected' => $cat,
|
||||
'taxonomy' => $taxonomy,
|
||||
'name' => $taxonomy,
|
||||
'value_field' => 'slug',
|
||||
] );
|
||||
}
|
||||
}, 10, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
new WPR_Templates_Category_Filter();
|
||||
|
||||
class WPR_Custom_Walker_CategoryDropdown extends \Walker_CategoryDropdown {
|
||||
function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
|
||||
$pad = str_repeat(' ', $depth * 3);
|
||||
|
||||
// Here you can modify the category name
|
||||
$cat_name = apply_filters('list_cats', $category->name, $category);
|
||||
|
||||
// Customization example: append count
|
||||
if( $args['show_count'] ) {
|
||||
$cat_name .= ' ('. $category->count .')';
|
||||
}
|
||||
|
||||
$output .= "\t<option class=\"level-$depth\" value=\"".$category->slug."\"";
|
||||
if ( $category->slug == $args['selected'] ) {
|
||||
$output .= ' selected="selected"';
|
||||
}
|
||||
$output .= '>';
|
||||
$output .= str_replace('_', ' ', $pad.$cat_name);
|
||||
if ( $args['show_count'] ) {
|
||||
$output .= ' ('. $category->count .')';
|
||||
}
|
||||
$output .= "</option>\n";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
use WprAddons\Admin\Includes\WPR_Render_Templates;
|
||||
use WprAddons\Admin\Includes\WPR_Templates_Shortcode;
|
||||
use WprAddons\Admin\Includes\WPR_Templates_Modal_Popups;
|
||||
use WprAddons\Admin\Includes\WPR_Templates_Actions;
|
||||
use WprAddons\Admin\Templates\Library\WPR_Templates_Library_Blocks;
|
||||
use WprAddons\Admin\Templates\Library\WPR_Templates_Library_Sections;
|
||||
use WprAddons\Admin\Templates\Library\WPR_Templates_Library_Pages;
|
||||
use WprAddons\Admin\Templates\Library\WPR_Templates_Library_Popups;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
/**
|
||||
* WPR_Templates_Library setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class WPR_Templates_Library {
|
||||
|
||||
/**
|
||||
** Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// Register CPTs
|
||||
add_action( 'init', [ $this, 'register_templates_library_cpt' ] );
|
||||
add_action( 'template_redirect', [ $this, 'block_template_frontend' ] );
|
||||
add_action( 'current_screen', [ $this, 'redirect_to_options_page' ] );
|
||||
|
||||
// Templates Shortcode
|
||||
new WPR_Templates_Shortcode();
|
||||
|
||||
// Init Popups
|
||||
new WPR_Templates_Modal_Popups();
|
||||
|
||||
// Init Theme Builder
|
||||
new WPR_Render_Templates();
|
||||
|
||||
// Template Actions
|
||||
new WPR_Templates_Actions();
|
||||
|
||||
// Add Blocks to Library
|
||||
new WPR_Templates_Library_Blocks();
|
||||
|
||||
// Add Sections to Library
|
||||
new WPR_Templates_Library_Sections();
|
||||
|
||||
// Add Pages to Library
|
||||
new WPR_Templates_Library_Pages();
|
||||
|
||||
// Add Popups to Library
|
||||
new WPR_Templates_Library_Popups();
|
||||
|
||||
// Enable Elementor for 'wpr_templates'
|
||||
$this->add_elementor_cpt_support();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
** Register Templates Library
|
||||
*/
|
||||
public function redirect_to_options_page() {
|
||||
if ( get_current_screen()->post_type == 'wpr_templates' && isset($_GET['action']) && $_GET['action'] == 'edit' ) {
|
||||
$elementor_template_type = isset($_GET['post']) ? sanitize_text_field(wp_unslash($_GET['post'])) : '';
|
||||
|
||||
if ( 'wpr-popups' === Utilities::get_elementor_template_type( $elementor_template_type ) ) {
|
||||
wp_redirect('admin.php?page=wpr-popups');
|
||||
} else {
|
||||
wp_redirect('admin.php?page=wpr-theme-builder');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function register_templates_library_cpt() {
|
||||
|
||||
$args = array(
|
||||
'label' => esc_html__( 'Royal Templates', 'wpr-addons' ),
|
||||
'public' => true,
|
||||
'rewrite' => false,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'exclude_from_search' => true,
|
||||
'capability_type' => 'post',
|
||||
'hierarchical' => false,
|
||||
);
|
||||
|
||||
register_post_type( 'wpr_templates', $args );
|
||||
|
||||
$tax_args = [
|
||||
'hierarchical' => true,
|
||||
'show_ui' => true,
|
||||
'show_in_nav_menus' => false,
|
||||
'show_admin_column' => true,
|
||||
'query_var' => is_admin(),
|
||||
'rewrite' => false,
|
||||
'public' => false,
|
||||
];
|
||||
|
||||
register_taxonomy( 'wpr_template_type', 'wpr_templates', $tax_args );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
** Don't display on the frontend for non edit_posts capable users
|
||||
*/
|
||||
public function block_template_frontend() {
|
||||
if ( is_singular( 'wpr_templates' ) && ! current_user_can( 'edit_posts' ) ) {
|
||||
wp_redirect( site_url(), 301 );
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*** Add elementor support for wpr_templates.
|
||||
**/
|
||||
function add_elementor_cpt_support() {
|
||||
if ( ! is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cpt_support = get_option( 'elementor_cpt_support' );
|
||||
|
||||
if ( ! $cpt_support ) {
|
||||
update_option( 'elementor_cpt_support', ['post', 'page', 'wpr_templates'] );
|
||||
} elseif ( ! in_array( 'wpr_templates', $cpt_support ) ) {
|
||||
$cpt_support[] = 'wpr_templates';
|
||||
update_option( 'elementor_cpt_support', $cpt_support );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new WPR_Templates_Library();
|
||||
@@ -0,0 +1,524 @@
|
||||
<?php
|
||||
|
||||
namespace WprAddons\Admin\Includes;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
/**
|
||||
** WPR_Templates_Loop setup
|
||||
*/
|
||||
class WPR_Templates_Loop {
|
||||
|
||||
/**
|
||||
** Loop Through Custom Templates
|
||||
*/
|
||||
public static function render_theme_builder_templates( $template ) {
|
||||
// WP_Query arguments
|
||||
$args = array (
|
||||
'post_type' => array( 'wpr_templates' ),
|
||||
'post_status' => array( 'publish' ),
|
||||
'posts_per_page' => -1,
|
||||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'wpr_template_type',
|
||||
'field' => 'slug',
|
||||
'terms' => [ $template, 'user' ],
|
||||
'operator' => 'AND'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// The Query
|
||||
$user_templates = get_posts( $args );
|
||||
|
||||
// The Loop
|
||||
echo '<ul class="wpr-'. esc_attr($template) .'-templates-list wpr-my-templates-list" data-pro="'. esc_attr(defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code()) .'">';
|
||||
|
||||
if ( ! empty( $user_templates ) ) {
|
||||
foreach ( $user_templates as $user_template ) {
|
||||
$slug = $user_template->post_name;
|
||||
|
||||
if ( !str_contains( $slug, 'user-' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$edit_url = str_replace( 'edit', 'elementor', get_edit_post_link( $user_template->ID ) );
|
||||
$show_on_canvas = get_post_meta(Utilities::get_template_id($slug), 'wpr_'. $template .'_show_on_canvas', true);
|
||||
|
||||
echo '<li>';
|
||||
echo '<h3 class="wpr-title">'. esc_html($user_template->post_title) .'</h3>';
|
||||
|
||||
echo '<div class="wpr-action-buttons">';
|
||||
// Activate
|
||||
echo '<span class="wpr-template-conditions button button-primary" data-slug="'. esc_attr($slug) .'" data-show-on-canvas="'. esc_attr($show_on_canvas) .'">'. esc_html__( 'Manage Conditions', 'wpr-addons' ) .'</span>';
|
||||
// Edit
|
||||
echo '<a href="'. esc_url($edit_url) .'" class="wpr-edit-template button button-primary">'. esc_html__( 'Edit Template', 'wpr-addons' ) .'</a>';
|
||||
|
||||
// Delete
|
||||
$one_time_nonce = wp_create_nonce( 'delete_post-' . $slug );
|
||||
|
||||
echo '<span class="wpr-delete-template button button-primary" data-nonce="'. esc_attr($one_time_nonce) .'" data-slug="'. esc_attr($slug) .'" data-warning="'. esc_html__( 'Are you sure you want to delete this template?', 'wpr-addons' ) .'"><span class="dashicons dashicons-no-alt"></span></span>';
|
||||
|
||||
|
||||
echo '</div>';
|
||||
echo '</li>';
|
||||
}
|
||||
} else {
|
||||
echo '<li class="wpr-no-templates">You don\'t have any templates yet!</li>';
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
// Restore original Post Data
|
||||
wp_reset_postdata();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
** Loop Through My Templates
|
||||
*/
|
||||
public static function render_elementor_saved_templates() {
|
||||
|
||||
// WP_Query arguments
|
||||
$args = array (
|
||||
'post_type' => array( 'elementor_library' ),
|
||||
'post_status' => array( 'publish' ),
|
||||
'meta_key' => '_elementor_template_type',
|
||||
'meta_value' => ['page', 'section'],
|
||||
'numberposts' => -1
|
||||
);
|
||||
|
||||
// The Query
|
||||
$user_templates = get_posts( $args );
|
||||
|
||||
// My Templates List
|
||||
echo '<ul class="wpr-my-templates-list striped">';
|
||||
|
||||
// The Loop
|
||||
if ( ! empty( $user_templates ) ) {
|
||||
foreach ( $user_templates as $user_template ) {
|
||||
// Edit URL
|
||||
$edit_url = str_replace( 'edit', 'elementor', get_edit_post_link( $user_template->ID ) );
|
||||
|
||||
// List
|
||||
echo '<li>';
|
||||
echo '<h3 class="wpr-title">'. esc_html($user_template->post_title) .'</h3>';
|
||||
|
||||
echo '<span class="wpr-action-buttons">';
|
||||
echo '<a href="'. esc_url($edit_url) .'" class="wpr-edit-template button button-primary">'. esc_html__( 'Edit', 'wpr-addons' ) .'</a>';
|
||||
echo '<span class="wpr-delete-template button button-primary" data-slug="'. esc_attr($user_template->post_name) .'" data-warning="'. esc_html__( 'Are you sure you want to delete this template?', 'wpr-addons' ) .'"><span class="dashicons dashicons-no-alt"></span></span>';
|
||||
echo '</span>';
|
||||
echo '</li>';
|
||||
}
|
||||
} else {
|
||||
echo '<li class="wpr-no-templates">You don\'t have any templates yet!</li>';
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
||||
// Restore original Post Data
|
||||
wp_reset_postdata();
|
||||
}
|
||||
|
||||
/**
|
||||
** Render Conditions Popup
|
||||
*/
|
||||
public static function render_conditions_popup( $canvas = false ) {
|
||||
|
||||
// Active Tab
|
||||
$active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'wpr_tab_header';
|
||||
|
||||
?>
|
||||
|
||||
<div class="wpr-condition-popup-wrap wpr-admin-popup-wrap">
|
||||
<div class="wpr-condition-popup wpr-admin-popup">
|
||||
<header>
|
||||
<h2><?php esc_html_e( 'Where Do You Want to Display Your Template?', 'wpr-addons' ); ?></h2>
|
||||
<p>
|
||||
<?php esc_html_e( 'Set the conditions that determine where your Template is used throughout your site.', 'wpr-addons' ); ?><br>
|
||||
<?php esc_html_e( 'For example, choose \'Entire Site\' to display the template across your site.', 'wpr-addons' ); ?>
|
||||
</p>
|
||||
</header>
|
||||
<span class="close-popup dashicons dashicons-no-alt"></span>
|
||||
|
||||
<!-- Conditions -->
|
||||
<div class="wpr-conditions-wrap">
|
||||
<div class="wpr-conditions-sample">
|
||||
<?php if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) : ?>
|
||||
<!-- Global -->
|
||||
<select name="global_condition_select" class="global-condition-select">
|
||||
<option value="global"><?php esc_html_e( 'Entire Site', 'wpr-addons' ); ?></option>
|
||||
<option value="archive"><?php esc_html_e( 'Archives', 'wpr-addons' ); ?></option>
|
||||
<option value="single"><?php esc_html_e( 'Singular', 'wpr-addons' ); ?></option>
|
||||
</select>
|
||||
|
||||
<!-- Archive -->
|
||||
<select name="archives_condition_select" class="archives-condition-select">
|
||||
<?php if ( 'wpr_tab_header' === $active_tab || 'wpr_tab_footer' === $active_tab ) : ?>
|
||||
<optgroup label="<?php esc_html_e( 'Archives', 'wpr-addons' ); ?>">
|
||||
<option value="all_archives"><?php esc_html_e( 'All Archives', 'wpr-addons' ); ?></option>
|
||||
<option value="posts"><?php esc_html_e( 'Posts Archive', 'wpr-addons' ); ?></option>
|
||||
<?php // Custom Post Types
|
||||
$custom_post_types = Utilities::get_custom_types_of( 'post', true );
|
||||
foreach ($custom_post_types as $key => $value) {
|
||||
if ( 'e-landing-page' === $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->is_plan( 'expert' ) || 'product' === $key ) {
|
||||
echo '<option value="'. esc_attr($key) .'">'. $value .' '. esc_html__( 'Archive', 'wpr-addons' ) .'</option>';
|
||||
} else {
|
||||
echo '<option value="pro-'. esc_attr(substr($key, 0, 3)) .'">'. $value .' '. esc_html__( 'Archive (Expert)', 'wpr-addons' ) .'</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<option value="author"><?php esc_html_e( 'Author Archive', 'wpr-addons' ); ?></option>
|
||||
<option value="date"><?php esc_html_e( 'Date Archive', 'wpr-addons' ); ?></option>
|
||||
<option value="search"><?php esc_html_e( 'Search Results', 'wpr-addons' ); ?></option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="<?php esc_html_e( 'Taxonomy Archives', 'wpr-addons' ); ?>">
|
||||
<option value="categories" class="custom-ids"><?php esc_html_e( 'Post Categories', 'wpr-addons' ); ?></option>
|
||||
<option value="tags" class="custom-ids"><?php esc_html_e( 'Post Tags', 'wpr-addons' ); ?></option>
|
||||
<?php // Custom Taxonomies
|
||||
$custom_taxonomies = Utilities::get_custom_types_of( 'tax', true );
|
||||
foreach ($custom_taxonomies as $key => $value) {
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->is_plan( 'expert' ) || 'product_cat' === $key || 'product_tag' === $key ) {
|
||||
echo '<option value="'. esc_attr($key) .'" class="custom-type-ids">'. esc_html($value) .'</option>';
|
||||
} else {
|
||||
echo '<option value="pro-'. esc_attr(substr($key, 0, 3)) .'" class="custom-type-ids">'. esc_html($value) .' (Expert)</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</optgroup>
|
||||
<?php else: ?>
|
||||
<?php if ( 'wpr_tab_archive' === $active_tab ) : ?>
|
||||
<optgroup label="<?php esc_html_e( 'Archives', 'wpr-addons' ); ?>">
|
||||
<option value="all_archives"><?php esc_html_e( 'All Archives', 'wpr-addons' ); ?></option>
|
||||
<option value="posts"><?php esc_html_e( 'Posts Archive', 'wpr-addons' ); ?></option>
|
||||
|
||||
<?php // Custom Post Types
|
||||
$custom_post_types = Utilities::get_custom_types_of( 'post', true );
|
||||
foreach ($custom_post_types as $key => $value) {
|
||||
if ( 'product' === $key || 'e-landing-page' === $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->is_plan( 'expert' ) ) {
|
||||
echo '<option value="'. esc_attr($key) .'">'. $value .' '. esc_html__( 'Archive', 'wpr-addons' ) .'</option>';
|
||||
} else {
|
||||
echo '<option value="pro-'. esc_attr(substr($key, 0, 3)) .'">'. $value .' '. esc_html__( 'Archive (Expert)', 'wpr-addons' ) .'</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<option value="author"><?php esc_html_e( 'Author Archive', 'wpr-addons' ); ?></option>
|
||||
<option value="date"><?php esc_html_e( 'Date Archive', 'wpr-addons' ); ?></option>
|
||||
<option value="search"><?php esc_html_e( 'Search Results', 'wpr-addons' ); ?></option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="<?php esc_html_e( 'Taxonomy Archives', 'wpr-addons' ); ?>">
|
||||
<option value="categories" class="custom-ids"><?php esc_html_e( 'Post Categories', 'wpr-addons' ); ?></option>
|
||||
<option value="tags" class="custom-ids"><?php esc_html_e( 'Post Tags', 'wpr-addons' ); ?></option>
|
||||
<?php // Custom Taxonomies
|
||||
$custom_taxonomies = Utilities::get_custom_types_of( 'tax', true );
|
||||
foreach ($custom_taxonomies as $key => $value) {
|
||||
if ( 'product_cat' === $key || 'product_tag' === $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->is_plan( 'expert' ) ) {
|
||||
echo '<option value="'. esc_attr($key) .'" class="custom-type-ids">'. esc_html($value) .'</option>';
|
||||
} else {
|
||||
echo '<option value="pro-'. esc_attr(substr($key, 0, 3)) .'" class="custom-type-ids">'. esc_html($value) .' (Expert)</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</optgroup>
|
||||
<?php elseif ( 'wpr_tab_product_archive' === $active_tab ): ?>
|
||||
<option value="products"><?php esc_html_e( 'Products Archive', 'wpr-addons' ); ?></option>
|
||||
<option value="product_cat" class="custom-type-ids"><?php esc_html_e( 'Products Categories', 'wpr-addons' ); ?></option>
|
||||
<option value="product_tag" class="custom-type-ids"><?php esc_html_e( 'Products Tags', 'wpr-addons' ); ?></option>
|
||||
<option value="product_search"><?php esc_html_e( 'Products Search', 'wpr-addons' ); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
|
||||
<!-- Single -->
|
||||
<select name="singles_condition_select" class="singles-condition-select">
|
||||
<?php if ( 'wpr_tab_header' === $active_tab || 'wpr_tab_footer' === $active_tab ) : ?>
|
||||
<option value="front_page"><?php esc_html_e( 'Front Page', 'wpr-addons' ); ?></option>
|
||||
<option value="page_404"><?php esc_html_e( '404 Page', 'wpr-addons' ); ?></option>
|
||||
<option value="pages" class="custom-ids"><?php esc_html_e( 'Pages', 'wpr-addons' ); ?></option>
|
||||
<option value="posts" class="custom-ids"><?php esc_html_e( 'Posts', 'wpr-addons' ); ?></option>
|
||||
<?php // Custom Post Types
|
||||
$custom_post_types = Utilities::get_custom_types_of( 'post', true );
|
||||
foreach ($custom_post_types as $key => $value) {
|
||||
if ( 'e-landing-page' === $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->is_plan( 'expert' ) || 'product' === $key ) {
|
||||
echo '<option value="'. esc_attr($key) .'" class="custom-type-ids">'. esc_html($value) .'</option>';
|
||||
} else {
|
||||
echo '<option value="pro-'. esc_attr(substr($key, 0, 3)) .'" class="custom-type-ids">'. esc_html($value) .' (Expert)</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php else: ?>
|
||||
<?php if ( 'wpr_tab_single' === $active_tab ) : ?>
|
||||
<option value="front_page"><?php esc_html_e( 'Front Page', 'wpr-addons' ); ?></option>
|
||||
<option value="page_404"><?php esc_html_e( '404 Page', 'wpr-addons' ); ?></option>
|
||||
<option value="pages" class="custom-ids"><?php esc_html_e( 'Pages', 'wpr-addons' ); ?></option>
|
||||
<option value="posts" class="custom-ids"><?php esc_html_e( 'Posts', 'wpr-addons' ); ?></option>
|
||||
|
||||
<?php // Custom Post Types
|
||||
$custom_post_types = Utilities::get_custom_types_of( 'post', true );
|
||||
foreach ($custom_post_types as $key => $value) {
|
||||
if ( 'product' === $key || 'e-landing-page' === $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->is_plan( 'expert' ) ) {
|
||||
echo '<option value="'. esc_attr($key) .'" class="custom-type-ids">'. esc_html($value) .'</option>';
|
||||
} else {
|
||||
echo '<option value="pro-'. esc_attr(substr($key, 0, 3)) .'" class="custom-type-ids">'. esc_html($value) .' (Expert)</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php elseif ( 'wpr_tab_product_single' === $active_tab ): ?>
|
||||
<option value="product" class="custom-product-ids custom-type-ids"><?php esc_html_e( 'Products', 'wpr-addons' ); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
|
||||
<input type="text" placeholder="<?php esc_html_e( 'Enter comma separated IDs', 'wpr-addons' ); ?>" name="condition_input_ids" class="wpr-condition-input-ids">
|
||||
<span class="wpr-delete-template-conditions dashicons dashicons-no-alt"></span>
|
||||
|
||||
<?php else: // Free user conditions ?>
|
||||
|
||||
<!-- Global -->
|
||||
<select name="global_condition_select" class="global-condition-select">
|
||||
<option value="global"><?php esc_html_e( 'Entire Site', 'wpr-addons' ); ?></option>
|
||||
<option value="archive"><?php esc_html_e( 'Archives (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="single"><?php esc_html_e( 'Singular (Pro)', 'wpr-addons' ); ?></option>
|
||||
</select>
|
||||
|
||||
<!-- Archive -->
|
||||
<select name="archives_condition_select" class="archives-condition-select">
|
||||
<?php if ( 'wpr_tab_header' === $active_tab || 'wpr_tab_footer' === $active_tab ) : ?>
|
||||
<optgroup label="<?php esc_html_e( 'Archives', 'wpr-addons' ); ?>">
|
||||
<option value="all_archives"><?php esc_html_e( 'All Archives (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="posts"><?php esc_html_e( 'Posts Archive (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="author"><?php esc_html_e( 'Author Archive (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="date"><?php esc_html_e( 'Date Archive (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="search"><?php esc_html_e( 'Search Results (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="categories" class="custom-ids"><?php esc_html_e( 'Post Categories (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="tags" class="custom-ids"><?php esc_html_e( 'Post Tags (Pro)', 'wpr-addons' ); ?></option>
|
||||
</optgroup>
|
||||
<optgroup label="<?php esc_html_e( 'WooCommerce Archives', 'wpr-addons' ); ?>">
|
||||
<option value="products" class="custom-ids"><?php esc_html_e( 'Products Archive (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="products_cats" class="custom-ids"><?php esc_html_e( 'Product Categories (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="product_tags" class="custom-ids"><?php esc_html_e( 'Product Tags (Pro)', 'wpr-addons' ); ?></option>
|
||||
</optgroup>
|
||||
<optgroup label="<?php esc_html_e( 'Custom Post Type Archives', 'wpr-addons' ); ?>">
|
||||
<?php // Custom Post Types
|
||||
$custom_post_types = Utilities::get_custom_types_of( 'post', true );
|
||||
foreach ($custom_post_types as $key => $value) {
|
||||
if ( 'product' === $key || 'e-landing-page' === $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo '<option value="'. esc_attr(substr($key, 0, 3)) .'" class="custom-type-ids">'. esc_html($value) .' (Expert)</option>';
|
||||
}
|
||||
?>
|
||||
<?php // Custom Taxonomies
|
||||
$custom_taxonomies = Utilities::get_custom_types_of( 'tax', true );
|
||||
foreach ($custom_taxonomies as $key => $value) {
|
||||
if ( 'product_cat' === $key || 'product_tag' === $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// List Taxonomies
|
||||
echo '<option value="'. esc_attr($key) .'" class="custom-type-ids">'. esc_html($value) .' (Expert)</option>';
|
||||
}
|
||||
?>
|
||||
</optgroup>
|
||||
<?php else: ?>
|
||||
<?php if ( 'wpr_tab_archive' === $active_tab ) : ?>
|
||||
<optgroup label="<?php esc_html_e( 'Archives', 'wpr-addons' ); ?>">
|
||||
<option value="all_archives"><?php esc_html_e( 'All Archives', 'wpr-addons' ); ?></option>
|
||||
<option value="posts"><?php esc_html_e( 'Posts Archive', 'wpr-addons' ); ?></option>
|
||||
<option value="author"><?php esc_html_e( 'Author Archive', 'wpr-addons' ); ?></option>
|
||||
<option value="date"><?php esc_html_e( 'Date Archive', 'wpr-addons' ); ?></option>
|
||||
<option value="search"><?php esc_html_e( 'Search Results', 'wpr-addons' ); ?></option>
|
||||
<option value="categories" class="custom-ids"><?php esc_html_e( 'Post Categories', 'wpr-addons' ); ?></option>
|
||||
<option value="tags" class="custom-ids"><?php esc_html_e( 'Post Tags', 'wpr-addons' ); ?></option>
|
||||
</optgroup>
|
||||
<optgroup label="<?php esc_html_e( 'Custom Post Type Archives', 'wpr-addons' ); ?>">
|
||||
<?php // Custom Post Types
|
||||
$custom_post_types = Utilities::get_custom_types_of( 'post', true );
|
||||
foreach ($custom_post_types as $key => $value) {
|
||||
if ( 'product' === $key || 'e-landing-page' === $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo '<option value="'. esc_attr(substr($key, 0, 3)) .'" class="custom-type-ids">'. esc_html($value) .' (Expert)</option>';
|
||||
}
|
||||
?>
|
||||
<?php // Custom Taxonomies
|
||||
$custom_taxonomies = Utilities::get_custom_types_of( 'tax', true );
|
||||
foreach ($custom_taxonomies as $key => $value) {
|
||||
if ( 'product_cat' === $key || 'product_tag' === $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// List Taxonomies
|
||||
echo '<option value="'. esc_attr($key) .'" class="custom-type-ids">'. esc_html($value) .' (Expert)</option>';
|
||||
}
|
||||
?>
|
||||
</optgroup>
|
||||
<?php elseif ( 'wpr_tab_product_archive' === $active_tab ): ?>
|
||||
<option value="products"><?php esc_html_e( 'Products Archive', 'wpr-addons' ); ?></option>
|
||||
<option value="product_cat" class="custom-type-ids"><?php esc_html_e( 'Products Categories (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="product_tag" class="custom-type-ids"><?php esc_html_e( 'Products Tags (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="product_search"><?php esc_html_e( 'Products Search (Pro)', 'wpr-addons' ); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
|
||||
<!-- Single -->
|
||||
<select name="singles_condition_select" class="singles-condition-select">
|
||||
<?php if ( 'wpr_tab_header' === $active_tab || 'wpr_tab_footer' === $active_tab ) : ?>
|
||||
<option value="front_page"><?php esc_html_e( 'Front Page (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="page_404"><?php esc_html_e( '404 Page (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="pages" class="custom-ids"><?php esc_html_e( 'Pages (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="posts" class="custom-ids"><?php esc_html_e( 'Posts (Pro)', 'wpr-addons' ); ?></option>
|
||||
<option value="product" class="custom-ids"><?php esc_html_e( 'Product (Pro)', 'wpr-addons' ); ?></option>
|
||||
<?php // Custom Post Types
|
||||
$custom_post_types = Utilities::get_custom_types_of( 'post', true );
|
||||
foreach ($custom_post_types as $key => $value) {
|
||||
if ( 'product' === $key || 'e-landing-page' === $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo '<option value="'. esc_attr($key) .'" class="custom-type-ids">'. esc_html($value) .' (Expert)</option>';
|
||||
}
|
||||
?>
|
||||
<?php else: ?>
|
||||
<?php if ( 'wpr_tab_single' === $active_tab ) : ?>
|
||||
<option value="front_page"><?php esc_html_e( 'Front Page', 'wpr-addons' ); ?></option>
|
||||
<option value="page_404"><?php esc_html_e( '404 Page', 'wpr-addons' ); ?></option>
|
||||
<option value="pages" class="custom-ids"><?php esc_html_e( 'Pages', 'wpr-addons' ); ?></option>
|
||||
<option value="posts" class="custom-ids"><?php esc_html_e( 'Posts', 'wpr-addons' ); ?></option>
|
||||
|
||||
<?php // Custom Post Types
|
||||
$custom_post_types = Utilities::get_custom_types_of( 'post', true );
|
||||
foreach ($custom_post_types as $key => $value) {
|
||||
if ( 'product' === $key || 'e-landing-page' === $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo '<option value="'. esc_attr($key) .'" class="custom-type-ids">'. esc_html($value) .' (Expert)</option>';
|
||||
}
|
||||
?>
|
||||
<?php elseif ( 'wpr_tab_product_single' === $active_tab ): ?>
|
||||
<option value="product" class="custom-type-ids"><?php esc_html_e( 'Products', 'wpr-addons' ); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
|
||||
<input type="text" placeholder="<?php esc_html_e( 'Enter comma separated IDs (Pro)', 'wpr-addons' ); ?>" name="condition_input_ids" class="wpr-condition-input-ids">
|
||||
<span class="wpr-delete-template-conditions dashicons dashicons-no-alt"></span>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php // Expert Notice
|
||||
|
||||
if ( !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->is_plan( 'expert' ) ) {
|
||||
echo '<span class="wpr-expert-notice" style="display:none;text-align:center;"><br>
|
||||
<span style="color:#f44;font-size:18px;" class="dashicons dashicons-warning"></span>
|
||||
<strong style="color:#f44;">Please Note:</strong>
|
||||
<strong>Custom Post Types</strong>, <strong>Custom Taxonomies</strong> and <strong>Custom Fields</strong><br>
|
||||
are only supported in the <strong style="color:#f44;"><a href="https://royal-elementor-addons.com/?ref=rea-plugin-backend-conditions-upgrade-expert#purchasepro" target="_blank" style="text-decoration:none">Expert Version.</a></strong>
|
||||
</span>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php if ( $canvas ) : ?>
|
||||
<div class="wpr-canvas-condition wpr-setting-custom-ckbox">
|
||||
<span><?php esc_html_e( 'Show this template on Elementor Canvas pages', 'wpr-addons' ); ?></span>
|
||||
<input type="checkbox" name="wpr-show-on-canvas" id="wpr-show-on-canvas">
|
||||
<label for="wpr-show-on-canvas"></label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
// Pro Notice
|
||||
if ( !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ) {
|
||||
echo '<span style="color: #7f8b96;"><br>Conditions are fully supported in the <strong><a href="https://royal-elementor-addons.com/?ref=rea-plugin-backend-conditions-upgrade-pro#purchasepro" target="_blank">Pro and Expert versions.</a></strong></span>';
|
||||
// echo '<span style="color: #7f8b96;"><br>Conditions are fully supported in the <strong><a href="'. admin_url('admin.php?page=wpr-addons-pricing') .'" target="_blank">Pro version</a></strong></span>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<span class="wpr-add-conditions"><?php esc_html_e( 'Add Conditions', 'wpr-addons' ); ?></span>
|
||||
<span class="wpr-save-conditions"><?php esc_html_e( 'Save Conditions', 'wpr-addons' ); ?></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
** Render Create Template Popup
|
||||
*/
|
||||
public static function render_create_template_popup() {
|
||||
?>
|
||||
|
||||
<!-- Custom Template Popup -->
|
||||
<div class="wpr-user-template-popup-wrap wpr-admin-popup-wrap">
|
||||
<div class="wpr-user-template-popup wpr-admin-popup">
|
||||
<header>
|
||||
<h2><?php esc_html_e( 'Templates Help You Work Efficiently!', 'wpr-addons' ); ?></h2>
|
||||
<p><?php esc_html_e( 'Use templates to create the different pieces of your site, and reuse them with one click whenever needed.', 'wpr-addons' ); ?></p>
|
||||
</header>
|
||||
|
||||
<input type="text" name="user_template_title" class="wpr-user-template-title" placeholder="<?php esc_html_e( 'Enter Template Title', 'wpr-addons' ); ?>">
|
||||
<input type="hidden" name="user_template_type" class="user-template-type">
|
||||
<span class="wpr-create-template"><?php esc_html_e( 'Create Template', 'wpr-addons' ); ?></span>
|
||||
<span class="close-popup dashicons dashicons-no-alt"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
** Check if Library Template Exists
|
||||
*/
|
||||
public static function template_exists( $slug ) {
|
||||
$result = false;
|
||||
$wpr_templates = get_posts( ['post_type' => 'wpr_templates', 'posts_per_page' => '-1'] );
|
||||
|
||||
foreach ( $wpr_templates as $post ) {
|
||||
|
||||
if ( $slug === $post->post_name ) {
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Includes;
|
||||
|
||||
use WprAddons\Plugin;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* WPR_Templates_Modal_Popups setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class WPR_Templates_Modal_Popups {
|
||||
|
||||
/**
|
||||
** Instance of Elemenntor Frontend class.
|
||||
*
|
||||
** @var \Elementor\Frontend()
|
||||
*/
|
||||
private static $elementor_instance;
|
||||
|
||||
/**
|
||||
** Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Elementor Frontend
|
||||
self::$elementor_instance = \Elementor\Plugin::instance();
|
||||
|
||||
add_action( 'template_include', [ $this, 'set_post_type_template' ], 9999 );
|
||||
|
||||
add_action( 'wp_footer', [ $this, 'render_popups' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set blank template for editor
|
||||
*/
|
||||
public function set_post_type_template( $template ) {
|
||||
|
||||
if ( is_singular( 'wpr_templates' ) ) {
|
||||
if ( 'wpr-popups' === Utilities::get_elementor_template_type(get_the_ID()) && self::$elementor_instance->preview->is_preview_mode() ) {
|
||||
$template = WPR_ADDONS_PATH . 'modules/popup/editor.php';
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
** Popups
|
||||
*/
|
||||
public function render_popups() {
|
||||
$conditions = json_decode( get_option('wpr_popup_conditions'), true );
|
||||
|
||||
if ( ! empty( $conditions ) ) {
|
||||
$conditions = $this->reverse_template_conditions( $conditions );
|
||||
|
||||
// Global
|
||||
if ( isset( $conditions['global'] ) ) {
|
||||
WPR_Templates_Modal_Popups::display_popups_by_location( $conditions, 'global' );
|
||||
}
|
||||
|
||||
// Custom
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) {
|
||||
// Archive
|
||||
\WprAddonsPro\Classes\Pro_Modules::archive_pages_popup_conditions( $conditions );
|
||||
|
||||
// Single
|
||||
\WprAddonsPro\Classes\Pro_Modules::single_pages_popup_conditions( $conditions );
|
||||
}
|
||||
|
||||
|
||||
// Enqueue ScrolBar JS //TODO - check if displayed multiple times
|
||||
wp_enqueue_script( 'wpr-popup-scroll-js', WPR_ADDONS_URL .'assets/js/lib/perfect-scrollbar/perfect-scrollbar.min.js', [ 'jquery' ], '0.4.9' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Reverse Template Conditions
|
||||
*/
|
||||
public function reverse_template_conditions( $conditions ) {
|
||||
$reverse = [];
|
||||
|
||||
foreach ( $conditions as $key => $condition ) {
|
||||
foreach( $condition as $location ) {
|
||||
if ( ! isset( $reverse[$location] ) ) {
|
||||
$reverse[$location] = [ $key ];
|
||||
} else {
|
||||
array_push( $reverse[$location], $key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $reverse;
|
||||
}
|
||||
|
||||
/**
|
||||
** Display Popups by Location
|
||||
*/
|
||||
public static function display_popups_by_location( $conditions, $page ) {
|
||||
foreach ( $conditions[$page] as $key => $popup ) {
|
||||
WPR_Templates_Modal_Popups::render_popup_content( $popup );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Display Elementor Content
|
||||
*/
|
||||
public static function render_popup_content( $slug ) {
|
||||
$template_name = '';
|
||||
|
||||
$template_id = Utilities::get_template_id( $slug );
|
||||
|
||||
if ( defined('ICL_LANGUAGE_CODE') ) {
|
||||
$default_language_code = apply_filters('wpml_default_language', null);
|
||||
$current_language_code = apply_filters( 'wpml_current_language', NULL );
|
||||
|
||||
|
||||
IF ( ICL_LANGUAGE_CODE !== $default_language_code ) {
|
||||
$template_id = apply_filters('wpml_object_id', $template_id, 'wpr_templates', true, $current_language_code);
|
||||
}
|
||||
}
|
||||
|
||||
$get_settings = WPR_Templates_Modal_Popups::get_template_settings( $slug );
|
||||
$get_elementor_content = self::$elementor_instance->frontend->get_builder_content( $template_id, false );
|
||||
|
||||
if ( '' === $get_elementor_content ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Encode Settings
|
||||
$get_encoded_settings = ! empty( $get_settings ) ? wp_json_encode( $get_settings ) : '[]';
|
||||
|
||||
// Template Settings Attribute
|
||||
$template_settings_attr = "data-settings='". esc_attr($get_encoded_settings) ."'";
|
||||
|
||||
// Return if NOT available for current user
|
||||
if ( ! WPR_Templates_Modal_Popups::check_available_user_roles( $get_settings['popup_show_for_roles'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! self::$elementor_instance->preview->is_preview_mode() ) {
|
||||
echo '<div id="wpr-popup-id-'. esc_attr($template_id) .'" class="wpr-template-popup" '. $template_settings_attr .'>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<div class="wpr-template-popup-inner">';
|
||||
|
||||
// Popup Overlay & Close Button
|
||||
echo '<div class="wpr-popup-overlay"></div>';
|
||||
|
||||
// Template Container
|
||||
echo '<div class="wpr-popup-container">';
|
||||
|
||||
// Close Button
|
||||
if ( \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_font_icon_svg' ) ) { // GOGA: why not included
|
||||
echo '<div class="wpr-popup-close-btn"><i class="fa fa-times"></i></div>';
|
||||
} else {
|
||||
echo '<div class="wpr-popup-close-btn"><i class="eicon-close"></i></div>';
|
||||
}
|
||||
|
||||
// Elementor Template Content
|
||||
echo '<div class="wpr-popup-container-inner">';
|
||||
echo ''. $get_elementor_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Get Template Settings
|
||||
*/
|
||||
public static function get_template_settings( $slug ) {
|
||||
$settings = [];
|
||||
$defaults = [];
|
||||
|
||||
$template_id = Utilities::get_template_id( $slug );
|
||||
$meta_settings = get_post_meta( $template_id, '_elementor_page_settings', true );
|
||||
|
||||
$popup_defaults = [
|
||||
'popup_trigger' => 'load',
|
||||
'popup_load_delay' => 1,
|
||||
'popup_scroll_progress' => 10,
|
||||
'popup_inactivity_time' => 15,
|
||||
'popup_element_scroll' => '',
|
||||
'popup_custom_trigger' => '',
|
||||
'popup_specific_date' => date( 'Y-m-d H:i', strtotime( '+1 month' ) + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ),
|
||||
'popup_stop_after_date' => false,
|
||||
'popup_stop_after_date_select' => date( 'Y-m-d H:i', strtotime( '+1 day' ) + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ),
|
||||
'popup_show_again_delay' => 1,
|
||||
'popup_disable_esc_key' => false,
|
||||
'popup_automatic_close_switch' => false,
|
||||
'popup_automatic_close_delay' => 10,
|
||||
'popup_animation' => 'fade',
|
||||
'popup_animation_duration' => 1,
|
||||
'popup_show_for_roles' => '',
|
||||
'popup_show_via_referral' => false,
|
||||
'popup_referral_keyword' => '',
|
||||
'popup_display_as' => 'modal',
|
||||
'popup_show_on_device' => true,
|
||||
'popup_show_on_device_mobile' => true,
|
||||
'popup_show_on_device_tablet' => true,
|
||||
'popup_disable_page_scroll' => true,
|
||||
'popup_overlay_disable_close' => false,
|
||||
'popup_close_button_display_delay' => 0,
|
||||
];
|
||||
|
||||
// Determine Template
|
||||
if ( strpos( $slug, 'popup') ) {
|
||||
$defaults = $popup_defaults;
|
||||
}
|
||||
|
||||
foreach( $defaults as $option => $value ) {
|
||||
if ( isset($meta_settings[$option]) ) {
|
||||
$settings[$option] = $meta_settings[$option];
|
||||
}
|
||||
}
|
||||
|
||||
return array_merge( $defaults, $settings );
|
||||
}
|
||||
|
||||
/**
|
||||
** Check Available User Rols
|
||||
*/
|
||||
public static function check_available_user_roles( $selected_roles ) {
|
||||
if ( empty( $selected_roles ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$current_user = wp_get_current_user();
|
||||
|
||||
if ( ! empty( $current_user->roles ) ) {
|
||||
$role = $current_user->roles[0];
|
||||
} else {
|
||||
$role = 'guest';
|
||||
}
|
||||
|
||||
if ( in_array( $role, $selected_roles ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace WprAddons\Admin\Includes;
|
||||
|
||||
use Elementor;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* WPR_Templates_Shortcode setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class WPR_Templates_Shortcode {
|
||||
|
||||
public function __construct() {
|
||||
add_shortcode( 'wpr-template', [ $this, 'shortcode' ] );
|
||||
|
||||
add_action('elementor/element/after_section_start', [ $this, 'extend_shortcode' ], 10, 3 );
|
||||
}
|
||||
|
||||
public function shortcode( $attributes = [] ) {
|
||||
if ( empty( $attributes['id'] ) ) {
|
||||
return '';
|
||||
} else {
|
||||
$id = intval($attributes['id']);
|
||||
}
|
||||
|
||||
// Ensure only publicly published posts can be accessed
|
||||
$post = get_post($id);
|
||||
|
||||
if (!$post || $post->post_status !== 'publish' || in_array($post->post_status, ['draft', 'private', 'future'])) {
|
||||
return 'You do not have permission to view this post.';
|
||||
}
|
||||
|
||||
// Optionally check if the post is password protected
|
||||
if (post_password_required($post)) {
|
||||
return 'This post is password protected.';
|
||||
}
|
||||
|
||||
// WPML language handling
|
||||
if (defined('ICL_LANGUAGE_CODE')) {
|
||||
$default_language_code = apply_filters('wpml_default_language', null);
|
||||
|
||||
if ( ICL_LANGUAGE_CODE !== $default_language_code ) {
|
||||
$id = icl_object_id($id, 'elementor_library', false, ICL_LANGUAGE_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
$edit_link = '<span class="wpr-template-edit-btn" data-permalink="'. esc_url(get_permalink($id)) .'">Edit Template</span>';
|
||||
|
||||
$type = get_post_meta(get_the_ID(), '_wpr_template_type', true) || get_post_meta($id, '_elementor_template_type', true);
|
||||
$has_css = 'internal' === get_option( 'elementor_css_print_method' ) || '' !== $type;
|
||||
|
||||
return Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $id, $has_css ) . $edit_link;
|
||||
}
|
||||
|
||||
public function extend_shortcode( $section, $section_id, $args ) {
|
||||
if ( $section->get_name() == 'shortcode' && $section_id == 'section_shortcode' ) {
|
||||
$section->add_control(
|
||||
'select_template' ,
|
||||
[
|
||||
'label' => esc_html__( 'Select Template', 'wpr-addons' ),
|
||||
'type' => 'wpr-ajax-select2',
|
||||
'options' => 'ajaxselect2/get_elementor_templates',
|
||||
'label_block' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,393 @@
|
||||
<?php
|
||||
use WprAddons\Plugin;
|
||||
|
||||
// Register Post Type
|
||||
function register_mega_menu_cpt() {
|
||||
$args = array(
|
||||
'label' => esc_html__( 'Royal Mega Menu', 'wpr-addons' ),
|
||||
'public' => true,
|
||||
'publicly_queryable' => true,
|
||||
'rewrite' => false,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'exclude_from_search' => true,
|
||||
'capability_type' => 'post',
|
||||
'supports' => array( 'title', 'editor', 'elementor' ),
|
||||
'hierarchical' => false,
|
||||
);
|
||||
|
||||
register_post_type( 'wpr_mega_menu', $args );
|
||||
}
|
||||
|
||||
// Convert to Canvas Template
|
||||
function convert_to_canvas_template( $template ) {
|
||||
if ( is_singular('wpr_mega_menu') ) {
|
||||
$template = WPR_ADDONS_PATH . 'admin/templates/wpr-canvas.php';
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
// Init Mega Menu
|
||||
function init_mega_menu() {
|
||||
register_mega_menu_cpt();
|
||||
add_action( 'template_include', 'convert_to_canvas_template', 9999 );
|
||||
}
|
||||
|
||||
add_action('init', 'init_mega_menu', 999);
|
||||
|
||||
|
||||
// Confinue only for Dashboard Screen
|
||||
if ( !is_admin() ) return;
|
||||
|
||||
// Init Actions
|
||||
add_filter( 'option_elementor_cpt_support', 'add_mega_menu_cpt_support' );
|
||||
add_filter( 'default_option_elementor_cpt_support', 'add_mega_menu_cpt_support' );
|
||||
add_action( 'admin_footer', 'render_settings_popup', 10 );
|
||||
add_action( 'wp_ajax_wpr_create_mega_menu_template', 'wpr_create_mega_menu_template' );
|
||||
add_action( 'wp_ajax_wpr_save_mega_menu_settings', 'wpr_save_mega_menu_settings' );
|
||||
add_action( 'admin_enqueue_scripts', 'enqueue_scripts' );
|
||||
|
||||
// Add Elementor Editor Support
|
||||
function add_mega_menu_cpt_support( $value ) {
|
||||
if ( empty( $value ) ) {
|
||||
$value = [];
|
||||
}
|
||||
|
||||
return array_merge( $value, ['wpr_mega_menu'] );
|
||||
}
|
||||
|
||||
// Create Menu Template
|
||||
function wpr_create_mega_menu_template() {
|
||||
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-mega-menu-js' ) || !current_user_can( 'manage_options' ) ) {
|
||||
return; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
// $menu_id = intval( $_REQUEST['menu'] );
|
||||
// $menu_item_id = intval( $_REQUEST['item'] );
|
||||
$menu_item_id = intval( $_POST['item_id'] );
|
||||
$mega_menu_id = get_post_meta( $menu_item_id, 'wpr-mega-menu-item', true );
|
||||
|
||||
if ( ! $mega_menu_id ) {
|
||||
|
||||
$mega_menu_id = wp_insert_post( array(
|
||||
'post_title' => 'wpr-mega-menu-item-' . $menu_item_id,
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'wpr_mega_menu',
|
||||
) );
|
||||
|
||||
update_post_meta( $menu_item_id, 'wpr-mega-menu-item', $mega_menu_id );
|
||||
|
||||
}
|
||||
|
||||
$edit_link = add_query_arg(
|
||||
array(
|
||||
'post' => $mega_menu_id,
|
||||
'action' => 'elementor',
|
||||
),
|
||||
admin_url( 'post.php' )
|
||||
);
|
||||
|
||||
wp_send_json([
|
||||
'data' => [
|
||||
'edit_link' => $edit_link
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
// Render Settings Popup
|
||||
function render_settings_popup() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( 'nav-menus' !== $screen->base ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="wpr-mm-settings-popup-wrap">
|
||||
<div class="wpr-mm-settings-popup">
|
||||
<div class="wpr-mm-settings-popup-header">
|
||||
<span class="wpr-mm-popup-logo" style="background:url('<?php echo WPR_ADDONS_ASSETS_URL .'img/logo-40x40.png'; ?>') no-repeat center center / contain;">RE</span>
|
||||
<span><?php esc_html_e('Royal Mega Menu', 'wpr-addons'); ?></span>
|
||||
<span class="wpr-mm-popup-title"><?php esc_html_e('Menu Item: ', 'wpr-addons'); ?><span></span></span>
|
||||
<span class="dashicons dashicons-no-alt wpr-mm-settings-close-popup-btn"></span>
|
||||
</div>
|
||||
|
||||
<?php $pro_active = defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ? 'data-pro-active="true"' : 'data-pro-active="false"'; ?>
|
||||
|
||||
<div class="wpr-mm-settings-wrap" <?php echo $pro_active; ?>>
|
||||
<h4><?php esc_html_e('General', 'wpr-addons'); ?></h4>
|
||||
<div class="wpr-mm-setting wpr-mm-setting-switcher">
|
||||
<h4><?php esc_html_e('Enable Mega Menu', 'wpr-addons'); ?></h4>
|
||||
<input type="checkbox" id="wpr_mm_enable">
|
||||
<label for="wpr_mm_enable"></label>
|
||||
</div>
|
||||
<div class="wpr-mm-setting">
|
||||
<h4><?php esc_html_e('Mega Menu Content', 'wpr-addons'); ?></h4>
|
||||
<button class="button button-primary wpr-edit-mega-menu-btn">
|
||||
<i class="eicon-elementor-square" aria-hidden="true"></i>
|
||||
<?php esc_html_e('Edit with Elementor', 'wpr-addons'); ?>
|
||||
</button>
|
||||
</div>
|
||||
<div class="wpr-mm-setting">
|
||||
<h4><?php esc_html_e('Dropdown Position', 'wpr-addons'); ?></h4>
|
||||
<select id="wpr_mm_position">
|
||||
<option value="default"><?php esc_html_e('Default', 'wpr-addons'); ?></option>
|
||||
<option value="relative"><?php esc_html_e('Relative', 'wpr-addons'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="wpr-mm-setting">
|
||||
<h4><?php esc_html_e('Dropdown Width', 'wpr-addons'); ?></h4>
|
||||
<select id="wpr_mm_width">
|
||||
<option value="default"><?php esc_html_e('Default', 'wpr-addons'); ?></option>
|
||||
<?php if ( !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ) : ?>
|
||||
<option value="pro-st"><?php esc_html_e('Fit to Section (Pro)', 'wpr-addons'); ?></option>
|
||||
<?php else: ?>
|
||||
<option value="stretch"><?php esc_html_e('Fit to Section', 'wpr-addons'); ?></option>
|
||||
<?php endif; ?>
|
||||
<option value="full"><?php esc_html_e('Full Width', 'wpr-addons'); ?></option>
|
||||
<option value="custom"><?php esc_html_e('Custom', 'wpr-addons'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="wpr-mm-setting">
|
||||
<h4><?php esc_html_e('Custom Width (px)', 'wpr-addons'); ?></h4>
|
||||
<input type="number" id="wpr_mm_custom_width" value="600">
|
||||
</div>
|
||||
<div class="wpr-mm-setting <?php echo !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ? 'wpr-mm-pro-setting' : ''; ?>">
|
||||
<h4><?php esc_html_e('Mobile Sub Content', 'wpr-addons'); ?></h4>
|
||||
<div>
|
||||
<select id="wpr_mm_mobile_content">
|
||||
<option value="mega"><?php esc_html_e('Mega Menu', 'wpr-addons'); ?></option>
|
||||
<option value="wp-sub"><?php esc_html_e('WordPress Sub Items', 'wpr-addons'); ?></option>
|
||||
</select>
|
||||
|
||||
<div class="wpr-mm-pro-radio">
|
||||
<input type="radio" name="mc" checked="checked">
|
||||
<label>Mega Menu</label><br>
|
||||
<input type="radio" name="mc">
|
||||
<label>WordPress Sub Items</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpr-mm-setting <?php echo !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ? 'wpr-mm-pro-setting' : ''; ?>">
|
||||
<h4><?php esc_html_e('Mobile Sub Render', 'wpr-addons'); ?></h4>
|
||||
<div>
|
||||
<select id="wpr_mm_render">
|
||||
<option value="default"><?php esc_html_e('Default', 'wpr-addons'); ?></option>
|
||||
<option value="ajax"><?php esc_html_e('Load with AJAX', 'wpr-addons'); ?></option>
|
||||
</select>
|
||||
|
||||
<div class="wpr-mm-pro-radio">
|
||||
<input type="radio" name="mr" checked="checked">
|
||||
<label>Default</label><br>
|
||||
<input type="radio" name="mr">
|
||||
<label>Load with AJAX</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<h4 <?php echo !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ? 'class="wpr-mm-pro-heading"' : ''; ?>>
|
||||
<?php esc_html_e('Icon', 'wpr-addons'); ?>
|
||||
</h4>
|
||||
<div <?php echo !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ? 'class="wpr-mm-pro-section"' : ''; ?>>
|
||||
<div class="wpr-mm-setting wpr-mm-setting-icon">
|
||||
<h4><?php esc_html_e('Icon Select', 'wpr-addons'); ?></h4>
|
||||
<div><span class="wpr-mm-active-icon"><i class="fas fa-ban"></i></span><span><i class="fas fa-angle-down"></i></span></div>
|
||||
<input type="text" id="wpr_mm_icon_picker" data-alpha="true" value="">
|
||||
</div>
|
||||
<div class="wpr-mm-setting wpr-mm-setting-color">
|
||||
<h4><?php esc_html_e('Icon Color', 'wpr-addons'); ?></h4>
|
||||
<input type="text" id="wpr_mm_icon_color" data-alpha="true" value="rgba(0,0,0,0.6);">
|
||||
</div>
|
||||
<div class="wpr-mm-setting">
|
||||
<h4><?php esc_html_e('Icon Size (px)', 'wpr-addons'); ?></h4>
|
||||
<input type="number" id="wpr_mm_icon_size" value="14">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<h4 <?php echo !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ? 'class="wpr-mm-pro-heading"' : ''; ?>>
|
||||
<?php esc_html_e('Badge', 'wpr-addons'); ?>
|
||||
</h4>
|
||||
<div <?php echo !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ? 'class="wpr-mm-pro-section"' : ''; ?>>
|
||||
<div class="wpr-mm-setting">
|
||||
<h4><?php esc_html_e('Badge Text', 'wpr-addons'); ?></h4>
|
||||
<input type="text" id="wpr_mm_badge_text" value="">
|
||||
</div>
|
||||
<div class="wpr-mm-setting wpr-mm-setting-color">
|
||||
<h4><?php esc_html_e('Badge Text Color', 'wpr-addons'); ?></h4>
|
||||
<input type="text" id="wpr_mm_badge_color" data-alpha="true" value="rgba(0,0,0,0.6);">
|
||||
</div>
|
||||
<div class="wpr-mm-setting wpr-mm-setting-color">
|
||||
<h4><?php esc_html_e('Badge Background Color', 'wpr-addons'); ?></h4>
|
||||
<input type="text" id="wpr_mm_badge_bg_color" data-alpha="true" value="rgba(0,0,0,0.6);">
|
||||
</div>
|
||||
<div class="wpr-mm-setting wpr-mm-setting-switcher">
|
||||
<h4><?php esc_html_e('Enable Animation', 'wpr-addons'); ?></h4>
|
||||
<input type="checkbox" id="wpr_mm_badge_animation">
|
||||
<label for="wpr_mm_badge_animation"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpr-mm-settings-popup-footer">
|
||||
<button class="button wpr-save-mega-menu-btn"><?php esc_html_e('Save', 'wpr-addons'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Iframe Popup -->
|
||||
<div class="wpr-mm-editor-popup-wrap">
|
||||
<div class="wpr-mm-editor-close-popup-btn"><span class="dashicons dashicons-no-alt"></span></div>
|
||||
<div class="wpr-mm-editor-popup-iframe"></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Save Mega Menu Settings
|
||||
function wpr_save_mega_menu_settings() {
|
||||
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-mega-menu-js' ) || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
if ( isset($_POST['item_settings']) ) {
|
||||
update_post_meta( $_POST['item_id'], 'wpr-mega-menu-settings', $_POST['item_settings'] );
|
||||
}
|
||||
|
||||
wp_send_json_success($_POST['item_settings']);
|
||||
}
|
||||
|
||||
// Get Menu Items Data
|
||||
function get_menu_items_data( $menu_id = false ) {
|
||||
|
||||
if ( ! $menu_id ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$menu = wp_get_nav_menu_object( $menu_id );
|
||||
|
||||
$menu_items = wp_get_nav_menu_items( $menu );
|
||||
|
||||
if ( ! $menu_items ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $menu_items;
|
||||
}
|
||||
|
||||
// Get Mega Menu Item Settings
|
||||
function get_menu_items_settings() {
|
||||
$menu_items = get_menu_items_data( get_selected_menu_id() );
|
||||
|
||||
$settings = [];
|
||||
|
||||
if ( ! $menu_items ) {
|
||||
return [];
|
||||
} else {
|
||||
foreach ( $menu_items as $key => $item_object ) {
|
||||
$item_id = $item_object->ID;
|
||||
|
||||
$item_meta = get_post_meta( $item_id, 'wpr-mega-menu-settings', true );
|
||||
|
||||
if ( !empty($item_meta) ) {
|
||||
$settings[ $item_id ] = $item_meta;
|
||||
} else {
|
||||
$settings[ $item_id ] = [];
|
||||
}
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Selected menu ID
|
||||
* @author Tom Hemsley (https://wordpress.org/plugins/megamenu/)
|
||||
*/
|
||||
function get_selected_menu_id() {
|
||||
$nav_menus = wp_get_nav_menus( array('orderby' => 'name') );
|
||||
$menu_count = count( $nav_menus );
|
||||
$nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0;
|
||||
$add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : false;
|
||||
|
||||
$current_menu_id = $nav_menu_selected_id;
|
||||
|
||||
// If we have one theme location, and zero menus, we take them right into editing their first menu
|
||||
$page_count = wp_count_posts( 'page' );
|
||||
$one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false;
|
||||
|
||||
// Get recently edited nav menu
|
||||
$recently_edited = absint( get_user_option( 'nav_menu_recently_edited' ) );
|
||||
if ( empty( $recently_edited ) && is_nav_menu( $current_menu_id ) ) {
|
||||
$recently_edited = $current_menu_id;
|
||||
}
|
||||
|
||||
// Use $recently_edited if none are selected
|
||||
if ( empty( $current_menu_id ) && ! isset( $_GET['menu'] ) && is_nav_menu( $recently_edited ) ) {
|
||||
$current_menu_id = $recently_edited;
|
||||
}
|
||||
|
||||
// On deletion of menu, if another menu exists, show it
|
||||
if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete' == $_GET['action'] ) {
|
||||
$current_menu_id = $nav_menus[0]->term_id;
|
||||
}
|
||||
|
||||
// Set $current_menu_id to 0 if no menus
|
||||
if ( $one_theme_location_no_menus ) {
|
||||
$current_menu_id = 0;
|
||||
} elseif ( empty( $current_menu_id ) && ! empty( $nav_menus ) && ! $add_new_screen ) {
|
||||
// if we have no selection yet, and we have menus, set to the first one in the list
|
||||
$current_menu_id = $nav_menus[0]->term_id;
|
||||
}
|
||||
|
||||
return $current_menu_id;
|
||||
|
||||
}
|
||||
|
||||
// Enqueue Scripts and Styles
|
||||
function enqueue_scripts( $hook ) {
|
||||
|
||||
// Get Plugin Version
|
||||
$version = Plugin::instance()->get_version();
|
||||
|
||||
// Deny if NOT a Menu Page
|
||||
if ( 'nav-menus.php' == $hook ) {
|
||||
|
||||
// Color Picker
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
wp_enqueue_script( 'wp-color-picker-alpha', WPR_ADDONS_URL .'assets/js/admin/lib/wp-color-picker-alpha.min.js', ['jquery', 'wp-color-picker'], $version, true );
|
||||
|
||||
// Icon Picker
|
||||
wp_enqueue_script( 'wpr-iconpicker-js', WPR_ADDONS_URL .'assets/js/admin/lib/iconpicker/fontawesome-iconpicker.min.js', ['jquery'], $version, true );
|
||||
wp_enqueue_style( 'wpr-iconpicker-css', WPR_ADDONS_URL .'assets/js/admin/lib/iconpicker/fontawesome-iconpicker.min.css', $version, true );
|
||||
wp_enqueue_style( 'wpr-el-fontawesome-css', ELEMENTOR_URL .'assets/lib/font-awesome/css/all.min.css', [], $version );
|
||||
|
||||
// enqueue CSS
|
||||
wp_enqueue_style( 'wpr-mega-menu-css', WPR_ADDONS_URL .'assets/css/admin/mega-menu.css', [], $version );
|
||||
|
||||
// enqueue JS
|
||||
wp_enqueue_script( 'wpr-mega-menu-js', WPR_ADDONS_URL .'assets/js/admin/mega-menu.js', ['jquery'], $version );
|
||||
|
||||
wp_localize_script(
|
||||
'wpr-mega-menu-js',
|
||||
'WprMegaMenuSettingsData',
|
||||
[
|
||||
'settingsData' => get_menu_items_settings(),
|
||||
'nonce' => wp_create_nonce( 'wpr-mega-menu-js' ),
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
use WprAddons\Plugin;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
// Add second featured image
|
||||
add_action( 'add_meta_boxes', 'secondary_image_add_metabox' );
|
||||
function secondary_image_add_metabox () {
|
||||
$post_types = Utilities::get_custom_types_of( 'post', false );
|
||||
|
||||
foreach ( $post_types as $key => $value ) {
|
||||
$meta_option = get_option( 'wpr_meta_secondary_image_' . $key, 'on' );
|
||||
|
||||
if ( 'page' !== $key && 'e-landing-page' !== $key && $meta_option === 'on' ) {
|
||||
add_meta_box( 'wpr-secondary-image', __( 'Secondary Image', 'wpr-addons' ), 'secondary_image_metabox', $key, 'side', 'low');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function secondary_image_metabox ( $post ) {
|
||||
global $content_width, $_wp_additional_image_sizes;
|
||||
|
||||
$image_id = get_post_meta( $post->ID, 'wpr_secondary_image_id', true );
|
||||
|
||||
$old_content_width = $content_width;
|
||||
$content_width = 254;
|
||||
|
||||
if ( $image_id && get_post( $image_id ) ) {
|
||||
|
||||
if ( ! isset( $_wp_additional_image_sizes['post-thumbnail'] ) ) {
|
||||
$thumbnail_html = wp_get_attachment_image( $image_id, array( $content_width, $content_width ) );
|
||||
} else {
|
||||
$thumbnail_html = wp_get_attachment_image( $image_id, 'post-thumbnail' );
|
||||
}
|
||||
|
||||
if ( ! empty( $thumbnail_html ) ) {
|
||||
$content = $thumbnail_html;
|
||||
$content .= '<p class="hide-if-no-js"><a href="javascript:;" id="remove_secondary_image_button" >' . esc_html__( 'Remove secondary image', 'wpr-addons' ) . '</a></p>';
|
||||
$content .= '<input type="hidden" id="upload_secondary_image" name="wpr_secondary_cover_image" value="' . esc_attr( $image_id ) . '" />';
|
||||
}
|
||||
|
||||
$content_width = $old_content_width;
|
||||
} else {
|
||||
|
||||
$content = '<img src="" style="width:' . esc_attr( $content_width ) . 'px;height:auto;border:0;display:none;" />';
|
||||
$content .= '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set secondary image', 'wpr-addons' ) . '" href="javascript:;" id="upload_secondary_image_button" id="set-secondary-image" data-uploader_title="' . esc_attr__( 'Choose an image', 'wpr-addons' ) . '" data-uploader_button_text="' . esc_attr__( 'Set secondary image', 'wpr-addons' ) . '">' . esc_html__( 'Set secondary image', 'wpr-addons' ) . '</a></p>';
|
||||
$content .= '<input type="hidden" id="upload_secondary_image" name="wpr_secondary_cover_image" value="" />';
|
||||
|
||||
}
|
||||
|
||||
echo $content;
|
||||
}
|
||||
|
||||
add_action( 'save_post', 'secondary_image_save', 10, 1 );
|
||||
function secondary_image_save ( $post_id ) {
|
||||
if( isset( $_POST['wpr_secondary_cover_image'] ) ) {
|
||||
$image_id = (int) $_POST['wpr_secondary_cover_image'];
|
||||
update_post_meta( $post_id, 'wpr_secondary_image_id', $image_id );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function wpdocs_selectively_enqueue_admin_script( $hook ) {
|
||||
if ( 'post.php' != $hook ) {
|
||||
return;
|
||||
}
|
||||
// Get Plugin Version
|
||||
$version = Plugin::instance()->get_version();
|
||||
// enqueue JS
|
||||
wp_enqueue_script( 'wpr-secondary-image-js', WPR_ADDONS_URL .'assets/js/admin/metabox/secondary-image.js', ['jquery'], $version );
|
||||
}
|
||||
|
||||
add_action( 'admin_enqueue_scripts', 'wpdocs_selectively_enqueue_admin_script' );
|
||||
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Notices;
|
||||
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class WprPluginSaleNotice {
|
||||
// Declare class properties
|
||||
public $past_date;
|
||||
public $past_date_rml;
|
||||
public $install_date;
|
||||
public $remind_me_later;
|
||||
|
||||
public function __construct() {
|
||||
// delete_option('wpr_plugin_sale_dismiss_notice'); // uncomment for testing
|
||||
|
||||
$this->past_date = strtotime( '-2 days' );
|
||||
$this->past_date_rml = strtotime( '-15 days' );
|
||||
$this->install_date = get_option('royal_elementor_addons_activation_time_for_sale');
|
||||
$this->remind_me_later = get_option('wpr_sale_remind_me_later');
|
||||
// add_action( 'admin_init', [$this, 'render_notice'] ); // uncomment for testing
|
||||
|
||||
if ( current_user_can('administrator') ) {
|
||||
if ( !get_option('wpr_plugin_sale_dismiss_notice') ) {
|
||||
if ( (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) && !wpr_fs()->is_plan( 'expert' ) ) {
|
||||
add_action( 'admin_init', [$this, 'render_notice'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'admin_head', [$this, 'enqueue_scripts' ] );
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_wpr_plugin_sale_dismiss_notice', [$this, 'wpr_plugin_sale_dismiss_notice'] );
|
||||
add_action( 'wp_ajax_wpr_sale_remind_me_later', [$this, 'wpr_sale_remind_me_later'] );
|
||||
}
|
||||
|
||||
public function render_notice() {
|
||||
// add_action( 'admin_notices', [$this, 'render_plugin_sale_notice' ]); // uncomment for testing
|
||||
if ( $this->past_date >= $this->install_date ) {
|
||||
if ( get_option('wpr_sale_remind_me_later') && !($this->past_date_rml >= $this->remind_me_later) ) {
|
||||
return;
|
||||
}
|
||||
add_action( 'admin_notices', [$this, 'render_plugin_sale_notice' ]);
|
||||
}
|
||||
}
|
||||
|
||||
public function wpr_plugin_sale_dismiss_notice() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
add_option( 'wpr_plugin_sale_dismiss_notice', true );
|
||||
}
|
||||
|
||||
public function wpr_sale_remind_me_later() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
update_option( 'wpr_sale_remind_me_later', absint(intval(strtotime('now'))) );
|
||||
}
|
||||
|
||||
public function render_plugin_sale_notice() {
|
||||
if ( is_admin() ) {
|
||||
echo '<div class="notice wpr-plugin-sale-notice is-dismissible">
|
||||
<div>
|
||||
<h3><span>Flash Sale</span><br> Royal Elementor Addons Pro</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
140+ Designer Made Templates Kit
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
100+ Advanced Elementor Widgets
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
Dynamic Website Builder <a class="wpr-dynamic-tutorial" href="https://www.youtube.com/watch?v=kE1zmi3fxh8" target="_blank">View Demo</a>
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
Advanced Theme Builder
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
Advanced WooCommerce Builder
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
Advanced Form Builder
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
Mega Menu Builder
|
||||
</li>
|
||||
<li>
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/check-mark.png">
|
||||
Ajax Live Search and much more...
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
Hurry up! Upgrade within the <strong>next 24 hours</strong> and get a
|
||||
<strong>20% Discount</strong>.<br><br>
|
||||
Use Promo Code: <strong style="border: 1px dashed #C3C4C7;padding: 2px 10px;">REAFLASH20</strong>
|
||||
</p>
|
||||
<br>
|
||||
<div>
|
||||
<a href="https://royal-elementor-addons.com/?ref=rea-plugin-backend-salebanner-upgrade-pro#purchasepro" target="_blank" class="wpr-upgrade-to-pro-button button button-secondary">Upgrade to Pro <span class="dashicons dashicons-arrow-right-alt"></span></a>
|
||||
<a target="#" target="_blank" class="wpr-upgrade-to-pro-button button button-secondary wpr-remind-later">Remind Me Later</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="image-wrap"><img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/sale-banner-20.png"></div>
|
||||
<canvas id="wpr-notice-confetti"></canvas>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
public static function enqueue_scripts() {
|
||||
// Load Confetti
|
||||
wp_enqueue_script( 'wpr-confetti-js', WPR_ADDONS_URL .'assets/js/admin/lib/confetti/confetti.min.js', ['jquery'] );
|
||||
|
||||
// Scripts & Styles
|
||||
echo "
|
||||
<style>
|
||||
.wpr-plugin-sale-notice {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
padding: 30px;
|
||||
border: 0 !important;
|
||||
box-shadow: 0 0 5px rgb(0 0 0 / 0.1);
|
||||
|
||||
padding-left: 40px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice-logo {
|
||||
display: none;
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice-logo img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice h3 {
|
||||
font-size: 36px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 35px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice h3 span {
|
||||
display: inline-block;
|
||||
margin-bottom: 15px;
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
background-color: #f51f3d;
|
||||
padding: 2px 12px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice ul li {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice ul img {
|
||||
display: inline-block;
|
||||
width: 11px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice p {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice .wpr-upgrade-to-pro-button {
|
||||
border: 2px solid #e4e4e4;
|
||||
color: #9f9c9c;
|
||||
background-color: #fff;
|
||||
padding: 5px 25px;
|
||||
font-weight: bold;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice .wpr-upgrade-to-pro-button:hover {
|
||||
border: 2px solid #6a4bff4f;
|
||||
color: #6A4BFF;
|
||||
background: #f6f7f7;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice .wpr-upgrade-to-pro-button:first-child {
|
||||
border: 2px solid #6A4BFF;
|
||||
color: #ffffff;
|
||||
background-color: #6A4BFF;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice .wpr-upgrade-to-pro-button .dashicons {
|
||||
font-size: 14px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice .wpr-dynamic-tutorial {
|
||||
text-decoration: none;
|
||||
color: #FFF;
|
||||
background: #e1ad01;
|
||||
padding: 4px 10px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.wpr-plugin-sale-notice .image-wrap {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
#wpr-notice-confetti {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1400px) {
|
||||
.wpr-plugin-sale-notice .image-wrap img {
|
||||
zoom: 0.9;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1366px) {
|
||||
.wpr-plugin-sale-notice .image-wrap img {
|
||||
zoom: 0.7;
|
||||
}
|
||||
}
|
||||
</style>";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'Royal Addons' === Utilities::get_plugin_name() ) {
|
||||
new WprPluginSaleNotice();
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Notices;
|
||||
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class WprPluginNotice {
|
||||
public function __construct() {
|
||||
|
||||
if ( current_user_can('administrator') ) {
|
||||
|
||||
if ( !get_option('wpr_plugin_update_dismiss_notice' ) ) {
|
||||
add_action( 'admin_init', [$this, 'render_notice'] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'admin_head', [$this, 'enqueue_scripts' ] );
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_wpr_plugin_update_dismiss_notice', [$this, 'wpr_plugin_update_dismiss_notice'] );
|
||||
}
|
||||
|
||||
public function render_notice() {
|
||||
add_action( 'admin_notices', [$this, 'render_plugin_update_notice' ]);
|
||||
}
|
||||
|
||||
public function wpr_plugin_update_dismiss_notice() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
add_option( 'wpr_plugin_update_dismiss_notice', true );
|
||||
}
|
||||
|
||||
public function render_plugin_update_notice() {
|
||||
global $current_screen;
|
||||
|
||||
if ( is_admin() ) {
|
||||
if ( 'royal-addons_page_wpr-templates-kit' === $current_screen->id || 'update' === $current_screen->id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<div class="notice wpr-plugin-update-notice is-dismissible">
|
||||
<div class="wpr-plugin-update-notice-logo">
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'/img/logo-128x128.png">
|
||||
</div>
|
||||
<div>
|
||||
<h3><span>New Features</span><br> Introducing New Widgets</h3>
|
||||
<p>We are excited to announce that we have added new Widgets, Template Kits, and other Elementor<br> features to enhance your website building experience. Stay tuned for the weekly updates!</p>
|
||||
<ul class="wpr-new-widgets-list">
|
||||
<li><a target="_blank" href="https://royal-elementor-addons.com/advanced-sticky-header/?ref=rea-plugin-backend-update-notice">Advanced Sticky Header</a></li>
|
||||
<li><a target="_blank" href="https://royal-elementor-addons.com/elementor-form-builder-widget/?ref=rea-plugin-backend-update-notice">Form Builder</a></li>
|
||||
<li><a target="_blank" href="https://royal-elementor-addons.com/elementor-mega-menu-widget/?ref=rea-plugin-backend-update-notice">Mega Menu</a></li>
|
||||
<li><a target="_blank" href="https://royal-elementor-addons.com/elementor-offcanvas-menu-widget/?ref=rea-plugin-backend-update-notice">Off-Canvas Content</a></li>
|
||||
<li><a target="_blank" href="https://royal-elementor-addons.com/elementor-instagram-feed-widget/?ref=rea-plugin-backend-update-notice">Instagram Feed</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="image-wrap"><img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'img/new-theme-builder.png"></div>
|
||||
<canvas id="wpr-notice-confetti"></canvas>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
public static function enqueue_scripts() {
|
||||
// Load Confetti
|
||||
wp_enqueue_script( 'wpr-confetti-js', WPR_ADDONS_URL .'assets/js/admin/lib/confetti/confetti.min.js', ['jquery'] );
|
||||
|
||||
// Scripts & Styles
|
||||
echo "
|
||||
<style>
|
||||
.wpr-plugin-update-notice {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
padding: 30px;
|
||||
border: 0 !important;
|
||||
box-shadow: 0 0 5px rgb(0 0 0 / 0.1);
|
||||
|
||||
padding-left: 40px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice-logo {
|
||||
display: none;
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice-logo img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice h3 {
|
||||
font-size: 36px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice h3 span {
|
||||
display: inline-block;
|
||||
margin-bottom: 15px;
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
background-color: #f51f3d;
|
||||
padding: 2px 12px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice p {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice ul {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice ul a {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice ul li a:after {
|
||||
content: ' ';
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
top: -2px;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
margin-left: 12px;
|
||||
margin-right: 12px;
|
||||
background-color: #e0e0e0;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice ul li:last-child a:after {
|
||||
display: none;
|
||||
}
|
||||
.wpr-get-started-button.button-primary {
|
||||
background-color: #6A4BFF;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-primary:hover {
|
||||
background-color: #583ed7;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-secondary {
|
||||
border: 1px solid #6A4BFF;
|
||||
color: #6A4BFF;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-secondary:hover {
|
||||
background-color: #6A4BFF;
|
||||
border: 2px solid #6A4BFF;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.wpr-get-started-button {
|
||||
padding: 5px 25px !important;
|
||||
}
|
||||
|
||||
.wpr-get-started-button .dashicons {
|
||||
font-size: 12px;
|
||||
line-height: 28px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice .image-wrap {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice .image-wrap img {
|
||||
zoom: 0.45;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1366px) {
|
||||
.wpr-plugin-update-notice h3 {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.wpr-plugin-update-notice .image-wrap img {
|
||||
zoom: 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1280px) {
|
||||
.wpr-plugin-update-notice .image-wrap img {
|
||||
zoom: 0.35;
|
||||
}
|
||||
}
|
||||
|
||||
#wpr-notice-confetti {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'Royal Addons' === Utilities::get_plugin_name() ) {
|
||||
new WprPluginNotice();
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Notices;
|
||||
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class WprProFeaturesNotice {
|
||||
public function __construct() {
|
||||
|
||||
if ( function_exists('wpr_fs') && !wpr_fs()->is_plan( 'expert' ) ) {
|
||||
|
||||
if ( current_user_can('administrator') ) {
|
||||
|
||||
if ( !get_option('wpr_pro_features_dismiss_notice' ) ) {
|
||||
add_action( 'admin_init', [$this, 'render_notice'] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_admin() && !get_option('wpr_pro_features_dismiss_notice' ) ) {
|
||||
add_action( 'admin_head', [$this, 'enqueue_scripts' ] );
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_wpr_pro_features_dismiss_notice', [$this, 'wpr_pro_features_dismiss_notice'] );
|
||||
}
|
||||
}
|
||||
|
||||
public function render_notice() {
|
||||
add_action( 'admin_notices', [$this, 'render_pro_features_notice' ]);
|
||||
}
|
||||
|
||||
public function wpr_pro_features_dismiss_notice() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
add_option( 'wpr_pro_features_dismiss_notice', true );
|
||||
return 'responsetext';
|
||||
}
|
||||
|
||||
public function render_pro_features_notice() {
|
||||
global $current_screen;
|
||||
|
||||
if ( is_admin() && 'toplevel_page_wpr-addons' == $current_screen->id ) {
|
||||
echo '<div class="wpr-pro-features-notice-wrap">';
|
||||
echo '<div class="notice wpr-pro-features-notice is-dismissible">
|
||||
<div class="wpr-pro-features-notice-logo">
|
||||
<img src="'. esc_url(WPR_ADDONS_ASSETS_URL) .'/img/logo-128x128.png">
|
||||
</div>
|
||||
<div>
|
||||
<h3><span>Big Update</span><br>Dynamic Content</h3>
|
||||
<p>We are happy to announce that <strong>Royal Elementor Addons Expert</strong> version now supports <strong>Dynamic Content</strong> wich includes:</p>
|
||||
<ul class="wpr-new-widgets-list">
|
||||
<li><strong>Dynamic Tags (Elementor)</strong></li>
|
||||
<li><strong>Advanced Custom Fields (Extended)</strong></li>
|
||||
<li><strong>Custom Post Type Generator</strong></li>
|
||||
<li><strong>Custom Taxonomy Generator</strong></li>
|
||||
<li><a target="_blank" href="https://www.youtube.com/watch?v=wis1rQTn1tg">Product Wishlist (WooCommerce)</a></li>
|
||||
<li><a target="_blank" href="https://www.youtube.com/watch?v=wis1rQTn1tg">Product Compare (WooCommerce)</a></li>
|
||||
</ul>
|
||||
|
||||
<a class="wpr-pro-features-btn" href="https://royal-elementor-addons.com/#purchasepro?ref=rea-plugin-backend-expertnoticebanner-checkbtn-upgrade-expert#purchasepro" target="_blank">Upgrade to Expert</a>
|
||||
<a class="wpr-pro-features-btn wpr-dynamic-tutorial" href="https://www.youtube.com/watch?v=kE1zmi3fxh8" target="_blank">Dynamic Tutorial</a>
|
||||
</div>
|
||||
<canvas id="wpr-notice-confetti"></canvas>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
public static function enqueue_scripts() {
|
||||
global $current_screen;
|
||||
|
||||
|
||||
if ( !(is_admin() && 'toplevel_page_wpr-addons' == $current_screen->id) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load Confetti
|
||||
wp_enqueue_script( 'wpr-confetti-js', WPR_ADDONS_URL .'assets/js/admin/lib/confetti/confetti.min.js', ['jquery'] );
|
||||
|
||||
// Scripts & Styles
|
||||
echo "
|
||||
<script>
|
||||
jQuery( document ).ready( function($) {
|
||||
|
||||
$('html, body').animate({
|
||||
scrollTop: 0
|
||||
}, 'slow');
|
||||
$('body').addClass('wpr-pro-features-body');
|
||||
$(document).find('.wpr-pro-features-notice-wrap').css('opacity', 1);
|
||||
|
||||
if ( jQuery('#wpr-notice-confetti').length ) {
|
||||
const wprConfetti = confetti.create( document.getElementById('wpr-notice-confetti'), {
|
||||
resize: true
|
||||
});
|
||||
|
||||
setTimeout( function () {
|
||||
wprConfetti( {
|
||||
particleCount: 150,
|
||||
origin: { x: 1, y: 2 },
|
||||
gravity: 0.3,
|
||||
spread: 50,
|
||||
ticks: 150,
|
||||
angle: 120,
|
||||
startVelocity: 60,
|
||||
colors: [
|
||||
'#0e6ef1',
|
||||
'#f5b800',
|
||||
'#ff344c',
|
||||
'#98e027',
|
||||
'#9900f1',
|
||||
],
|
||||
} );
|
||||
}, 500 );
|
||||
|
||||
setTimeout( function () {
|
||||
wprConfetti( {
|
||||
particleCount: 150,
|
||||
origin: { x: 0, y: 2 },
|
||||
gravity: 0.3,
|
||||
spread: 50,
|
||||
ticks: 200,
|
||||
angle: 60,
|
||||
startVelocity: 60,
|
||||
colors: [
|
||||
'#0e6ef1',
|
||||
'#f5b800',
|
||||
'#ff344c',
|
||||
'#98e027',
|
||||
'#9900f1',
|
||||
],
|
||||
} );
|
||||
}, 900 );
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.wpr-pro-features-body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice-wrap {
|
||||
position: absolute;
|
||||
display: block;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
z-index: 999;
|
||||
background-color: rgba(0, 0, 0, 0.2);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.wpr-settings-page-header .wpr-pro-features-notice.notice {
|
||||
display: flex !important;
|
||||
position: absolute !important;
|
||||
top: 30%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 410px;
|
||||
align-items: center;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
padding: 30px;
|
||||
border: 0 !important;
|
||||
box-shadow: 0 0 5px rgb(0 0 0 / 0.3);
|
||||
padding-left: 40px;
|
||||
z-index: 999;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice-logo {
|
||||
display: none;
|
||||
margin-right: 30px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice-logo img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice h3 {
|
||||
font-size: 32px;
|
||||
margin-top: 0;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice h3 span {
|
||||
display: inline-block;
|
||||
margin-bottom: 15px;
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
background-color: #f51f3d;
|
||||
padding: 2px 12px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice p {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 25px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice ul a {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice ul li:last-child a:after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.wpr-pro-features-btn,
|
||||
.wpr-new-widgets-list + a {
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
text-transform: uppercase;
|
||||
color: #fff;
|
||||
background: #6A4BFF;
|
||||
padding: 5px 18px 7px;
|
||||
border-radius: 3px;
|
||||
margin-top: 30px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-btn.wpr-dynamic-tutorial {
|
||||
background: #e1ad01;
|
||||
}
|
||||
|
||||
.wpr-pro-features-btn:hover {
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
.wpr-pro-features-btn:focus {
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-primary {
|
||||
background-color: #6A4BFF;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-primary:hover {
|
||||
background-color: #583ed7;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-secondary {
|
||||
border: 1px solid #6A4BFF;
|
||||
color: #6A4BFF;
|
||||
}
|
||||
|
||||
.wpr-get-started-button.button-secondary:hover {
|
||||
background-color: #6A4BFF;
|
||||
border: 2px solid #6A4BFF;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.wpr-get-started-button {
|
||||
padding: 5px 25px !important;
|
||||
}
|
||||
|
||||
.wpr-get-started-button .dashicons {
|
||||
font-size: 12px;
|
||||
line-height: 28px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice .image-wrap {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice .image-wrap img {
|
||||
zoom: 0.45;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1366px) {
|
||||
.wpr-pro-features-notice h3 {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.wpr-pro-features-notice .image-wrap img {
|
||||
zoom: 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1280px) {
|
||||
.wpr-pro-features-notice .image-wrap img {
|
||||
zoom: 0.35;
|
||||
}
|
||||
}
|
||||
|
||||
#wpr-notice-confetti {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'Royal Addons' === Utilities::get_plugin_name() ) {
|
||||
new WprProFeaturesNotice();
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Notices;
|
||||
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class WprRatingNotice {
|
||||
private $past_date;
|
||||
|
||||
public function __construct() {
|
||||
global $pagenow;
|
||||
$this->past_date = false == get_option('wpr_maybe_later_time') ? strtotime( '-14 days' ) : strtotime('-7 days');
|
||||
|
||||
if ( current_user_can('administrator') ) {
|
||||
if ( empty(get_option('wpr_rating_dismiss_notice', false)) && empty(get_option('wpr_rating_already_rated', false)) ) {
|
||||
add_action( 'admin_init', [$this, 'check_plugin_install_time'] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'admin_head', [$this, 'enqueue_scripts' ] );
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_wpr_rating_dismiss_notice', [$this, 'wpr_rating_dismiss_notice'] );
|
||||
add_action( 'wp_ajax_wpr_rating_maybe_later', [$this, 'wpr_rating_maybe_later'] );
|
||||
add_action( 'wp_ajax_wpr_rating_already_rated', [$this, 'wpr_rating_already_rated'] );
|
||||
add_action( 'wp_ajax_wpr_rating_need_help', [$this, 'wpr_rating_need_help'] );
|
||||
}
|
||||
|
||||
public function check_plugin_install_time() {
|
||||
$install_date = get_option('royal_elementor_addons_activation_time');
|
||||
|
||||
if ( false == get_option('wpr_maybe_later_time') && false !== $install_date && $this->past_date >= $install_date ) {
|
||||
add_action( 'admin_notices', [$this, 'render_rating_notice' ]);
|
||||
} else if ( false != get_option('wpr_maybe_later_time') && $this->past_date >= get_option('wpr_maybe_later_time') ) {
|
||||
add_action( 'admin_notices', [$this, 'render_rating_notice' ]);
|
||||
}
|
||||
}
|
||||
|
||||
public function wpr_rating_maybe_later() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
update_option( 'wpr_maybe_later_time', strtotime('now') );
|
||||
}
|
||||
|
||||
function wpr_rating_already_rated() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
update_option( 'wpr_rating_already_rated' , true );
|
||||
}
|
||||
|
||||
public function wpr_rating_dismiss_notice() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
update_option( 'wpr_rating_dismiss_notice', true );
|
||||
}
|
||||
|
||||
public function wpr_rating_need_help() {
|
||||
$nonce = $_POST['nonce'];
|
||||
|
||||
if ( !wp_verify_nonce( $nonce, 'wpr-plugin-notice-js') || !current_user_can( 'manage_options' ) ) {
|
||||
exit; // Get out of here, the nonce is rotten!
|
||||
}
|
||||
|
||||
// Reset Activation Time if user Needs Help
|
||||
update_option( 'royal_elementor_addons_activation_time', strtotime('now') );
|
||||
}
|
||||
|
||||
public function render_rating_notice() {
|
||||
global $pagenow;
|
||||
|
||||
if ( is_admin() ) {
|
||||
$plugin_info = get_plugin_data( __FILE__ , true, true );
|
||||
$dont_disturb = esc_url( get_admin_url() . '?spare_me=1' );
|
||||
|
||||
echo '<div class="notice wpr-rating-notice is-dismissible" style="border-left-color: #7A75FF!important; display: flex; align-items: center; position: relative;">
|
||||
<div class="wpr-rating-notice-logo">
|
||||
<img src="' . WPR_ADDONS_ASSETS_URL . '/img/logo-128x128.png">
|
||||
</div>
|
||||
<div>
|
||||
<h3>Thank you for using Royal Elementor Addons to build this website!</h3>
|
||||
<p style="">Could you please do us a BIG favor and give it a 5-star rating on WordPress? Just to help us spread the word and boost our motivation.</p>
|
||||
<p>
|
||||
<a href="https://wordpress.org/support/plugin/royal-elementor-addons/reviews/" target="_blank" class="wpr-you-deserve-it button button-primary">OK, you deserve it!</a>
|
||||
<a class="wpr-maybe-later"><span class="dashicons dashicons-clock"></span> Maybe Later</a>
|
||||
<a class="wpr-already-rated"><span class="dashicons dashicons-yes"></span> I Already did</a>
|
||||
</p>
|
||||
</div>
|
||||
<button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>
|
||||
</div>';
|
||||
|
||||
// <a href="https://wordpress.org/support/plugin/royal-elementor-addons/" target="_blank" class="wpr-need-support"><span class="dashicons dashicons-sos"></span> I need support!</a>
|
||||
// <a class="wpr-notice-dismiss-2"><span class="dashicons dashicons-thumbs-down"></span> NO, not good enough</a>
|
||||
}
|
||||
}
|
||||
|
||||
public static function enqueue_scripts() {
|
||||
echo "
|
||||
<style>
|
||||
.wpr-rating-notice {
|
||||
padding: 10px 20px;
|
||||
border-top: 0;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.wpr-rating-notice-logo {
|
||||
margin-right: 20px;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.wpr-rating-notice-logo img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.wpr-rating-notice h3 {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.wpr-rating-notice p {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.wpr-maybe-later,
|
||||
.wpr-already-rated,
|
||||
.wpr-need-support,
|
||||
.wpr-notice-dismiss-2 {
|
||||
text-decoration: none;
|
||||
margin-left: 12px;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wpr-already-rated .dashicons,
|
||||
.wpr-maybe-later .dashicons,
|
||||
.wpr-need-support .dashicons {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.wpr-notice-dismiss-2 .dashicons {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.wpr-rating-notice .notice-dismiss {
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 1px;
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 9px;
|
||||
background: none;
|
||||
color: #787c82;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wpr-rating-notice .notice-dismiss:before {
|
||||
background: none;
|
||||
color: #787c82;
|
||||
content: '\\f153';
|
||||
display: block;
|
||||
font: normal 16px/20px dashicons;
|
||||
speak: never;
|
||||
height: 20px;
|
||||
text-align: center;
|
||||
width: 20px;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.wpr-rating-notice .notice-dismiss:hover:before {
|
||||
color: #d63638;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
|
||||
echo "
|
||||
<script>
|
||||
jQuery(document).ready(function($) {
|
||||
$('.wpr-rating-notice .notice-dismiss').on('click', function() {
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'wpr_rating_dismiss_notice',
|
||||
nonce: '" . wp_create_nonce('wpr-plugin-notice-js') . "'
|
||||
},
|
||||
success: function() {
|
||||
$('.wpr-rating-notice').fadeOut();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( 'Royal Addons' === Utilities::get_plugin_name() ) {
|
||||
new WprRatingNotice();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
use WprAddons\Admin\Includes\WPR_Templates_Loop;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
// Register Menus
|
||||
function wpr_addons_add_popups_menu() {
|
||||
add_submenu_page( 'wpr-addons', 'Popup Builder', 'Popup Builder', 'manage_options', 'wpr-popups', 'wpr_addons_popups_page' );
|
||||
}
|
||||
add_action( 'admin_menu', 'wpr_addons_add_popups_menu' );
|
||||
|
||||
function wpr_addons_popups_page() {
|
||||
|
||||
?>
|
||||
|
||||
<div class="wrap wpr-settings-page-wrap">
|
||||
|
||||
<div class="wpr-settings-page-header">
|
||||
<h1><?php echo esc_html(Utilities::get_plugin_name(true)); ?></h1>
|
||||
<p><?php esc_html_e( 'The most powerful Elementor Addons in the universe.', 'wpr-addons' ); ?></p>
|
||||
|
||||
<!-- Custom Template -->
|
||||
<div class="wpr-preview-buttons">
|
||||
<div class="wpr-user-template">
|
||||
<span><?php esc_html_e( 'Create Template', 'wpr-addons' ); ?></span>
|
||||
<span class="plus-icon">+</span>
|
||||
</div>
|
||||
|
||||
<a href="https://www.youtube.com/watch?v=TbKTNpuXM68" class="wpr-options-button button" target="_blank" style="padding: 10px 22px;">
|
||||
<?php echo esc_html__( 'How to use Popups', 'wpr-addons' ); ?>
|
||||
<span class="dashicons dashicons-video-alt3"></span>
|
||||
</a>
|
||||
|
||||
<a href="https://royaladdons.frill.co/b/6m4d5qm4/feature-ideas" class="wpr-options-button button" target="_blank" style="padding: 8px 22px;">
|
||||
<?php echo esc_html__( 'Request New Feature', 'wpr-addons' ); ?>
|
||||
<span class="dashicons dashicons-star-empty"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpr-settings-page">
|
||||
<form method="post" action="options.php">
|
||||
<?php
|
||||
|
||||
// Active Tab
|
||||
$active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'wpr_tab_popups';
|
||||
|
||||
?>
|
||||
|
||||
<!-- Template ID Holder -->
|
||||
<input type="hidden" name="wpr_template" id="wpr_template" value="">
|
||||
|
||||
<!-- Conditions Popup -->
|
||||
<?php WPR_Templates_Loop::render_conditions_popup(); ?>
|
||||
|
||||
<!-- Create Templte Popup -->
|
||||
<?php WPR_Templates_Loop::render_create_template_popup(); ?>
|
||||
|
||||
<!-- Tabs -->
|
||||
<div class="nav-tab-wrapper wpr-nav-tab-wrapper">
|
||||
<a href="?page=wpr-theme-builder&tab=wpr_tab_popups" data-title="popup" class="nav-tab <?php echo ($active_tab == 'wpr_tab_popups') ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e( 'Popups', 'wpr-addons' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) {
|
||||
$url = '';
|
||||
$url = admin_url( 'edit.php?s&post_status=all&post_type=wpr_templates&wpr_template_type=popup&filter_action=Filter' );
|
||||
|
||||
echo '<a href="' . esc_url( $url ) . '" class="button button-primary wpr-translate-templates wpr-options-button"><span class="dashicons dashicons-admin-site"></span><span>Translate WPML Templates</span></a>';
|
||||
echo '<a href="https://www.youtube.com/watch?v=y7yjItsMBmw" class="button button-primary wpr-translate-templates wpr-options-button tutorial">'. esc_html__("Video Tutorial") .'</a>';
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ( $active_tab == 'wpr_tab_popups' ) : ?>
|
||||
|
||||
<!-- Save Conditions -->
|
||||
<input type="hidden" name="wpr_popup_conditions" id="wpr_popup_conditions" value="<?php echo esc_attr(get_option('wpr_popup_conditions', '[]')); ?>">
|
||||
|
||||
<?php WPR_Templates_Loop::render_theme_builder_templates( 'popup' ); ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
} // End wpr_addons_popups_page()
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
use WprAddons\Admin\Templates\Library\WPR_Templates_Data;
|
||||
use WprAddons\Admin\Templates\Library\WPR_Templates_Library_Blocks;
|
||||
use WprAddons\Classes\Utilities;
|
||||
use Elementor\Plugin;
|
||||
|
||||
// Register Menus
|
||||
function wpr_addons_add_premade_blocks_menu() {
|
||||
add_submenu_page( 'wpr-addons', 'Premade Blocks', 'Premade Blocks', 'manage_options', 'wpr-premade-blocks', 'wpr_addons_premade_blocks_page' );
|
||||
}
|
||||
add_action( 'admin_menu', 'wpr_addons_add_premade_blocks_menu' );
|
||||
|
||||
/**
|
||||
** Render Premade Blocks Page
|
||||
*/
|
||||
function wpr_addons_premade_blocks_page() {
|
||||
|
||||
?>
|
||||
|
||||
<div class="wpr-premade-blocks-page">
|
||||
|
||||
<div class="wpr-settings-page-header">
|
||||
<h1><?php echo esc_html(Utilities::get_plugin_name(true)); ?></h1>
|
||||
<p><?php esc_html_e( 'The most powerful Elementor Addon in the universe.', 'wpr-addons' ); ?></p>
|
||||
</div>
|
||||
|
||||
<?php WPR_Templates_Library_Blocks::render_library_templates_blocks(); ?>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
} // End wpr_addons_premade_blocks_page()
|
||||
File diff suppressed because it is too large
Load Diff
+3242
File diff suppressed because it is too large
Load Diff
+177
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Templates\Library;
|
||||
use WprAddons\Classes\Utilities;
|
||||
use WprAddons\Admin\Templates\Library\WPR_Templates_Data;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* WPR_Templates_Library_Blocks setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class WPR_Templates_Library_Blocks {
|
||||
|
||||
/**
|
||||
** Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// Template Library Popup
|
||||
add_action( 'wp_ajax_render_library_templates_blocks', [ $this, 'render_library_templates_blocks' ] );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
** Template Library Popup
|
||||
*/
|
||||
public static function render_library_templates_blocks() {
|
||||
$license = !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ? 'free' : 'premium';
|
||||
|
||||
?>
|
||||
|
||||
<div class="wpr-tplib-sidebar" data-license="<?php echo esc_attr($license); ?>">
|
||||
<div class="wpr-tplib-filters-wrap">
|
||||
<div class="wpr-tplib-filters">
|
||||
<h3>
|
||||
<span data-filter="all"><?php esc_html_e( 'Category', 'wpr-addons' ); ?></span>
|
||||
<i class="fas fa-angle-down"></i>
|
||||
</h3>
|
||||
|
||||
<div class="wpr-tplib-filters-list">
|
||||
<ul>
|
||||
|
||||
<li data-filter="all"><?php esc_html_e( 'All', 'wpr-addons' ) ?></li>
|
||||
|
||||
<?php
|
||||
|
||||
$modules = Utilities::get_available_modules( Utilities::get_registered_modules() );
|
||||
|
||||
$exclude_widgets = [
|
||||
'logo',
|
||||
'mega-menu',
|
||||
'forms',
|
||||
'phone-call',
|
||||
'back-to-top',
|
||||
'popup-trigger',
|
||||
'lottie-animations',
|
||||
'taxonomy-list',
|
||||
'page-list',
|
||||
'elementor-template',
|
||||
'flip-carousel',
|
||||
'feature-list',
|
||||
'dual-color-heading',
|
||||
'reading-progress-bar',
|
||||
'image-accordion',
|
||||
'advanced-accordion',
|
||||
'charts',
|
||||
];
|
||||
|
||||
foreach ($modules as $title => $slug) {
|
||||
if ( ! in_array($slug[0], $exclude_widgets) ) {
|
||||
echo '<li data-filter="'. esc_attr($slug[0]) .'">'. esc_html($title) .'</li>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpr-tplib-sub-filters">
|
||||
<ul>
|
||||
<li data-sub-filter="all" class="wpr-tplib-activ-filter"><?php esc_html_e( 'All', 'wpr-addons' ); ?></li>
|
||||
<li data-sub-filter="grid"><?php esc_html_e( 'Grid', 'wpr-addons' ) ?></li>
|
||||
<li data-sub-filter="slider"><?php esc_html_e( 'Slider', 'wpr-addons' ) ?></li>
|
||||
<li data-sub-filter="carousel"><?php esc_html_e( 'Carousel', 'wpr-addons' ) ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpr-tplib-search">
|
||||
<input type="text" placeholder="Search Template">
|
||||
<i class="eicon-search"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpr-tplib-template-gird elementor-clearfix">
|
||||
<div class="wpr-tplib-template-gird-inner">
|
||||
|
||||
<?php
|
||||
|
||||
foreach ($modules as $title => $data) :
|
||||
$module_slug = $data[0];
|
||||
$blocks = WPR_Templates_Data::get_available_blocks();
|
||||
|
||||
if ( !isset($blocks[$module_slug]) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for ( $i=0; $i < count($blocks[$module_slug]); $i++ ) :
|
||||
|
||||
$template_slug = array_keys($blocks[$module_slug])[$i];
|
||||
$template_sub = isset($blocks[$module_slug][$template_slug]['sub']) ? $blocks[$module_slug][$template_slug]['sub'] : '';
|
||||
$template_title = $title .' '. $template_slug;
|
||||
$preview_type = $blocks[$module_slug][$template_slug]['type'];
|
||||
$preview_url = $blocks[$module_slug][$template_slug]['url'];
|
||||
$template_class = (strpos($template_slug, 'pro') && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ) || (strpos($template_slug, 'zzz') && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ) ? ' wpr-tplib-pro-wrap' : '';
|
||||
|
||||
if (defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code()) {
|
||||
$template_class .= ' wpr-tplib-pro-active';
|
||||
}
|
||||
|
||||
$template_slug_for_image = strpos($template_slug, 'zzz') ? substr($template_slug, 0, -4) : $template_slug;
|
||||
|
||||
// Add Extra Keywords for Search
|
||||
$data_template_title = $template_title;
|
||||
if ( false !== strpos($title, 'Form Builder') ) {
|
||||
$data_template_title .= ' contact';
|
||||
} else if ( false !== strpos($title, 'Nav Menu') ) {
|
||||
$data_template_title .= ' header';
|
||||
} else if ( false !== strpos($title, 'Post Grid') ) {
|
||||
$data_template_title .= ' blog';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="wpr-tplib-template-wrap<?php echo esc_attr($template_class); ?>" data-title="<?php echo esc_attr(strtolower($data_template_title)); ?>">
|
||||
<div class="wpr-tplib-template" data-slug="<?php echo esc_attr($template_slug); ?>" data-filter="<?php echo esc_attr($module_slug); ?>" data-sub-filter="<?php echo esc_attr($template_sub); ?>" data-preview-type="<?php echo esc_attr($preview_type); ?>" data-preview-url="<?php echo esc_attr($preview_url); ?>">
|
||||
<div class="wpr-tplib-template-media">
|
||||
<img class="lazy" src="<?php echo esc_url(WPR_ADDONS_ASSETS_URL .'img/icon-256x256.png'); ?>" data-src="<?php echo esc_url('https://royal-elementor-addons.com/library/premade-styles/'. $module_slug .'/'. $template_slug_for_image .'.jpg'); ?>">
|
||||
<div class="wpr-tplib-template-media-overlay">
|
||||
<i class="eicon-eye"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpr-tplib-template-footer elementor-clearfix">
|
||||
<?php if ( !defined('WPR_ADDONS_PRO_VERSION') && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ) : ?>
|
||||
<h3><?php echo strpos($template_slug, 'pro') ? esc_html(str_replace('-pro', ' Pro', $template_title)) : esc_html(str_replace('-zzz', ' Pro', $template_title)); ?></h3>
|
||||
<?php else : ?>
|
||||
<h3><?php echo strpos($template_slug, 'pro') ? esc_html(str_replace('-pro', '', $template_title)) : esc_html(str_replace('-zzz', '', $template_title)); ?></h3>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( ( strpos($template_slug, 'pro') && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ) || ( strpos($template_slug, 'zzz') ) && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ) : ?>
|
||||
<span class="wpr-tplib-insert-template wpr-tplib-insert-pro"><i class="eicon-star"></i> <span><?php esc_html_e( 'Go Pro', 'wpr-addons' ); ?></span></span>
|
||||
<?php else : ?>
|
||||
<span class="wpr-tplib-insert-template"><i class="eicon-file-download"></i> <span><?php esc_html_e( 'Insert', 'wpr-addons' ); ?></span></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endfor; ?>
|
||||
<?php endforeach;?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( !(isset($current_screen) && 'royal-addons_page_wpr-premade-blocks' === $current_screen->id) ) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Templates\Library;
|
||||
use WprAddons\Classes\Utilities;
|
||||
use WprAddons\Admin\Templates\Library\WPR_Templates_Data;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* WPR_Templates_Library_Pages setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class WPR_Templates_Library_Pages {
|
||||
|
||||
/**
|
||||
** Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// Template Library Popup
|
||||
add_action( 'wp_ajax_render_library_templates_pages', [ $this, 'render_library_templates_pages' ] );
|
||||
add_action( 'wp_ajax_render_library_templates_pages_grid_items', [ $this, 'render_library_templates_pages_grid_items' ] );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
** Template Library Popup
|
||||
*/
|
||||
public static function render_library_templates_pages() {
|
||||
$license = !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ? 'free' : 'premium';
|
||||
|
||||
?>
|
||||
|
||||
<div class="wpr-tplib-sidebar" data-license="<?php echo esc_attr($license); ?>">
|
||||
<div class="wpr-tplib-price" data-filter="mixed">
|
||||
<h3>
|
||||
<span><?php esc_html_e( 'Mixed', 'wpr-addons' ); ?></span>
|
||||
<i class="fas fa-angle-down"></i>
|
||||
</h3>
|
||||
|
||||
<div class="wpr-tplib-price-list">
|
||||
<ul>
|
||||
<li data-filter="mixed"><?php esc_html_e( 'Mixed', 'wpr-addons' ); ?></li>
|
||||
<li data-filter="free"><?php esc_html_e( 'Free', 'wpr-addons' ); ?></li>
|
||||
<li data-filter="pro"><?php esc_html_e( 'Premium', 'wpr-addons' ); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpr-tplib-search">
|
||||
<input type="text" placeholder="Search Template">
|
||||
<i class="eicon-search"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpr-tplib-template-gird elementor-clearfix">
|
||||
<div class="wpr-tplib-template-gird-inner">
|
||||
|
||||
<?php //WPR_Templates_Library_Pages::render_library_templates_pages_grid_items(); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wpr-tplib-template-gird-loading">
|
||||
<div class="wpr-wave">
|
||||
<div class="wpr-rect wpr-rect1"></div>
|
||||
<div class="wpr-rect wpr-rect2"></div>
|
||||
<div class="wpr-rect wpr-rect3"></div>
|
||||
<div class="wpr-rect wpr-rect4"></div>
|
||||
<div class="wpr-rect wpr-rect5"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
wp_die();
|
||||
}
|
||||
|
||||
/**
|
||||
** Template Library Grid Items
|
||||
*/
|
||||
public static function render_library_templates_pages_grid_items() {
|
||||
$kits = WPR_Templates_Data::get_available_kits_for_pages();
|
||||
|
||||
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
|
||||
$kits_per_page = 10; // should be set to 10
|
||||
|
||||
$start = ($page - 1) * $kits_per_page;
|
||||
$end = $start + $kits_per_page;
|
||||
|
||||
$kits = array_slice($kits, $start, $kits_per_page, true);
|
||||
|
||||
foreach( $kits as $kit => $data ) :
|
||||
|
||||
foreach( $data['pages'] as $key => $page ) :
|
||||
|
||||
$template_title = $data['name'] .' - '. str_replace('-', ' ', ucwords($page));
|
||||
$template_price = ('pro' === $data['price'] && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ) ? 'pro' : 'free';
|
||||
$template_class = 'pro' === $template_price ? ' wpr-tplib-pro-wrap' : '';
|
||||
$preview_url = $data['preview'][$key];
|
||||
|
||||
?>
|
||||
|
||||
<div class="wpr-tplib-template-wrap<?php echo esc_attr($template_class); ?>" style="position:absolute;top:9999999999px;" data-title="<?php echo esc_attr(strtolower($template_title)); ?>" data-price="<?php echo esc_attr($template_price); ?>">
|
||||
<div class="wpr-tplib-template" data-slug="<?php echo esc_attr($page); ?>" data-kit="<?php echo esc_attr($kit); ?>" data-preview-type="iframe" data-preview-url="<?php echo esc_attr($preview_url); ?>">
|
||||
<div class="wpr-tplib-template-media">
|
||||
<img class="lazy" src="<?php echo esc_url(WPR_ADDONS_ASSETS_URL .'img/icon-256x256.png'); ?>" data-src="<?php echo esc_url('https://royal-elementor-addons.com/library/templates-kit/'. $kit .'/'. $page .'.jpg'); ?>">
|
||||
<div class="wpr-tplib-template-media-overlay">
|
||||
<i class="eicon-eye"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpr-tplib-template-footer elementor-clearfix">
|
||||
<h3>
|
||||
<span><?php echo esc_html($data['name']) ?></span>
|
||||
<span><?php echo ' - '. esc_html(ucwords($page)); ?></span>
|
||||
</h3>
|
||||
|
||||
<?php if ( 'pro' === $data['price'] && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ) : ?>
|
||||
<span class="wpr-tplib-insert-template wpr-tplib-insert-pro"><i class="eicon-star"></i> <span><?php esc_html_e( 'Go Pro', 'wpr-addons' ); ?></span></span>
|
||||
<?php else : ?>
|
||||
<span class="wpr-tplib-insert-template"><i class="eicon-file-download"></i> <span><?php esc_html_e( 'Insert', 'wpr-addons' ); ?></span></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endforeach;
|
||||
|
||||
endforeach;
|
||||
|
||||
wp_die();
|
||||
}
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Templates\Library;
|
||||
use WprAddons\Classes\Utilities;
|
||||
use WprAddons\Admin\Templates\Library\WPR_Templates_Data;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* WPR_Templates_Library_Popups setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class WPR_Templates_Library_Popups {
|
||||
|
||||
/**
|
||||
** Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// Template Library Popup
|
||||
add_action( 'wp_ajax_render_library_templates_popups', [ $this, 'render_library_templates_popups' ] );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
** Template Library Popup
|
||||
*/
|
||||
public function render_library_templates_popups() {
|
||||
$license = !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ? 'free' : 'premium';
|
||||
|
||||
?>
|
||||
|
||||
<div class="wpr-tplib-sidebar" data-license="<?php echo esc_attr($license); ?>">
|
||||
<div class="wpr-tplib-search">
|
||||
<input type="text" placeholder="Search Template">
|
||||
<i class="eicon-search"></i>
|
||||
</div>
|
||||
|
||||
<div class="wpr-tplib-filters-wrap">
|
||||
<div class="wpr-tplib-filters">
|
||||
<h3>
|
||||
<span><?php esc_html_e( 'Category', 'wpr-addons' ); ?></span>
|
||||
<i class="fas fa-angle-down"></i>
|
||||
</h3>
|
||||
|
||||
<div class="wpr-tplib-filters-list">
|
||||
<ul>
|
||||
<li data-filter="all"><?php esc_html_e( 'All', 'wpr-addons' ) ?></li>
|
||||
<li data-filter="cookie"><?php esc_html_e( 'Cookie', 'wpr-addons' ) ?></li>
|
||||
<li data-filter="discount"><?php esc_html_e( 'Discount', 'wpr-addons' ) ?></li>
|
||||
<li data-filter="subscribe"><?php esc_html_e( 'Subscribe', 'wpr-addons' ) ?></li>
|
||||
<li data-filter="yesno"><?php esc_html_e( 'Yes/No', 'wpr-addons' ) ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wpr-tplib-template-gird elementor-clearfix">
|
||||
<div class="wpr-tplib-template-gird-inner">
|
||||
|
||||
<?php
|
||||
|
||||
$popups = WPR_Templates_Data::get_available_popups();
|
||||
|
||||
foreach ($popups as $type => $data) :
|
||||
|
||||
for ( $i=0; $i < count($popups[$type]); $i++ ) :
|
||||
|
||||
$template_slug = array_keys($popups[$type])[$i];
|
||||
$template_title = ucfirst($type) .' '. $template_slug;
|
||||
$preview_type = $popups[$type][$template_slug]['type'];
|
||||
$preview_url = $popups[$type][$template_slug]['url'];
|
||||
$template_class = ( strpos($template_slug, 'pro') && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ) ? ' wpr-tplib-pro-wrap' : '';
|
||||
|
||||
?>
|
||||
|
||||
<div class="wpr-tplib-template-wrap<?php echo esc_attr($template_class); ?>">
|
||||
<div class="wpr-tplib-template" data-slug="<?php echo esc_attr($template_slug); ?>" data-filter="<?php echo esc_attr($type); ?>" data-preview-type="<?php echo esc_attr($preview_type); ?>" data-preview-url="<?php echo esc_attr($preview_url); ?>">
|
||||
<div class="wpr-tplib-template-media">
|
||||
<img class="lazy" src="<?php echo esc_url(WPR_ADDONS_ASSETS_URL .'img/icon-256x256.png'); ?>" data-src="<?php echo esc_url('https://royal-elementor-addons.com/library/premade-styles/popups/'. $type .'/'. $template_slug .'.jpg'); ?>">
|
||||
<div class="wpr-tplib-template-media-overlay">
|
||||
<i class="eicon-eye"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpr-tplib-template-footer elementor-clearfix">
|
||||
<h3><?php echo esc_html(str_replace('-pro', ' Pro', $template_title)); ?></h3>
|
||||
|
||||
<?php if ( strpos($template_slug, 'pro') && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ) : ?>
|
||||
<span class="wpr-tplib-insert-template wpr-tplib-insert-pro"><i class="eicon-star"></i> <span><?php esc_html_e( 'Go Pro', 'wpr-addons' ); ?></span></span>
|
||||
<?php else : ?>
|
||||
<span class="wpr-tplib-insert-template"><i class="eicon-file-download"></i> <span><?php esc_html_e( 'Insert', 'wpr-addons' ); ?></span></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endfor; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php exit();
|
||||
}
|
||||
|
||||
}
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
namespace WprAddons\Admin\Templates\Library;
|
||||
use WprAddons\Classes\Utilities;
|
||||
use WprAddons\Admin\Templates\Library\WPR_Templates_Data;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* WPR_Templates_Library_Sections setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class WPR_Templates_Library_Sections {
|
||||
|
||||
/**
|
||||
** Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// Template Library Popup
|
||||
add_action( 'wp_ajax_render_library_templates_sections', [ $this, 'render_library_templates_sections' ] );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
** Template Library Popup
|
||||
*/
|
||||
public static function render_library_templates_sections() {
|
||||
$license = !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ? 'free' : 'premium';
|
||||
|
||||
?>
|
||||
|
||||
<div class="wpr-tplib-sidebar" data-license="<?php echo esc_attr($license); ?>">
|
||||
<div class="wpr-tplib-filters-wrap">
|
||||
<div class="wpr-tplib-filters">
|
||||
<h3>
|
||||
<span data-filter="all"><?php esc_html_e( 'Category', 'wpr-addons' ); ?></span>
|
||||
<i class="fas fa-angle-down"></i>
|
||||
</h3>
|
||||
|
||||
<div class="wpr-tplib-filters-list">
|
||||
<ul>
|
||||
|
||||
<li data-filter="all"><?php esc_html_e( 'All', 'wpr-addons' ) ?></li>
|
||||
|
||||
<?php
|
||||
|
||||
$sections = WPR_Templates_Data::get_available_sections();
|
||||
|
||||
foreach ($sections as $title => $data) {
|
||||
$slug = self::create_slug($title);
|
||||
echo '<li data-filter="'. esc_attr($slug) .'">'. esc_html($title) .'</li>';
|
||||
}
|
||||
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpr-tplib-search">
|
||||
<input type="text" placeholder="Search Template">
|
||||
<i class="eicon-search"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpr-tplib-template-gird wpr-tplib-sections-grid elementor-clearfix">
|
||||
<div class="wpr-tplib-template-gird-inner">
|
||||
|
||||
<?php
|
||||
|
||||
foreach ($sections as $title => $data) :
|
||||
$slug = self::create_slug($title);
|
||||
|
||||
for ( $i=0; $i < count($data); $i++ ) :
|
||||
|
||||
$template_slug = $slug .'-'. $data[$i];
|
||||
$template_class = strpos($template_slug, 'pro') && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ? ' wpr-tplib-pro-wrap' : '';
|
||||
$template_class .= strpos($template_slug, 'woo') && !class_exists( 'woocommerce' ) ? ' wpr-tplib-woo-wrap' : '';
|
||||
|
||||
if (defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code()) {
|
||||
$template_class .= ' wpr-tplib-pro-active';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="wpr-tplib-template-wrap<?php echo esc_attr($template_class); ?>" data-title="<?php echo esc_attr(strtolower($title)); ?>">
|
||||
<div class="wpr-tplib-template" data-slug="<?php echo esc_attr($data[$i]); ?>" data-filter="<?php echo esc_attr($slug); ?>" data-preview-type="image">
|
||||
<div class="wpr-tplib-template-media">
|
||||
<img class="lazy" src="<?php echo esc_url(WPR_ADDONS_ASSETS_URL .'img/icon-256x256.png'); ?>" data-src="<?php echo esc_url('https://royal-elementor-addons.com/library/premade-sections/'. $slug .'/'. $data[$i] .'.jpg'); ?>">
|
||||
<div class="wpr-tplib-template-media-overlay">
|
||||
<i class="eicon-eye"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wpr-tplib-template-footer elementor-clearfix">
|
||||
<?php $title_v = $title .' '. esc_html($data[$i]);?>
|
||||
<?php if ( !defined('WPR_ADDONS_PRO_VERSION') && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ) : ?>
|
||||
<h3><?php echo strpos($template_slug, 'pro') ? esc_html(str_replace('-pro', ' Pro', $title_v)) : esc_html(str_replace('-zzz', ' Pro', $title_v)); ?></h3>
|
||||
<?php else : ?>
|
||||
<h3><?php echo strpos($template_slug, 'pro') ? esc_html(str_replace('-pro', '', $title_v)) : esc_html(str_replace('-zzz', '', $title_v)); ?></h3>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( ( strpos($template_slug, 'pro') && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ) || ( strpos($template_slug, 'zzz') ) && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ) : ?>
|
||||
<span class="wpr-tplib-insert-template wpr-tplib-insert-pro"><i class="eicon-star"></i> <span><?php esc_html_e( 'Go Pro', 'wpr-addons' ); ?></span></span>
|
||||
<?php else : ?>
|
||||
<span class="wpr-tplib-insert-template"><i class="eicon-file-download"></i> <span><?php esc_html_e( 'Insert', 'wpr-addons' ); ?></span></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endfor; ?>
|
||||
<?php endforeach;?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( !(isset($current_screen) && 'royal-addons_page_wpr-premade-sections' === $current_screen->id) ) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_slug($str, $delimiter = '-'){
|
||||
// Try to convert the string with iconv
|
||||
$converted_str = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
|
||||
|
||||
// If iconv fails, fallback to the original string
|
||||
if ($converted_str === false) {
|
||||
$converted_str = $str; // Fallback to the original string
|
||||
}
|
||||
|
||||
// Continue with the rest of the slug generation
|
||||
$slug = strtolower(trim(preg_replace('/[\s-]+/', $delimiter, preg_replace('/[^A-Za-z0-9-]+/', $delimiter, preg_replace('/[&]/', 'and', preg_replace('/[\']/', '', $converted_str)))), $delimiter));
|
||||
|
||||
return $slug;
|
||||
}
|
||||
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
use WprAddons\Admin\Includes\WPR_Render_Templates;
|
||||
|
||||
/**
|
||||
* Wpr_Astra_Compat setup
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Astra theme compatibility.
|
||||
*/
|
||||
class Wpr_Astra_Compat {
|
||||
|
||||
/**
|
||||
* Instance of Wpr_Astra_Compat.
|
||||
*
|
||||
* @var Wpr_Astra_Compat
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* WPR_Render_Templates() Class
|
||||
*/
|
||||
private $render_templates;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new Wpr_Astra_Compat();
|
||||
|
||||
add_action( 'wp', [ self::$instance, 'hooks' ] );
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all the Actions / Filters.
|
||||
*/
|
||||
public function hooks() {
|
||||
$this->render_templates = new WPR_Render_Templates( true );
|
||||
|
||||
if ( $this->render_templates->is_template_available('header') ) {
|
||||
add_action( 'template_redirect', [ $this, 'astra_setup_header' ], 10 );
|
||||
// add_action( 'astra_header', [$this->render_templates, 'replace_header'] );
|
||||
add_action( 'get_header', [ $this->render_templates, 'replace_header' ] );
|
||||
add_action( 'elementor/page_templates/canvas/before_content', [ $this->render_templates, 'add_canvas_header' ] );
|
||||
}
|
||||
|
||||
if ( $this->render_templates->is_template_available('footer') ) {
|
||||
add_action( 'template_redirect', [ $this, 'astra_setup_footer' ], 10 );
|
||||
add_action( 'astra_footer', [$this->render_templates, 'replace_footer'] );
|
||||
// add_action( 'get_footer', [$this->render_templates, 'replace_footer'] );
|
||||
add_action( 'elementor/page_templates/canvas/after_content', [ $this->render_templates, 'add_canvas_footer' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable header from the theme.
|
||||
*/
|
||||
public function astra_setup_header() {
|
||||
remove_action( 'astra_header', 'astra_header_markup' );
|
||||
|
||||
// Remove the new header builder action.
|
||||
if ( class_exists( '\Astra_Builder_Helper' ) && \Astra_Builder_Helper::$is_header_footer_builder_active ) {
|
||||
remove_action( 'astra_header', [ Astra_Builder_Header::get_instance(), 'prepare_header_builder_markup' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable footer from the theme.
|
||||
*/
|
||||
public function astra_setup_footer() {
|
||||
remove_action( 'astra_footer', 'astra_footer_markup' );
|
||||
|
||||
// Remove the new footer builder action.
|
||||
if ( class_exists( '\Astra_Builder_Helper' ) && \Astra_Builder_Helper::$is_header_footer_builder_active ) {
|
||||
remove_action( 'astra_footer', [ Astra_Builder_Footer::get_instance(), 'footer_markup' ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Wpr_Astra_Compat::instance();
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
use WprAddons\Admin\Includes\WPR_Render_Templates;
|
||||
|
||||
/**
|
||||
* Wpr_GeneratePress_Compat setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class Wpr_GeneratePress_Compat {
|
||||
|
||||
/**
|
||||
* Instance of Wpr_GeneratePress_Compat
|
||||
*
|
||||
* @var Wpr_GeneratePress_Compat
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* WPR_Render_Templates() Class
|
||||
*/
|
||||
private $render_templates;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new Wpr_GeneratePress_Compat();
|
||||
|
||||
add_action( 'wp', [ self::$instance, 'hooks' ] );
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all the Actions / Filters.
|
||||
*/
|
||||
public function hooks() {
|
||||
$this->render_templates = new WPR_Render_Templates( true );
|
||||
|
||||
if ( $this->render_templates->is_template_available('header') ) {
|
||||
add_action( 'template_redirect', [ $this, 'generatepress_setup_header' ] );
|
||||
add_action( 'generate_header', [$this->render_templates, 'replace_header'] );
|
||||
add_action( 'elementor/page_templates/canvas/before_content', [ $this->render_templates, 'add_canvas_header' ] );
|
||||
}
|
||||
|
||||
if ( $this->render_templates->is_template_available('footer') ) {
|
||||
add_action( 'template_redirect', [ $this, 'generatepress_setup_footer' ] );
|
||||
add_action( 'generate_footer', [$this->render_templates, 'replace_footer'] );
|
||||
add_action( 'elementor/page_templates/canvas/after_content', [ $this->render_templates, 'add_canvas_footer' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable header from the theme.
|
||||
*/
|
||||
public function generatepress_setup_header() {
|
||||
remove_action( 'generate_header', 'generate_construct_header' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable footer from the theme.
|
||||
*/
|
||||
public function generatepress_setup_footer() {
|
||||
remove_action( 'generate_footer', 'generate_construct_footer_widgets', 5 );
|
||||
remove_action( 'generate_footer', 'generate_construct_footer' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Wpr_GeneratePress_Compat::instance();
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
use WprAddons\Admin\Includes\WPR_Render_Templates;
|
||||
|
||||
/**
|
||||
* OceanWP theme compatibility.
|
||||
*/
|
||||
class Wpr_OceanWP_Compat {
|
||||
|
||||
/**
|
||||
* Instance of Wpr_OceanWP_Compat.
|
||||
*
|
||||
* @var Wpr_OceanWP_Compat
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* WPR_Render_Templates() Class
|
||||
*/
|
||||
private $render_templates;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new Wpr_OceanWP_Compat();
|
||||
|
||||
add_action( 'wp', [ self::$instance, 'hooks' ] );
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all the Actions / Filters.
|
||||
*/
|
||||
public function hooks() {
|
||||
$this->render_templates = new WPR_Render_Templates( true );
|
||||
|
||||
if ( $this->render_templates->is_template_available('header') ) {
|
||||
add_action( 'template_redirect', [ $this, 'setup_header' ], 10 );
|
||||
add_action( 'ocean_header', [$this->render_templates, 'replace_header'] );
|
||||
add_action( 'elementor/page_templates/canvas/before_content', [ $this->render_templates, 'add_canvas_header' ] );
|
||||
}
|
||||
|
||||
if ( $this->render_templates->is_template_available('footer') ) {
|
||||
add_action( 'template_redirect', [ $this, 'setup_footer' ], 10 );
|
||||
add_action( 'ocean_footer', [$this->render_templates, 'replace_footer'] );
|
||||
add_action( 'elementor/page_templates/canvas/after_content', [ $this->render_templates, 'add_canvas_footer' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable header from the theme.
|
||||
*/
|
||||
public function setup_header() {
|
||||
remove_action( 'ocean_top_bar', 'oceanwp_top_bar_template' );
|
||||
remove_action( 'ocean_header', 'oceanwp_header_template' );
|
||||
remove_action( 'ocean_page_header', 'oceanwp_page_header_template' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable footer from the theme.
|
||||
*/
|
||||
public function setup_footer() {
|
||||
remove_action( 'ocean_footer', 'oceanwp_footer_template' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Wpr_OceanWP_Compat::instance();
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
use WprAddons\Admin\Includes\WPR_Conditions_Manager;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
$conditions = json_decode( get_option('wpr_footer_conditions', '[]'), true );
|
||||
$template_slug = WPR_Conditions_Manager::header_footer_display_conditions($conditions);
|
||||
|
||||
// Render WPR Header
|
||||
Utilities::render_elementor_template($template_slug);
|
||||
|
||||
wp_footer();
|
||||
|
||||
// Royal themes compatibility
|
||||
echo '</div>'; // .page-content
|
||||
echo '</div>'; // #page-wrap
|
||||
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
use WprAddons\Admin\Includes\WPR_Conditions_Manager;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
$conditions = json_decode( get_option('wpr_header_conditions', '[]'), true );
|
||||
$template_slug = WPR_Conditions_Manager::header_footer_display_conditions($conditions);
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html <?php language_attributes(); ?>>
|
||||
<head>
|
||||
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
||||
<?php if ( ! current_theme_supports( 'title-tag' ) ) : ?>
|
||||
<title>
|
||||
<?php echo esc_html(wp_get_document_title()); ?>
|
||||
</title>
|
||||
<?php endif; ?>
|
||||
<?php wp_head(); ?>
|
||||
</head>
|
||||
|
||||
<body <?php body_class(); ?>>
|
||||
|
||||
<?php
|
||||
|
||||
do_action( 'wp_body_open' );
|
||||
|
||||
// Royal themes compatibility
|
||||
echo '<div id="page-wrap">';
|
||||
|
||||
// Render WPR Header
|
||||
Utilities::render_elementor_template($template_slug);
|
||||
|
||||
// Royal themes compatibility
|
||||
echo '<div class="page-content">';
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
use WprAddons\Admin\Includes\WPR_Render_Templates;
|
||||
|
||||
/**
|
||||
* Storefront theme compatibility.
|
||||
*/
|
||||
class Wpr_Storefront_Compat {
|
||||
|
||||
/**
|
||||
* Instance of Wpr_Storefront_Compat.
|
||||
*
|
||||
* @var Wpr_Storefront_Compat
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* WPR_Render_Templates() Class
|
||||
*/
|
||||
private $render_templates;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new Wpr_Storefront_Compat();
|
||||
|
||||
add_action( 'wp', [ self::$instance, 'hooks' ] );
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all the Actions / Filters.
|
||||
*/
|
||||
public function hooks() {
|
||||
$this->render_templates = new WPR_Render_Templates( true );
|
||||
|
||||
if ( $this->render_templates->is_template_available('header') ) {
|
||||
add_action( 'template_redirect', [ $this, 'setup_header' ], 10 );
|
||||
add_action( 'storefront_before_header', [$this->render_templates, 'replace_header'], 500 );
|
||||
add_action( 'elementor/page_templates/canvas/before_content', [ $this->render_templates, 'add_canvas_header' ] );
|
||||
}
|
||||
|
||||
if ( $this->render_templates->is_template_available('footer') ) {
|
||||
add_action( 'template_redirect', [ $this, 'setup_footer' ], 10 );
|
||||
add_action( 'storefront_after_footer', [$this->render_templates, 'replace_footer'], 500 );
|
||||
add_action( 'elementor/page_templates/canvas/after_content', [ $this->render_templates, 'add_canvas_footer' ] );
|
||||
}
|
||||
|
||||
if ( $this->render_templates->is_template_available('header') || $this->render_templates->is_template_available('footer') ) {
|
||||
add_action( 'wp_head', [ $this, 'styles' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add inline CSS to hide empty divs for header and footer in storefront
|
||||
*
|
||||
* @since 1.2.0
|
||||
* @return void
|
||||
*/
|
||||
public function styles() {
|
||||
$css = '<style id="wpr-disable-storefront-hf">';
|
||||
|
||||
if ( $this->render_templates->is_template_available('header') ) {
|
||||
$css .= '.site-header {
|
||||
display: none;
|
||||
}';
|
||||
}
|
||||
|
||||
if ( $this->render_templates->is_template_available('footer') ) {
|
||||
$css .= '.site-footer {
|
||||
display: none;
|
||||
}';
|
||||
}
|
||||
|
||||
$css .= '</style>';
|
||||
|
||||
// Echo plain CSS (no user input or variables)
|
||||
echo ''. $css; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable header from the theme.
|
||||
*/
|
||||
public function setup_header() {
|
||||
for ( $priority = 0; $priority < 200; $priority ++ ) {
|
||||
remove_all_actions( 'storefront_header', $priority );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable footer from the theme.
|
||||
*/
|
||||
public function setup_footer() {
|
||||
for ( $priority = 0; $priority < 200; $priority ++ ) {
|
||||
remove_all_actions( 'storefront_footer', $priority );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Wpr_Storefront_Compat::instance();
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
use WprAddons\Admin\Includes\WPR_Conditions_Manager;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
$conditions = json_decode( get_option('wpr_footer_conditions', '[]'), true );
|
||||
$template_slug = WPR_Conditions_Manager::header_footer_display_conditions($conditions);
|
||||
|
||||
// Render WPR Header
|
||||
Utilities::render_elementor_template($template_slug);
|
||||
|
||||
wp_footer();
|
||||
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
use WprAddons\Admin\Includes\WPR_Conditions_Manager;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
$conditions = json_decode( get_option('wpr_header_conditions', '[]'), true );
|
||||
$template_slug = WPR_Conditions_Manager::header_footer_display_conditions($conditions);
|
||||
|
||||
?><!DOCTYPE html>
|
||||
<html <?php language_attributes(); ?>>
|
||||
<?php if ( 'Astra' != wp_get_theme()->get('Name') ) { ?>
|
||||
<head>
|
||||
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
||||
<?php if ( ! current_theme_supports( 'title-tag' ) ) : ?>
|
||||
<title>
|
||||
<?php echo esc_html(wp_get_document_title()); ?>
|
||||
</title>
|
||||
<?php endif; ?>
|
||||
<?php wp_head(); ?>
|
||||
</head>
|
||||
<?php } ?>
|
||||
|
||||
<body <?php body_class(); ?>>
|
||||
|
||||
<?php
|
||||
|
||||
do_action( 'wp_body_open' );
|
||||
|
||||
// Render WPR Header
|
||||
Utilities::render_elementor_template($template_slug);
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
use Elementor\Utils;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
\Elementor\Plugin::$instance->frontend->add_body_class( 'elementor-template-canvas' );
|
||||
|
||||
$is_preview_mode = \Elementor\Plugin::$instance->preview->is_preview_mode();
|
||||
// $woocommerce_class = $is_preview_mode && class_exists( 'WooCommerce' ) ? 'woocommerce woocommerce-page woocommerce-shop canvas-test' : '';
|
||||
$woocommerce_class = $is_preview_mode && class_exists( 'WooCommerce' ) ? 'woocommerce woocommerce-page' : '';
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html <?php language_attributes(); ?>>
|
||||
<head>
|
||||
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
||||
<?php if ( ! current_theme_supports( 'title-tag' ) ) : ?>
|
||||
<title><?php echo wp_get_document_title(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></title>
|
||||
<?php endif; ?>
|
||||
<?php wp_head(); ?>
|
||||
<?php
|
||||
|
||||
// Keep the following line after `wp_head()` call, to ensure it's not overridden by another templates.
|
||||
Utils::print_unescaped_internal_string( Utils::get_meta_viewport( 'canvas' ) );
|
||||
?>
|
||||
</head>
|
||||
|
||||
<body <?php body_class($woocommerce_class); ?>>
|
||||
<?php
|
||||
wp_body_open();
|
||||
|
||||
/**
|
||||
* Before canvas page template content.
|
||||
*
|
||||
* Fires before the content of Elementor canvas page template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
do_action( 'elementor/page_templates/canvas/before_content' );
|
||||
|
||||
// Elementor Editor
|
||||
if (( \Elementor\Plugin::$instance->preview->is_preview_mode() && Utilities::is_theme_builder_template()) || is_singular('wpr_mega_menu') ) {
|
||||
\Elementor\Plugin::$instance->modules_manager->get_modules( 'page-templates' )->print_content();
|
||||
|
||||
// Frontend
|
||||
} else {
|
||||
// Display Custom Elementor Templates
|
||||
do_action( 'elementor/page_templates/canvas/wpr_print_content' );
|
||||
}
|
||||
|
||||
/**
|
||||
* After canvas page template content.
|
||||
*
|
||||
* Fires after the content of Elementor canvas page template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
do_action( 'elementor/page_templates/canvas/after_content' );
|
||||
|
||||
wp_footer();
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
use WprAddons\Admin\Includes\WPR_Templates_Loop;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
// Register Menus
|
||||
function wpr_addons_add_theme_builder_menu() {
|
||||
add_submenu_page( 'wpr-addons', 'Theme Builder', 'Theme Builder', 'manage_options', 'wpr-theme-builder', 'wpr_addons_theme_builder_page' );
|
||||
}
|
||||
add_action( 'admin_menu', 'wpr_addons_add_theme_builder_menu' );
|
||||
|
||||
function wpr_addons_theme_builder_page() {
|
||||
|
||||
?>
|
||||
|
||||
<div class="wrap wpr-settings-page-wrap">
|
||||
|
||||
<div class="wpr-settings-page-header">
|
||||
<h1><?php echo esc_html(Utilities::get_plugin_name(true)); ?></h1>
|
||||
|
||||
<p><?php esc_html_e( 'The most powerful Elementor Addon in the universe.', 'wpr-addons' ); ?></p>
|
||||
<!-- <a href="https://royaladdons.frill.co/b/6m4d5qm4/feature-ideas" class="" target="_blank" style="padding: 8px 22px;">
|
||||
<?php echo esc_html__( 'Request New Feature', 'wpr-addons' ); ?>
|
||||
</a> -->
|
||||
|
||||
<!-- Custom Template -->
|
||||
<div class="wpr-preview-buttons">
|
||||
<div class="wpr-user-template">
|
||||
<span><?php esc_html_e( 'Create Template', 'wpr-addons' ); ?></span>
|
||||
<span class="plus-icon">+</span>
|
||||
|
||||
<?php
|
||||
if ( ! class_exists( 'WooCommerce' ) && isset($_GET['tab']) && ('wpr_tab_product_archive' === $_GET['tab'] || 'wpr_tab_product_single' === $_GET['tab'] )) {
|
||||
echo '<div></div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<a href="https://www.youtube.com/watch?v=kE1zmi3fxh8" class="wpr-dynamic-tutorial wpr-options-button button" target="_blank" style="padding: 8px 22px;">
|
||||
<?php echo esc_html__( 'Dynamic Websites Tutorial', 'wpr-addons' ); ?>
|
||||
<span class="dashicons dashicons-video-alt3"></span>
|
||||
</a>
|
||||
|
||||
<a href="https://www.youtube.com/watch?v=f_3tNiBC3dw" class="wpr-how-to-use-woo-builder wpr-options-button button" target="_blank" style="padding: 8px 22px; margin-left: 10px;">
|
||||
<?php echo esc_html__( 'WooCommerce Builder Tutorial', 'wpr-addons' ); ?>
|
||||
<span class="dashicons dashicons-video-alt3"></span>
|
||||
</a>
|
||||
|
||||
<a href="https://www.youtube.com/watch?v=cwkhwO_rPuo" class="wpr-how-to-use-theme-builder wpr-options-button button" target="_blank" style="padding: 8px 22px; margin-left: 10px;">
|
||||
<?php echo esc_html__( 'Theme Builder Tutorial', 'wpr-addons' ); ?>
|
||||
<span class="dashicons dashicons-video-alt3"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wpr-settings-page">
|
||||
<form method="post" action="options.php">
|
||||
<?php
|
||||
|
||||
// Active Tab
|
||||
$active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'wpr_tab_header';
|
||||
|
||||
?>
|
||||
|
||||
<!-- Template ID Holder -->
|
||||
<input type="hidden" name="wpr_template" id="wpr_template" value="">
|
||||
|
||||
<!-- Conditions Popup -->
|
||||
<?php WPR_Templates_Loop::render_conditions_popup(true); ?>
|
||||
|
||||
<!-- Create Templte Popup -->
|
||||
<?php WPR_Templates_Loop::render_create_template_popup(); ?>
|
||||
|
||||
<!-- Tabs -->
|
||||
<div class="nav-tab-wrapper wpr-nav-tab-wrapper">
|
||||
<a href="?page=wpr-theme-builder&tab=wpr_tab_header" data-title="Header" class="nav-tab <?php echo ($active_tab == 'wpr_tab_header') ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e( 'Header', 'wpr-addons' ); ?>
|
||||
</a>
|
||||
<a href="?page=wpr-theme-builder&tab=wpr_tab_footer" data-title="Footer" class="nav-tab <?php echo ($active_tab == 'wpr_tab_footer') ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e( 'Footer', 'wpr-addons' ); ?>
|
||||
</a>
|
||||
<a href="?page=wpr-theme-builder&tab=wpr_tab_archive" data-title="Archive" class="nav-tab <?php echo ($active_tab == 'wpr_tab_archive') ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e( 'Archive', 'wpr-addons' ); ?>
|
||||
</a>
|
||||
<a href="?page=wpr-theme-builder&tab=wpr_tab_single" data-title="Single" class="nav-tab <?php echo ($active_tab == 'wpr_tab_single') ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e( 'Single', 'wpr-addons' ); ?>
|
||||
</a>
|
||||
|
||||
<a href="?page=wpr-theme-builder&tab=wpr_tab_product_archive" data-title="Product Archive" class="nav-tab <?php echo $active_tab == 'wpr_tab_product_archive' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e( 'Product Archive', 'wpr-addons' ); ?>
|
||||
</a>
|
||||
<a href="?page=wpr-theme-builder&tab=wpr_tab_product_single" data-title="Product Single" class="nav-tab <?php echo $active_tab == 'wpr_tab_product_single' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e( 'Product Single', 'wpr-addons' ); ?>
|
||||
</a>
|
||||
|
||||
<a href="?page=wpr-theme-builder&tab=wpr_tab_my_templates" data-title="My Templates" class="nav-tab <?php echo ($active_tab == 'wpr_tab_my_templates') ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e( 'Saved Templates', 'wpr-addons' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) {
|
||||
$url = '';
|
||||
if ( 'wpr_tab_my_templates' === $active_tab ) {
|
||||
$url = admin_url( 'edit.php?post_type=elementor_library&tabs_group=library' );
|
||||
} else {
|
||||
$url = admin_url( 'edit.php?s&post_status=all&post_type=wpr_templates&wpr_template_type='. str_replace("wpr_tab_", "", $active_tab) .'&filter_action=Filter' );
|
||||
}
|
||||
echo '<a href="' . esc_url( $url ) . '" class="button button-primary wpr-translate-templates wpr-options-button"><span class="dashicons dashicons-admin-site"></span><span>Translate WPML Templates</span></a>';
|
||||
echo '<a href="https://www.youtube.com/watch?v=y7yjItsMBmw" class="button button-primary wpr-translate-templates wpr-options-button tutorial">'. esc_html__("Video Tutorial") .'</a>';
|
||||
} else if ( is_plugin_active('polylang/polylang.php') ) {
|
||||
$url = '';
|
||||
if ( 'wpr_tab_my_templates' === $active_tab ) {
|
||||
$url = admin_url( 'edit.php?post_type=elementor_library&tabs_group=library' );
|
||||
} else {
|
||||
$url = admin_url( 'edit.php?s&post_status=all&post_type=wpr_templates&wpr_template_type='. str_replace("wpr_tab_", "", $active_tab) .'&filter_action=Filter' );
|
||||
}
|
||||
echo '<a href="' . esc_url( $url ) . '" class="button button-primary wpr-translate-templates wpr-options-button"><span class="dashicons dashicons-admin-site"></span><span>Translate POLYLANG Templates</span></a>';
|
||||
echo '<a href="https://www.youtube.com/watch?v=y7yjItsMBmw" class="button button-primary wpr-translate-templates wpr-options-button tutorial">'. esc_html__("Video Tutorial") .'</a>';
|
||||
}
|
||||
?>
|
||||
<?php if ( $active_tab == 'wpr_tab_header' ) : ?>
|
||||
|
||||
<!-- Save Conditions -->
|
||||
<input type="hidden" name="wpr_header_conditions" id="wpr_header_conditions" value="<?php echo esc_attr(get_option('wpr_header_conditions', '[]')); ?>">
|
||||
|
||||
<?php WPR_Templates_Loop::render_theme_builder_templates( 'header' ); ?>
|
||||
|
||||
<?php elseif ( $active_tab == 'wpr_tab_footer' ) : ?>
|
||||
|
||||
<!-- Save Conditions -->
|
||||
<input type="hidden" name="wpr_footer_conditions" id="wpr_footer_conditions" value="<?php echo esc_attr(get_option('wpr_footer_conditions', '[]')); ?>">
|
||||
|
||||
<?php WPR_Templates_Loop::render_theme_builder_templates( 'footer' ); ?>
|
||||
|
||||
<?php elseif ( $active_tab == 'wpr_tab_archive' ) : ?>
|
||||
|
||||
<!-- Save Conditions -->
|
||||
<input type="hidden" name="wpr_archive_conditions" id="wpr_archive_conditions" value="<?php echo esc_attr(get_option('wpr_archive_conditions', '[]')); ?>">
|
||||
|
||||
<?php WPR_Templates_Loop::render_theme_builder_templates( 'archive' ); ?>
|
||||
|
||||
<?php elseif ( $active_tab == 'wpr_tab_single' ) : ?>
|
||||
|
||||
<!-- Save Conditions -->
|
||||
<input type="hidden" name="wpr_single_conditions" id="wpr_single_conditions" value="<?php echo esc_attr(get_option('wpr_single_conditions', '[]')); ?>">
|
||||
|
||||
<?php WPR_Templates_Loop::render_theme_builder_templates( 'single' ); ?>
|
||||
|
||||
<?php elseif ( $active_tab == 'wpr_tab_product_archive' ) : ?>
|
||||
|
||||
<?php if ( class_exists( 'WooCommerce' ) ) : ?>
|
||||
<!-- Save Conditions -->
|
||||
<input type="hidden" name="wpr_product_archive_conditions" id="wpr_product_archive_conditions" value="<?php echo esc_attr(get_option('wpr_product_archive_conditions', '[]')); ?>">
|
||||
|
||||
<?php WPR_Templates_Loop::render_theme_builder_templates( 'product_archive' ); ?>
|
||||
<?php else : ?>
|
||||
<div class="wpr-activate-woo-notice"><span class="dashicons dashicons-info-outline"></span> Please install/activate WooCommerce in order to create product archive templates!</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php elseif ( $active_tab == 'wpr_tab_product_single' ) : ?>
|
||||
|
||||
<?php if ( class_exists( 'WooCommerce' ) ) : ?>
|
||||
<!-- Save Conditions -->
|
||||
<input type="hidden" name="wpr_product_single_conditions" id="wpr_product_single_conditions" value="<?php echo esc_attr(get_option('wpr_product_single_conditions', '[]')); ?>">
|
||||
|
||||
<?php WPR_Templates_Loop::render_theme_builder_templates( 'product_single' ); ?>
|
||||
<?php else : ?>
|
||||
<div class="wpr-activate-woo-notice"><span class="dashicons dashicons-info-outline"></span> Please install/activate WooCommerce in order to create product single templates!</div>
|
||||
<?php endif ; ?>
|
||||
|
||||
<?php elseif ( $active_tab == 'wpr_tab_my_templates' ) : ?>
|
||||
|
||||
<?php Wpr_Templates_Loop::render_elementor_saved_templates(); ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
} // End wpr_addons_theme_builder_page()
|
||||
Reference in New Issue
Block a user