royal-elementor-addons
Last commit date
admin
5 days ago
assets
5 days ago
base
5 days ago
classes
5 days ago
extensions
5 days ago
freemius
5 days ago
includes
5 days ago
languages
5 days ago
modules
5 days ago
LICENSE
5 days ago
plugin.php
5 days ago
readme.txt
5 days ago
wpml-config.xml
5 days ago
wpr-addons.php
5 days ago
wpr-addons.php
272 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Plugin Name: Royal Elementor Addons |
| 4 | * Description: The only plugin you need for Elementor page builder. |
| 5 | * Plugin URI: https://royal-elementor-addons.com/ |
| 6 | * Author: WP Royal |
| 7 | * Version: 1.7.1064 |
| 8 | * License: GPLv3 |
| 9 | * Author URI: https://royal-elementor-addons.com/ |
| 10 | * Elementor tested up to: 4.1.4 |
| 11 | * Elementor Pro tested up to: 4.1.2 |
| 12 | * |
| 13 | * Text Domain: wpr-addons |
| 14 | */ |
| 15 | |
| 16 | if ( ! defined( 'ABSPATH' ) ) { |
| 17 | exit; // Exit if accessed directly. |
| 18 | } |
| 19 | |
| 20 | define( 'WPR_ADDONS_VERSION', '1.7.1064' ); |
| 21 | |
| 22 | define( 'WPR_ADDONS__FILE__', __FILE__ ); |
| 23 | define( 'WPR_ADDONS_PLUGIN_BASE', plugin_basename( WPR_ADDONS__FILE__ ) ); |
| 24 | define( 'WPR_ADDONS_PATH', plugin_dir_path( WPR_ADDONS__FILE__ ) ); |
| 25 | define( 'WPR_ADDONS_MODULES_PATH', WPR_ADDONS_PATH . 'modules/' ); |
| 26 | define( 'WPR_ADDONS_URL', plugins_url( '/', WPR_ADDONS__FILE__ ) ); |
| 27 | define( 'WPR_ADDONS_ASSETS_URL', WPR_ADDONS_URL . 'assets/' ); |
| 28 | define( 'WPR_ADDONS_MODULES_URL', WPR_ADDONS_URL . 'modules/' ); |
| 29 | |
| 30 | /** |
| 31 | * Feemius Integration |
| 32 | */ |
| 33 | |
| 34 | if ( function_exists( 'wpr_fs' ) ) { |
| 35 | wpr_fs()->set_basename( false, __FILE__ ); |
| 36 | } else { |
| 37 | $register_freemius = true; |
| 38 | |
| 39 | if ( get_option('royal_elementor_addons_pro_activation_time') ) { |
| 40 | if ( function_exists('is_plugin_active') ) { |
| 41 | if ( is_plugin_active('wpr-addons-pro/wpr-addons-pro.php') || is_plugin_active('royal-elementor-addons-pro/wpr-addons-pro.php') ) { |
| 42 | $register_freemius = false; |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | if ( $register_freemius ) { |
| 48 | // Create a helper function for easy SDK access. |
| 49 | function wpr_fs() { |
| 50 | global $wpr_fs; |
| 51 | |
| 52 | if ( ! isset( $wpr_fs ) ) { |
| 53 | // Include Freemius SDK. |
| 54 | require_once dirname(__FILE__) . '/freemius/start.php'; |
| 55 | |
| 56 | $wpr_fs = fs_dynamic_init( array( |
| 57 | 'id' => '8416', |
| 58 | 'slug' => 'wpr-addons', |
| 59 | 'premium_slug' => 'wpr-addons-pro', |
| 60 | 'type' => 'plugin', |
| 61 | 'public_key' => 'pk_a0b21b234a7c9581a555b9ee9f28a', |
| 62 | 'is_premium' => false, |
| 63 | 'has_premium_version' => true, |
| 64 | 'has_paid_plans' => false, |
| 65 | 'has_addons' => false, |
| 66 | 'has_affiliation' => 'selected', |
| 67 | 'menu' => array( |
| 68 | 'slug' => 'wpr-addons', |
| 69 | 'first-path' => 'admin.php?page=wpr-templates-kit', |
| 70 | 'support' => false, |
| 71 | 'affiliation' => true, |
| 72 | 'pricing' => false, |
| 73 | ), |
| 74 | ) ); |
| 75 | } |
| 76 | |
| 77 | return $wpr_fs; |
| 78 | } |
| 79 | |
| 80 | // Init Freemius. |
| 81 | wpr_fs(); |
| 82 | // Signal that SDK was initiated. |
| 83 | do_action( 'wpr_fs_loaded' ); |
| 84 | |
| 85 | wpr_fs()->add_filter( 'show_deactivation_subscription_cancellation', '__return_false' ); |
| 86 | wpr_fs()->add_filter( 'deactivate_on_activation', '__return_false' ); |
| 87 | |
| 88 | function disable_contact_for_free_users( $is_visible, $menu_id ) { |
| 89 | |
| 90 | if ( 'contact' != $menu_id ) { |
| 91 | return $is_visible; |
| 92 | } |
| 93 | |
| 94 | return wpr_fs()->can_use_premium_code(); |
| 95 | } |
| 96 | |
| 97 | wpr_fs()->add_filter( 'is_submenu_visible', 'disable_contact_for_free_users', 10, 2 ); |
| 98 | |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | |
| 103 | /** |
| 104 | * Load gettext translate for our text domain. |
| 105 | * |
| 106 | * @since 1.0.0 |
| 107 | * |
| 108 | * @return void |
| 109 | */ |
| 110 | function wpr_addons_load_plugin() { |
| 111 | if ( ! did_action( 'elementor/loaded' ) ) { |
| 112 | add_action( 'admin_notices', 'wpr_addons_fail_load' ); |
| 113 | return; |
| 114 | } |
| 115 | |
| 116 | $elementor_version_required = '2.0.0'; |
| 117 | if ( ! version_compare( ELEMENTOR_VERSION, $elementor_version_required, '>=' ) ) { |
| 118 | add_action( 'admin_notices', 'wpr_addons_fail_load_out_of_date' ); |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | require( WPR_ADDONS_PATH . 'plugin.php' ); |
| 123 | } |
| 124 | add_action( 'plugins_loaded', 'wpr_addons_load_plugin' ); |
| 125 | |
| 126 | /** |
| 127 | * Show in WP Dashboard notice about the plugin is not activated. |
| 128 | * |
| 129 | * @since 1.0.0 |
| 130 | * |
| 131 | * @return void |
| 132 | */ |
| 133 | function wpr_addons_fail_load() { |
| 134 | $screen = get_current_screen(); |
| 135 | if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) { |
| 136 | return; |
| 137 | } |
| 138 | |
| 139 | $plugin = 'elementor/elementor.php'; |
| 140 | |
| 141 | if ( _is_elementor_installed() ) { |
| 142 | if ( ! current_user_can( 'activate_plugins' ) ) { |
| 143 | return; |
| 144 | } |
| 145 | |
| 146 | $activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin='. $plugin .'&plugin_status=all&paged=1&s', 'activate-plugin_'. $plugin ); |
| 147 | |
| 148 | $message = '<p>' . esc_html__( 'Royal Elementor Addons is not working because you need to activate the Elementor plugin.', 'wpr-addons' ) . '</p>'; |
| 149 | $message .= '<p>' . sprintf( '<a href="%s" class="button-primary">%s</a>', $activation_url, esc_html__( 'Activate Elementor Now', 'wpr-addons' ) ) . '</p>'; |
| 150 | } else { |
| 151 | if ( ! current_user_can( 'install_plugins' ) ) { |
| 152 | return; |
| 153 | } |
| 154 | |
| 155 | $install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' ); |
| 156 | |
| 157 | $message = '<p>' . esc_html__( 'Royal Elementor Addons is not working because you need to install the Elementor plugin', 'wpr-addons' ) . '</p>'; |
| 158 | $message .= '<p>' . sprintf( '<a href="%s" class="button-primary">%s</a>', $install_url, esc_html__( 'Install Elementor Now', 'wpr-addons' ) ) . '</p>'; |
| 159 | } |
| 160 | |
| 161 | echo '<div class="error"><p>'. wp_kses_post($message) .'</p></div>'; |
| 162 | } |
| 163 | |
| 164 | function wpr_addons_fail_load_out_of_date() { |
| 165 | if ( ! current_user_can( 'update_plugins' ) ) { |
| 166 | return; |
| 167 | } |
| 168 | |
| 169 | $file_path = 'elementor/elementor.php'; |
| 170 | |
| 171 | $upgrade_link = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file_path, 'upgrade-plugin_'. $file_path ); |
| 172 | $message = '<p>' . esc_html__( 'Royal Elementor Addons is not working because you are using an old version of Elementor.', 'wpr-addons' ) . '</p>'; |
| 173 | $message .= '<p>' . sprintf( '<a href="%s" class="button-primary">%s</a>', $upgrade_link, esc_html__( 'Update Elementor Now', 'wpr-addons' ) ) . '</p>'; |
| 174 | |
| 175 | echo '<div class="error">'. wp_kses_post($message) .'</div>'; |
| 176 | } |
| 177 | |
| 178 | if ( ! function_exists( '_is_elementor_installed' ) ) { |
| 179 | |
| 180 | function _is_elementor_installed() { |
| 181 | $file_path = 'elementor/elementor.php'; |
| 182 | $installed_plugins = get_plugins(); |
| 183 | |
| 184 | return isset( $installed_plugins[ $file_path ] ); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | |
| 189 | /** |
| 190 | * Redirect to Options Page |
| 191 | * |
| 192 | * @since 1.0.0 |
| 193 | * |
| 194 | */ |
| 195 | |
| 196 | function wpr_plugin_activate() { |
| 197 | set_transient('wpr_plugin_do_activation_redirect', true, 60); |
| 198 | } |
| 199 | |
| 200 | function wpr_plugin_redirect() { |
| 201 | if (get_transient('wpr_plugin_do_activation_redirect')) { |
| 202 | delete_transient('wpr_plugin_do_activation_redirect'); |
| 203 | |
| 204 | if ( !isset($_GET['activate-multi']) ) { |
| 205 | wp_redirect('admin.php?page=wpr-addons'); |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | if ( did_action( 'elementor/loaded' ) ) { |
| 211 | register_activation_hook(__FILE__, 'wpr_plugin_activate'); |
| 212 | add_action('admin_init', 'wpr_plugin_redirect'); |
| 213 | } |
| 214 | |
| 215 | // Set Plugin Activation Time |
| 216 | function royal_elementor_addons_activation_time() {//TODO: Try to locate this in rating-notice.php later if possible |
| 217 | if ( false === get_option( 'royal_elementor_addons_activation_time' ) ) { |
| 218 | add_option( 'royal_elementor_addons_activation_time', absint(intval(strtotime('now'))) ); |
| 219 | } |
| 220 | |
| 221 | if ( false === get_option( 'royal_elementor_addons_activation_time_for_sale' ) ) { |
| 222 | add_option( 'royal_elementor_addons_activation_time_for_sale', absint(intval(strtotime('now'))) ); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | register_activation_hook( __FILE__, 'royal_elementor_addons_activation_time' ); |
| 227 | |
| 228 | // Plugin Deactivation |
| 229 | function royal_elementor_addons_deactivate() { |
| 230 | // Reset "never show backup popup" preference so it shows again on reactivation. |
| 231 | delete_metadata( 'user', 0, 'wpr_dismiss_backup_popup', '', true ); |
| 232 | } |
| 233 | |
| 234 | // hook already exists with template kits notice |
| 235 | register_deactivation_hook( __FILE__, 'royal_elementor_addons_deactivate' ); |
| 236 | |
| 237 | function wpr_script_loader_tag( $tag, $handle ) { |
| 238 | if ( 'jquery-core' !== $handle && 'jquery-migrate' !== $handle && 'wpr-addons-js' !== $handle && 'wpr-isotope' !== $handle ) { |
| 239 | return $tag; |
| 240 | } |
| 241 | |
| 242 | |
| 243 | // Modern implementations may employ WP_HTML_Tag_Processor here. |
| 244 | // return str_replace( ' src=', ' defer src=', $tag ); |
| 245 | return str_replace( ' src', ' data-cfasync="false" src', $tag ); |
| 246 | } |
| 247 | |
| 248 | function exclude_wpr_scripts_from_wp_optimize( $excluded_handles ) { |
| 249 | // Replace 'my-script-handle' with the handle of the script you want to exclude. |
| 250 | $excluded_handles[] = 'wpr-addons-js'; |
| 251 | |
| 252 | return $excluded_handles; |
| 253 | } |
| 254 | |
| 255 | function exclude_wpr_styles_from_wp_optimize( $excluded_handles ) { |
| 256 | // Replace 'my-style-handle' with the handle of the style you want to exclude. |
| 257 | $excluded_handles[] = 'wpr-addons-css'; |
| 258 | |
| 259 | return $excluded_handles; |
| 260 | } |
| 261 | |
| 262 | if ( 'on' === get_option('wpr_ignore_wp_rocket_js', 'on') ) { |
| 263 | add_filter( 'script_loader_tag', 'wpr_script_loader_tag', 10, 2 ); |
| 264 | } |
| 265 | |
| 266 | if ( 'on' === get_option('wpr_ignore_wp_optimize_js', 'on') ) { |
| 267 | add_filter( 'wpo_minify_excluded_js_handles', 'exclude_wpr_scripts_from_wp_optimize' ); |
| 268 | } |
| 269 | |
| 270 | if ( 'on' === get_option('wpr_ignore_wp_optimize_css', 'on') ) { |
| 271 | add_filter( 'wpo_minify_excluded_css_handles', 'exclude_wpr_styles_from_wp_optimize' ); |
| 272 | } |