PATH:
home
/
lab2454c
/
foreclass.com
/
wp-content
/
plugins
/
search-replace-for-elementor
/
inc
/
admin
<?php /** * Load plugin files and check requirements. * * @package ELEMSNR * @copyright Copyright (c) 2023, Developry Ltd. * @license https://www.gnu.org/licenses/gpl-2.0.html GNU Public License * @since 1.0 */ namespace ELEMSNR; ! defined( ABSPATH ) || exit; // Exit if accessed directly. /** * Don't allow to have both Free and Pro active at the same time. */ register_activation_hook( ELEMSNR_PLUGIN_BASENAME, __NAMESPACE__ . '\elemsnr_activation' ); function elemsnr_activation() { // Deactitve the Pro version if active. if ( is_plugin_active( 'search-replace-for-elementor-pro/search-replace-for-elementor.php' ) ) { deactivate_plugins( 'search-replace-for-elementor-pro/search-replace-for-elementor.php', true ); } } add_action( 'admin_init', __NAMESPACE__ . '\elemsnr_min_requirements' ); /** * Stop plugin activation if minimum requirement aren't met. */ function elemsnr_min_requirements() { require_once ABSPATH . 'wp-admin/includes/plugin.php'; if ( ! did_action( 'elementor/loaded' ) ) { add_action( 'admin_notices', __NAMESPACE__ . '\elemsnr_elementor_missing' ); deactivate_plugins( ELEMSNR_PLUGIN_BASENAME ); return; } if ( ! version_compare( ELEMENTOR_VERSION, ELEMSNR_MIN_ELEMENTOR_VERSION, '>=' ) ) { add_action( 'admin_notices', __NAMESPACE__ . '\elemsnr_elementor_min_version' ); deactivate_plugins( ELEMSNR_PLUGIN_BASENAME ); return; } if ( version_compare( PHP_VERSION, ELEMSNR_MIN_PHP_VERSION ) >= 0 && version_compare( $GLOBALS['wp_version'], ELEMSNR_MIN_WP_VERSION ) >= 0 ) { load_plugin_textdomain( ELEMSNR_PLUGIN_TEXTDOMAIN, false, ELEMSNR_PLUGIN_BASENAME . 'lang' ); add_action( 'plugin_action_links', __NAMESPACE__ . '\elemsnr_add_action_links', 10, 2 ); add_action( 'elementor/editor/after_enqueue_scripts', __NAMESPACE__ . '\elemsnr_enqueue_elementor_assets' ); add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\elemsnr_enqueue_admin_assets' ); } else { add_action( 'admin_notices', __NAMESPACE__ . '\elemsnr_wordpress_php_min_version' ); deactivate_plugins( ELEMSNR_PLUGIN_BASENAME ); } } /** * Display message if Elemetor or Elementor PRO aren't active. */ function elemsnr_elementor_missing() { if ( isset( $_GET['activate'] ) ) { unset( $_GET['activate'] ); } $message = sprintf( /* translators: %1$s is replaced with "Plugin Name" */ /* translators: %2$s is replaced with "Elementor" */ esc_html__( '%1$s requires %2$s to be installed and activated.', 'search-replace-for-elementor' ), '<strong>' . esc_html__( 'Search & Replace for Elementor', 'search-replace-for-elementor' ) . '</strong>', '<strong>' . esc_html__( 'Elementor', 'search-replace-for-elementor' ) . '</strong>' ); printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); } /** * Display message if Elemetor or Elementor PRO don't meet minimum required version. */ function elemsnr_elementor_min_version() { if ( isset( $_GET['activate'] ) ) { unset( $_GET['activate'] ); } $message = sprintf( /* translators: %1$s is replaced with "Plugin Name" */ /* translators: %2$s is replaced with "Elementor" */ /* translators: %3$s is replaced with "Required Elementor Version" */ esc_html__( '%1$s requires %2$s version %3$s or greater.', 'search-replace-for-elementor' ), '<strong>' . esc_html__( 'Search & Replace for Elementor', 'search-replace-for-elementor' ) . '</strong>', '<strong>' . esc_html__( 'Elementor', 'search-replace-for-elementor' ) . '</strong>', ELEMSNR_MIN_ELEMENTOR_VERSION ); printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); } /** * Display message system doesn't meet minimum require PHP version. */ function elemsnr_wordpress_php_min_version() { $message = sprintf( /* translators: %1$s is replaced with "Plugin Name" */ /* translators: %2$s is replaced with "Min PHP Version" */ /* translators: %3$s is replaced with "Min WP Version" */ wp_kses( __( '%1$s requires a minimum of PHP %2$s and WordPress %3$s', 'search-replace-for-elementor' ), json_decode( ELEMSNR_PLUGIN_ALLOWED_HTML_ARR ) ), '<strong>' . ELEMSNR_PLUGIN_NAME . '</strong>', '<em>' . ELEMSNR_MIN_PHP_VERSION . '</em>', '<em>' . ELEMSNR_MIN_WP_VERSION . '</em>.<br />' ); $message .= sprintf( /* translators: %1$s is replaced with "PHP Version" */ /* translators: %2$s is replaced with "WordPress Version" */ wp_kses( __( 'You are currently running PHP %1$s and WordPress %2$s.', 'search-replace-for-elementor' ), json_decode( ELEMSNR_PLUGIN_ALLOWED_HTML_ARR ) ), '<strong>' . PHP_VERSION . '</strong>', '<strong>' . $GLOBALS['wp_version'] . '</strong>' ); printf( '<div class="notice notice-error is-dismissible"><p>%1$s</p></div>', $message ); } /** * Add settings link after plugin activation under Plugins. */ function elemsnr_add_action_links( $links, $file_path ) { if ( ELEMSNR_PLUGIN_BASENAME === $file_path ) { $links['settings'] = '<a href="' . esc_url( admin_url( 'admin.php?page=elemsnr-global' ) ) . '">' . esc_html__( 'Settings', 'search-replace-for-elementor' ) . '</a>'; $links['upgrade'] = '<a href="https://' . ELEMSNR_PLUGIN_DOMAIN . '" target="_blank" class="elemsnr-admin"><strong class="text-green">' . esc_html__( 'Get Pro', 'search-replace-for-elementor' ) . '</strong></a>'; return array_reverse( $links ); } return $links; } /** * Enqueue admin JS and CSS files either from dev/prod folder. (see main plugin file) */ function elemsnr_enqueue_admin_assets() { // $screen = get_current_screen(); // Load the following assest only for Search and Replace for Elementor pages. // if ( strpos( $screen->id, 'elemsnr-' ) ) {} wp_register_script( 'elemsnr-admin', ELEMSNR_PLUGIN_DIR_URL . 'assets/dist/js/elemsnr-admin.min.js', array( 'jquery' ), ELEMSNR_PLUGIN_VERSION, true ); wp_register_style( 'elemsnr-admin', ELEMSNR_PLUGIN_DIR_URL . 'assets/dist/css/elemsnr-admin.min.css', ELEMSNR_PLUGIN_VERSION, 'all' ); wp_localize_script( 'elemsnr-admin', 'elemsnr', array( 'plugin_url' => ELEMSNR_PLUGIN_DIR_URL, 'ajax_url' => admin_url( 'admin-ajax.php' ), 'ajax_nonce' => wp_create_nonce( 'elemsnr-ajax-nonce' ), ) ); wp_enqueue_script( 'elemsnr-admin' ); wp_enqueue_style( 'elemsnr-admin' ); } /** * Enqueue Elementor editor JS and CSS files either from dev/prod folder. (see main plugin file) */ function elemsnr_enqueue_elementor_assets() { wp_register_script( 'search-replace-for-elementor', ELEMSNR_PLUGIN_DIR_URL . 'assets/dist/js/elemsnr-search-replace.min.js', array( 'jquery' ), ELEMSNR_PLUGIN_VERSION, true ); wp_register_style( 'search-replace-for-elementor', ELEMSNR_PLUGIN_DIR_URL . 'assets/dist/css/elemsnr-search-replace.min.css', ELEMSNR_PLUGIN_VERSION, 'all' ); wp_localize_script( 'search-replace-for-elementor', 'elemsnr', array( 'plugin_url' => ELEMSNR_PLUGIN_DIR_URL, 'ajax_url' => admin_url( 'admin-ajax.php' ), 'ajax_nonce' => wp_create_nonce( 'elemsnr-ajax-nonce' ), ) ); wp_enqueue_script( 'search-replace-for-elementor' ); wp_enqueue_style( 'search-replace-for-elementor' ); } /** * Add styles to WP Admin to hide empty elemsnr page rows in the menu. */ add_action( 'admin_head', function() { echo '<style>.wp-submenu a[href*="page=elemsnr-license"], .wp-submenu a[href*="page=elemsnr-help"], .wp-submenu a[href*="page=elemsnr-backup"], .wp-submenu a[href*="page=elemsnr-options"] { display: none !important; height: 0 !important; } </sytle>'; } ); /** * Add plugin rating notice to get some feedback for users. */ /* add_action( 'admin_notices', __NAMESPACE__ . '\elemsnr_rating_notice_display' ); function elemsnr_rating_notice_display() { if ( ! get_option( 'elemsnr_rating_notice' ) ) { ?> <div class="notice notice-success is-dismissible elemsnr-admin elemnsnr-admin--notice"> <h3><?php echo ELEMSNR_PLUGIN_NAME; ?></h3> <p> <?php esc_html_e( 'Could you please kindly help the plugin in your turn by giving it 5 stars rating? (Thank you in advance)', 'search-replace-for-elementor' ); ?> </p> <div class="elemnsnr-button-group"> <a href="<?php echo ELEMSNR_PLUGIN_WPORG_URL; ?>" target="_blank" class="button button-primary"> <?php esc_html_e( 'Rate us @ WordPress.org', 'search-replace-for-elementor' ); ?> <i class="dashicons dashicons-external"></i> </a> <a href="<?php echo esc_url( admin_url( 'index.php?elemsnr-rating-notice-dismiss' ) ); ?>" class="button"> <?php esc_html_e( 'I already did', '' ); ?> </a> <a href="<?php echo esc_url( admin_url( 'index.php?elemsnr-rating-notice-dismiss' ) ); ?>" class="button"> <?php esc_html_e( 'Don\'t show this notice again!', 'search-replace-for-elementor' ); ?> </a> </div> </div> <?php } } add_action( 'admin_init', __NAMESPACE__ . '\elemsnr_notice_dismiss' ); function elemsnr_notice_dismiss() { if ( isset( $_GET['elemsnr-rating-notice-dismiss'] ) ) { add_option( 'elemsnr_rating_notice', 1 ); } } add_action( 'deactivated_plugin', __NAMESPACE__ . '\elemsnr_deactivate_plugin' ); function elemsnr_deactivate_plugin() { if ( get_option( 'elemsnr_rating_notice' ) ) { delete_option( 'elemsnr_rating_notice' ); } } */ // add_action( 'activated_plugin', __NAMESPACE__ . '\elemsnr_activate_plugin' );
[-] options.php
[edit]
[+]
..
[-] admin.php
[edit]
[-] requirements.php
[edit]
[-] backup.php
[edit]
[+]
views
[-] global.php
[edit]