Plugin Directory

Changeset 3187397


Ignore:
Timestamp:
11/13/2024 11:04:10 AM (14 months ago)
Author:
dynamicooo
Message:

tagging version 5.0.14

Location:
dynamic-visibility-for-elementor
Files:
28 edited
1 copied

Legend:

Unmodified
Added
Removed
  • dynamic-visibility-for-elementor/tags/5.0.14/class/trait/elementor.php

    r3102226 r3187397  
    231231        return false;
    232232    }
    233 
     233   
    234234    public static function set_all_settings_by_id( $element_id = null, $settings = array(), $post_id = null ) {
    235235        if ( ! $post_id ) {
    236236            $post_id = get_the_ID();
    237             if ( ! $post_id ) {
     237            if ( ! $post_id && isset( $_GET['post'] ) ) {
    238238                $post_id = intval( $_GET['post'] );
    239239            }
    240240        }
     241   
    241242        $post_meta = self::get_settings_by_id( null, $post_id );
    242243        if ( $element_id ) {
     
    247248            }
    248249            $post_meta = Helper::set_array_value_by_keys( is_array( $post_meta ) ? $post_meta : [], $keys_array, $settings );
    249             array_walk_recursive($post_meta, function ( $v, $k ) {
    250                 $v = self::escape_json_string( $v );
    251             });
    252         }
     250        }
     251   
    253252        $post_meta_prepared = wp_json_encode( $post_meta );
    254         $post_meta_prepared = wp_slash( $post_meta_prepared );
    255253        update_metadata( 'post', $post_id, '_elementor_data', $post_meta_prepared );
    256254    }
    257 
     255   
    258256    public static function set_settings_by_id( $element_id, $key, $value = null, $post_id = null ) {
    259257        if ( ! $post_id ) {
    260258            $post_id = get_the_ID();
    261             if ( ! $post_id ) {
     259            if ( ! $post_id && isset( $_GET['post'] ) ) {
    262260                $post_id = intval( $_GET['post'] );
    263261            }
    264262        }
     263   
    265264        $post_meta = self::get_elementor_data( $post_id );
    266265        $keys_array = self::array_find_deep( $post_meta, $element_id );
     
    273272            $keys_array[] = $key;
    274273            $post_meta = Helper::set_array_value_by_keys( is_array( $post_meta ) ? $post_meta : [], $keys_array, $value );
    275             array_walk_recursive($post_meta, function ( $v, $k ) {
    276                 $v = self::escape_json_string( $v );
    277             });
     274   
    278275            $post_meta_prepared = wp_json_encode( $post_meta );
    279             $post_meta_prepared = wp_slash( $post_meta_prepared );
    280276            update_metadata( 'post', $post_id, '_elementor_data', $post_meta_prepared );
    281277        }
    282278        return $post_id;
    283     }
    284 
    285     public static function set_dynamic_tag( $editor_data ) {
    286         if ( is_array( $editor_data ) ) {
    287             foreach ( $editor_data as $key => $avalue ) {
    288                 $editor_data[ $key ] = self::set_dynamic_tag( $avalue );
    289             }
    290             if ( isset( $editor_data['elType'] ) ) {
    291                 foreach ( $editor_data['settings'] as $skey => $avalue ) {
    292                     $editor_data['settings'][ \Elementor\Core\DynamicTags\Manager::DYNAMIC_SETTING_KEY ][ $skey ] = 'token';
    293                 }
    294             }
    295         }
    296         return $editor_data;
    297279    }
    298280
     
    371353
    372354        if ( $datasource ) {
    373             $id_page = $datasource;
     355            $datasource = absint( $datasource );
     356            if ( $datasource > 0 && get_post( $datasource ) ) {
     357                $id_page = $datasource;
     358            }
    374359        }
    375360
    376361        if ( $id_page && $fromparent ) {
    377362            $the_parent = wp_get_post_parent_id( $id_page );
    378             if ( $the_parent != 0 ) {
     363            if ( $the_parent !== 0 ) {
    379364                $id_page = $the_parent;
    380365            }
    381366        }
    382367
    383         if ( ! $id_page ) {
     368        if ( !$id_page ) {
    384369            global $wp;
    385370            $current_url = home_url( add_query_arg( array(), $wp->request ) );
     
    387372        }
    388373
    389         // Myself
    390         $type_page = get_post_type( $id_page );
    391         $id_page = self::get_rev_ID( $id_page, $type_page );
    392 
    393         // Demo
    394         if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
    395             global $product;
    396             global $post;
    397 
    398             // BACKUP
    399             $original_post = $post;
    400             $original_product = $product;
    401 
    402             $demoPage = get_post_meta( get_the_ID(), 'demo_id', true ); // using get_the_id to retrieve Template ID
    403             if ( $demoPage ) {
    404                 $id_page = $demoPage;
    405                 $product = self::wooc_data( $id_page );
    406                 $post = get_post( $id_page );
    407             }
    408 
    409             // RESET
    410             $post = $original_post;
    411             if ( $type_page != 'product' ) {
    412                 $product = $original_product;
    413             }
     374        if ( $id_page ) {
     375            $type_page = get_post_type( $id_page );
     376            $id_page = self::get_translated_post_id( $id_page, $type_page );
    414377        }
    415378
     
    472435        return $icon_html;
    473436    }
    474 
    475     public static function get_elementor_elements( $type = '' ) {
    476         global $wpdb;
    477         $sql_query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}postmeta
    478             WHERE meta_key LIKE %s
    479             AND meta_value LIKE %s
    480             AND post_id IN (
    481                 SELECT id FROM {$wpdb->prefix}posts
    482                 WHERE post_status LIKE 'publish'
    483             )",
    484             '_elementor_data',
    485             '%"widgetType":"' . $wpdb->esc_like( $type ) . '"%'
    486         );
    487 
    488         $results = $wpdb->get_results( $sql_query );
    489         if ( ! count( $results ) ) {
    490             return false;
    491         }
    492         $elements = array();
    493         foreach ( $results as $result ) {
    494             $post_id = $result->post_id;
    495             $elementor_data = $result->meta_value;
    496             $elements_tmp = self::get_elements_from_elementor_data( $elementor_data, 'form' );
    497             if ( ! empty( $elements_tmp ) ) {
    498                 foreach ( $elements_tmp as $key => $value ) {
    499                     $elements[ $post_id ][ $key ] = $value;
    500                 }
    501             }
    502         }
    503 
    504         return $elements;
    505     }
    506 
     437   
    507438    public static function get_elements_from_elementor_data( $elementor_data, $type = '' ) {
    508439        $elements = array();
     
    563494    }
    564495}
     496
  • dynamic-visibility-for-elementor/tags/5.0.14/class/trait/filesystem.php

    r3102226 r3187397  
    44trait Filesystem {
    55
    6     public static function dir_to_array( $dir, $hidden = false, $files = true ) {
    7         $result = array();
    8         $cdir = scandir( $dir );
    9         foreach ( $cdir as $key => $value ) {
    10             if ( ! in_array( $value, array( '.', '..' ) ) ) {
    11                 if ( is_dir( $dir . DIRECTORY_SEPARATOR . $value ) ) {
    12                     $result[ $value ] = self::dir_to_array( $dir . DIRECTORY_SEPARATOR . $value, $hidden, $files );
    13                 } elseif ( $files ) {
    14                     if ( substr( $value, 0, 1 ) != '.' ) { // hidden file
    15                         $result[] = $value;
    16                     }
    17                 }
    18             }
    19         }
    20         return $result;
    21     }
     6    public static function is_empty_dir( $dirname ) {
     7        $base_dir = realpath( get_home_path() );
     8        $dirname = realpath( $dirname );
    229
    23     public static function is_empty_dir( $dirname ) {
    24         if ( ! is_dir( $dirname ) ) {
     10        if ( $dirname === false || strpos( $dirname, $base_dir ) !== 0 ) {
     11            // Invalid path or outside the allowed directory
     12            return false;
     13        }
     14
     15        if ( ! is_dir( $dirname ) ) {
     16            return false;
     17        }
     18
     19        $iterator = new \FilesystemIterator( $dirname, \FilesystemIterator::SKIP_DOTS );
     20        foreach ( $iterator as $fileinfo ) {
     21            $filename = $fileinfo->getFilename();
     22            if ( ! in_array( $filename, array( '.svn', '.git' ), true ) ) {
     23                return false;
     24            }
     25        }
     26        return true;
     27    }
     28
     29    public static function url_to_path( $url ) {
     30        $relative_url = wp_make_link_relative( $url );
     31        $relative_path = wp_normalize_path( ltrim( $relative_url, '/' ) );
     32   
     33        $home_path = wp_normalize_path( get_home_path() );
     34        $path = $home_path . $relative_path;
     35   
     36        $normalized_path = wp_normalize_path( $path );
     37   
     38        if ( strpos( $normalized_path, $home_path ) !== 0 ) {
     39            // Invalid path or outside the allowed directory
    2540            return false;
    2641        }
    27         foreach ( scandir( $dirname ) as $file ) {
    28             if ( ! in_array( $file, array( '.', '..', '.svn', '.git' ) ) ) {
    29                 return false;
    30             }
    31         }
    32         return true;
    33     }
    34 
    35     public static function url_to_path( $url ) {
    36         return substr( get_home_path(), 0, -1 ) . wp_make_link_relative( $url );
     42   
     43        return $path;
    3744    }
    3845}
  • dynamic-visibility-for-elementor/tags/5.0.14/class/trait/form.php

    r3102226 r3187397  
    132132    }
    133133
    134     public static function options_array( $string = '', $val = 'pro' ) {
    135         $arr = explode( PHP_EOL, $string );
    136         foreach ( $arr as $akey => $astring ) {
    137             $pieces = explode( '|', $astring, 2 );
    138             if ( count( $pieces ) > 1 ) {
    139                 if ( $val == 'pro' ) {
    140                     $arr[ $akey ] = array(
    141                         'text' => reset( $pieces ),
    142                         'value' => end( $pieces ),
    143                     );
    144                 }
    145                 if ( $val == 'acf' ) {
    146                     $arr[ $akey ] = array(
    147                         'text' => end( $pieces ),
    148                         'value' => reset( $pieces ),
    149                     );
    150                 }
    151             }
    152         }
    153         return $arr;
    154     }
    155 
    156134    public static function form_field_value( $arr = array(), $default = null ) {
    157135        $str = '';
  • dynamic-visibility-for-elementor/tags/5.0.14/class/trait/image.php

    r3102226 r3187397  
    33
    44trait Image {
    5 
    6     public static function get_thumbnail_sizes() {
    7         $sizes = get_intermediate_image_sizes();
    8         $ret = [];
    9 
    10         foreach ( $sizes as $s ) {
    11             $ret[ $s ] = $s;
    12         }
    13 
    14         return $ret;
    15     }
    165
    176    public static function is_resized_image( $imagePath ) {
     
    3322    public static function get_image_id( $image_url ) {
    3423        global $wpdb;
    35         $sql = $wpdb->prepare( "SELECT ID FROM {$wpdb->prefix}posts WHERE post_type LIKE 'attachment' AND guid LIKE %s;",
     24        $sql = $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid LIKE %s;",
    3625            '%' . $wpdb->esc_like( $image_url ) . '%'
    3726        );
     27
    3828        $attachment = $wpdb->get_col( $sql );
    3929        $img_id = reset( $attachment );
     
    5444     */
    5545    public static function get_image_alt( int $attachment_ID ) {
     46        if ( ! get_post( $attachment_ID ) ) {
     47            return '';
     48        }
    5649        $alt = get_post_meta( $attachment_ID, '_wp_attachment_image_alt', true );
    5750        if ( ! empty( $alt ) ) {
     
    6154    }
    6255
     56
    6357    /**
    64      * Get Attachment
     58     * Get Image Attachment
    6559     *
    6660     * @param string|int $attachment_id
    6761     * @return array<string,mixed>|null
    6862     */
    69     public static function get_attachment( $attachment_id ) {
     63    public static function get_image_attachment( $attachment_id ) {
    7064        $attachment_id = intval( $attachment_id ); // phpstan
    7165        if ( ! $attachment_id ) {
     
    7569        $attachment = get_post( $attachment_id );
    7670        if ( ! $attachment || 'attachment' !== $attachment->post_type ) {
     71            return null;
     72        }
     73
     74        if ( ! current_user_can( 'read_post', $attachment_id ) ) {
     75            return null;
     76        }
     77
     78        if ( ! wp_attachment_is_image( $attachment_id ) ) {
    7779            return null;
    7880        }
     
    8890            'caption' => wp_kses_post( $attachment->post_excerpt ),
    8991            'description' => wp_kses_post( $attachment->post_content ),
    90             'href' => get_attachment_link( $attachment_id ),
    91             'src' => $img_src[0],
     92            'href' => esc_url( get_attachment_link( $attachment_id ) ),
     93            'src' => esc_url( $img_src[0] ),
    9294            'title' => esc_html( $attachment->post_title ),
    93             'url' => $img_src[0],
    94             'width' => $img_src[1],
    95             'height' => $img_src[2],
     95            'url' => esc_url( $img_src[0] ),
     96            'width' => intval( $img_src[1] ),
     97            'height' => intval( $img_src[2] ),
    9698        ];
    9799    }
  • dynamic-visibility-for-elementor/tags/5.0.14/class/trait/meta.php

    r3102226 r3187397  
    2323        }
    2424        return array();
     25    }
     26
     27    /**
     28     * @param string $source_type
     29     * @param string $other_post_source
     30     * @return string|null
     31     */
     32    public static function get_acf_source_id($source_type, $other_post_source = false) {
     33        switch ($source_type) {
     34            case 'current_post':
     35                return Helper::get_the_id($other_post_source);
     36           
     37            case 'current_user':
     38                $user_id = get_current_user_id();
     39                return 'user_' . $user_id;
     40           
     41            case 'current_author':
     42                $user_id = get_the_author_meta('ID');
     43                return 'user_' . $user_id;
     44           
     45            case 'current_term':
     46                $queried_object = get_queried_object();
     47                if ($queried_object instanceof \WP_Term) {
     48                    $taxonomy = $queried_object->taxonomy;
     49                    $term_id = $queried_object->term_id;
     50                    return $taxonomy . '_' . $term_id;
     51                }
     52                return '';
     53           
     54            case 'options_page':
     55                return 'option';
     56        }
     57        return null;
    2558    }
    2659
     
    903936
    904937    public static function get_acf_field_value( $idField, $id_page = null, $format = true ) {
     938        // Apply filter to allow bypassing loop check for specific use cases
     939        $bypass_loop_check = apply_filters( 'dynamicooo/acf/bypass_loop_check', false, $idField, $id_page );
    905940
    906941        if ( ! $id_page ) {
    907942            $id_page = acf_get_valid_post_id();
    908943        }
     944
     945        // Check if the ACF loop is already active, unless bypassing is enabled
     946        if ( ! $bypass_loop_check ) {
     947            if ( acf_get_loop( 'active' ) ) {
     948                $sub_field_value = get_sub_field( $idField );
     949                if ( $sub_field_value !== false ) {
     950                    return $sub_field_value;
     951                }
     952            }
     953        }
     954
     955        // Get the ACF field post data
    909956        $dataACFieldPost = self::get_acf_field_post( $idField );
    910957
    911         // field in a Repeater or in a Flexible content
     958        // Handle fields within a Repeater or Flexible content
    912959        if ( $dataACFieldPost ) {
    913960            $parentID = $dataACFieldPost->post_parent;
    914961            $parent_settings = self::get_acf_field_settings( $parentID );
    915962            $custom_in_loop = apply_filters( 'dynamicooo/acf/in-loop', false, $parent_settings );
     963
     964            // Check if the parent field is a repeater, flexible content, or a custom loop
    916965            if ( ( isset( $parent_settings['type'] ) && ( $parent_settings['type'] == 'repeater' || $parent_settings['type'] == 'flexible_content' ) ) || $custom_in_loop ) {
    917966                $parent_post = get_post( $parentID );
    918967                $row = acf_get_loop( 'active' );
     968
     969                // If not already in a loop, initiate the loop
    919970                if ( ! $row ) {
    920971                    if ( have_rows( $parent_post->post_excerpt, $id_page ) ) {
     
    929980        }
    930981
    931         // post
     982        // Retrieve the main field
    932983        $theField = get_field( $idField, $id_page, $format );
    933984
    934985        if ( ! $theField ) {
    935 
    936986            $locations = self::get_acf_field_locations( $dataACFieldPost );
    937987
     988            // Check if taxonomy or other locations apply
    938989            if ( is_tax() || is_category() || is_tag() || in_array( 'taxonomy', $locations ) ) {
    939990                $term = get_queried_object();
     
    941992            }
    942993
     994            // Check if author field is applicable
    943995            if ( ! $theField && is_author() ) {
    944996                $author_id = get_the_author_meta( 'ID' );
     
    946998            }
    947999
     1000            // Check if the user or options fields are applicable
    9481001            if ( ! $theField && in_array( 'user', $locations ) ) {
    9491002                $user_id = get_current_user_id();
  • dynamic-visibility-for-elementor/tags/5.0.14/class/trait/navigation.php

    r3102226 r3187397  
    8383    }
    8484
    85     /* -------------------- */
    86 
    8785    // Search and Filter Pro - Navigation
    8886    public static function get_wp_link_page_sf( $i ) {
  • dynamic-visibility-for-elementor/tags/5.0.14/class/trait/strings.php

    r3102226 r3187397  
    1111        $string = preg_replace( '/<\/' . $tag . '>/i', '', $string );
    1212        return $string;
    13     }
    14 
    15     public static function escape_json_string( $value ) {
    16         // # list from www.json.org: (\b backspace, \f formfeed)
    17         $escapers = array( '\\', '/', '"', "\n", "\r", "\t", "\x08", "\x0c" );
    18         $replacements = array( '\\\\', '\\/', '\\"', "\\n", "\\r", "\\t", "\\f", "\\b" );
    19         $result = str_replace( $escapers, $replacements, $value );
    20         return $result;
    2113    }
    2214
  • dynamic-visibility-for-elementor/tags/5.0.14/class/trait/wp.php

    r3102226 r3187397  
    166166    }
    167167
     168    /**
     169     * @return array<string>
     170     */
    168171    public static function get_woocommerce_taxonomies() {
    169172        return [
     
    298301    }
    299302
    300     public static function get_posts_by_type( $typeId, $myself = null, $group = false ) {
    301 
    302         $exclude_io = array();
    303         if ( isset( $myself ) && $myself ) {
    304             $exclude_io = array( $myself );
    305         }
    306         $templates = array();
    307         $get_templates = get_posts(array(
    308             'post_type' => $typeId,
    309             'numberposts' => -1,
    310             'post__not_in' => $exclude_io,
    311             'post_status' => 'publish',
    312             'orderby' => 'title',
    313             'order' => 'DESC',
    314             'suppress_filters' => false,
    315         ));
    316 
    317         if ( ! empty( $get_templates ) ) {
    318             foreach ( $get_templates as $template ) {
    319                 $templates[ $template->ID ] = $template->post_title;
    320             }
    321         }
    322 
    323         return $templates;
    324     }
    325 
    326    
    327 
    328303    /**
    329304     * Get Roles
     
    347322        }
    348323        return $ret;
    349     }
    350 
    351     public static function get_current_user_role() {
    352         if ( is_user_logged_in() ) {
    353             $user = wp_get_current_user();
    354             $role = (array) $user->roles;
    355             return $role[0];
    356         } else {
    357             return false;
    358         }
    359324    }
    360325
     
    448413    }
    449414
    450     public static function get_taxonomy_by_term_id( $term_id ) {
    451         $term = get_term( $term_id );
    452         if ( $term ) {
    453             return $term->taxonomy;
    454         }
    455         return false;
    456     }
    457 
    458     public static function get_author_fields( $meta = false, $group = false, $info = true ) {
    459         return static::get_user_fields( $meta, $group, $info );
    460     }
    461 
    462415    public static function get_user_fields( $meta = false, $group = false, $info = true ) {
    463416        $userFieldsKey = array();
     
    560513    }
    561514
    562     public static function wooc_data( $idprod = null ) {
    563         global $product;
    564 
    565         if ( Helper::is_woocommerce_active() ) {
    566 
    567             if ( isset( $idprod ) ) {
    568                 $product = wc_get_product( $idprod );
    569             } else {
    570                 $product = wc_get_product();
    571             }
    572         }
    573         if ( empty( $product ) ) {
    574             return;
    575         }
    576 
    577         return $product;
    578     }
    579 
    580     public static function get_rev_ID( $revid, $revtype = false ) {
     515    /**
     516     * @param int|string $original_id
     517     * @param boolean $post_type
     518     * @return int
     519     */
     520    public static function get_translated_post_id( $original_id, $post_type = false ) {
     521        $original_id = absint( $original_id );
     522       
    581523        // Check if WPML is installed
    582524        if ( ! Helper::is_plugin_active( 'sitepress-multilingual-cms' ) ) {
    583             return $revid;
    584         }
    585 
    586         if ( ! $revtype ) {
    587             $revtype = get_post_type( $revid );
    588         }
    589         $rev_id = apply_filters( 'wpml_object_id', $revid, $revtype, true );
    590         if ( ! $rev_id ) {
    591             return $revid;
    592         }
    593         return $rev_id;
     525            return $original_id;
     526        }
     527
     528        if ( ! $post_type ) {
     529            $post_type = get_post_type( $original_id );
     530        }
     531        $translated_id = apply_filters( 'wpml_object_id', $original_id, $post_type, true );
     532        if ( ! $translated_id ) {
     533            return $original_id;
     534        }
     535        return $translated_id;
    594536    }
    595537
     
    609551        if ( $field == 'post_excerpt' || $field == 'excerpt' ) {
    610552            $post = get_post( $post_id );
    611             $postValue = $post->post_excerpt;
     553            if ( $post ) {
     554                $postValue = $post->post_excerpt;
     555            }
    612556        }
    613557
     
    11571101        return $array;
    11581102    }
    1159 
    1160     /**
    1161      * Convert ACF Post Objects to IDS
    1162      *
    1163      * @param object|array<mixed>|void $input
    1164      *
    1165      * @return array<mixed>|void
    1166      */
    1167     public static function convert_acf_post_objects_to_ids( $input ) {
    1168         if ( is_array( $input ) ) {
    1169             if ( ! empty( $input ) && is_object( $input[0] ) ) {
    1170                 return array_map( function ( $post ) {
    1171                     return $post->ID;
    1172                 }, $input );
    1173             }
    1174             return $input;
    1175         } elseif ( is_object( $input ) ) {
    1176             return $input->ID ?? '';
    1177         }
    1178 
    1179         return $input;
    1180     }
    11811103}
  • dynamic-visibility-for-elementor/tags/5.0.14/constants.php

    r3109242 r3187397  
    11<?php
    2 define( 'DVE_VERSION', '5.0.13' );
     2define( 'DVE_VERSION', '5.0.14' );
    33define( 'DVE_MINIMUM_ELEMENTOR_VERSION', '2.9.0' );
    44define( 'DVE_PRODUCT_NAME', 'Dynamic Visibility for Elementor' );
  • dynamic-visibility-for-elementor/tags/5.0.14/core/plugin.php

    r2983063 r3187397  
    44use DynamicVisibilityForElementor\Helper;
    55
    6 if ( ! defined( 'ABSPATH' ) ) {
    7     exit; // Exit if accessed directly.
     6if (!defined("ABSPATH")) {
     7    exit(); // Exit if accessed directly.
    88}
    99
     
    1313 * @since 0.0.1
    1414 */
    15 class Plugin {
    16     /**
    17      * @var \DynamicVisibilityForElementor\Controls
    18      */
    19     public $controls;
    20     /**
    21      * @var \DynamicVisibilityForElementor\Wpml
    22      */
    23     public $wpml;
    24     /**
    25      * @var \DynamicVisibilityForElementor\AdminPages\Notices
    26      */
    27     public $notices;
    28 
    29     protected static $instance;
    30 
    31     /**
    32      * Constructor
    33      *
    34      * @since 0.0.1
    35      * @access public
    36      */
    37     public function __construct() {
    38         self::$instance = $this;
    39         $this->init();
    40     }
    41 
    42     /**
    43      * @return Plugin
    44      */
    45     public static function instance() {
    46         if ( is_null( self::$instance ) ) {
    47             new self();
    48         }
    49         return self::$instance;
    50     }
    51 
    52     public function init() {
    53         $this->init_managers();
    54 
    55         // Promo
    56         if ( current_user_can( 'install_plugins' ) ) {
    57             $this->promo_notice();
    58         }
    59        
    60         add_action( 'elementor/init', [ $this, 'add_dve_to_elementor' ] );
    61 
    62         // Admin Style
    63         add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin' ] );
    64 
    65         // Plugin page
    66         add_filter( 'plugin_action_links_' . DVE_PLUGIN_BASE, [ $this, 'add_action_links' ] );
    67         add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 );
    68     }
    69 
    70     public function init_managers() {
    71         $this->wpml = new Wpml();
    72         $this->controls = new Controls();
    73         $this->notices = new AdminPages\Notices();
    74         new Ajax();
    75         new Elements();
    76     }
    77 
    78     public function add_dve_to_elementor() {
    79         add_action('elementor/frontend/after_register_styles', function () {
    80             wp_register_style(
    81                 'dce-dynamic-visibility-style',
    82                 DVE_URL . 'assets/css/dynamic-visibility.css',
    83                 [],
    84                 DVE_VERSION
    85             );
    86             // Enqueue Visibility Style
    87             wp_enqueue_style( 'dce-dynamic-visibility-style' );
    88         });
    89 
    90         add_action( 'wp_enqueue_scripts', function () {
    91             wp_register_script(
    92                 'dce-visibility',
    93                 DVE_URL .  'assets/js/visibility.js',
    94                 [],
    95                 DVE_VERSION
    96             );
    97         });
    98 
    99         // DCE Custom Icons - in Elementor Editor
    100         add_action('elementor/preview/enqueue_styles', function () {
    101             wp_register_style(
    102                 'dce-preview',
    103                 DVE_URL . 'assets/css/preview.css',
    104                 [],
    105                 DVE_VERSION
    106             );
    107             // Enqueue DCE Elementor Style
    108             wp_enqueue_style( 'dce-preview' );
    109         });
    110 
    111         add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'dce_editor' ) );
    112 
    113         // Controls
    114         add_action( 'elementor/controls/controls_registered', [ $this->controls, 'on_controls_registered' ] );
    115 
    116         new Extensions\DynamicVisibility();
    117     }
    118 
    119     /**
    120      * Enqueue admin
    121      *
    122      * @access public
    123      */
    124     public function enqueue_admin() {
    125         // Style
    126         wp_register_style(
    127             'dve-admin-css',
    128             DVE_URL . 'assets/css/admin.css',
    129             [],
    130             DVE_VERSION
    131         );
    132         wp_enqueue_style( 'dve-admin-css' );
    133 
    134         // Scripts
    135         wp_enqueue_script(
    136             'dve-admin-js',
    137             DVE_URL . 'assets/js/admin.js',
    138             [],
    139             DVE_VERSION,
    140             true
    141         );
    142     }
    143 
    144 
    145     public function promo_notice() {
    146         $msg = sprintf( __( '%1$sBuy now Dynamic.ooo - Dynamic Content for Elementor%2$s and save 10&#37; using promo code %3$sVISIBILITY%4$s.', 'dynamic-visibility-for-elementor' ) . '<br />', '<a target="_blank" href="https://www.dynamic.ooo/upgrade/visibility-to-premium?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash-promo">', '</a>', '<strong>', '</strong>' );
    147         $msg .= sprintf( __( 'We give you %1$sover 140 features for Elementor%2$s that will save you time and money on achieving complex results. We support ACF Free and ACF Pro, JetEngine, Meta Box, WooCommerce, WPML, Search and Filter Pro, Pods, Toolset and Timber.', 'dynamic-visibility-for-elementor' ), '<strong>', '</strong>' );
    148         $this->notices->info( $msg, 'upgrade_10' );
    149     }
    150 
    151     public function add_action_links( $links ) {
    152         $my_links[] = sprintf( '<a href="https://www.dynamic.ooo/upgrade/visibility-to-premium?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash" target="_blank"">' . __( 'Go Premium', 'dynamic-visibility-for-elementor' ) . '</a>' );
    153         return array_merge( $links, $my_links );
    154     }
    155 
    156     public function plugin_row_meta( $plugin_meta, $plugin_file ) {
    157         if ( 'dynamic-visibility-for-elementor/dynamic-visibility-for-elementor.php' === $plugin_file ) {
    158             $row_meta = [
    159                 'docs' => '<a href="https://dnmc.ooo/visibilitydoc" aria-label="' . esc_attr( __( 'View Dynamic Visibility Documentation', 'dynamic-visibility-for-elementor' ) ) . '" target="_blank">' . __( 'Docs', 'dynamic-visibility-for-elementor' ) . '</a>',
    160                 'community' => '<a href="http://facebook.com/groups/dynamic.ooo" aria-label="' . esc_attr( __( 'Facebook Community', 'dynamic-visibility-for-elementor' ) ) . '" target="_blank">' . __( 'FB Community', 'dynamic-visibility-for-elementor' ) . '</a>',
    161             ];
    162 
    163             $plugin_meta = array_merge( $plugin_meta, $row_meta );
    164         }
    165 
    166         return $plugin_meta;
    167     }
    168 
    169     /**
    170      * Enqueue admin styles
    171      *
    172      * @access public
    173      */
    174     public function dce_editor() {
    175         // Register styles
    176         wp_register_style(
    177             'dce-icons',
    178             DVE_URL . 'assets/css/dce-icon.css',
    179             [],
    180             DVE_VERSION
    181         );
    182         // Enqueue styles Icons
    183         wp_enqueue_style( 'dce-icons' );
    184 
    185         // Register styles
    186         wp_register_style(
    187             'dce-editor',
    188             DVE_URL . 'assets/css/editor.css',
    189             [],
    190             DVE_VERSION
    191         );
    192         wp_enqueue_style( 'dce-editor' );
    193 
    194         wp_register_script(
    195             'dce-script-editor',
    196             DVE_URL . 'assets/js/editor.js',
    197             [],
    198             DVE_VERSION
    199         );
    200         wp_enqueue_script( 'dce-script-editor' );
    201 
    202         wp_register_script(
    203             'dce-editor-visibility',
    204             DVE_URL . 'assets/js/editor-dynamic-visibility.js',
    205             [],
    206             DVE_VERSION
    207         );
    208         wp_enqueue_script( 'dce-editor-visibility' );
    209 
    210         // select2
    211         wp_enqueue_style(
    212             'dce-select2',
    213             DVE_URL . 'assets/lib/select2/select2.min.css',
    214             [],
    215             DVE_VERSION
    216         );
    217         wp_enqueue_script(
    218             'dce-select2',
    219             DVE_URL . 'assets/lib/select2/select2.full.min.js',
    220             [ 'jquery' ],
    221             DVE_VERSION,
    222             true
    223         );
    224     }
     15class Plugin
     16{
     17    /**
     18     * @var \DynamicVisibilityForElementor\Controls
     19     */
     20    public $controls;
     21    /**
     22     * @var \DynamicVisibilityForElementor\Wpml
     23     */
     24    public $wpml;
     25    /**
     26     * @var \DynamicVisibilityForElementor\AdminPages\Notices
     27     */
     28    public $notices;
     29
     30    protected static $instance;
     31
     32    /**
     33     * Constructor
     34     *
     35     * @since 0.0.1
     36     * @access public
     37     */
     38    public function __construct()
     39    {
     40        self::$instance = $this;
     41        $this->init();
     42    }
     43
     44    /**
     45     * @return Plugin
     46     */
     47    public static function instance()
     48    {
     49        if (is_null(self::$instance)) {
     50            new self();
     51        }
     52        return self::$instance;
     53    }
     54
     55    public function init()
     56    {
     57        $this->init_managers();
     58
     59        // Promo
     60        if (current_user_can("install_plugins")) {
     61            $this->promo_notice();
     62        }
     63
     64        add_action("elementor/init", [$this, "add_dve_to_elementor"]);
     65
     66        // Admin Style
     67        add_action("admin_enqueue_scripts", [$this, "enqueue_admin"]);
     68
     69        // Plugin page
     70        add_filter("plugin_action_links_" . DVE_PLUGIN_BASE, [
     71            $this,
     72            "add_action_links",
     73        ]);
     74        add_filter("plugin_row_meta", [$this, "plugin_row_meta"], 10, 2);
     75    }
     76
     77    public function init_managers()
     78    {
     79        $this->wpml = new Wpml();
     80        $this->controls = new Controls();
     81        $this->notices = new AdminPages\Notices();
     82        new Ajax();
     83        new Elements();
     84    }
     85
     86    public function add_dve_to_elementor()
     87    {
     88        add_action("elementor/frontend/after_register_styles", function () {
     89            wp_register_style(
     90                "dce-dynamic-visibility-style",
     91                DVE_URL . "assets/css/dynamic-visibility.css",
     92                [],
     93                DVE_VERSION
     94            );
     95            // Enqueue Visibility Style
     96            wp_enqueue_style("dce-dynamic-visibility-style");
     97        });
     98
     99        add_action("wp_enqueue_scripts", function () {
     100            wp_register_script(
     101                "dce-visibility",
     102                DVE_URL . "assets/js/visibility.js",
     103                ["jquery"],
     104                DVE_VERSION
     105            );
     106        });
     107
     108        // DCE Custom Icons - in Elementor Editor
     109        add_action("elementor/preview/enqueue_styles", function () {
     110            wp_register_style(
     111                "dce-preview",
     112                DVE_URL . "assets/css/preview.css",
     113                [],
     114                DVE_VERSION
     115            );
     116            // Enqueue DCE Elementor Style
     117            wp_enqueue_style("dce-preview");
     118        });
     119
     120        add_action("elementor/editor/after_enqueue_scripts", [
     121            $this,
     122            "dce_editor",
     123        ]);
     124
     125        // Controls
     126        add_action("elementor/controls/controls_registered", [
     127            $this->controls,
     128            "on_controls_registered",
     129        ]);
     130
     131        new Extensions\DynamicVisibility();
     132    }
     133
     134    /**
     135     * Enqueue admin
     136     *
     137     * @access public
     138     */
     139    public function enqueue_admin()
     140    {
     141        // Style
     142        wp_register_style(
     143            "dve-admin-css",
     144            DVE_URL . "assets/css/admin.css",
     145            [],
     146            DVE_VERSION
     147        );
     148        wp_enqueue_style("dve-admin-css");
     149
     150        // Scripts
     151        wp_enqueue_script(
     152            "dve-admin-js",
     153            DVE_URL . "assets/js/admin.js",
     154            [],
     155            DVE_VERSION,
     156            true
     157        );
     158    }
     159
     160    public function promo_notice()
     161    {
     162        $msg = sprintf(
     163            __(
     164                '%1$sBuy now Dynamic.ooo - Dynamic Content for Elementor%2$s and save 10&#37; using promo code %3$sVISIBILITY%4$s.',
     165                "dynamic-visibility-for-elementor"
     166            ) . "<br />",
     167            '<a target="_blank" href="https://www.dynamic.ooo/upgrade/visibility-to-premium?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash-promo">',
     168            "</a>",
     169            "<strong>",
     170            "</strong>"
     171        );
     172        $msg .= sprintf(
     173            __(
     174                'We give you %1$sover 140 features for Elementor%2$s that will save you time and money on achieving complex results. We support ACF Free and ACF Pro, JetEngine, Meta Box, WooCommerce, WPML, Search and Filter Pro, Pods, Toolset and Timber.',
     175                "dynamic-visibility-for-elementor"
     176            ),
     177            "<strong>",
     178            "</strong>"
     179        );
     180        $this->notices->info($msg, "upgrade_10");
     181    }
     182
     183    public function add_action_links($links)
     184    {
     185        $my_links[] = sprintf(
     186            '<a href="https://www.dynamic.ooo/upgrade/visibility-to-premium?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash" target="_blank"">' .
     187                __("Go Premium", "dynamic-visibility-for-elementor") .
     188                "</a>"
     189        );
     190        return array_merge($links, $my_links);
     191    }
     192
     193    public function plugin_row_meta($plugin_meta, $plugin_file)
     194    {
     195        if (
     196            "dynamic-visibility-for-elementor/dynamic-visibility-for-elementor.php" ===
     197            $plugin_file
     198        ) {
     199            $row_meta = [
     200                "docs" =>
     201                    '<a href="https://dnmc.ooo/visibilitydoc" aria-label="' .
     202                    esc_attr(
     203                        __(
     204                            "View Dynamic Visibility Documentation",
     205                            "dynamic-visibility-for-elementor"
     206                        )
     207                    ) .
     208                    '" target="_blank">' .
     209                    __("Docs", "dynamic-visibility-for-elementor") .
     210                    "</a>",
     211                "community" =>
     212                    '<a href="http://facebook.com/groups/dynamic.ooo" aria-label="' .
     213                    esc_attr(
     214                        __(
     215                            "Facebook Community",
     216                            "dynamic-visibility-for-elementor"
     217                        )
     218                    ) .
     219                    '" target="_blank">' .
     220                    __("FB Community", "dynamic-visibility-for-elementor") .
     221                    "</a>",
     222            ];
     223
     224            $plugin_meta = array_merge($plugin_meta, $row_meta);
     225        }
     226
     227        return $plugin_meta;
     228    }
     229
     230    /**
     231     * Enqueue admin styles
     232     *
     233     * @access public
     234     */
     235    public function dce_editor()
     236    {
     237        // Register styles
     238        wp_register_style(
     239            "dce-icons",
     240            DVE_URL . "assets/css/dce-icon.css",
     241            [],
     242            DVE_VERSION
     243        );
     244        // Enqueue styles Icons
     245        wp_enqueue_style("dce-icons");
     246
     247        // Register styles
     248        wp_register_style(
     249            "dce-editor",
     250            DVE_URL . "assets/css/editor.css",
     251            [],
     252            DVE_VERSION
     253        );
     254        wp_enqueue_style("dce-editor");
     255
     256        wp_register_script(
     257            "dce-script-editor",
     258            DVE_URL . "assets/js/editor.js",
     259            [],
     260            DVE_VERSION
     261        );
     262        wp_enqueue_script("dce-script-editor");
     263
     264        wp_register_script(
     265            "dce-editor-visibility",
     266            DVE_URL . "assets/js/editor-dynamic-visibility.js",
     267            [],
     268            DVE_VERSION
     269        );
     270        wp_enqueue_script("dce-editor-visibility");
     271
     272        // select2
     273        wp_enqueue_style(
     274            "dce-select2",
     275            DVE_URL . "assets/lib/select2/select2.min.css",
     276            [],
     277            DVE_VERSION
     278        );
     279        wp_enqueue_script(
     280            "dce-select2",
     281            DVE_URL . "assets/lib/select2/select2.full.min.js",
     282            ["jquery"],
     283            DVE_VERSION,
     284            true
     285        );
     286    }
    225287}
    226288
  • dynamic-visibility-for-elementor/tags/5.0.14/dynamic-visibility-for-elementor.php

    r3109242 r3187397  
    55 * Description: Visibility rules for widgets, containers, sections, columns or pages with advanced conditions and removing the element from the DOM.
    66 * Plugin URI: https://www.dynamic.ooo/widget/dynamic-visibility/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash
    7  * Version: 5.0.13
     7 * Version: 5.0.14
    88 * Author: Dynamic.ooo
    99 * Author URI: https://www.dynamic.ooo/
     
    1313 * License: GPL-3.0
    1414 * License URI: http://www.gnu.org/licenses/gpl-3.0.txt
    15  * Elementor tested up to: 3.21.8
    16  * Elementor Pro tested up to: 3.21.3
     15 * Elementor tested up to: 3.25.5
     16 * Elementor Pro tested up to: 3.25.2
    1717 *
    1818 * This program is free software: you can redistribute it and/or modify
  • dynamic-visibility-for-elementor/tags/5.0.14/includes/extensions/dynamic-visibility.php

    r3109215 r3187397  
    656656                unset( $_triggers['events'] );
    657657            }
     658            if ( ! Helper::is_myfastapp_active() ) {
     659                unset( $_triggers['myfastapp'] );
     660            }
    658661            $element->add_control(
    659662                'dce_visibility_triggers',
     
    13201323                    'label_block' => true,
    13211324                    'query_type' => 'posts',
     1325                    'dynamic' => [
     1326                        'active' => false,
     1327                    ],
    13221328                    'multiple' => true,
    13231329                    'separator' => 'before',
     
    16711677            } else {
    16721678                $element->add_control(
    1673                 'dce_visibility_woo_notice',
    1674                 [
    1675                     'type' => Controls_Manager::RAW_HTML,
    1676                     'raw' => esc_html__( 'You need WooCommerce to use this trigger.', 'dynamic-visibility-for-elementor' ),
    1677                     'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
    1678                 ]
     1679                    'dce_visibility_woo_notice',
     1680                    [
     1681                        'type' => Controls_Manager::RAW_HTML,
     1682                        'raw' => esc_html__( 'You need WooCommerce to use this trigger.', 'dynamic-visibility-for-elementor' ),
     1683                        'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
     1684                    ]
    16791685                );
    16801686            }
     
    16921698                );
    16931699            } elseif ( Helper::is_myfastapp_active() ) {
    1694                     $element->add_control(
    1695                         'dce_visibility_myfastapp',
    1696                         [
    1697                             'label' => esc_html__( 'The visitor is', 'dynamic-visibility-for-elementor' ),
    1698                             'type' => Controls_Manager::SELECT,
    1699                             'options' => [
    1700                                 'all' => esc_html__( 'on the site or in the app', 'dynamic-visibility-for-elementor' ),
    1701                                 'site' => esc_html__( 'on the site', 'dynamic-visibility-for-elementor' ),
    1702                                 'app' => esc_html__( 'in the app', 'dynamic-visibility-for-elementor' ),
    1703                             ],
    1704                             'default' => 'all',
    1705                         ]
    1706                     );
    1707             } else {
    17081700                $element->add_control(
    1709                     'dce_visibility_myfastapp_notice',
     1701                    'dce_visibility_myfastapp',
    17101702                    [
    1711                         'type' => Controls_Manager::RAW_HTML,
    1712                         'raw' => esc_html__( 'You need My FastAPP to use this trigger.', 'dynamic-visibility-for-elementor' ),
    1713                         'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
     1703                        'label' => esc_html__( 'The visitor is', 'dynamic-visibility-for-elementor' ),
     1704                        'type' => Controls_Manager::SELECT,
     1705                        'options' => [
     1706                            'all' => esc_html__( 'on the site or in the app', 'dynamic-visibility-for-elementor' ),
     1707                            'site' => esc_html__( 'on the site', 'dynamic-visibility-for-elementor' ),
     1708                            'app' => esc_html__( 'in the app', 'dynamic-visibility-for-elementor' ),
     1709                        ],
     1710                        'default' => 'all',
    17141711                    ]
    17151712                );
     
    26172614                        $ips = array_map( 'trim', $ips );
    26182615                        ++$triggers_n;
    2619                         if ( in_array( $_SERVER['REMOTE_ADDR'], $ips ) ) {
     2616                        if ( isset( $_SERVER['REMOTE_ADDR'] ) && in_array( $_SERVER['REMOTE_ADDR'], $ips ) ) {
    26202617                            $conditions['dce_visibility_ip'] = esc_html__( 'Remote IP', 'dynamic-visibility-for-elementor' );
    26212618                        }
  • dynamic-visibility-for-elementor/tags/5.0.14/modules/query-control/module.php

    r3102226 r3187397  
    55use Elementor\Core\Base\Module as Base_Module;
    66use DynamicVisibilityForElementor\Helper;
     7use Elementor\Core\Editor\Editor;
    78
    89if ( ! defined( 'ABSPATH' ) ) {
     
    3132
    3233    public function ajax_call_filter_autocomplete( array $data ) {
     34        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     35            throw new \Exception( 'Access denied.' );
     36        }
    3337
    3438        if ( empty( $data['query_type'] ) || empty( $data['q'] ) ) {
     
    4448
    4549    protected function get_options( $data ) {
     50        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     51            throw new \Exception( 'Access denied.' );
     52        }
     53
    4654        $results = [];
    4755        $fields = Helper::get_options( $data['q'] );
     
    5866
    5967    protected function get_fields( $data ) {
     68        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     69            throw new \Exception( 'Access denied.' );
     70        }
     71
    6072        $results = [];
    6173        $object_types = $data['object_type'];
     
    88100     */
    89101    protected function get_dsh_fields( $data ) {
     102        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     103            throw new \Exception( 'Access denied.' );
     104        }
     105
    90106        $results = [];
    91107
     
    223239
    224240    protected function get_terms_fields( $data ) {
     241        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     242            throw new \Exception( 'Access denied.' );
     243        }
     244       
    225245        $results = [];
    226246        $results = $this->get_fields( $data );
     
    240260
    241261    protected function get_taxonomies_fields( $data ) {
     262        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     263            throw new \Exception( 'Access denied.' );
     264        }
     265
    242266        $results = [];
    243267        $results = $this->get_fields( $data );
     
    258282
    259283    protected function get_metas( $data ) {
     284        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     285            throw new \Exception( 'Access denied.' );
     286        }
     287
    260288        $results = [];
    261289        $function = 'get_' . $data['object_type'] . '_metas';
     
    273301
    274302    protected function get_pods( $data ) {
     303        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     304            throw new \Exception( 'Access denied.' );
     305        }
     306
    275307        $results = [];
    276308        $function = 'get_' . $data['object_type'] . '_pods';
     
    288320
    289321    protected function get_posts( $data ) {
     322        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     323            throw new \Exception( 'Access denied.' );
     324        }
     325
    290326        $results = [];
    291327        $object_type = $data['object_type'] ?? 'any';
     
    320356
    321357    protected function get_jet( $data ) {
     358        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     359            throw new \Exception( 'Access denied.' );
     360        }
     361
    322362        if ( ! Helper::is_jetengine_active() ) {
    323363            return [];
     
    370410     */
    371411    protected function get_metabox( $data ) {
     412        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     413            throw new \Exception( 'Access denied.' );
     414        }
     415
    372416        if ( ! Helper::is_metabox_active() ) {
    373417            return [];
     
    415459     */
    416460    protected function get_metabox_relationship( $data ) {
     461        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     462            throw new \Exception( 'Access denied.' );
     463        }
     464
    417465        if ( ! Helper::is_metabox_active() ) {
    418466            return [];
     
    439487
    440488    protected function get_acf( $data ) {
     489        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     490            throw new \Exception( 'Access denied.' );
     491        }
     492       
    441493        $results = [];
    442494        $types = ( ! empty( $data['object_type'] ) ) ? $data['object_type'] : array();
     
    465517     */
    466518    protected function get_acf_groups( $data ) {
     519        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     520            throw new \Exception( 'Access denied.' );
     521        }
     522
    467523        $groups = acf_get_field_groups();
    468524        $results = [];
     
    477533
    478534    protected function get_acf_flexible_content_layouts( $data ) {
     535        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     536            throw new \Exception( 'Access denied.' );
     537        }
     538
    479539        $groups = acf_get_field_groups();
    480540        $layouts = [];
     
    500560
    501561    protected function get_acfposts( $data ) {
     562        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     563            throw new \Exception( 'Access denied.' );
     564        }
     565
    502566        $data['object_type'] = array( 'text', 'textarea', 'select', 'number', 'date_time_picker', 'date_picker', 'oembed', 'file', 'url', 'image', 'wysiwyg' );
    503567        $results = $this->get_acf( $data );
     
    531595
    532596    protected function get_terms( $data ) {
     597        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     598            throw new \Exception( 'Access denied.' );
     599        }
     600
    533601        $results = [];
    534602        $taxonomies = ( ! empty( $data['object_type'] ) ) ? $data['object_type'] : get_object_taxonomies( '' );
     
    554622
    555623    protected function get_users( $data ) {
     624        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     625            throw new \Exception( 'Access denied.' );
     626        }
     627
    556628        $results = [];
    557629
     
    591663
    592664    protected function get_authors( $data ) {
     665        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     666            throw new \Exception( 'Access denied.' );
     667        }
     668
    593669        $results = [];
    594670        $query_params = [
     
    631707     */
    632708    protected function get_value_titles_for_acf( $request ) {
     709        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     710            throw new \Exception( 'Access denied.' );
     711        }
     712
    633713        $ids = (array) $request['id'];
    634714        $results = [];
     
    647727     */
    648728    protected function get_value_titles_for_acf_flexible_content_layouts( $request ) {
     729        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     730            throw new \Exception( 'Access denied.' );
     731        }
     732
    649733        $ids = (array) $request['id'];
    650734        $results = [];
     
    660744     */
    661745    protected function get_value_titles_for_acfposts( $request ) {
     746        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     747            throw new \Exception( 'Access denied.' );
     748        }
     749
    662750        $ids = (array) $request['id'];
    663751        $results = $this->get_value_titles_for_acf( $request );
     
    681769     */
    682770    protected function get_value_titles_for_metas( $request ) {
     771        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     772            throw new \Exception( 'Access denied.' );
     773        }
     774
    683775        $ids = (array) $request['id'];
    684776        $results = [];
     
    700792     */
    701793    protected function get_value_titles_for_fields( $request ) {
     794        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     795            throw new \Exception( 'Access denied.' );
     796        }
     797
    702798        $ids = (array) $request['id'];
    703799        $results = [];
     
    742838     */
    743839    protected function get_value_titles_for_dsh_fields( $request ) {
     840        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     841            throw new \Exception( 'Access denied.' );
     842        }
     843
    744844        return $this->get_value_titles_for_fields( $request );
    745845    }
     
    750850     */
    751851    protected function get_value_titles_for_posts( $request ) {
     852        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     853            throw new \Exception( 'Access denied.' );
     854        }
     855
    752856        $ids = (array) $request['id'];
    753857        $results = [];
     
    776880    /**
    777881     * @param array<string,mixed> $request
    778      * @return array<int,mixed>
     882     * @return array<int|string,mixed>
    779883     */
    780884    protected function get_value_titles_for_terms( $request ) {
     885        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     886            throw new \Exception( 'Access denied.' );
     887        }
     888
    781889        $id = $request['id'];
    782890        $results = [];
     891
    783892        if ( is_numeric( $id ) ) {
    784             $term = get_term_by( 'term_taxonomy_id', $id );
    785             $results[ $id ] = $term->name;
     893            $term = get_term( $id );
     894
     895            if ( $term && ! is_wp_error( $term ) ) {
     896                $results[ $term->term_id ] = $term->name;
     897            }
     898
    786899            return $results;
    787900        } else {
    788             $query_params = [
    789                 'slug' => $id,
    790             ];
    791             $terms = get_terms( $query_params );
    792             foreach ( $terms as $term ) {
    793                 $results[ $term->term_id ] = $term->name;
    794             }
     901            $terms = get_terms( [ 'slug' => $id ] );
     902
     903            if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
     904                foreach ( $terms as $term ) {
     905                    if ( ! empty( $term->term_id ) && ! empty( $term->name ) ) {
     906                        $results[ $term->term_id ] = $term->name;
     907                    }
     908                }
     909            }
     910
    795911            return $results;
    796912        }
     
    802918     */
    803919    protected function get_value_titles_for_taxonomies( $request ) {
     920        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     921            throw new \Exception( 'Access denied.' );
     922        }
     923
    804924        $ids = (array) $request['id'];
    805925        $results = [];
     
    822942     */
    823943    protected function get_value_titles_for_users( $request ) {
     944        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     945            throw new \Exception( 'Access denied.' );
     946        }
     947
    824948        $ids = (array) $request['id'];
    825949        $results = [];
     
    860984     */
    861985    protected function get_value_titles_for_authors( $request ) {
     986        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     987            throw new \Exception( 'Access denied.' );
     988        }
     989
    862990        $ids = (array) $request['id'];
    863991        $results = [];
     
    8831011     */
    8841012    protected function get_value_titles_for_terms_fields( $request ) {
     1013        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     1014            throw new \Exception( 'Access denied.' );
     1015        }
     1016
    8851017        $ids = (array) $request['id'];
    8861018        $ids_post = array();
     
    9201052     */
    9211053    protected function get_value_titles_for_taxonomies_fields( $request ) {
     1054        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     1055            throw new \Exception( 'Access denied.' );
     1056        }
     1057
    9221058        $ids = (array) $request['id'];
    9231059        $ids_post = array();
  • dynamic-visibility-for-elementor/tags/5.0.14/readme.txt

    r3109242 r3187397  
    33Tags: elementor, visibility, hide, dynamic, container, widget
    44Requires at least: 5.2
    5 Tested up to: 6.5.5
     5Tested up to: 6.7
    66Requires PHP: 7.1
    7 Stable tag: 5.0.13
     7Stable tag: 5.0.14
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    7272
    7373== Changelog ==
     74
     75= 5.0.14 =
     76* Fix: JS error in some cases
    7477
    7578= 5.0.13 =
  • dynamic-visibility-for-elementor/trunk/class/trait/elementor.php

    r3102226 r3187397  
    231231        return false;
    232232    }
    233 
     233   
    234234    public static function set_all_settings_by_id( $element_id = null, $settings = array(), $post_id = null ) {
    235235        if ( ! $post_id ) {
    236236            $post_id = get_the_ID();
    237             if ( ! $post_id ) {
     237            if ( ! $post_id && isset( $_GET['post'] ) ) {
    238238                $post_id = intval( $_GET['post'] );
    239239            }
    240240        }
     241   
    241242        $post_meta = self::get_settings_by_id( null, $post_id );
    242243        if ( $element_id ) {
     
    247248            }
    248249            $post_meta = Helper::set_array_value_by_keys( is_array( $post_meta ) ? $post_meta : [], $keys_array, $settings );
    249             array_walk_recursive($post_meta, function ( $v, $k ) {
    250                 $v = self::escape_json_string( $v );
    251             });
    252         }
     250        }
     251   
    253252        $post_meta_prepared = wp_json_encode( $post_meta );
    254         $post_meta_prepared = wp_slash( $post_meta_prepared );
    255253        update_metadata( 'post', $post_id, '_elementor_data', $post_meta_prepared );
    256254    }
    257 
     255   
    258256    public static function set_settings_by_id( $element_id, $key, $value = null, $post_id = null ) {
    259257        if ( ! $post_id ) {
    260258            $post_id = get_the_ID();
    261             if ( ! $post_id ) {
     259            if ( ! $post_id && isset( $_GET['post'] ) ) {
    262260                $post_id = intval( $_GET['post'] );
    263261            }
    264262        }
     263   
    265264        $post_meta = self::get_elementor_data( $post_id );
    266265        $keys_array = self::array_find_deep( $post_meta, $element_id );
     
    273272            $keys_array[] = $key;
    274273            $post_meta = Helper::set_array_value_by_keys( is_array( $post_meta ) ? $post_meta : [], $keys_array, $value );
    275             array_walk_recursive($post_meta, function ( $v, $k ) {
    276                 $v = self::escape_json_string( $v );
    277             });
     274   
    278275            $post_meta_prepared = wp_json_encode( $post_meta );
    279             $post_meta_prepared = wp_slash( $post_meta_prepared );
    280276            update_metadata( 'post', $post_id, '_elementor_data', $post_meta_prepared );
    281277        }
    282278        return $post_id;
    283     }
    284 
    285     public static function set_dynamic_tag( $editor_data ) {
    286         if ( is_array( $editor_data ) ) {
    287             foreach ( $editor_data as $key => $avalue ) {
    288                 $editor_data[ $key ] = self::set_dynamic_tag( $avalue );
    289             }
    290             if ( isset( $editor_data['elType'] ) ) {
    291                 foreach ( $editor_data['settings'] as $skey => $avalue ) {
    292                     $editor_data['settings'][ \Elementor\Core\DynamicTags\Manager::DYNAMIC_SETTING_KEY ][ $skey ] = 'token';
    293                 }
    294             }
    295         }
    296         return $editor_data;
    297279    }
    298280
     
    371353
    372354        if ( $datasource ) {
    373             $id_page = $datasource;
     355            $datasource = absint( $datasource );
     356            if ( $datasource > 0 && get_post( $datasource ) ) {
     357                $id_page = $datasource;
     358            }
    374359        }
    375360
    376361        if ( $id_page && $fromparent ) {
    377362            $the_parent = wp_get_post_parent_id( $id_page );
    378             if ( $the_parent != 0 ) {
     363            if ( $the_parent !== 0 ) {
    379364                $id_page = $the_parent;
    380365            }
    381366        }
    382367
    383         if ( ! $id_page ) {
     368        if ( !$id_page ) {
    384369            global $wp;
    385370            $current_url = home_url( add_query_arg( array(), $wp->request ) );
     
    387372        }
    388373
    389         // Myself
    390         $type_page = get_post_type( $id_page );
    391         $id_page = self::get_rev_ID( $id_page, $type_page );
    392 
    393         // Demo
    394         if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
    395             global $product;
    396             global $post;
    397 
    398             // BACKUP
    399             $original_post = $post;
    400             $original_product = $product;
    401 
    402             $demoPage = get_post_meta( get_the_ID(), 'demo_id', true ); // using get_the_id to retrieve Template ID
    403             if ( $demoPage ) {
    404                 $id_page = $demoPage;
    405                 $product = self::wooc_data( $id_page );
    406                 $post = get_post( $id_page );
    407             }
    408 
    409             // RESET
    410             $post = $original_post;
    411             if ( $type_page != 'product' ) {
    412                 $product = $original_product;
    413             }
     374        if ( $id_page ) {
     375            $type_page = get_post_type( $id_page );
     376            $id_page = self::get_translated_post_id( $id_page, $type_page );
    414377        }
    415378
     
    472435        return $icon_html;
    473436    }
    474 
    475     public static function get_elementor_elements( $type = '' ) {
    476         global $wpdb;
    477         $sql_query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}postmeta
    478             WHERE meta_key LIKE %s
    479             AND meta_value LIKE %s
    480             AND post_id IN (
    481                 SELECT id FROM {$wpdb->prefix}posts
    482                 WHERE post_status LIKE 'publish'
    483             )",
    484             '_elementor_data',
    485             '%"widgetType":"' . $wpdb->esc_like( $type ) . '"%'
    486         );
    487 
    488         $results = $wpdb->get_results( $sql_query );
    489         if ( ! count( $results ) ) {
    490             return false;
    491         }
    492         $elements = array();
    493         foreach ( $results as $result ) {
    494             $post_id = $result->post_id;
    495             $elementor_data = $result->meta_value;
    496             $elements_tmp = self::get_elements_from_elementor_data( $elementor_data, 'form' );
    497             if ( ! empty( $elements_tmp ) ) {
    498                 foreach ( $elements_tmp as $key => $value ) {
    499                     $elements[ $post_id ][ $key ] = $value;
    500                 }
    501             }
    502         }
    503 
    504         return $elements;
    505     }
    506 
     437   
    507438    public static function get_elements_from_elementor_data( $elementor_data, $type = '' ) {
    508439        $elements = array();
     
    563494    }
    564495}
     496
  • dynamic-visibility-for-elementor/trunk/class/trait/filesystem.php

    r3102226 r3187397  
    44trait Filesystem {
    55
    6     public static function dir_to_array( $dir, $hidden = false, $files = true ) {
    7         $result = array();
    8         $cdir = scandir( $dir );
    9         foreach ( $cdir as $key => $value ) {
    10             if ( ! in_array( $value, array( '.', '..' ) ) ) {
    11                 if ( is_dir( $dir . DIRECTORY_SEPARATOR . $value ) ) {
    12                     $result[ $value ] = self::dir_to_array( $dir . DIRECTORY_SEPARATOR . $value, $hidden, $files );
    13                 } elseif ( $files ) {
    14                     if ( substr( $value, 0, 1 ) != '.' ) { // hidden file
    15                         $result[] = $value;
    16                     }
    17                 }
    18             }
    19         }
    20         return $result;
    21     }
     6    public static function is_empty_dir( $dirname ) {
     7        $base_dir = realpath( get_home_path() );
     8        $dirname = realpath( $dirname );
    229
    23     public static function is_empty_dir( $dirname ) {
    24         if ( ! is_dir( $dirname ) ) {
     10        if ( $dirname === false || strpos( $dirname, $base_dir ) !== 0 ) {
     11            // Invalid path or outside the allowed directory
     12            return false;
     13        }
     14
     15        if ( ! is_dir( $dirname ) ) {
     16            return false;
     17        }
     18
     19        $iterator = new \FilesystemIterator( $dirname, \FilesystemIterator::SKIP_DOTS );
     20        foreach ( $iterator as $fileinfo ) {
     21            $filename = $fileinfo->getFilename();
     22            if ( ! in_array( $filename, array( '.svn', '.git' ), true ) ) {
     23                return false;
     24            }
     25        }
     26        return true;
     27    }
     28
     29    public static function url_to_path( $url ) {
     30        $relative_url = wp_make_link_relative( $url );
     31        $relative_path = wp_normalize_path( ltrim( $relative_url, '/' ) );
     32   
     33        $home_path = wp_normalize_path( get_home_path() );
     34        $path = $home_path . $relative_path;
     35   
     36        $normalized_path = wp_normalize_path( $path );
     37   
     38        if ( strpos( $normalized_path, $home_path ) !== 0 ) {
     39            // Invalid path or outside the allowed directory
    2540            return false;
    2641        }
    27         foreach ( scandir( $dirname ) as $file ) {
    28             if ( ! in_array( $file, array( '.', '..', '.svn', '.git' ) ) ) {
    29                 return false;
    30             }
    31         }
    32         return true;
    33     }
    34 
    35     public static function url_to_path( $url ) {
    36         return substr( get_home_path(), 0, -1 ) . wp_make_link_relative( $url );
     42   
     43        return $path;
    3744    }
    3845}
  • dynamic-visibility-for-elementor/trunk/class/trait/form.php

    r3102226 r3187397  
    132132    }
    133133
    134     public static function options_array( $string = '', $val = 'pro' ) {
    135         $arr = explode( PHP_EOL, $string );
    136         foreach ( $arr as $akey => $astring ) {
    137             $pieces = explode( '|', $astring, 2 );
    138             if ( count( $pieces ) > 1 ) {
    139                 if ( $val == 'pro' ) {
    140                     $arr[ $akey ] = array(
    141                         'text' => reset( $pieces ),
    142                         'value' => end( $pieces ),
    143                     );
    144                 }
    145                 if ( $val == 'acf' ) {
    146                     $arr[ $akey ] = array(
    147                         'text' => end( $pieces ),
    148                         'value' => reset( $pieces ),
    149                     );
    150                 }
    151             }
    152         }
    153         return $arr;
    154     }
    155 
    156134    public static function form_field_value( $arr = array(), $default = null ) {
    157135        $str = '';
  • dynamic-visibility-for-elementor/trunk/class/trait/image.php

    r3102226 r3187397  
    33
    44trait Image {
    5 
    6     public static function get_thumbnail_sizes() {
    7         $sizes = get_intermediate_image_sizes();
    8         $ret = [];
    9 
    10         foreach ( $sizes as $s ) {
    11             $ret[ $s ] = $s;
    12         }
    13 
    14         return $ret;
    15     }
    165
    176    public static function is_resized_image( $imagePath ) {
     
    3322    public static function get_image_id( $image_url ) {
    3423        global $wpdb;
    35         $sql = $wpdb->prepare( "SELECT ID FROM {$wpdb->prefix}posts WHERE post_type LIKE 'attachment' AND guid LIKE %s;",
     24        $sql = $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid LIKE %s;",
    3625            '%' . $wpdb->esc_like( $image_url ) . '%'
    3726        );
     27
    3828        $attachment = $wpdb->get_col( $sql );
    3929        $img_id = reset( $attachment );
     
    5444     */
    5545    public static function get_image_alt( int $attachment_ID ) {
     46        if ( ! get_post( $attachment_ID ) ) {
     47            return '';
     48        }
    5649        $alt = get_post_meta( $attachment_ID, '_wp_attachment_image_alt', true );
    5750        if ( ! empty( $alt ) ) {
     
    6154    }
    6255
     56
    6357    /**
    64      * Get Attachment
     58     * Get Image Attachment
    6559     *
    6660     * @param string|int $attachment_id
    6761     * @return array<string,mixed>|null
    6862     */
    69     public static function get_attachment( $attachment_id ) {
     63    public static function get_image_attachment( $attachment_id ) {
    7064        $attachment_id = intval( $attachment_id ); // phpstan
    7165        if ( ! $attachment_id ) {
     
    7569        $attachment = get_post( $attachment_id );
    7670        if ( ! $attachment || 'attachment' !== $attachment->post_type ) {
     71            return null;
     72        }
     73
     74        if ( ! current_user_can( 'read_post', $attachment_id ) ) {
     75            return null;
     76        }
     77
     78        if ( ! wp_attachment_is_image( $attachment_id ) ) {
    7779            return null;
    7880        }
     
    8890            'caption' => wp_kses_post( $attachment->post_excerpt ),
    8991            'description' => wp_kses_post( $attachment->post_content ),
    90             'href' => get_attachment_link( $attachment_id ),
    91             'src' => $img_src[0],
     92            'href' => esc_url( get_attachment_link( $attachment_id ) ),
     93            'src' => esc_url( $img_src[0] ),
    9294            'title' => esc_html( $attachment->post_title ),
    93             'url' => $img_src[0],
    94             'width' => $img_src[1],
    95             'height' => $img_src[2],
     95            'url' => esc_url( $img_src[0] ),
     96            'width' => intval( $img_src[1] ),
     97            'height' => intval( $img_src[2] ),
    9698        ];
    9799    }
  • dynamic-visibility-for-elementor/trunk/class/trait/meta.php

    r3102226 r3187397  
    2323        }
    2424        return array();
     25    }
     26
     27    /**
     28     * @param string $source_type
     29     * @param string $other_post_source
     30     * @return string|null
     31     */
     32    public static function get_acf_source_id($source_type, $other_post_source = false) {
     33        switch ($source_type) {
     34            case 'current_post':
     35                return Helper::get_the_id($other_post_source);
     36           
     37            case 'current_user':
     38                $user_id = get_current_user_id();
     39                return 'user_' . $user_id;
     40           
     41            case 'current_author':
     42                $user_id = get_the_author_meta('ID');
     43                return 'user_' . $user_id;
     44           
     45            case 'current_term':
     46                $queried_object = get_queried_object();
     47                if ($queried_object instanceof \WP_Term) {
     48                    $taxonomy = $queried_object->taxonomy;
     49                    $term_id = $queried_object->term_id;
     50                    return $taxonomy . '_' . $term_id;
     51                }
     52                return '';
     53           
     54            case 'options_page':
     55                return 'option';
     56        }
     57        return null;
    2558    }
    2659
     
    903936
    904937    public static function get_acf_field_value( $idField, $id_page = null, $format = true ) {
     938        // Apply filter to allow bypassing loop check for specific use cases
     939        $bypass_loop_check = apply_filters( 'dynamicooo/acf/bypass_loop_check', false, $idField, $id_page );
    905940
    906941        if ( ! $id_page ) {
    907942            $id_page = acf_get_valid_post_id();
    908943        }
     944
     945        // Check if the ACF loop is already active, unless bypassing is enabled
     946        if ( ! $bypass_loop_check ) {
     947            if ( acf_get_loop( 'active' ) ) {
     948                $sub_field_value = get_sub_field( $idField );
     949                if ( $sub_field_value !== false ) {
     950                    return $sub_field_value;
     951                }
     952            }
     953        }
     954
     955        // Get the ACF field post data
    909956        $dataACFieldPost = self::get_acf_field_post( $idField );
    910957
    911         // field in a Repeater or in a Flexible content
     958        // Handle fields within a Repeater or Flexible content
    912959        if ( $dataACFieldPost ) {
    913960            $parentID = $dataACFieldPost->post_parent;
    914961            $parent_settings = self::get_acf_field_settings( $parentID );
    915962            $custom_in_loop = apply_filters( 'dynamicooo/acf/in-loop', false, $parent_settings );
     963
     964            // Check if the parent field is a repeater, flexible content, or a custom loop
    916965            if ( ( isset( $parent_settings['type'] ) && ( $parent_settings['type'] == 'repeater' || $parent_settings['type'] == 'flexible_content' ) ) || $custom_in_loop ) {
    917966                $parent_post = get_post( $parentID );
    918967                $row = acf_get_loop( 'active' );
     968
     969                // If not already in a loop, initiate the loop
    919970                if ( ! $row ) {
    920971                    if ( have_rows( $parent_post->post_excerpt, $id_page ) ) {
     
    929980        }
    930981
    931         // post
     982        // Retrieve the main field
    932983        $theField = get_field( $idField, $id_page, $format );
    933984
    934985        if ( ! $theField ) {
    935 
    936986            $locations = self::get_acf_field_locations( $dataACFieldPost );
    937987
     988            // Check if taxonomy or other locations apply
    938989            if ( is_tax() || is_category() || is_tag() || in_array( 'taxonomy', $locations ) ) {
    939990                $term = get_queried_object();
     
    941992            }
    942993
     994            // Check if author field is applicable
    943995            if ( ! $theField && is_author() ) {
    944996                $author_id = get_the_author_meta( 'ID' );
     
    946998            }
    947999
     1000            // Check if the user or options fields are applicable
    9481001            if ( ! $theField && in_array( 'user', $locations ) ) {
    9491002                $user_id = get_current_user_id();
  • dynamic-visibility-for-elementor/trunk/class/trait/navigation.php

    r3102226 r3187397  
    8383    }
    8484
    85     /* -------------------- */
    86 
    8785    // Search and Filter Pro - Navigation
    8886    public static function get_wp_link_page_sf( $i ) {
  • dynamic-visibility-for-elementor/trunk/class/trait/strings.php

    r3102226 r3187397  
    1111        $string = preg_replace( '/<\/' . $tag . '>/i', '', $string );
    1212        return $string;
    13     }
    14 
    15     public static function escape_json_string( $value ) {
    16         // # list from www.json.org: (\b backspace, \f formfeed)
    17         $escapers = array( '\\', '/', '"', "\n", "\r", "\t", "\x08", "\x0c" );
    18         $replacements = array( '\\\\', '\\/', '\\"', "\\n", "\\r", "\\t", "\\f", "\\b" );
    19         $result = str_replace( $escapers, $replacements, $value );
    20         return $result;
    2113    }
    2214
  • dynamic-visibility-for-elementor/trunk/class/trait/wp.php

    r3102226 r3187397  
    166166    }
    167167
     168    /**
     169     * @return array<string>
     170     */
    168171    public static function get_woocommerce_taxonomies() {
    169172        return [
     
    298301    }
    299302
    300     public static function get_posts_by_type( $typeId, $myself = null, $group = false ) {
    301 
    302         $exclude_io = array();
    303         if ( isset( $myself ) && $myself ) {
    304             $exclude_io = array( $myself );
    305         }
    306         $templates = array();
    307         $get_templates = get_posts(array(
    308             'post_type' => $typeId,
    309             'numberposts' => -1,
    310             'post__not_in' => $exclude_io,
    311             'post_status' => 'publish',
    312             'orderby' => 'title',
    313             'order' => 'DESC',
    314             'suppress_filters' => false,
    315         ));
    316 
    317         if ( ! empty( $get_templates ) ) {
    318             foreach ( $get_templates as $template ) {
    319                 $templates[ $template->ID ] = $template->post_title;
    320             }
    321         }
    322 
    323         return $templates;
    324     }
    325 
    326    
    327 
    328303    /**
    329304     * Get Roles
     
    347322        }
    348323        return $ret;
    349     }
    350 
    351     public static function get_current_user_role() {
    352         if ( is_user_logged_in() ) {
    353             $user = wp_get_current_user();
    354             $role = (array) $user->roles;
    355             return $role[0];
    356         } else {
    357             return false;
    358         }
    359324    }
    360325
     
    448413    }
    449414
    450     public static function get_taxonomy_by_term_id( $term_id ) {
    451         $term = get_term( $term_id );
    452         if ( $term ) {
    453             return $term->taxonomy;
    454         }
    455         return false;
    456     }
    457 
    458     public static function get_author_fields( $meta = false, $group = false, $info = true ) {
    459         return static::get_user_fields( $meta, $group, $info );
    460     }
    461 
    462415    public static function get_user_fields( $meta = false, $group = false, $info = true ) {
    463416        $userFieldsKey = array();
     
    560513    }
    561514
    562     public static function wooc_data( $idprod = null ) {
    563         global $product;
    564 
    565         if ( Helper::is_woocommerce_active() ) {
    566 
    567             if ( isset( $idprod ) ) {
    568                 $product = wc_get_product( $idprod );
    569             } else {
    570                 $product = wc_get_product();
    571             }
    572         }
    573         if ( empty( $product ) ) {
    574             return;
    575         }
    576 
    577         return $product;
    578     }
    579 
    580     public static function get_rev_ID( $revid, $revtype = false ) {
     515    /**
     516     * @param int|string $original_id
     517     * @param boolean $post_type
     518     * @return int
     519     */
     520    public static function get_translated_post_id( $original_id, $post_type = false ) {
     521        $original_id = absint( $original_id );
     522       
    581523        // Check if WPML is installed
    582524        if ( ! Helper::is_plugin_active( 'sitepress-multilingual-cms' ) ) {
    583             return $revid;
    584         }
    585 
    586         if ( ! $revtype ) {
    587             $revtype = get_post_type( $revid );
    588         }
    589         $rev_id = apply_filters( 'wpml_object_id', $revid, $revtype, true );
    590         if ( ! $rev_id ) {
    591             return $revid;
    592         }
    593         return $rev_id;
     525            return $original_id;
     526        }
     527
     528        if ( ! $post_type ) {
     529            $post_type = get_post_type( $original_id );
     530        }
     531        $translated_id = apply_filters( 'wpml_object_id', $original_id, $post_type, true );
     532        if ( ! $translated_id ) {
     533            return $original_id;
     534        }
     535        return $translated_id;
    594536    }
    595537
     
    609551        if ( $field == 'post_excerpt' || $field == 'excerpt' ) {
    610552            $post = get_post( $post_id );
    611             $postValue = $post->post_excerpt;
     553            if ( $post ) {
     554                $postValue = $post->post_excerpt;
     555            }
    612556        }
    613557
     
    11571101        return $array;
    11581102    }
    1159 
    1160     /**
    1161      * Convert ACF Post Objects to IDS
    1162      *
    1163      * @param object|array<mixed>|void $input
    1164      *
    1165      * @return array<mixed>|void
    1166      */
    1167     public static function convert_acf_post_objects_to_ids( $input ) {
    1168         if ( is_array( $input ) ) {
    1169             if ( ! empty( $input ) && is_object( $input[0] ) ) {
    1170                 return array_map( function ( $post ) {
    1171                     return $post->ID;
    1172                 }, $input );
    1173             }
    1174             return $input;
    1175         } elseif ( is_object( $input ) ) {
    1176             return $input->ID ?? '';
    1177         }
    1178 
    1179         return $input;
    1180     }
    11811103}
  • dynamic-visibility-for-elementor/trunk/constants.php

    r3109242 r3187397  
    11<?php
    2 define( 'DVE_VERSION', '5.0.13' );
     2define( 'DVE_VERSION', '5.0.14' );
    33define( 'DVE_MINIMUM_ELEMENTOR_VERSION', '2.9.0' );
    44define( 'DVE_PRODUCT_NAME', 'Dynamic Visibility for Elementor' );
  • dynamic-visibility-for-elementor/trunk/core/plugin.php

    r2983063 r3187397  
    44use DynamicVisibilityForElementor\Helper;
    55
    6 if ( ! defined( 'ABSPATH' ) ) {
    7     exit; // Exit if accessed directly.
     6if (!defined("ABSPATH")) {
     7    exit(); // Exit if accessed directly.
    88}
    99
     
    1313 * @since 0.0.1
    1414 */
    15 class Plugin {
    16     /**
    17      * @var \DynamicVisibilityForElementor\Controls
    18      */
    19     public $controls;
    20     /**
    21      * @var \DynamicVisibilityForElementor\Wpml
    22      */
    23     public $wpml;
    24     /**
    25      * @var \DynamicVisibilityForElementor\AdminPages\Notices
    26      */
    27     public $notices;
    28 
    29     protected static $instance;
    30 
    31     /**
    32      * Constructor
    33      *
    34      * @since 0.0.1
    35      * @access public
    36      */
    37     public function __construct() {
    38         self::$instance = $this;
    39         $this->init();
    40     }
    41 
    42     /**
    43      * @return Plugin
    44      */
    45     public static function instance() {
    46         if ( is_null( self::$instance ) ) {
    47             new self();
    48         }
    49         return self::$instance;
    50     }
    51 
    52     public function init() {
    53         $this->init_managers();
    54 
    55         // Promo
    56         if ( current_user_can( 'install_plugins' ) ) {
    57             $this->promo_notice();
    58         }
    59        
    60         add_action( 'elementor/init', [ $this, 'add_dve_to_elementor' ] );
    61 
    62         // Admin Style
    63         add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin' ] );
    64 
    65         // Plugin page
    66         add_filter( 'plugin_action_links_' . DVE_PLUGIN_BASE, [ $this, 'add_action_links' ] );
    67         add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 );
    68     }
    69 
    70     public function init_managers() {
    71         $this->wpml = new Wpml();
    72         $this->controls = new Controls();
    73         $this->notices = new AdminPages\Notices();
    74         new Ajax();
    75         new Elements();
    76     }
    77 
    78     public function add_dve_to_elementor() {
    79         add_action('elementor/frontend/after_register_styles', function () {
    80             wp_register_style(
    81                 'dce-dynamic-visibility-style',
    82                 DVE_URL . 'assets/css/dynamic-visibility.css',
    83                 [],
    84                 DVE_VERSION
    85             );
    86             // Enqueue Visibility Style
    87             wp_enqueue_style( 'dce-dynamic-visibility-style' );
    88         });
    89 
    90         add_action( 'wp_enqueue_scripts', function () {
    91             wp_register_script(
    92                 'dce-visibility',
    93                 DVE_URL .  'assets/js/visibility.js',
    94                 [],
    95                 DVE_VERSION
    96             );
    97         });
    98 
    99         // DCE Custom Icons - in Elementor Editor
    100         add_action('elementor/preview/enqueue_styles', function () {
    101             wp_register_style(
    102                 'dce-preview',
    103                 DVE_URL . 'assets/css/preview.css',
    104                 [],
    105                 DVE_VERSION
    106             );
    107             // Enqueue DCE Elementor Style
    108             wp_enqueue_style( 'dce-preview' );
    109         });
    110 
    111         add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'dce_editor' ) );
    112 
    113         // Controls
    114         add_action( 'elementor/controls/controls_registered', [ $this->controls, 'on_controls_registered' ] );
    115 
    116         new Extensions\DynamicVisibility();
    117     }
    118 
    119     /**
    120      * Enqueue admin
    121      *
    122      * @access public
    123      */
    124     public function enqueue_admin() {
    125         // Style
    126         wp_register_style(
    127             'dve-admin-css',
    128             DVE_URL . 'assets/css/admin.css',
    129             [],
    130             DVE_VERSION
    131         );
    132         wp_enqueue_style( 'dve-admin-css' );
    133 
    134         // Scripts
    135         wp_enqueue_script(
    136             'dve-admin-js',
    137             DVE_URL . 'assets/js/admin.js',
    138             [],
    139             DVE_VERSION,
    140             true
    141         );
    142     }
    143 
    144 
    145     public function promo_notice() {
    146         $msg = sprintf( __( '%1$sBuy now Dynamic.ooo - Dynamic Content for Elementor%2$s and save 10&#37; using promo code %3$sVISIBILITY%4$s.', 'dynamic-visibility-for-elementor' ) . '<br />', '<a target="_blank" href="https://www.dynamic.ooo/upgrade/visibility-to-premium?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash-promo">', '</a>', '<strong>', '</strong>' );
    147         $msg .= sprintf( __( 'We give you %1$sover 140 features for Elementor%2$s that will save you time and money on achieving complex results. We support ACF Free and ACF Pro, JetEngine, Meta Box, WooCommerce, WPML, Search and Filter Pro, Pods, Toolset and Timber.', 'dynamic-visibility-for-elementor' ), '<strong>', '</strong>' );
    148         $this->notices->info( $msg, 'upgrade_10' );
    149     }
    150 
    151     public function add_action_links( $links ) {
    152         $my_links[] = sprintf( '<a href="https://www.dynamic.ooo/upgrade/visibility-to-premium?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash" target="_blank"">' . __( 'Go Premium', 'dynamic-visibility-for-elementor' ) . '</a>' );
    153         return array_merge( $links, $my_links );
    154     }
    155 
    156     public function plugin_row_meta( $plugin_meta, $plugin_file ) {
    157         if ( 'dynamic-visibility-for-elementor/dynamic-visibility-for-elementor.php' === $plugin_file ) {
    158             $row_meta = [
    159                 'docs' => '<a href="https://dnmc.ooo/visibilitydoc" aria-label="' . esc_attr( __( 'View Dynamic Visibility Documentation', 'dynamic-visibility-for-elementor' ) ) . '" target="_blank">' . __( 'Docs', 'dynamic-visibility-for-elementor' ) . '</a>',
    160                 'community' => '<a href="http://facebook.com/groups/dynamic.ooo" aria-label="' . esc_attr( __( 'Facebook Community', 'dynamic-visibility-for-elementor' ) ) . '" target="_blank">' . __( 'FB Community', 'dynamic-visibility-for-elementor' ) . '</a>',
    161             ];
    162 
    163             $plugin_meta = array_merge( $plugin_meta, $row_meta );
    164         }
    165 
    166         return $plugin_meta;
    167     }
    168 
    169     /**
    170      * Enqueue admin styles
    171      *
    172      * @access public
    173      */
    174     public function dce_editor() {
    175         // Register styles
    176         wp_register_style(
    177             'dce-icons',
    178             DVE_URL . 'assets/css/dce-icon.css',
    179             [],
    180             DVE_VERSION
    181         );
    182         // Enqueue styles Icons
    183         wp_enqueue_style( 'dce-icons' );
    184 
    185         // Register styles
    186         wp_register_style(
    187             'dce-editor',
    188             DVE_URL . 'assets/css/editor.css',
    189             [],
    190             DVE_VERSION
    191         );
    192         wp_enqueue_style( 'dce-editor' );
    193 
    194         wp_register_script(
    195             'dce-script-editor',
    196             DVE_URL . 'assets/js/editor.js',
    197             [],
    198             DVE_VERSION
    199         );
    200         wp_enqueue_script( 'dce-script-editor' );
    201 
    202         wp_register_script(
    203             'dce-editor-visibility',
    204             DVE_URL . 'assets/js/editor-dynamic-visibility.js',
    205             [],
    206             DVE_VERSION
    207         );
    208         wp_enqueue_script( 'dce-editor-visibility' );
    209 
    210         // select2
    211         wp_enqueue_style(
    212             'dce-select2',
    213             DVE_URL . 'assets/lib/select2/select2.min.css',
    214             [],
    215             DVE_VERSION
    216         );
    217         wp_enqueue_script(
    218             'dce-select2',
    219             DVE_URL . 'assets/lib/select2/select2.full.min.js',
    220             [ 'jquery' ],
    221             DVE_VERSION,
    222             true
    223         );
    224     }
     15class Plugin
     16{
     17    /**
     18     * @var \DynamicVisibilityForElementor\Controls
     19     */
     20    public $controls;
     21    /**
     22     * @var \DynamicVisibilityForElementor\Wpml
     23     */
     24    public $wpml;
     25    /**
     26     * @var \DynamicVisibilityForElementor\AdminPages\Notices
     27     */
     28    public $notices;
     29
     30    protected static $instance;
     31
     32    /**
     33     * Constructor
     34     *
     35     * @since 0.0.1
     36     * @access public
     37     */
     38    public function __construct()
     39    {
     40        self::$instance = $this;
     41        $this->init();
     42    }
     43
     44    /**
     45     * @return Plugin
     46     */
     47    public static function instance()
     48    {
     49        if (is_null(self::$instance)) {
     50            new self();
     51        }
     52        return self::$instance;
     53    }
     54
     55    public function init()
     56    {
     57        $this->init_managers();
     58
     59        // Promo
     60        if (current_user_can("install_plugins")) {
     61            $this->promo_notice();
     62        }
     63
     64        add_action("elementor/init", [$this, "add_dve_to_elementor"]);
     65
     66        // Admin Style
     67        add_action("admin_enqueue_scripts", [$this, "enqueue_admin"]);
     68
     69        // Plugin page
     70        add_filter("plugin_action_links_" . DVE_PLUGIN_BASE, [
     71            $this,
     72            "add_action_links",
     73        ]);
     74        add_filter("plugin_row_meta", [$this, "plugin_row_meta"], 10, 2);
     75    }
     76
     77    public function init_managers()
     78    {
     79        $this->wpml = new Wpml();
     80        $this->controls = new Controls();
     81        $this->notices = new AdminPages\Notices();
     82        new Ajax();
     83        new Elements();
     84    }
     85
     86    public function add_dve_to_elementor()
     87    {
     88        add_action("elementor/frontend/after_register_styles", function () {
     89            wp_register_style(
     90                "dce-dynamic-visibility-style",
     91                DVE_URL . "assets/css/dynamic-visibility.css",
     92                [],
     93                DVE_VERSION
     94            );
     95            // Enqueue Visibility Style
     96            wp_enqueue_style("dce-dynamic-visibility-style");
     97        });
     98
     99        add_action("wp_enqueue_scripts", function () {
     100            wp_register_script(
     101                "dce-visibility",
     102                DVE_URL . "assets/js/visibility.js",
     103                ["jquery"],
     104                DVE_VERSION
     105            );
     106        });
     107
     108        // DCE Custom Icons - in Elementor Editor
     109        add_action("elementor/preview/enqueue_styles", function () {
     110            wp_register_style(
     111                "dce-preview",
     112                DVE_URL . "assets/css/preview.css",
     113                [],
     114                DVE_VERSION
     115            );
     116            // Enqueue DCE Elementor Style
     117            wp_enqueue_style("dce-preview");
     118        });
     119
     120        add_action("elementor/editor/after_enqueue_scripts", [
     121            $this,
     122            "dce_editor",
     123        ]);
     124
     125        // Controls
     126        add_action("elementor/controls/controls_registered", [
     127            $this->controls,
     128            "on_controls_registered",
     129        ]);
     130
     131        new Extensions\DynamicVisibility();
     132    }
     133
     134    /**
     135     * Enqueue admin
     136     *
     137     * @access public
     138     */
     139    public function enqueue_admin()
     140    {
     141        // Style
     142        wp_register_style(
     143            "dve-admin-css",
     144            DVE_URL . "assets/css/admin.css",
     145            [],
     146            DVE_VERSION
     147        );
     148        wp_enqueue_style("dve-admin-css");
     149
     150        // Scripts
     151        wp_enqueue_script(
     152            "dve-admin-js",
     153            DVE_URL . "assets/js/admin.js",
     154            [],
     155            DVE_VERSION,
     156            true
     157        );
     158    }
     159
     160    public function promo_notice()
     161    {
     162        $msg = sprintf(
     163            __(
     164                '%1$sBuy now Dynamic.ooo - Dynamic Content for Elementor%2$s and save 10&#37; using promo code %3$sVISIBILITY%4$s.',
     165                "dynamic-visibility-for-elementor"
     166            ) . "<br />",
     167            '<a target="_blank" href="https://www.dynamic.ooo/upgrade/visibility-to-premium?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash-promo">',
     168            "</a>",
     169            "<strong>",
     170            "</strong>"
     171        );
     172        $msg .= sprintf(
     173            __(
     174                'We give you %1$sover 140 features for Elementor%2$s that will save you time and money on achieving complex results. We support ACF Free and ACF Pro, JetEngine, Meta Box, WooCommerce, WPML, Search and Filter Pro, Pods, Toolset and Timber.',
     175                "dynamic-visibility-for-elementor"
     176            ),
     177            "<strong>",
     178            "</strong>"
     179        );
     180        $this->notices->info($msg, "upgrade_10");
     181    }
     182
     183    public function add_action_links($links)
     184    {
     185        $my_links[] = sprintf(
     186            '<a href="https://www.dynamic.ooo/upgrade/visibility-to-premium?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash" target="_blank"">' .
     187                __("Go Premium", "dynamic-visibility-for-elementor") .
     188                "</a>"
     189        );
     190        return array_merge($links, $my_links);
     191    }
     192
     193    public function plugin_row_meta($plugin_meta, $plugin_file)
     194    {
     195        if (
     196            "dynamic-visibility-for-elementor/dynamic-visibility-for-elementor.php" ===
     197            $plugin_file
     198        ) {
     199            $row_meta = [
     200                "docs" =>
     201                    '<a href="https://dnmc.ooo/visibilitydoc" aria-label="' .
     202                    esc_attr(
     203                        __(
     204                            "View Dynamic Visibility Documentation",
     205                            "dynamic-visibility-for-elementor"
     206                        )
     207                    ) .
     208                    '" target="_blank">' .
     209                    __("Docs", "dynamic-visibility-for-elementor") .
     210                    "</a>",
     211                "community" =>
     212                    '<a href="http://facebook.com/groups/dynamic.ooo" aria-label="' .
     213                    esc_attr(
     214                        __(
     215                            "Facebook Community",
     216                            "dynamic-visibility-for-elementor"
     217                        )
     218                    ) .
     219                    '" target="_blank">' .
     220                    __("FB Community", "dynamic-visibility-for-elementor") .
     221                    "</a>",
     222            ];
     223
     224            $plugin_meta = array_merge($plugin_meta, $row_meta);
     225        }
     226
     227        return $plugin_meta;
     228    }
     229
     230    /**
     231     * Enqueue admin styles
     232     *
     233     * @access public
     234     */
     235    public function dce_editor()
     236    {
     237        // Register styles
     238        wp_register_style(
     239            "dce-icons",
     240            DVE_URL . "assets/css/dce-icon.css",
     241            [],
     242            DVE_VERSION
     243        );
     244        // Enqueue styles Icons
     245        wp_enqueue_style("dce-icons");
     246
     247        // Register styles
     248        wp_register_style(
     249            "dce-editor",
     250            DVE_URL . "assets/css/editor.css",
     251            [],
     252            DVE_VERSION
     253        );
     254        wp_enqueue_style("dce-editor");
     255
     256        wp_register_script(
     257            "dce-script-editor",
     258            DVE_URL . "assets/js/editor.js",
     259            [],
     260            DVE_VERSION
     261        );
     262        wp_enqueue_script("dce-script-editor");
     263
     264        wp_register_script(
     265            "dce-editor-visibility",
     266            DVE_URL . "assets/js/editor-dynamic-visibility.js",
     267            [],
     268            DVE_VERSION
     269        );
     270        wp_enqueue_script("dce-editor-visibility");
     271
     272        // select2
     273        wp_enqueue_style(
     274            "dce-select2",
     275            DVE_URL . "assets/lib/select2/select2.min.css",
     276            [],
     277            DVE_VERSION
     278        );
     279        wp_enqueue_script(
     280            "dce-select2",
     281            DVE_URL . "assets/lib/select2/select2.full.min.js",
     282            ["jquery"],
     283            DVE_VERSION,
     284            true
     285        );
     286    }
    225287}
    226288
  • dynamic-visibility-for-elementor/trunk/dynamic-visibility-for-elementor.php

    r3109242 r3187397  
    55 * Description: Visibility rules for widgets, containers, sections, columns or pages with advanced conditions and removing the element from the DOM.
    66 * Plugin URI: https://www.dynamic.ooo/widget/dynamic-visibility/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash
    7  * Version: 5.0.13
     7 * Version: 5.0.14
    88 * Author: Dynamic.ooo
    99 * Author URI: https://www.dynamic.ooo/
     
    1313 * License: GPL-3.0
    1414 * License URI: http://www.gnu.org/licenses/gpl-3.0.txt
    15  * Elementor tested up to: 3.21.8
    16  * Elementor Pro tested up to: 3.21.3
     15 * Elementor tested up to: 3.25.5
     16 * Elementor Pro tested up to: 3.25.2
    1717 *
    1818 * This program is free software: you can redistribute it and/or modify
  • dynamic-visibility-for-elementor/trunk/includes/extensions/dynamic-visibility.php

    r3109215 r3187397  
    656656                unset( $_triggers['events'] );
    657657            }
     658            if ( ! Helper::is_myfastapp_active() ) {
     659                unset( $_triggers['myfastapp'] );
     660            }
    658661            $element->add_control(
    659662                'dce_visibility_triggers',
     
    13201323                    'label_block' => true,
    13211324                    'query_type' => 'posts',
     1325                    'dynamic' => [
     1326                        'active' => false,
     1327                    ],
    13221328                    'multiple' => true,
    13231329                    'separator' => 'before',
     
    16711677            } else {
    16721678                $element->add_control(
    1673                 'dce_visibility_woo_notice',
    1674                 [
    1675                     'type' => Controls_Manager::RAW_HTML,
    1676                     'raw' => esc_html__( 'You need WooCommerce to use this trigger.', 'dynamic-visibility-for-elementor' ),
    1677                     'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
    1678                 ]
     1679                    'dce_visibility_woo_notice',
     1680                    [
     1681                        'type' => Controls_Manager::RAW_HTML,
     1682                        'raw' => esc_html__( 'You need WooCommerce to use this trigger.', 'dynamic-visibility-for-elementor' ),
     1683                        'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
     1684                    ]
    16791685                );
    16801686            }
     
    16921698                );
    16931699            } elseif ( Helper::is_myfastapp_active() ) {
    1694                     $element->add_control(
    1695                         'dce_visibility_myfastapp',
    1696                         [
    1697                             'label' => esc_html__( 'The visitor is', 'dynamic-visibility-for-elementor' ),
    1698                             'type' => Controls_Manager::SELECT,
    1699                             'options' => [
    1700                                 'all' => esc_html__( 'on the site or in the app', 'dynamic-visibility-for-elementor' ),
    1701                                 'site' => esc_html__( 'on the site', 'dynamic-visibility-for-elementor' ),
    1702                                 'app' => esc_html__( 'in the app', 'dynamic-visibility-for-elementor' ),
    1703                             ],
    1704                             'default' => 'all',
    1705                         ]
    1706                     );
    1707             } else {
    17081700                $element->add_control(
    1709                     'dce_visibility_myfastapp_notice',
     1701                    'dce_visibility_myfastapp',
    17101702                    [
    1711                         'type' => Controls_Manager::RAW_HTML,
    1712                         'raw' => esc_html__( 'You need My FastAPP to use this trigger.', 'dynamic-visibility-for-elementor' ),
    1713                         'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
     1703                        'label' => esc_html__( 'The visitor is', 'dynamic-visibility-for-elementor' ),
     1704                        'type' => Controls_Manager::SELECT,
     1705                        'options' => [
     1706                            'all' => esc_html__( 'on the site or in the app', 'dynamic-visibility-for-elementor' ),
     1707                            'site' => esc_html__( 'on the site', 'dynamic-visibility-for-elementor' ),
     1708                            'app' => esc_html__( 'in the app', 'dynamic-visibility-for-elementor' ),
     1709                        ],
     1710                        'default' => 'all',
    17141711                    ]
    17151712                );
     
    26172614                        $ips = array_map( 'trim', $ips );
    26182615                        ++$triggers_n;
    2619                         if ( in_array( $_SERVER['REMOTE_ADDR'], $ips ) ) {
     2616                        if ( isset( $_SERVER['REMOTE_ADDR'] ) && in_array( $_SERVER['REMOTE_ADDR'], $ips ) ) {
    26202617                            $conditions['dce_visibility_ip'] = esc_html__( 'Remote IP', 'dynamic-visibility-for-elementor' );
    26212618                        }
  • dynamic-visibility-for-elementor/trunk/modules/query-control/module.php

    r3102226 r3187397  
    55use Elementor\Core\Base\Module as Base_Module;
    66use DynamicVisibilityForElementor\Helper;
     7use Elementor\Core\Editor\Editor;
    78
    89if ( ! defined( 'ABSPATH' ) ) {
     
    3132
    3233    public function ajax_call_filter_autocomplete( array $data ) {
     34        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     35            throw new \Exception( 'Access denied.' );
     36        }
    3337
    3438        if ( empty( $data['query_type'] ) || empty( $data['q'] ) ) {
     
    4448
    4549    protected function get_options( $data ) {
     50        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     51            throw new \Exception( 'Access denied.' );
     52        }
     53
    4654        $results = [];
    4755        $fields = Helper::get_options( $data['q'] );
     
    5866
    5967    protected function get_fields( $data ) {
     68        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     69            throw new \Exception( 'Access denied.' );
     70        }
     71
    6072        $results = [];
    6173        $object_types = $data['object_type'];
     
    88100     */
    89101    protected function get_dsh_fields( $data ) {
     102        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     103            throw new \Exception( 'Access denied.' );
     104        }
     105
    90106        $results = [];
    91107
     
    223239
    224240    protected function get_terms_fields( $data ) {
     241        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     242            throw new \Exception( 'Access denied.' );
     243        }
     244       
    225245        $results = [];
    226246        $results = $this->get_fields( $data );
     
    240260
    241261    protected function get_taxonomies_fields( $data ) {
     262        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     263            throw new \Exception( 'Access denied.' );
     264        }
     265
    242266        $results = [];
    243267        $results = $this->get_fields( $data );
     
    258282
    259283    protected function get_metas( $data ) {
     284        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     285            throw new \Exception( 'Access denied.' );
     286        }
     287
    260288        $results = [];
    261289        $function = 'get_' . $data['object_type'] . '_metas';
     
    273301
    274302    protected function get_pods( $data ) {
     303        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     304            throw new \Exception( 'Access denied.' );
     305        }
     306
    275307        $results = [];
    276308        $function = 'get_' . $data['object_type'] . '_pods';
     
    288320
    289321    protected function get_posts( $data ) {
     322        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     323            throw new \Exception( 'Access denied.' );
     324        }
     325
    290326        $results = [];
    291327        $object_type = $data['object_type'] ?? 'any';
     
    320356
    321357    protected function get_jet( $data ) {
     358        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     359            throw new \Exception( 'Access denied.' );
     360        }
     361
    322362        if ( ! Helper::is_jetengine_active() ) {
    323363            return [];
     
    370410     */
    371411    protected function get_metabox( $data ) {
     412        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     413            throw new \Exception( 'Access denied.' );
     414        }
     415
    372416        if ( ! Helper::is_metabox_active() ) {
    373417            return [];
     
    415459     */
    416460    protected function get_metabox_relationship( $data ) {
     461        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     462            throw new \Exception( 'Access denied.' );
     463        }
     464
    417465        if ( ! Helper::is_metabox_active() ) {
    418466            return [];
     
    439487
    440488    protected function get_acf( $data ) {
     489        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     490            throw new \Exception( 'Access denied.' );
     491        }
     492       
    441493        $results = [];
    442494        $types = ( ! empty( $data['object_type'] ) ) ? $data['object_type'] : array();
     
    465517     */
    466518    protected function get_acf_groups( $data ) {
     519        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     520            throw new \Exception( 'Access denied.' );
     521        }
     522
    467523        $groups = acf_get_field_groups();
    468524        $results = [];
     
    477533
    478534    protected function get_acf_flexible_content_layouts( $data ) {
     535        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     536            throw new \Exception( 'Access denied.' );
     537        }
     538
    479539        $groups = acf_get_field_groups();
    480540        $layouts = [];
     
    500560
    501561    protected function get_acfposts( $data ) {
     562        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     563            throw new \Exception( 'Access denied.' );
     564        }
     565
    502566        $data['object_type'] = array( 'text', 'textarea', 'select', 'number', 'date_time_picker', 'date_picker', 'oembed', 'file', 'url', 'image', 'wysiwyg' );
    503567        $results = $this->get_acf( $data );
     
    531595
    532596    protected function get_terms( $data ) {
     597        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     598            throw new \Exception( 'Access denied.' );
     599        }
     600
    533601        $results = [];
    534602        $taxonomies = ( ! empty( $data['object_type'] ) ) ? $data['object_type'] : get_object_taxonomies( '' );
     
    554622
    555623    protected function get_users( $data ) {
     624        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     625            throw new \Exception( 'Access denied.' );
     626        }
     627
    556628        $results = [];
    557629
     
    591663
    592664    protected function get_authors( $data ) {
     665        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     666            throw new \Exception( 'Access denied.' );
     667        }
     668
    593669        $results = [];
    594670        $query_params = [
     
    631707     */
    632708    protected function get_value_titles_for_acf( $request ) {
     709        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     710            throw new \Exception( 'Access denied.' );
     711        }
     712
    633713        $ids = (array) $request['id'];
    634714        $results = [];
     
    647727     */
    648728    protected function get_value_titles_for_acf_flexible_content_layouts( $request ) {
     729        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     730            throw new \Exception( 'Access denied.' );
     731        }
     732
    649733        $ids = (array) $request['id'];
    650734        $results = [];
     
    660744     */
    661745    protected function get_value_titles_for_acfposts( $request ) {
     746        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     747            throw new \Exception( 'Access denied.' );
     748        }
     749
    662750        $ids = (array) $request['id'];
    663751        $results = $this->get_value_titles_for_acf( $request );
     
    681769     */
    682770    protected function get_value_titles_for_metas( $request ) {
     771        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     772            throw new \Exception( 'Access denied.' );
     773        }
     774
    683775        $ids = (array) $request['id'];
    684776        $results = [];
     
    700792     */
    701793    protected function get_value_titles_for_fields( $request ) {
     794        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     795            throw new \Exception( 'Access denied.' );
     796        }
     797
    702798        $ids = (array) $request['id'];
    703799        $results = [];
     
    742838     */
    743839    protected function get_value_titles_for_dsh_fields( $request ) {
     840        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     841            throw new \Exception( 'Access denied.' );
     842        }
     843
    744844        return $this->get_value_titles_for_fields( $request );
    745845    }
     
    750850     */
    751851    protected function get_value_titles_for_posts( $request ) {
     852        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     853            throw new \Exception( 'Access denied.' );
     854        }
     855
    752856        $ids = (array) $request['id'];
    753857        $results = [];
     
    776880    /**
    777881     * @param array<string,mixed> $request
    778      * @return array<int,mixed>
     882     * @return array<int|string,mixed>
    779883     */
    780884    protected function get_value_titles_for_terms( $request ) {
     885        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     886            throw new \Exception( 'Access denied.' );
     887        }
     888
    781889        $id = $request['id'];
    782890        $results = [];
     891
    783892        if ( is_numeric( $id ) ) {
    784             $term = get_term_by( 'term_taxonomy_id', $id );
    785             $results[ $id ] = $term->name;
     893            $term = get_term( $id );
     894
     895            if ( $term && ! is_wp_error( $term ) ) {
     896                $results[ $term->term_id ] = $term->name;
     897            }
     898
    786899            return $results;
    787900        } else {
    788             $query_params = [
    789                 'slug' => $id,
    790             ];
    791             $terms = get_terms( $query_params );
    792             foreach ( $terms as $term ) {
    793                 $results[ $term->term_id ] = $term->name;
    794             }
     901            $terms = get_terms( [ 'slug' => $id ] );
     902
     903            if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
     904                foreach ( $terms as $term ) {
     905                    if ( ! empty( $term->term_id ) && ! empty( $term->name ) ) {
     906                        $results[ $term->term_id ] = $term->name;
     907                    }
     908                }
     909            }
     910
    795911            return $results;
    796912        }
     
    802918     */
    803919    protected function get_value_titles_for_taxonomies( $request ) {
     920        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     921            throw new \Exception( 'Access denied.' );
     922        }
     923
    804924        $ids = (array) $request['id'];
    805925        $results = [];
     
    822942     */
    823943    protected function get_value_titles_for_users( $request ) {
     944        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     945            throw new \Exception( 'Access denied.' );
     946        }
     947
    824948        $ids = (array) $request['id'];
    825949        $results = [];
     
    860984     */
    861985    protected function get_value_titles_for_authors( $request ) {
     986        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     987            throw new \Exception( 'Access denied.' );
     988        }
     989
    862990        $ids = (array) $request['id'];
    863991        $results = [];
     
    8831011     */
    8841012    protected function get_value_titles_for_terms_fields( $request ) {
     1013        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     1014            throw new \Exception( 'Access denied.' );
     1015        }
     1016
    8851017        $ids = (array) $request['id'];
    8861018        $ids_post = array();
     
    9201052     */
    9211053    protected function get_value_titles_for_taxonomies_fields( $request ) {
     1054        if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) {
     1055            throw new \Exception( 'Access denied.' );
     1056        }
     1057
    9221058        $ids = (array) $request['id'];
    9231059        $ids_post = array();
  • dynamic-visibility-for-elementor/trunk/readme.txt

    r3109242 r3187397  
    33Tags: elementor, visibility, hide, dynamic, container, widget
    44Requires at least: 5.2
    5 Tested up to: 6.5.5
     5Tested up to: 6.7
    66Requires PHP: 7.1
    7 Stable tag: 5.0.13
     7Stable tag: 5.0.14
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    7272
    7373== Changelog ==
     74
     75= 5.0.14 =
     76* Fix: JS error in some cases
    7477
    7578= 5.0.13 =
Note: See TracChangeset for help on using the changeset viewer.