'Version' ] ); return $data['Version'] ?? null; } } if ( ! function_exists( 'easyel_enable_svg_upload' ) ) { function easyel_enable_svg_upload( $mimes ) { $mimes['svg'] = 'image/svg+xml'; $mimes['svgz'] = 'image/svg+xml'; return $mimes; } add_filter( 'upload_mimes', 'easyel_enable_svg_upload' ); } if ( ! function_exists( 'easyel_fix_svg_filetype' ) ) { function easyel_fix_svg_filetype( $data, $file, $filename, $mimes ) { $ext = pathinfo( $filename, PATHINFO_EXTENSION ); if ( strtolower( $ext ) === 'svg' || strtolower( $ext ) === 'svgz' ) { $data['ext'] = 'svg'; $data['type'] = 'image/svg+xml'; } return $data; } add_filter( 'wp_check_filetype_and_ext', 'easyel_fix_svg_filetype', 10, 4 ); } if ( ! function_exists( 'easyel_handle_sideload_svg' ) ) { function easyel_handle_sideload_svg( $file ) { $ext = pathinfo( $file['name'], PATHINFO_EXTENSION ); if ( strtolower( $ext ) === 'svg' || strtolower( $ext ) === 'svgz' ) { $file['type'] = 'image/svg+xml'; } return $file; } add_filter( 'wp_handle_sideload_prefilter', 'easyel_handle_sideload_svg' ); } if ( ! function_exists( 'easyel_get_cf7_forms' ) ) { /** * Get a list of all CF7 forms * * @return array */ function easyel_get_cf7_forms() { $forms = get_posts( [ 'post_type' => 'wpcf7_contact_form', 'post_status' => 'publish', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', ] ); if ( ! empty( $forms ) ) { return wp_list_pluck( $forms, 'post_title', 'ID' ); } return []; } } // Domain Search Code add_action('template_redirect', function(){ // phpcs:ignore WordPress.Security.NonceVerification.Missing if (isset($_POST['easyel_domain_redirect'])) { // phpcs:ignore WordPress.Security.NonceVerification.Missing $domain = isset($_POST['domain']) ? sanitize_text_field(wp_unslash($_POST['domain'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing $base_url = isset($_POST['base_url']) ? esc_url_raw( wp_unslash($_POST['base_url'] ) ) : ''; if ( !empty($domain) && !empty($base_url) && filter_var($base_url, FILTER_VALIDATE_URL) ) { $redirect_url = esc_url_raw($base_url . urlencode($domain)); wp_redirect($redirect_url); exit; } } }); function easyel_get_extension_fields() { $fields = [ 'enable_cursor' => [ 'label' => __('Magic Cursor', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/magic-cursor.svg', 'is_pro' => true, 'group' => 'GSAP Extensions', 'demo_url' => 'https://wpeasyelements.com/', ], 'enable_sticky_elements' => [ 'label' => __('Sticky Elements', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/sticky-elements.svg', 'is_pro' => true, 'group' => 'General Extensions', 'demo_url' => 'https://wpeasyelements.com/', ], 'enable_cursor_hover_effect' => [ 'label' => __('Cursor Hover Effect', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/cursor-hover-effect.svg', 'is_pro' => true, 'group' => 'GSAP Extensions', 'demo_url' => 'https://wpeasyelements.com/', ], 'enable_cursor_move_effect' => [ 'label' => __('Cursor Move Effect', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/cursor-move-effect.svg', 'is_pro' => true, 'group' => 'GSAP Extensions', 'demo_url' => 'https://wpeasyelements.com/', ], 'enable_scroll_trigger' => [ 'label' => __('ScrollTrigger', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/scrolltrigger.svg', 'is_pro' => true, 'group' => 'GSAP Extensions', 'demo_url' => 'https://wpeasyelements.com/', ], 'enable_parallax_image' => [ 'label' => __('Background Parallax', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/background-parallax.svg', 'is_pro' => true, 'group' => 'GSAP Extensions', 'demo_url' => 'https://wpeasyelements.com/', ], 'enable_drawsvg' => [ 'label' => __('DrawSVG', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/drawsvg.svg', 'is_pro' => true, 'upcoming' => true, 'group' => 'GSAP Extensions', 'demo_url' => 'https://wpeasyelements.com/', ], 'enable_image_3d_effect' => [ 'label' => __('Image 3D Effect', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/image-3d-effect.svg', 'is_pro' => true, 'upcoming' => true, 'group' => 'GSAP Extensions', 'demo_url' => 'https://wpeasyelements.com/', ], 'enable_smooth_scroller' => [ 'label' => __('Scroll Smoother', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/image-3d-effect.svg', 'is_pro' => true, 'setting' => true, 'group' => 'GSAP Extensions', 'demo_url' => 'https://wpeasyelements.com/extensions/scroll-smoother/', 'docx_url' => 'https://wpeasyelements.com/extensions/docs/scroll-smoother/', ], 'enable_bounce_animation' => [ 'label' => __('Bounce Animation', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/image-3d-effect.svg', 'is_pro' => true, 'setting' => true, 'group' => 'GSAP Extensions', 'demo_url' => 'https://wpeasyelements.com/extensions/bounce-animation/', 'docx_url' => 'https://wpeasyelements.com/extensions/docs/bounce-animation/', ], 'enable_wrapper_link' => [ 'label' => __('Wrapper Link', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/wrapper-link.svg', 'is_pro' => false, 'group' => 'General Extensions', 'demo_url' => 'https://wpeasyelements.com/extensions/wrapper-link/', 'docx_url' => 'https://wpeasyelements.com/extensions/wrapper-link/', ], 'enable_post_duplicator' => [ 'label' => __('Duplicator', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/duplicator.svg', 'is_pro' => false, 'group' => 'General Extensions', 'demo_url' => 'https://wpeasyelements.com/docs/post-page-duplicate/', 'docx_url' => 'https://wpeasyelements.com/docs/post-page-duplicate/', ], 'enable_postpage_export' => [ 'label' => __('Easy Export', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/duplicator.svg', 'is_pro' => false, 'group' => 'General Extensions', 'demo_url' => 'https://wpeasyelements.com/extensions/docs/easy-export/', 'docx_url' => 'https://wpeasyelements.com/extensions/docs/easy-export/', ], 'enable_visibility_control' => [ 'label' => __('Visibility Control', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/visibility-control.svg', 'is_pro' => true, 'group' => 'General Extensions', 'demo_url' => 'https://wpeasyelements.com/', ], 'enable_dynamic_content' => [ 'label' => __('Dynamic Content', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/dynamic-content.svg', 'is_pro' => true, 'group' => 'General Extensions', 'demo_url' => 'https://wpeasyelements.com/', ], 'enable_live_copy_paste' => [ 'label' => __('Live Copy Paste', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/live-copy.svg', 'is_pro' => true, 'group' => 'General Extensions', 'demo_url' => 'https://wpeasyelements.com/', ], 'enable_easy_custom_css' => [ 'label' => __('Custom CSS', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/easy-custom-css.svg', 'is_pro' => true, 'group' => 'General Extensions', 'demo_url' => 'https://wpeasyelements.com/', ], 'enable_global_badge' => [ 'label' => __('Global Badge', 'easy-elements'), 'icon' => EASYELEMENTS_DIR_URL . 'includes/Admin/icons/extension/live-copy.svg', 'is_pro' => true, 'group' => 'General Extensions', 'demo_url' => 'https://wpeasyelements.com/extensions/global-badge/', 'docx_url' => 'https://wpeasyelements.com/extensions/docs/lobal-badge/', ], ]; return apply_filters('easyel_extension_fields', $fields); } function sanitize_conditions_array( $conditions ) { if ( ! is_array( $conditions ) ) { return []; } $sanitized = []; foreach ( $conditions as $cond ) { if ( ! is_array( $cond ) ) continue; $sanitized[] = [ 'include' => isset($cond['include']) ? sanitize_text_field($cond['include']) : 'include', 'main' => isset($cond['main']) ? sanitize_text_field($cond['main']) : '', 'sub' => isset($cond['sub']) ? sanitize_text_field($cond['sub']) : '', 'child_sub' => isset($cond['child_sub']) ? sanitize_text_field($cond['child_sub']) : '', ]; } return $sanitized; } /** * Safely decode JSON or return array as-is */ function safe_json_decode( $data ) { if ( is_string($data) ) { $decoded = json_decode($data, true); if ( json_last_error() === JSON_ERROR_NONE && is_array($decoded) ) { return $decoded; } return []; } elseif ( is_array($data) ) { return $data; } else { return []; } } class Easy_Widget_Injection { public static function init() { add_filter( 'elementor/controls/animations/additional_animations', [ __CLASS__, 'inject_easy_animations' ] ); } public static function inject_easy_animations( $animations ) { $animations['Easy Animations'] = [ 'scaleIn' => __( 'Scale In', 'easy-elements' ), ]; return $animations; } } // Initialize the class Easy_Widget_Injection::init(); /** * Check if a specific Easy Element extension setting is enabled. * * @param string $setting_key The key of the setting to check (e.g. 'enable_sticky_elements'). * @return bool True if enabled, false otherwise. */ function easy_element_is_enabled( $setting_key ) { if ( empty( $setting_key ) ) { return false; } $tab_slug = 'extensions'; $settings = get_option( 'easy_element_' . $tab_slug, [] ); // Sanitize and check $value = isset( $settings[ $setting_key ] ) ? (int) $settings[ $setting_key ] : 0; return ( $value === 1 ); } function easyel_translate_hfe_template( $template_id ) { if ( function_exists( 'pll_get_post' ) ) { $translated = pll_get_post( $template_id ); if ( $translated ) { $template_id = $translated; } } if ( has_filter( 'wpml_object_id' ) ) { $translated = apply_filters( 'wpml_object_id', $template_id, 'ee-elementor-hf', true ); if ( $translated ) { $template_id = $translated; } } return $template_id; } add_filter( 'easyel_get_settings_type_header', 'easyel_translate_hfe_template' ); add_filter( 'easyel_get_settings_type_footer', 'easyel_translate_hfe_template' ); add_filter( 'easyel_get_settings_type_easy_topbar', 'easyel_translate_hfe_template' ); add_filter( 'easyel_get_settings_type_easy_after__header', 'easyel_translate_hfe_template' ); add_filter( 'easyel_get_settings_type_before_footer', 'easyel_translate_hfe_template' ); if ( ! function_exists( 'easyel_get_valid_archive_post_types' ) ) { function easyel_get_valid_archive_post_types() { $post_types = get_post_types( [ 'public' => true, 'show_in_nav_menus' => true, ], 'objects' ); $valid = []; foreach ( $post_types as $post_type => $pt ) { if ( ! $pt->has_archive || ! get_post_type_archive_link( $post_type ) ) { continue; } if ( $post_type === 'page' ) { continue; } if ( ! empty( $pt->_builtin ) === false && str_starts_with( $post_type, 'elementor' ) ) { continue; } if ( ! $pt->publicly_queryable ) { continue; } $valid[ $post_type ] = $pt; } return $valid; } } if ( ! function_exists( 'easyel_get_hierarchical_taxonomies_by_post_type' ) ) { function easyel_get_hierarchical_taxonomies_by_post_type() { $map = []; $post_types = easyel_get_valid_archive_post_types(); foreach ($post_types as $post_type => $pt) { $taxonomies = get_object_taxonomies($post_type, 'objects'); foreach ($taxonomies as $tax_slug => $tax) { if (!$tax->public) { continue; } $map[$tax_slug] = [ 'post_type' => $post_type, 'taxonomy' => $tax_slug, ]; } } return $map; } } if ( ! function_exists('easyel_theme_builder_child_options') ) { /** * Get global condition arrays: needs_child_sub & no_child_sub * * @return array */ function easyel_theme_builder_child_options() { // Default needs_child_sub $needs_child_sub = [ 'author', 'category', 'child_of_category', 'any_child_of_category', 'in_category', 'in_category_children', 'post_tag', 'in_post_tag', 'child_of', 'any_child_of', 'product_cat', 'product_tag', 'product_brand', 'post', 'page', 'page_by_author', ]; // Default no_child_sub $no_child_sub = [ "all", "front_page", "not_found404", "index", "search", "date", "post_archive", "all_product_archive", "product_search", "shop_page", ]; // Get dynamic archive taxonomies $archive_taxonomies = function_exists('easyel_get_hierarchical_taxonomies_by_post_type') ? easyel_get_hierarchical_taxonomies_by_post_type() : []; if ( is_array($archive_taxonomies) || is_object($archive_taxonomies) ) { foreach ($archive_taxonomies as $tax_slug => $data) { $needs_child_sub[] = $tax_slug; $needs_child_sub[] = 'child_of_' . $tax_slug; $needs_child_sub[] = 'any_child_of_' . $tax_slug; $needs_child_sub[] = 'in_' . $tax_slug; $needs_child_sub[] = 'in_' . $tax_slug . '_children'; $needs_child_sub[] = $data['post_type'] . '_by_author'; if ( ! empty($data['post_type']) ) { $no_child_sub[] = $data['post_type']."_archive"; $needs_child_sub[] = $data['post_type']; } } } return [ 'needs_child_sub' => $needs_child_sub, 'no_child_sub' => $no_child_sub, ]; } } if ( ! function_exists( 'easyel_get_prepared_post_id' ) ) { function easyel_get_prepared_post_id() { if ( is_singular( 'post' ) ) { return get_the_ID(); } $cache_key = 'easyel_latest_post_id'; $post_id = wp_cache_get( $cache_key, 'easyel' ); if ( ! $post_id || get_post_status( $post_id ) !== 'publish' ) { $latest_post = get_posts([ 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 1, 'orderby' => 'date', 'order' => 'DESC', 'fields' => 'ids', ]); $post_id = !empty($latest_post) ? $latest_post[0] : 0; wp_cache_set( $cache_key, $post_id, 'easyel', 12 * HOUR_IN_SECONDS ); } return $post_id; } }