Changeset 3187397
- Timestamp:
- 11/13/2024 11:04:10 AM (14 months ago)
- Location:
- dynamic-visibility-for-elementor
- Files:
-
- 28 edited
- 1 copied
-
tags/5.0.14 (copied) (copied from dynamic-visibility-for-elementor/trunk)
-
tags/5.0.14/class/trait/elementor.php (modified) (7 diffs)
-
tags/5.0.14/class/trait/filesystem.php (modified) (1 diff)
-
tags/5.0.14/class/trait/form.php (modified) (1 diff)
-
tags/5.0.14/class/trait/image.php (modified) (6 diffs)
-
tags/5.0.14/class/trait/meta.php (modified) (5 diffs)
-
tags/5.0.14/class/trait/navigation.php (modified) (1 diff)
-
tags/5.0.14/class/trait/strings.php (modified) (1 diff)
-
tags/5.0.14/class/trait/wp.php (modified) (7 diffs)
-
tags/5.0.14/constants.php (modified) (1 diff)
-
tags/5.0.14/core/plugin.php (modified) (2 diffs)
-
tags/5.0.14/dynamic-visibility-for-elementor.php (modified) (2 diffs)
-
tags/5.0.14/includes/extensions/dynamic-visibility.php (modified) (5 diffs)
-
tags/5.0.14/modules/query-control/module.php (modified) (33 diffs)
-
tags/5.0.14/readme.txt (modified) (2 diffs)
-
trunk/class/trait/elementor.php (modified) (7 diffs)
-
trunk/class/trait/filesystem.php (modified) (1 diff)
-
trunk/class/trait/form.php (modified) (1 diff)
-
trunk/class/trait/image.php (modified) (6 diffs)
-
trunk/class/trait/meta.php (modified) (5 diffs)
-
trunk/class/trait/navigation.php (modified) (1 diff)
-
trunk/class/trait/strings.php (modified) (1 diff)
-
trunk/class/trait/wp.php (modified) (7 diffs)
-
trunk/constants.php (modified) (1 diff)
-
trunk/core/plugin.php (modified) (2 diffs)
-
trunk/dynamic-visibility-for-elementor.php (modified) (2 diffs)
-
trunk/includes/extensions/dynamic-visibility.php (modified) (5 diffs)
-
trunk/modules/query-control/module.php (modified) (33 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dynamic-visibility-for-elementor/tags/5.0.14/class/trait/elementor.php
r3102226 r3187397 231 231 return false; 232 232 } 233 233 234 234 public static function set_all_settings_by_id( $element_id = null, $settings = array(), $post_id = null ) { 235 235 if ( ! $post_id ) { 236 236 $post_id = get_the_ID(); 237 if ( ! $post_id ) {237 if ( ! $post_id && isset( $_GET['post'] ) ) { 238 238 $post_id = intval( $_GET['post'] ); 239 239 } 240 240 } 241 241 242 $post_meta = self::get_settings_by_id( null, $post_id ); 242 243 if ( $element_id ) { … … 247 248 } 248 249 $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 253 252 $post_meta_prepared = wp_json_encode( $post_meta ); 254 $post_meta_prepared = wp_slash( $post_meta_prepared );255 253 update_metadata( 'post', $post_id, '_elementor_data', $post_meta_prepared ); 256 254 } 257 255 258 256 public static function set_settings_by_id( $element_id, $key, $value = null, $post_id = null ) { 259 257 if ( ! $post_id ) { 260 258 $post_id = get_the_ID(); 261 if ( ! $post_id ) {259 if ( ! $post_id && isset( $_GET['post'] ) ) { 262 260 $post_id = intval( $_GET['post'] ); 263 261 } 264 262 } 263 265 264 $post_meta = self::get_elementor_data( $post_id ); 266 265 $keys_array = self::array_find_deep( $post_meta, $element_id ); … … 273 272 $keys_array[] = $key; 274 273 $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 278 275 $post_meta_prepared = wp_json_encode( $post_meta ); 279 $post_meta_prepared = wp_slash( $post_meta_prepared );280 276 update_metadata( 'post', $post_id, '_elementor_data', $post_meta_prepared ); 281 277 } 282 278 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;297 279 } 298 280 … … 371 353 372 354 if ( $datasource ) { 373 $id_page = $datasource; 355 $datasource = absint( $datasource ); 356 if ( $datasource > 0 && get_post( $datasource ) ) { 357 $id_page = $datasource; 358 } 374 359 } 375 360 376 361 if ( $id_page && $fromparent ) { 377 362 $the_parent = wp_get_post_parent_id( $id_page ); 378 if ( $the_parent != 0 ) {363 if ( $the_parent !== 0 ) { 379 364 $id_page = $the_parent; 380 365 } 381 366 } 382 367 383 if ( ! $id_page ) {368 if ( !$id_page ) { 384 369 global $wp; 385 370 $current_url = home_url( add_query_arg( array(), $wp->request ) ); … … 387 372 } 388 373 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 ); 414 377 } 415 378 … … 472 435 return $icon_html; 473 436 } 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 507 438 public static function get_elements_from_elementor_data( $elementor_data, $type = '' ) { 508 439 $elements = array(); … … 563 494 } 564 495 } 496 -
dynamic-visibility-for-elementor/tags/5.0.14/class/trait/filesystem.php
r3102226 r3187397 4 4 trait Filesystem { 5 5 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 ); 22 9 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 25 40 return false; 26 41 } 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; 37 44 } 38 45 } -
dynamic-visibility-for-elementor/tags/5.0.14/class/trait/form.php
r3102226 r3187397 132 132 } 133 133 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 156 134 public static function form_field_value( $arr = array(), $default = null ) { 157 135 $str = ''; -
dynamic-visibility-for-elementor/tags/5.0.14/class/trait/image.php
r3102226 r3187397 3 3 4 4 trait 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 }16 5 17 6 public static function is_resized_image( $imagePath ) { … … 33 22 public static function get_image_id( $image_url ) { 34 23 global $wpdb; 35 $sql = $wpdb->prepare( "SELECT ID FROM {$wpdb->p refix}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;", 36 25 '%' . $wpdb->esc_like( $image_url ) . '%' 37 26 ); 27 38 28 $attachment = $wpdb->get_col( $sql ); 39 29 $img_id = reset( $attachment ); … … 54 44 */ 55 45 public static function get_image_alt( int $attachment_ID ) { 46 if ( ! get_post( $attachment_ID ) ) { 47 return ''; 48 } 56 49 $alt = get_post_meta( $attachment_ID, '_wp_attachment_image_alt', true ); 57 50 if ( ! empty( $alt ) ) { … … 61 54 } 62 55 56 63 57 /** 64 * Get Attachment58 * Get Image Attachment 65 59 * 66 60 * @param string|int $attachment_id 67 61 * @return array<string,mixed>|null 68 62 */ 69 public static function get_ attachment( $attachment_id ) {63 public static function get_image_attachment( $attachment_id ) { 70 64 $attachment_id = intval( $attachment_id ); // phpstan 71 65 if ( ! $attachment_id ) { … … 75 69 $attachment = get_post( $attachment_id ); 76 70 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 ) ) { 77 79 return null; 78 80 } … … 88 90 'caption' => wp_kses_post( $attachment->post_excerpt ), 89 91 '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] ), 92 94 '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] ), 96 98 ]; 97 99 } -
dynamic-visibility-for-elementor/tags/5.0.14/class/trait/meta.php
r3102226 r3187397 23 23 } 24 24 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; 25 58 } 26 59 … … 903 936 904 937 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 ); 905 940 906 941 if ( ! $id_page ) { 907 942 $id_page = acf_get_valid_post_id(); 908 943 } 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 909 956 $dataACFieldPost = self::get_acf_field_post( $idField ); 910 957 911 // field in a Repeater or in aFlexible content958 // Handle fields within a Repeater or Flexible content 912 959 if ( $dataACFieldPost ) { 913 960 $parentID = $dataACFieldPost->post_parent; 914 961 $parent_settings = self::get_acf_field_settings( $parentID ); 915 962 $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 916 965 if ( ( isset( $parent_settings['type'] ) && ( $parent_settings['type'] == 'repeater' || $parent_settings['type'] == 'flexible_content' ) ) || $custom_in_loop ) { 917 966 $parent_post = get_post( $parentID ); 918 967 $row = acf_get_loop( 'active' ); 968 969 // If not already in a loop, initiate the loop 919 970 if ( ! $row ) { 920 971 if ( have_rows( $parent_post->post_excerpt, $id_page ) ) { … … 929 980 } 930 981 931 // post982 // Retrieve the main field 932 983 $theField = get_field( $idField, $id_page, $format ); 933 984 934 985 if ( ! $theField ) { 935 936 986 $locations = self::get_acf_field_locations( $dataACFieldPost ); 937 987 988 // Check if taxonomy or other locations apply 938 989 if ( is_tax() || is_category() || is_tag() || in_array( 'taxonomy', $locations ) ) { 939 990 $term = get_queried_object(); … … 941 992 } 942 993 994 // Check if author field is applicable 943 995 if ( ! $theField && is_author() ) { 944 996 $author_id = get_the_author_meta( 'ID' ); … … 946 998 } 947 999 1000 // Check if the user or options fields are applicable 948 1001 if ( ! $theField && in_array( 'user', $locations ) ) { 949 1002 $user_id = get_current_user_id(); -
dynamic-visibility-for-elementor/tags/5.0.14/class/trait/navigation.php
r3102226 r3187397 83 83 } 84 84 85 /* -------------------- */86 87 85 // Search and Filter Pro - Navigation 88 86 public static function get_wp_link_page_sf( $i ) { -
dynamic-visibility-for-elementor/tags/5.0.14/class/trait/strings.php
r3102226 r3187397 11 11 $string = preg_replace( '/<\/' . $tag . '>/i', '', $string ); 12 12 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;21 13 } 22 14 -
dynamic-visibility-for-elementor/tags/5.0.14/class/trait/wp.php
r3102226 r3187397 166 166 } 167 167 168 /** 169 * @return array<string> 170 */ 168 171 public static function get_woocommerce_taxonomies() { 169 172 return [ … … 298 301 } 299 302 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 328 303 /** 329 304 * Get Roles … … 347 322 } 348 323 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 }359 324 } 360 325 … … 448 413 } 449 414 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 462 415 public static function get_user_fields( $meta = false, $group = false, $info = true ) { 463 416 $userFieldsKey = array(); … … 560 513 } 561 514 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 581 523 // Check if WPML is installed 582 524 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; 594 536 } 595 537 … … 609 551 if ( $field == 'post_excerpt' || $field == 'excerpt' ) { 610 552 $post = get_post( $post_id ); 611 $postValue = $post->post_excerpt; 553 if ( $post ) { 554 $postValue = $post->post_excerpt; 555 } 612 556 } 613 557 … … 1157 1101 return $array; 1158 1102 } 1159 1160 /**1161 * Convert ACF Post Objects to IDS1162 *1163 * @param object|array<mixed>|void $input1164 *1165 * @return array<mixed>|void1166 */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 }1181 1103 } -
dynamic-visibility-for-elementor/tags/5.0.14/constants.php
r3109242 r3187397 1 1 <?php 2 define( 'DVE_VERSION', '5.0.1 3' );2 define( 'DVE_VERSION', '5.0.14' ); 3 3 define( 'DVE_MINIMUM_ELEMENTOR_VERSION', '2.9.0' ); 4 4 define( 'DVE_PRODUCT_NAME', 'Dynamic Visibility for Elementor' ); -
dynamic-visibility-for-elementor/tags/5.0.14/core/plugin.php
r2983063 r3187397 4 4 use DynamicVisibilityForElementor\Helper; 5 5 6 if ( ! defined( 'ABSPATH' )) {7 exit; // Exit if accessed directly.6 if (!defined("ABSPATH")) { 7 exit(); // Exit if accessed directly. 8 8 } 9 9 … … 13 13 * @since 0.0.1 14 14 */ 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% 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 } 15 class 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% 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 } 225 287 } 226 288 -
dynamic-visibility-for-elementor/tags/5.0.14/dynamic-visibility-for-elementor.php
r3109242 r3187397 5 5 * Description: Visibility rules for widgets, containers, sections, columns or pages with advanced conditions and removing the element from the DOM. 6 6 * 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.1 37 * Version: 5.0.14 8 8 * Author: Dynamic.ooo 9 9 * Author URI: https://www.dynamic.ooo/ … … 13 13 * License: GPL-3.0 14 14 * License URI: http://www.gnu.org/licenses/gpl-3.0.txt 15 * Elementor tested up to: 3.2 1.816 * Elementor Pro tested up to: 3.2 1.315 * Elementor tested up to: 3.25.5 16 * Elementor Pro tested up to: 3.25.2 17 17 * 18 18 * 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 656 656 unset( $_triggers['events'] ); 657 657 } 658 if ( ! Helper::is_myfastapp_active() ) { 659 unset( $_triggers['myfastapp'] ); 660 } 658 661 $element->add_control( 659 662 'dce_visibility_triggers', … … 1320 1323 'label_block' => true, 1321 1324 'query_type' => 'posts', 1325 'dynamic' => [ 1326 'active' => false, 1327 ], 1322 1328 'multiple' => true, 1323 1329 'separator' => 'before', … … 1671 1677 } else { 1672 1678 $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 ] 1679 1685 ); 1680 1686 } … … 1692 1698 ); 1693 1699 } 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 {1708 1700 $element->add_control( 1709 'dce_visibility_myfastapp _notice',1701 'dce_visibility_myfastapp', 1710 1702 [ 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', 1714 1711 ] 1715 1712 ); … … 2617 2614 $ips = array_map( 'trim', $ips ); 2618 2615 ++$triggers_n; 2619 if ( i n_array( $_SERVER['REMOTE_ADDR'], $ips ) ) {2616 if ( isset( $_SERVER['REMOTE_ADDR'] ) && in_array( $_SERVER['REMOTE_ADDR'], $ips ) ) { 2620 2617 $conditions['dce_visibility_ip'] = esc_html__( 'Remote IP', 'dynamic-visibility-for-elementor' ); 2621 2618 } -
dynamic-visibility-for-elementor/tags/5.0.14/modules/query-control/module.php
r3102226 r3187397 5 5 use Elementor\Core\Base\Module as Base_Module; 6 6 use DynamicVisibilityForElementor\Helper; 7 use Elementor\Core\Editor\Editor; 7 8 8 9 if ( ! defined( 'ABSPATH' ) ) { … … 31 32 32 33 public function ajax_call_filter_autocomplete( array $data ) { 34 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 35 throw new \Exception( 'Access denied.' ); 36 } 33 37 34 38 if ( empty( $data['query_type'] ) || empty( $data['q'] ) ) { … … 44 48 45 49 protected function get_options( $data ) { 50 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 51 throw new \Exception( 'Access denied.' ); 52 } 53 46 54 $results = []; 47 55 $fields = Helper::get_options( $data['q'] ); … … 58 66 59 67 protected function get_fields( $data ) { 68 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 69 throw new \Exception( 'Access denied.' ); 70 } 71 60 72 $results = []; 61 73 $object_types = $data['object_type']; … … 88 100 */ 89 101 protected function get_dsh_fields( $data ) { 102 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 103 throw new \Exception( 'Access denied.' ); 104 } 105 90 106 $results = []; 91 107 … … 223 239 224 240 protected function get_terms_fields( $data ) { 241 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 242 throw new \Exception( 'Access denied.' ); 243 } 244 225 245 $results = []; 226 246 $results = $this->get_fields( $data ); … … 240 260 241 261 protected function get_taxonomies_fields( $data ) { 262 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 263 throw new \Exception( 'Access denied.' ); 264 } 265 242 266 $results = []; 243 267 $results = $this->get_fields( $data ); … … 258 282 259 283 protected function get_metas( $data ) { 284 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 285 throw new \Exception( 'Access denied.' ); 286 } 287 260 288 $results = []; 261 289 $function = 'get_' . $data['object_type'] . '_metas'; … … 273 301 274 302 protected function get_pods( $data ) { 303 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 304 throw new \Exception( 'Access denied.' ); 305 } 306 275 307 $results = []; 276 308 $function = 'get_' . $data['object_type'] . '_pods'; … … 288 320 289 321 protected function get_posts( $data ) { 322 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 323 throw new \Exception( 'Access denied.' ); 324 } 325 290 326 $results = []; 291 327 $object_type = $data['object_type'] ?? 'any'; … … 320 356 321 357 protected function get_jet( $data ) { 358 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 359 throw new \Exception( 'Access denied.' ); 360 } 361 322 362 if ( ! Helper::is_jetengine_active() ) { 323 363 return []; … … 370 410 */ 371 411 protected function get_metabox( $data ) { 412 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 413 throw new \Exception( 'Access denied.' ); 414 } 415 372 416 if ( ! Helper::is_metabox_active() ) { 373 417 return []; … … 415 459 */ 416 460 protected function get_metabox_relationship( $data ) { 461 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 462 throw new \Exception( 'Access denied.' ); 463 } 464 417 465 if ( ! Helper::is_metabox_active() ) { 418 466 return []; … … 439 487 440 488 protected function get_acf( $data ) { 489 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 490 throw new \Exception( 'Access denied.' ); 491 } 492 441 493 $results = []; 442 494 $types = ( ! empty( $data['object_type'] ) ) ? $data['object_type'] : array(); … … 465 517 */ 466 518 protected function get_acf_groups( $data ) { 519 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 520 throw new \Exception( 'Access denied.' ); 521 } 522 467 523 $groups = acf_get_field_groups(); 468 524 $results = []; … … 477 533 478 534 protected function get_acf_flexible_content_layouts( $data ) { 535 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 536 throw new \Exception( 'Access denied.' ); 537 } 538 479 539 $groups = acf_get_field_groups(); 480 540 $layouts = []; … … 500 560 501 561 protected function get_acfposts( $data ) { 562 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 563 throw new \Exception( 'Access denied.' ); 564 } 565 502 566 $data['object_type'] = array( 'text', 'textarea', 'select', 'number', 'date_time_picker', 'date_picker', 'oembed', 'file', 'url', 'image', 'wysiwyg' ); 503 567 $results = $this->get_acf( $data ); … … 531 595 532 596 protected function get_terms( $data ) { 597 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 598 throw new \Exception( 'Access denied.' ); 599 } 600 533 601 $results = []; 534 602 $taxonomies = ( ! empty( $data['object_type'] ) ) ? $data['object_type'] : get_object_taxonomies( '' ); … … 554 622 555 623 protected function get_users( $data ) { 624 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 625 throw new \Exception( 'Access denied.' ); 626 } 627 556 628 $results = []; 557 629 … … 591 663 592 664 protected function get_authors( $data ) { 665 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 666 throw new \Exception( 'Access denied.' ); 667 } 668 593 669 $results = []; 594 670 $query_params = [ … … 631 707 */ 632 708 protected function get_value_titles_for_acf( $request ) { 709 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 710 throw new \Exception( 'Access denied.' ); 711 } 712 633 713 $ids = (array) $request['id']; 634 714 $results = []; … … 647 727 */ 648 728 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 649 733 $ids = (array) $request['id']; 650 734 $results = []; … … 660 744 */ 661 745 protected function get_value_titles_for_acfposts( $request ) { 746 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 747 throw new \Exception( 'Access denied.' ); 748 } 749 662 750 $ids = (array) $request['id']; 663 751 $results = $this->get_value_titles_for_acf( $request ); … … 681 769 */ 682 770 protected function get_value_titles_for_metas( $request ) { 771 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 772 throw new \Exception( 'Access denied.' ); 773 } 774 683 775 $ids = (array) $request['id']; 684 776 $results = []; … … 700 792 */ 701 793 protected function get_value_titles_for_fields( $request ) { 794 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 795 throw new \Exception( 'Access denied.' ); 796 } 797 702 798 $ids = (array) $request['id']; 703 799 $results = []; … … 742 838 */ 743 839 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 744 844 return $this->get_value_titles_for_fields( $request ); 745 845 } … … 750 850 */ 751 851 protected function get_value_titles_for_posts( $request ) { 852 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 853 throw new \Exception( 'Access denied.' ); 854 } 855 752 856 $ids = (array) $request['id']; 753 857 $results = []; … … 776 880 /** 777 881 * @param array<string,mixed> $request 778 * @return array<int ,mixed>882 * @return array<int|string,mixed> 779 883 */ 780 884 protected function get_value_titles_for_terms( $request ) { 885 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 886 throw new \Exception( 'Access denied.' ); 887 } 888 781 889 $id = $request['id']; 782 890 $results = []; 891 783 892 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 786 899 return $results; 787 900 } 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 795 911 return $results; 796 912 } … … 802 918 */ 803 919 protected function get_value_titles_for_taxonomies( $request ) { 920 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 921 throw new \Exception( 'Access denied.' ); 922 } 923 804 924 $ids = (array) $request['id']; 805 925 $results = []; … … 822 942 */ 823 943 protected function get_value_titles_for_users( $request ) { 944 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 945 throw new \Exception( 'Access denied.' ); 946 } 947 824 948 $ids = (array) $request['id']; 825 949 $results = []; … … 860 984 */ 861 985 protected function get_value_titles_for_authors( $request ) { 986 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 987 throw new \Exception( 'Access denied.' ); 988 } 989 862 990 $ids = (array) $request['id']; 863 991 $results = []; … … 883 1011 */ 884 1012 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 885 1017 $ids = (array) $request['id']; 886 1018 $ids_post = array(); … … 920 1052 */ 921 1053 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 922 1058 $ids = (array) $request['id']; 923 1059 $ids_post = array(); -
dynamic-visibility-for-elementor/tags/5.0.14/readme.txt
r3109242 r3187397 3 3 Tags: elementor, visibility, hide, dynamic, container, widget 4 4 Requires at least: 5.2 5 Tested up to: 6. 5.55 Tested up to: 6.7 6 6 Requires PHP: 7.1 7 Stable tag: 5.0.1 37 Stable tag: 5.0.14 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 72 72 73 73 == Changelog == 74 75 = 5.0.14 = 76 * Fix: JS error in some cases 74 77 75 78 = 5.0.13 = -
dynamic-visibility-for-elementor/trunk/class/trait/elementor.php
r3102226 r3187397 231 231 return false; 232 232 } 233 233 234 234 public static function set_all_settings_by_id( $element_id = null, $settings = array(), $post_id = null ) { 235 235 if ( ! $post_id ) { 236 236 $post_id = get_the_ID(); 237 if ( ! $post_id ) {237 if ( ! $post_id && isset( $_GET['post'] ) ) { 238 238 $post_id = intval( $_GET['post'] ); 239 239 } 240 240 } 241 241 242 $post_meta = self::get_settings_by_id( null, $post_id ); 242 243 if ( $element_id ) { … … 247 248 } 248 249 $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 253 252 $post_meta_prepared = wp_json_encode( $post_meta ); 254 $post_meta_prepared = wp_slash( $post_meta_prepared );255 253 update_metadata( 'post', $post_id, '_elementor_data', $post_meta_prepared ); 256 254 } 257 255 258 256 public static function set_settings_by_id( $element_id, $key, $value = null, $post_id = null ) { 259 257 if ( ! $post_id ) { 260 258 $post_id = get_the_ID(); 261 if ( ! $post_id ) {259 if ( ! $post_id && isset( $_GET['post'] ) ) { 262 260 $post_id = intval( $_GET['post'] ); 263 261 } 264 262 } 263 265 264 $post_meta = self::get_elementor_data( $post_id ); 266 265 $keys_array = self::array_find_deep( $post_meta, $element_id ); … … 273 272 $keys_array[] = $key; 274 273 $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 278 275 $post_meta_prepared = wp_json_encode( $post_meta ); 279 $post_meta_prepared = wp_slash( $post_meta_prepared );280 276 update_metadata( 'post', $post_id, '_elementor_data', $post_meta_prepared ); 281 277 } 282 278 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;297 279 } 298 280 … … 371 353 372 354 if ( $datasource ) { 373 $id_page = $datasource; 355 $datasource = absint( $datasource ); 356 if ( $datasource > 0 && get_post( $datasource ) ) { 357 $id_page = $datasource; 358 } 374 359 } 375 360 376 361 if ( $id_page && $fromparent ) { 377 362 $the_parent = wp_get_post_parent_id( $id_page ); 378 if ( $the_parent != 0 ) {363 if ( $the_parent !== 0 ) { 379 364 $id_page = $the_parent; 380 365 } 381 366 } 382 367 383 if ( ! $id_page ) {368 if ( !$id_page ) { 384 369 global $wp; 385 370 $current_url = home_url( add_query_arg( array(), $wp->request ) ); … … 387 372 } 388 373 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 ); 414 377 } 415 378 … … 472 435 return $icon_html; 473 436 } 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 507 438 public static function get_elements_from_elementor_data( $elementor_data, $type = '' ) { 508 439 $elements = array(); … … 563 494 } 564 495 } 496 -
dynamic-visibility-for-elementor/trunk/class/trait/filesystem.php
r3102226 r3187397 4 4 trait Filesystem { 5 5 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 ); 22 9 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 25 40 return false; 26 41 } 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; 37 44 } 38 45 } -
dynamic-visibility-for-elementor/trunk/class/trait/form.php
r3102226 r3187397 132 132 } 133 133 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 156 134 public static function form_field_value( $arr = array(), $default = null ) { 157 135 $str = ''; -
dynamic-visibility-for-elementor/trunk/class/trait/image.php
r3102226 r3187397 3 3 4 4 trait 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 }16 5 17 6 public static function is_resized_image( $imagePath ) { … … 33 22 public static function get_image_id( $image_url ) { 34 23 global $wpdb; 35 $sql = $wpdb->prepare( "SELECT ID FROM {$wpdb->p refix}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;", 36 25 '%' . $wpdb->esc_like( $image_url ) . '%' 37 26 ); 27 38 28 $attachment = $wpdb->get_col( $sql ); 39 29 $img_id = reset( $attachment ); … … 54 44 */ 55 45 public static function get_image_alt( int $attachment_ID ) { 46 if ( ! get_post( $attachment_ID ) ) { 47 return ''; 48 } 56 49 $alt = get_post_meta( $attachment_ID, '_wp_attachment_image_alt', true ); 57 50 if ( ! empty( $alt ) ) { … … 61 54 } 62 55 56 63 57 /** 64 * Get Attachment58 * Get Image Attachment 65 59 * 66 60 * @param string|int $attachment_id 67 61 * @return array<string,mixed>|null 68 62 */ 69 public static function get_ attachment( $attachment_id ) {63 public static function get_image_attachment( $attachment_id ) { 70 64 $attachment_id = intval( $attachment_id ); // phpstan 71 65 if ( ! $attachment_id ) { … … 75 69 $attachment = get_post( $attachment_id ); 76 70 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 ) ) { 77 79 return null; 78 80 } … … 88 90 'caption' => wp_kses_post( $attachment->post_excerpt ), 89 91 '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] ), 92 94 '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] ), 96 98 ]; 97 99 } -
dynamic-visibility-for-elementor/trunk/class/trait/meta.php
r3102226 r3187397 23 23 } 24 24 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; 25 58 } 26 59 … … 903 936 904 937 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 ); 905 940 906 941 if ( ! $id_page ) { 907 942 $id_page = acf_get_valid_post_id(); 908 943 } 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 909 956 $dataACFieldPost = self::get_acf_field_post( $idField ); 910 957 911 // field in a Repeater or in aFlexible content958 // Handle fields within a Repeater or Flexible content 912 959 if ( $dataACFieldPost ) { 913 960 $parentID = $dataACFieldPost->post_parent; 914 961 $parent_settings = self::get_acf_field_settings( $parentID ); 915 962 $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 916 965 if ( ( isset( $parent_settings['type'] ) && ( $parent_settings['type'] == 'repeater' || $parent_settings['type'] == 'flexible_content' ) ) || $custom_in_loop ) { 917 966 $parent_post = get_post( $parentID ); 918 967 $row = acf_get_loop( 'active' ); 968 969 // If not already in a loop, initiate the loop 919 970 if ( ! $row ) { 920 971 if ( have_rows( $parent_post->post_excerpt, $id_page ) ) { … … 929 980 } 930 981 931 // post982 // Retrieve the main field 932 983 $theField = get_field( $idField, $id_page, $format ); 933 984 934 985 if ( ! $theField ) { 935 936 986 $locations = self::get_acf_field_locations( $dataACFieldPost ); 937 987 988 // Check if taxonomy or other locations apply 938 989 if ( is_tax() || is_category() || is_tag() || in_array( 'taxonomy', $locations ) ) { 939 990 $term = get_queried_object(); … … 941 992 } 942 993 994 // Check if author field is applicable 943 995 if ( ! $theField && is_author() ) { 944 996 $author_id = get_the_author_meta( 'ID' ); … … 946 998 } 947 999 1000 // Check if the user or options fields are applicable 948 1001 if ( ! $theField && in_array( 'user', $locations ) ) { 949 1002 $user_id = get_current_user_id(); -
dynamic-visibility-for-elementor/trunk/class/trait/navigation.php
r3102226 r3187397 83 83 } 84 84 85 /* -------------------- */86 87 85 // Search and Filter Pro - Navigation 88 86 public static function get_wp_link_page_sf( $i ) { -
dynamic-visibility-for-elementor/trunk/class/trait/strings.php
r3102226 r3187397 11 11 $string = preg_replace( '/<\/' . $tag . '>/i', '', $string ); 12 12 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;21 13 } 22 14 -
dynamic-visibility-for-elementor/trunk/class/trait/wp.php
r3102226 r3187397 166 166 } 167 167 168 /** 169 * @return array<string> 170 */ 168 171 public static function get_woocommerce_taxonomies() { 169 172 return [ … … 298 301 } 299 302 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 328 303 /** 329 304 * Get Roles … … 347 322 } 348 323 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 }359 324 } 360 325 … … 448 413 } 449 414 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 462 415 public static function get_user_fields( $meta = false, $group = false, $info = true ) { 463 416 $userFieldsKey = array(); … … 560 513 } 561 514 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 581 523 // Check if WPML is installed 582 524 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; 594 536 } 595 537 … … 609 551 if ( $field == 'post_excerpt' || $field == 'excerpt' ) { 610 552 $post = get_post( $post_id ); 611 $postValue = $post->post_excerpt; 553 if ( $post ) { 554 $postValue = $post->post_excerpt; 555 } 612 556 } 613 557 … … 1157 1101 return $array; 1158 1102 } 1159 1160 /**1161 * Convert ACF Post Objects to IDS1162 *1163 * @param object|array<mixed>|void $input1164 *1165 * @return array<mixed>|void1166 */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 }1181 1103 } -
dynamic-visibility-for-elementor/trunk/constants.php
r3109242 r3187397 1 1 <?php 2 define( 'DVE_VERSION', '5.0.1 3' );2 define( 'DVE_VERSION', '5.0.14' ); 3 3 define( 'DVE_MINIMUM_ELEMENTOR_VERSION', '2.9.0' ); 4 4 define( 'DVE_PRODUCT_NAME', 'Dynamic Visibility for Elementor' ); -
dynamic-visibility-for-elementor/trunk/core/plugin.php
r2983063 r3187397 4 4 use DynamicVisibilityForElementor\Helper; 5 5 6 if ( ! defined( 'ABSPATH' )) {7 exit; // Exit if accessed directly.6 if (!defined("ABSPATH")) { 7 exit(); // Exit if accessed directly. 8 8 } 9 9 … … 13 13 * @since 0.0.1 14 14 */ 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% 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 } 15 class 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% 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 } 225 287 } 226 288 -
dynamic-visibility-for-elementor/trunk/dynamic-visibility-for-elementor.php
r3109242 r3187397 5 5 * Description: Visibility rules for widgets, containers, sections, columns or pages with advanced conditions and removing the element from the DOM. 6 6 * 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.1 37 * Version: 5.0.14 8 8 * Author: Dynamic.ooo 9 9 * Author URI: https://www.dynamic.ooo/ … … 13 13 * License: GPL-3.0 14 14 * License URI: http://www.gnu.org/licenses/gpl-3.0.txt 15 * Elementor tested up to: 3.2 1.816 * Elementor Pro tested up to: 3.2 1.315 * Elementor tested up to: 3.25.5 16 * Elementor Pro tested up to: 3.25.2 17 17 * 18 18 * This program is free software: you can redistribute it and/or modify -
dynamic-visibility-for-elementor/trunk/includes/extensions/dynamic-visibility.php
r3109215 r3187397 656 656 unset( $_triggers['events'] ); 657 657 } 658 if ( ! Helper::is_myfastapp_active() ) { 659 unset( $_triggers['myfastapp'] ); 660 } 658 661 $element->add_control( 659 662 'dce_visibility_triggers', … … 1320 1323 'label_block' => true, 1321 1324 'query_type' => 'posts', 1325 'dynamic' => [ 1326 'active' => false, 1327 ], 1322 1328 'multiple' => true, 1323 1329 'separator' => 'before', … … 1671 1677 } else { 1672 1678 $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 ] 1679 1685 ); 1680 1686 } … … 1692 1698 ); 1693 1699 } 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 {1708 1700 $element->add_control( 1709 'dce_visibility_myfastapp _notice',1701 'dce_visibility_myfastapp', 1710 1702 [ 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', 1714 1711 ] 1715 1712 ); … … 2617 2614 $ips = array_map( 'trim', $ips ); 2618 2615 ++$triggers_n; 2619 if ( i n_array( $_SERVER['REMOTE_ADDR'], $ips ) ) {2616 if ( isset( $_SERVER['REMOTE_ADDR'] ) && in_array( $_SERVER['REMOTE_ADDR'], $ips ) ) { 2620 2617 $conditions['dce_visibility_ip'] = esc_html__( 'Remote IP', 'dynamic-visibility-for-elementor' ); 2621 2618 } -
dynamic-visibility-for-elementor/trunk/modules/query-control/module.php
r3102226 r3187397 5 5 use Elementor\Core\Base\Module as Base_Module; 6 6 use DynamicVisibilityForElementor\Helper; 7 use Elementor\Core\Editor\Editor; 7 8 8 9 if ( ! defined( 'ABSPATH' ) ) { … … 31 32 32 33 public function ajax_call_filter_autocomplete( array $data ) { 34 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 35 throw new \Exception( 'Access denied.' ); 36 } 33 37 34 38 if ( empty( $data['query_type'] ) || empty( $data['q'] ) ) { … … 44 48 45 49 protected function get_options( $data ) { 50 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 51 throw new \Exception( 'Access denied.' ); 52 } 53 46 54 $results = []; 47 55 $fields = Helper::get_options( $data['q'] ); … … 58 66 59 67 protected function get_fields( $data ) { 68 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 69 throw new \Exception( 'Access denied.' ); 70 } 71 60 72 $results = []; 61 73 $object_types = $data['object_type']; … … 88 100 */ 89 101 protected function get_dsh_fields( $data ) { 102 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 103 throw new \Exception( 'Access denied.' ); 104 } 105 90 106 $results = []; 91 107 … … 223 239 224 240 protected function get_terms_fields( $data ) { 241 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 242 throw new \Exception( 'Access denied.' ); 243 } 244 225 245 $results = []; 226 246 $results = $this->get_fields( $data ); … … 240 260 241 261 protected function get_taxonomies_fields( $data ) { 262 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 263 throw new \Exception( 'Access denied.' ); 264 } 265 242 266 $results = []; 243 267 $results = $this->get_fields( $data ); … … 258 282 259 283 protected function get_metas( $data ) { 284 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 285 throw new \Exception( 'Access denied.' ); 286 } 287 260 288 $results = []; 261 289 $function = 'get_' . $data['object_type'] . '_metas'; … … 273 301 274 302 protected function get_pods( $data ) { 303 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 304 throw new \Exception( 'Access denied.' ); 305 } 306 275 307 $results = []; 276 308 $function = 'get_' . $data['object_type'] . '_pods'; … … 288 320 289 321 protected function get_posts( $data ) { 322 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 323 throw new \Exception( 'Access denied.' ); 324 } 325 290 326 $results = []; 291 327 $object_type = $data['object_type'] ?? 'any'; … … 320 356 321 357 protected function get_jet( $data ) { 358 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 359 throw new \Exception( 'Access denied.' ); 360 } 361 322 362 if ( ! Helper::is_jetengine_active() ) { 323 363 return []; … … 370 410 */ 371 411 protected function get_metabox( $data ) { 412 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 413 throw new \Exception( 'Access denied.' ); 414 } 415 372 416 if ( ! Helper::is_metabox_active() ) { 373 417 return []; … … 415 459 */ 416 460 protected function get_metabox_relationship( $data ) { 461 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 462 throw new \Exception( 'Access denied.' ); 463 } 464 417 465 if ( ! Helper::is_metabox_active() ) { 418 466 return []; … … 439 487 440 488 protected function get_acf( $data ) { 489 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 490 throw new \Exception( 'Access denied.' ); 491 } 492 441 493 $results = []; 442 494 $types = ( ! empty( $data['object_type'] ) ) ? $data['object_type'] : array(); … … 465 517 */ 466 518 protected function get_acf_groups( $data ) { 519 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 520 throw new \Exception( 'Access denied.' ); 521 } 522 467 523 $groups = acf_get_field_groups(); 468 524 $results = []; … … 477 533 478 534 protected function get_acf_flexible_content_layouts( $data ) { 535 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 536 throw new \Exception( 'Access denied.' ); 537 } 538 479 539 $groups = acf_get_field_groups(); 480 540 $layouts = []; … … 500 560 501 561 protected function get_acfposts( $data ) { 562 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 563 throw new \Exception( 'Access denied.' ); 564 } 565 502 566 $data['object_type'] = array( 'text', 'textarea', 'select', 'number', 'date_time_picker', 'date_picker', 'oembed', 'file', 'url', 'image', 'wysiwyg' ); 503 567 $results = $this->get_acf( $data ); … … 531 595 532 596 protected function get_terms( $data ) { 597 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 598 throw new \Exception( 'Access denied.' ); 599 } 600 533 601 $results = []; 534 602 $taxonomies = ( ! empty( $data['object_type'] ) ) ? $data['object_type'] : get_object_taxonomies( '' ); … … 554 622 555 623 protected function get_users( $data ) { 624 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 625 throw new \Exception( 'Access denied.' ); 626 } 627 556 628 $results = []; 557 629 … … 591 663 592 664 protected function get_authors( $data ) { 665 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 666 throw new \Exception( 'Access denied.' ); 667 } 668 593 669 $results = []; 594 670 $query_params = [ … … 631 707 */ 632 708 protected function get_value_titles_for_acf( $request ) { 709 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 710 throw new \Exception( 'Access denied.' ); 711 } 712 633 713 $ids = (array) $request['id']; 634 714 $results = []; … … 647 727 */ 648 728 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 649 733 $ids = (array) $request['id']; 650 734 $results = []; … … 660 744 */ 661 745 protected function get_value_titles_for_acfposts( $request ) { 746 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 747 throw new \Exception( 'Access denied.' ); 748 } 749 662 750 $ids = (array) $request['id']; 663 751 $results = $this->get_value_titles_for_acf( $request ); … … 681 769 */ 682 770 protected function get_value_titles_for_metas( $request ) { 771 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 772 throw new \Exception( 'Access denied.' ); 773 } 774 683 775 $ids = (array) $request['id']; 684 776 $results = []; … … 700 792 */ 701 793 protected function get_value_titles_for_fields( $request ) { 794 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 795 throw new \Exception( 'Access denied.' ); 796 } 797 702 798 $ids = (array) $request['id']; 703 799 $results = []; … … 742 838 */ 743 839 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 744 844 return $this->get_value_titles_for_fields( $request ); 745 845 } … … 750 850 */ 751 851 protected function get_value_titles_for_posts( $request ) { 852 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 853 throw new \Exception( 'Access denied.' ); 854 } 855 752 856 $ids = (array) $request['id']; 753 857 $results = []; … … 776 880 /** 777 881 * @param array<string,mixed> $request 778 * @return array<int ,mixed>882 * @return array<int|string,mixed> 779 883 */ 780 884 protected function get_value_titles_for_terms( $request ) { 885 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 886 throw new \Exception( 'Access denied.' ); 887 } 888 781 889 $id = $request['id']; 782 890 $results = []; 891 783 892 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 786 899 return $results; 787 900 } 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 795 911 return $results; 796 912 } … … 802 918 */ 803 919 protected function get_value_titles_for_taxonomies( $request ) { 920 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 921 throw new \Exception( 'Access denied.' ); 922 } 923 804 924 $ids = (array) $request['id']; 805 925 $results = []; … … 822 942 */ 823 943 protected function get_value_titles_for_users( $request ) { 944 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 945 throw new \Exception( 'Access denied.' ); 946 } 947 824 948 $ids = (array) $request['id']; 825 949 $results = []; … … 860 984 */ 861 985 protected function get_value_titles_for_authors( $request ) { 986 if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { 987 throw new \Exception( 'Access denied.' ); 988 } 989 862 990 $ids = (array) $request['id']; 863 991 $results = []; … … 883 1011 */ 884 1012 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 885 1017 $ids = (array) $request['id']; 886 1018 $ids_post = array(); … … 920 1052 */ 921 1053 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 922 1058 $ids = (array) $request['id']; 923 1059 $ids_post = array(); -
dynamic-visibility-for-elementor/trunk/readme.txt
r3109242 r3187397 3 3 Tags: elementor, visibility, hide, dynamic, container, widget 4 4 Requires at least: 5.2 5 Tested up to: 6. 5.55 Tested up to: 6.7 6 6 Requires PHP: 7.1 7 Stable tag: 5.0.1 37 Stable tag: 5.0.14 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 72 72 73 73 == Changelog == 74 75 = 5.0.14 = 76 * Fix: JS error in some cases 74 77 75 78 = 5.0.13 =
Note: See TracChangeset
for help on using the changeset viewer.