Fns.php
2861 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Helper class. |
| 4 | * |
| 5 | * @package RT_TPG |
| 6 | */ |
| 7 | |
| 8 | namespace RT\ThePostGrid\Helpers; |
| 9 | |
| 10 | use RT\ThePostGrid\Models\Field; |
| 11 | use RT\ThePostGrid\Models\ReSizer; |
| 12 | use RT\ThePostGridPro\Helpers\Functions; |
| 13 | |
| 14 | // Do not allow directly accessing this file. |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | exit( 'This script cannot be accessed directly.' ); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Helper class. |
| 21 | */ |
| 22 | class Fns { |
| 23 | |
| 24 | /** |
| 25 | * Get Ajax URL. |
| 26 | * |
| 27 | * @return string |
| 28 | */ |
| 29 | public function ajax_url() { |
| 30 | return admin_url( 'admin-ajax.php', 'relative' ); |
| 31 | } |
| 32 | |
| 33 | |
| 34 | /** |
| 35 | * Render view |
| 36 | * |
| 37 | * @param string $viewName View name. |
| 38 | * @param array $args Args. |
| 39 | * @param boolean $return Include/return. |
| 40 | * @return string |
| 41 | */ |
| 42 | public static function view( $viewName, $args = [], $return = false ) { |
| 43 | $file = str_replace( '.', '/', $viewName ); |
| 44 | $file = ltrim( $file, '/' ); |
| 45 | $viewFile = trailingslashit( RT_THE_POST_GRID_PLUGIN_PATH . '/resources' ) . $file . '.php'; |
| 46 | |
| 47 | if ( ! file_exists( $viewFile ) ) { |
| 48 | return new \WP_Error( |
| 49 | 'brock', |
| 50 | sprintf( |
| 51 | /* translators: %s File name */ |
| 52 | esc_html__( '%s file not found', 'the-post-grid' ), |
| 53 | $viewFile |
| 54 | ) |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | if ( $args ) { |
| 59 | extract( $args ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
| 60 | } |
| 61 | |
| 62 | if ( $return ) { |
| 63 | ob_start(); |
| 64 | include $viewFile; |
| 65 | |
| 66 | return ob_get_clean(); |
| 67 | } |
| 68 | |
| 69 | include $viewFile; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Update post view |
| 74 | * |
| 75 | * @param integer $post_id Listing ID. |
| 76 | * @return void |
| 77 | */ |
| 78 | public static function update_post_views_count( $post_id ) { |
| 79 | if ( ! $post_id && is_admin() ) { |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | $user_ip = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); // retrieve the current IP address of the visitor. |
| 84 | $key = 'tpg_cache_' . $user_ip . '_' . $post_id; |
| 85 | $value = [ $user_ip, $post_id ]; |
| 86 | $visited = get_transient( $key ); |
| 87 | |
| 88 | if ( false === ( $visited ) ) { |
| 89 | set_transient( $key, $value, HOUR_IN_SECONDS * 12 ); // store the unique key, Post ID & IP address for 12 hours if it does not exist. |
| 90 | |
| 91 | // now run post views function. |
| 92 | $count_key = self::get_post_view_count_meta_key(); |
| 93 | $count = get_post_meta( $post_id, $count_key, true ); |
| 94 | |
| 95 | if ( '' == $count ) { |
| 96 | update_post_meta( $post_id, $count_key, 1 ); |
| 97 | } else { |
| 98 | $count = absint( $count ); |
| 99 | $count ++; |
| 100 | |
| 101 | update_post_meta( $post_id, $count_key, $count ); |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Template Content |
| 108 | * |
| 109 | * @param string $template_name Template name. |
| 110 | * @param array $args Arguments. (default: array). |
| 111 | * @param string $template_path Template path. (default: ''). |
| 112 | * @param string $default_path Default path. (default: ''). |
| 113 | */ |
| 114 | public static function get_template( $template_name, $args = null, $template_path = '', $default_path = '' ) { |
| 115 | if ( ! empty( $args ) && is_array( $args ) ) { |
| 116 | extract( $args ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
| 117 | } |
| 118 | |
| 119 | $located = self::locate_template( $template_name, $template_path, $default_path ); |
| 120 | |
| 121 | if ( ! file_exists( $located ) ) { |
| 122 | /* translators: %s template */ |
| 123 | self::doing_it_wrong( __FUNCTION__, sprintf( esc_html__( '%s does not exist.', 'the-post-grid' ), '<code>' . $located . '</code>' ), '1.0' ); |
| 124 | |
| 125 | return; |
| 126 | } |
| 127 | |
| 128 | // Allow 3rd party plugin filter template file from their plugin. |
| 129 | $located = apply_filters( 'rttpg_get_template', $located, $template_name, $args ); |
| 130 | |
| 131 | do_action( 'rttpg_before_template_part', $template_name, $located, $args ); |
| 132 | |
| 133 | include $located; |
| 134 | |
| 135 | do_action( 'rttpg_after_template_part', $template_name, $located, $args ); |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Get template content and return |
| 140 | * |
| 141 | * @param string $template_name Template name. |
| 142 | * @param array $args Arguments. (default: array). |
| 143 | * @param string $template_path Template path. (default: ''). |
| 144 | * @param string $default_path Default path. (default: ''). |
| 145 | * |
| 146 | * @return string |
| 147 | */ |
| 148 | public static function get_template_html( $template_name, $args = [], $template_path = '', $default_path = '' ) { |
| 149 | ob_start(); |
| 150 | self::get_template( $template_name, $args, $template_path, $default_path ); |
| 151 | |
| 152 | return ob_get_clean(); |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Locate template. |
| 157 | * |
| 158 | * @param string $template_name Template. |
| 159 | * @param string $template_path Path. |
| 160 | * @param string $default_path Default path. |
| 161 | * @return mixed|void |
| 162 | */ |
| 163 | public static function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
| 164 | $template_name = $template_name . '.php'; |
| 165 | |
| 166 | if ( ! $template_path ) { |
| 167 | $template_path = rtTPG()->get_template_path(); |
| 168 | } |
| 169 | |
| 170 | if ( ! $default_path ) { |
| 171 | $default_path = rtTPG()->default_template_path() . '/templates/'; |
| 172 | } |
| 173 | |
| 174 | // Look within passed path within the theme - this is priority. |
| 175 | $template_files = []; |
| 176 | $template_files[] = trailingslashit( $template_path ) . $template_name; |
| 177 | |
| 178 | $template = locate_template( apply_filters( 'rttpg_locate_template_files', $template_files, $template_name, $template_path, $default_path ) ); |
| 179 | |
| 180 | // Get default template/. |
| 181 | if ( ! $template ) { |
| 182 | $template = trailingslashit( $default_path ) . $template_name; |
| 183 | } |
| 184 | |
| 185 | return apply_filters( 'rttpg_locate_template', $template, $template_name ); |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Mark something as being incorrectly called. |
| 190 | * |
| 191 | * @param string $function — The function that was called. |
| 192 | * @param string $message — A message explaining what has been done incorrectly. |
| 193 | * @param string $version — The version of WordPress where the message was added. |
| 194 | * @return void |
| 195 | */ |
| 196 | public static function doing_it_wrong( $function, $message, $version ) { |
| 197 | // phpcs:disable |
| 198 | $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
| 199 | _doing_it_wrong( $function, $message, $version ); |
| 200 | // phpcs:enable |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * Verify nonce. |
| 205 | * |
| 206 | * @return bool |
| 207 | */ |
| 208 | public static function verifyNonce() { |
| 209 | $nonce = isset( $_REQUEST[ rtTPG()->nonceId() ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ rtTPG()->nonceId() ] ) ) : null; |
| 210 | $nonceText = rtTPG()->nonceText(); |
| 211 | |
| 212 | if ( ! wp_verify_nonce( $nonce, $nonceText ) ) { |
| 213 | return false; |
| 214 | } |
| 215 | |
| 216 | return true; |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * All settings. |
| 221 | * |
| 222 | * @return array |
| 223 | */ |
| 224 | public static function rtAllOptionFields() { |
| 225 | $fields = array_merge( |
| 226 | Options::rtTPGCommonFilterFields(), |
| 227 | Options::rtTPGLayoutSettingFields(), |
| 228 | Options::responsiveSettingsColumn(), |
| 229 | Options::layoutMiscSettings(), |
| 230 | Options::stickySettings(), |
| 231 | // settings. |
| 232 | Options::rtTPGSCHeadingSettings(), |
| 233 | Options::rtTPGSCCategorySettings(), |
| 234 | Options::rtTPGSCTitleSettings(), |
| 235 | Options::rtTPGSCMetaSettings(), |
| 236 | Options::rtTPGSCImageSettings(), |
| 237 | Options::rtTPGSCExcerptSettings(), |
| 238 | Options::rtTPGSCButtonSettings(), |
| 239 | // style. |
| 240 | Options::rtTPGStyleFields(), |
| 241 | Options::rtTPGStyleHeading(), |
| 242 | Options::rtTPGStyleFullArea(), |
| 243 | Options::rtTPGStyleContentWrap(), |
| 244 | Options::rtTPGStyleCategory(), |
| 245 | Options::rtTPGPostType(), |
| 246 | Options::rtTPGStyleButtonColorFields(), |
| 247 | Options::rtTPAdvanceFilters(), |
| 248 | Options::itemFields() |
| 249 | ); |
| 250 | |
| 251 | return $fields; |
| 252 | } |
| 253 | |
| 254 | public static function rt_get_all_term_by_taxonomy( $taxonomy = null, $count = false, $parent = false ) { |
| 255 | $terms = []; |
| 256 | |
| 257 | if ( $taxonomy ) { |
| 258 | $temp_terms = get_terms( |
| 259 | [ |
| 260 | 'taxonomy' => $taxonomy, |
| 261 | 'hide_empty' => 0, |
| 262 | ] |
| 263 | ); |
| 264 | |
| 265 | if ( is_array( $temp_terms ) && ! empty( $temp_terms ) && empty( $temp_terms['errors'] ) ) { |
| 266 | foreach ( $temp_terms as $term ) { |
| 267 | $order = get_term_meta( $term->term_id, '_rt_order', true ); |
| 268 | if ( $order === '' ) { |
| 269 | update_term_meta( $term->term_id, '_rt_order', 0 ); |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | global $wp_version; |
| 274 | |
| 275 | $args = [ |
| 276 | 'taxonomy' => $taxonomy, |
| 277 | 'orderby' => 'meta_value_num', |
| 278 | 'meta_key' => '_rt_order', |
| 279 | 'hide_empty' => false, |
| 280 | ]; |
| 281 | |
| 282 | if ( $parent >= 0 && $parent !== false ) { |
| 283 | $args['parent'] = absint( $parent ); |
| 284 | } |
| 285 | |
| 286 | $args['orderby'] = 'meta_value_num'; |
| 287 | $args['meta_key'] = '_rt_order'; |
| 288 | |
| 289 | $termObjs = get_terms( $args ); |
| 290 | |
| 291 | foreach ( $termObjs as $term ) { |
| 292 | if ( $count ) { |
| 293 | $terms[ $term->term_id ] = [ |
| 294 | 'name' => $term->name, |
| 295 | 'count' => $term->count, |
| 296 | ]; |
| 297 | } else { |
| 298 | $terms[ $term->term_id ] = $term->name; |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | return $terms; |
| 305 | } |
| 306 | |
| 307 | public static function rt_get_selected_term_by_taxonomy( $taxonomy = null, $include = [], $count = false, $parent = false ) { |
| 308 | $terms = []; |
| 309 | |
| 310 | if ( $taxonomy ) { |
| 311 | $temp_terms = get_terms( |
| 312 | [ |
| 313 | 'taxonomy' => $taxonomy, |
| 314 | 'hide_empty' => 0, |
| 315 | ] |
| 316 | ); |
| 317 | |
| 318 | if ( is_array( $temp_terms ) && ! empty( $temp_terms ) && empty( $temp_terms['errors'] ) ) { |
| 319 | foreach ( $temp_terms as $term ) { |
| 320 | $order = get_term_meta( $term->term_id, '_rt_order', true ); |
| 321 | if ( $order === '' ) { |
| 322 | update_term_meta( $term->term_id, '_rt_order', 0 ); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | global $wp_version; |
| 327 | |
| 328 | $args = [ |
| 329 | 'taxonomy' => $taxonomy, |
| 330 | 'orderby' => 'meta_value_num', |
| 331 | 'meta_key' => '_rt_order', |
| 332 | 'include' => $include, |
| 333 | 'hide_empty' => false, |
| 334 | ]; |
| 335 | |
| 336 | if ( $parent >= 0 && $parent !== false ) { |
| 337 | $args['parent'] = absint( $parent ); |
| 338 | } |
| 339 | |
| 340 | $args['orderby'] = 'meta_value_num'; |
| 341 | $args['meta_key'] = '_rt_order'; |
| 342 | |
| 343 | $termObjs = get_terms( $args ); |
| 344 | |
| 345 | foreach ( $termObjs as $term ) { |
| 346 | if ( $count ) { |
| 347 | $terms[ $term->term_id ] = [ |
| 348 | 'name' => $term->name, |
| 349 | 'count' => $term->count, |
| 350 | ]; |
| 351 | } else { |
| 352 | $terms[ $term->term_id ] = $term->name; |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | return $terms; |
| 359 | } |
| 360 | |
| 361 | public static function getCurrentUserRoles() { |
| 362 | global $current_user; |
| 363 | |
| 364 | return $current_user->roles; |
| 365 | } |
| 366 | |
| 367 | public static function rt_get_taxonomy_for_filter( $post_type = null ) { |
| 368 | if ( ! $post_type ) { |
| 369 | $post_type = get_post_meta( get_the_ID(), 'tpg_post_type', true ); |
| 370 | } |
| 371 | |
| 372 | if ( ! $post_type ) { |
| 373 | $post_type = 'post'; |
| 374 | } |
| 375 | |
| 376 | return self::rt_get_all_taxonomy_by_post_type( $post_type ); |
| 377 | } |
| 378 | |
| 379 | public static function rt_get_all_taxonomy_by_post_type( $post_type = null ) { |
| 380 | $taxonomies = []; |
| 381 | |
| 382 | if ( $post_type && post_type_exists( $post_type ) ) { |
| 383 | $taxObj = get_object_taxonomies( $post_type, 'objects' ); |
| 384 | |
| 385 | if ( is_array( $taxObj ) && ! empty( $taxObj ) ) { |
| 386 | foreach ( $taxObj as $tKey => $taxonomy ) { |
| 387 | $taxonomies[ $tKey ] = $taxonomy->label; |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | if ( $post_type == 'post' ) { |
| 393 | unset( $taxonomies['post_format'] ); |
| 394 | } |
| 395 | |
| 396 | return $taxonomies; |
| 397 | } |
| 398 | |
| 399 | public static function rt_get_users() { |
| 400 | $users = []; |
| 401 | $u = get_users( apply_filters( 'tpg_author_arg', [] ) ); |
| 402 | |
| 403 | if ( ! empty( $u ) ) { |
| 404 | foreach ( $u as $user ) { |
| 405 | $users[ $user->ID ] = $user->display_name; |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | return $users; |
| 410 | } |
| 411 | |
| 412 | public static function rtFieldGenerator( $fields = [] ) { |
| 413 | $html = null; |
| 414 | |
| 415 | if ( is_array( $fields ) && ! empty( $fields ) ) { |
| 416 | $tpgField = new Field(); |
| 417 | foreach ( $fields as $fieldKey => $field ) { |
| 418 | $html .= $tpgField->Field( $fieldKey, $field ); |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | return $html; |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * Sanitize field value |
| 427 | * |
| 428 | * @param array $field |
| 429 | * @param null $value |
| 430 | * |
| 431 | * @return array|null |
| 432 | * @internal param $value |
| 433 | */ |
| 434 | public static function sanitize( $field = [], $value = null ) { |
| 435 | $newValue = null; |
| 436 | |
| 437 | if ( is_array( $field ) ) { |
| 438 | $type = ( ! empty( $field['type'] ) ? $field['type'] : 'text' ); |
| 439 | |
| 440 | if ( empty( $field['multiple'] ) ) { |
| 441 | if ( $type == 'text' || $type == 'number' || $type == 'select' || $type == 'checkbox' || $type == 'radio' ) { |
| 442 | $newValue = sanitize_text_field( $value ); |
| 443 | } elseif ( $type == 'url' ) { |
| 444 | $newValue = esc_url( $value ); |
| 445 | } elseif ( $type == 'slug' ) { |
| 446 | $newValue = sanitize_title_with_dashes( $value ); |
| 447 | } elseif ( $type == 'textarea' ) { |
| 448 | $newValue = wp_kses_post( $value ); |
| 449 | } elseif ( $type == 'script' ) { |
| 450 | $newValue = trim( $value ); |
| 451 | } elseif ( $type == 'colorpicker' ) { |
| 452 | $newValue = self::sanitize_hex_color( $value ); |
| 453 | } elseif ( $type == 'image_size' ) { |
| 454 | $newValue = []; |
| 455 | |
| 456 | foreach ( $value as $k => $v ) { |
| 457 | $newValue[ $k ] = esc_attr( $v ); |
| 458 | } |
| 459 | } elseif ( $type == 'style' ) { |
| 460 | $newValue = []; |
| 461 | |
| 462 | foreach ( $value as $k => $v ) { |
| 463 | if ( $k == 'color' ) { |
| 464 | $newValue[ $k ] = self::sanitize_hex_color( $v ); |
| 465 | } else { |
| 466 | $newValue[ $k ] = self::sanitize( [ 'type' => 'text' ], $v ); |
| 467 | } |
| 468 | } |
| 469 | } else { |
| 470 | $newValue = sanitize_text_field( $value ); |
| 471 | } |
| 472 | } else { |
| 473 | $newValue = []; |
| 474 | |
| 475 | if ( ! empty( $value ) ) { |
| 476 | if ( is_array( $value ) ) { |
| 477 | foreach ( $value as $key => $val ) { |
| 478 | if ( $type == 'style' && $key == 0 ) { |
| 479 | if ( function_exists( 'sanitize_hex_color' ) ) { |
| 480 | $newValue = sanitize_hex_color( $val ); |
| 481 | } else { |
| 482 | $newValue[] = self::sanitize_hex_color( $val ); |
| 483 | } |
| 484 | } else { |
| 485 | $newValue[] = sanitize_text_field( $val ); |
| 486 | } |
| 487 | } |
| 488 | } else { |
| 489 | $newValue[] = sanitize_text_field( $value ); |
| 490 | } |
| 491 | } |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | return $newValue; |
| 496 | } |
| 497 | |
| 498 | public static function sanitize_hex_color( $color ) { |
| 499 | if ( function_exists( 'sanitize_hex_color' ) ) { |
| 500 | return sanitize_hex_color( $color ); |
| 501 | } else { |
| 502 | if ( '' === $color ) { |
| 503 | return ''; |
| 504 | } |
| 505 | |
| 506 | // 3 or 6 hex digits, or the empty string. |
| 507 | if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) { |
| 508 | return $color; |
| 509 | } |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | public static function rtFieldGeneratorBackup( $fields = [], $multi = false ) { |
| 514 | $html = null; |
| 515 | |
| 516 | if ( is_array( $fields ) && ! empty( $fields ) ) { |
| 517 | $rtField = new Field(); |
| 518 | |
| 519 | if ( $multi ) { |
| 520 | foreach ( $fields as $field ) { |
| 521 | $html .= $rtField->Field( $field ); |
| 522 | } |
| 523 | } else { |
| 524 | $html .= $rtField->Field( $fields ); |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | return $html; |
| 529 | } |
| 530 | |
| 531 | public static function rtSmartStyle( $fields = [] ) { |
| 532 | $h = null; |
| 533 | |
| 534 | if ( ! empty( $fields ) ) { |
| 535 | foreach ( $fields as $key => $label ) { |
| 536 | $atts = ''; |
| 537 | $proText = ''; |
| 538 | $class = ''; |
| 539 | |
| 540 | $h .= '<div class="field-holder ' . esc_attr( $class ) . '">'; |
| 541 | |
| 542 | $h .= '<div class="field-label"><label>' . esc_html( $label ) . '' . self::htmlKses( $proText, 'basic' ) . '</label></div>'; |
| 543 | $h .= "<div class='field'>"; |
| 544 | // color. |
| 545 | $h .= "<div class='field-inner col-4'>"; |
| 546 | $h .= "<div class='field-inner-container size'>"; |
| 547 | $h .= "<span class='label'>Color</span>"; |
| 548 | $cValue = get_post_meta( get_the_ID(), $key . '_color', true ); |
| 549 | $h .= '<input type="text" value="' . esc_attr( $cValue ) . '" class="rt-color" name="' . esc_attr( $key ) . '_color">'; |
| 550 | $h .= '</div>'; |
| 551 | $h .= '</div>'; |
| 552 | |
| 553 | // Font size. |
| 554 | $h .= "<div class='field-inner col-4'>"; |
| 555 | $h .= "<div class='field-inner-container size'>"; |
| 556 | $h .= "<span class='label'>Font size</span>"; |
| 557 | $h .= '<select ' . self::htmlKses( $atts, 'basic' ) . ' name="' . esc_attr( $key ) . '_size" class="rt-select2">'; |
| 558 | $fSizes = Options::scFontSize(); |
| 559 | $sValue = get_post_meta( get_the_ID(), $key . '_size', true ); |
| 560 | $h .= "<option value=''>Default</option>"; |
| 561 | |
| 562 | foreach ( $fSizes as $size => $sizeLabel ) { |
| 563 | $sSlt = ( $size == $sValue ? 'selected' : null ); |
| 564 | $h .= '<option value="' . esc_attr( $size ) . '" ' . esc_attr( $sSlt ) . '>' . esc_html( $sizeLabel ) . '</option>'; |
| 565 | } |
| 566 | |
| 567 | $h .= '</select>'; |
| 568 | $h .= '</div>'; |
| 569 | $h .= '</div>'; |
| 570 | |
| 571 | // Weight. |
| 572 | $h .= "<div class='field-inner col-4'>"; |
| 573 | $h .= "<div class='field-inner-container weight'>"; |
| 574 | $h .= "<span class='label'>Weight</span>"; |
| 575 | $h .= '<select ' . self::htmlKses( $atts, 'basic' ) . ' name="' . esc_attr( $key ) . '_weight" class="rt-select2">'; |
| 576 | $h .= "<option value=''>Default</option>"; |
| 577 | $weights = Options::scTextWeight(); |
| 578 | $wValue = get_post_meta( get_the_ID(), $key . '_weight', true ); |
| 579 | |
| 580 | foreach ( $weights as $weight => $weightLabel ) { |
| 581 | $wSlt = ( $weight == $wValue ? 'selected' : null ); |
| 582 | $h .= '<option value="' . esc_attr( $weight ) . '" ' . esc_attr( $wSlt ) . '>' . esc_html( $weightLabel ) . '</option>'; |
| 583 | } |
| 584 | |
| 585 | $h .= '</select>'; |
| 586 | $h .= '</div>'; |
| 587 | $h .= '</div>'; |
| 588 | |
| 589 | // Alignment. |
| 590 | $h .= "<div class='field-inner col-4'>"; |
| 591 | $h .= "<div class='field-inner-container alignment'>"; |
| 592 | $h .= "<span class='label'>Alignment</span>"; |
| 593 | $h .= '<select ' . self::htmlKses( $atts, 'basic' ) . ' name="' . esc_attr( $key ) . '_alignment" class="rt-select2">'; |
| 594 | $h .= "<option value=''>Default</option>"; |
| 595 | $aligns = Options::scAlignment(); |
| 596 | $aValue = get_post_meta( get_the_ID(), $key . '_alignment', true ); |
| 597 | |
| 598 | foreach ( $aligns as $align => $alignLabel ) { |
| 599 | $aSlt = ( $align == $aValue ? 'selected' : null ); |
| 600 | $h .= '<option value="' . esc_attr( $align ) . '" ' . esc_attr( $aSlt ) . '>' . esc_html( $alignLabel ) . '</option>'; |
| 601 | } |
| 602 | |
| 603 | $h .= '</select>'; |
| 604 | $h .= '</div>'; |
| 605 | $h .= '</div>'; |
| 606 | |
| 607 | $h .= '</div>'; |
| 608 | $h .= '</div>'; |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | return $h; |
| 613 | } |
| 614 | |
| 615 | public static function custom_variation_price( $product ) { |
| 616 | $price = ''; |
| 617 | $max = $product->get_variation_sale_price( 'max' ); |
| 618 | $min = $product->get_variation_sale_price( 'min' ); |
| 619 | |
| 620 | if ( ! $min || $min !== $max ) { |
| 621 | $price .= wc_price( $product->get_price() ); |
| 622 | } |
| 623 | |
| 624 | if ( $max && $max !== $min ) { |
| 625 | $price .= ' - '; |
| 626 | $price .= wc_price( $max ); |
| 627 | } |
| 628 | |
| 629 | return $price; |
| 630 | } |
| 631 | |
| 632 | public static function getTPGShortCodeList() { |
| 633 | $scList = null; |
| 634 | $scQ = get_posts( |
| 635 | [ |
| 636 | 'post_type' => rtTPG()->post_type, |
| 637 | 'order_by' => 'title', |
| 638 | 'order' => 'DESC', |
| 639 | 'post_status' => 'publish', |
| 640 | 'posts_per_page' => - 1, |
| 641 | 'meta_query' => [ |
| 642 | [ |
| 643 | 'key' => 'layout', |
| 644 | 'value' => 'layout', |
| 645 | 'compare' => 'LIKE', |
| 646 | ], |
| 647 | ], |
| 648 | ] |
| 649 | ); |
| 650 | |
| 651 | if ( ! empty( $scQ ) ) { |
| 652 | foreach ( $scQ as $sc ) { |
| 653 | $scList[ $sc->ID ] = $sc->post_title; |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | return $scList; |
| 658 | } |
| 659 | |
| 660 | public static function getAllTPGShortCodeList() { |
| 661 | $scList = null; |
| 662 | $scQ = get_posts( |
| 663 | [ |
| 664 | 'post_type' => rtTPG()->post_type, |
| 665 | 'order_by' => 'title', |
| 666 | 'order' => 'ASC', |
| 667 | 'post_status' => 'publish', |
| 668 | 'posts_per_page' => - 1, |
| 669 | ] |
| 670 | ); |
| 671 | if ( ! empty( $scQ ) ) { |
| 672 | foreach ( $scQ as $sc ) { |
| 673 | $scList[ $sc->ID ] = $sc->post_title; |
| 674 | } |
| 675 | } |
| 676 | |
| 677 | return $scList; |
| 678 | } |
| 679 | |
| 680 | public static function socialShare( $pLink ) { |
| 681 | $html = null; |
| 682 | $html .= "<div class='single-tpg-share'> |
| 683 | <div class='fb-share'> |
| 684 | <div class='fb-share-button' data-href='" . esc_url( $pLink ) . "' data-layout='button_count'></div> |
| 685 | </div> |
| 686 | <div class='twitter-share'> |
| 687 | <a href='" . esc_url( $pLink ) . "' class='twitter-share-button'{count} data-url='https://about.twitter.com/resources/buttons#tweet'>Tweet</a> |
| 688 | </div> |
| 689 | <div class='googleplus-share'> |
| 690 | <div class='g-plusone'></div> |
| 691 | </div> |
| 692 | <div class='linkedin-share'> |
| 693 | <script type='IN/Share' data-counter='right'></script> |
| 694 | </div> |
| 695 | <div class='linkedin-share'> |
| 696 | <a data-pin-do='buttonPin' data-pin-count='beside' href='https://www.pinterest.com/pin/create/button/?url=https%3A%2F%2Fwww.flickr.com%2Fphotos%2Fkentbrew%2F6851755809%2F&media=https%3A%2F%2Ffarm8.staticflickr.com%2F7027%2F6851755809_df5b2051c9_z.jpg&description=Next%20stop%3A%20Pinterest'><img src='//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png' /></a> |
| 697 | </div> |
| 698 | </div>"; |
| 699 | $html .= '<div id="fb-root"></div> |
| 700 | <script>(function(d, s, id) { |
| 701 | var js, fjs = d.getElementsByTagName(s)[0]; |
| 702 | if (d.getElementById(id)) return; |
| 703 | js = d.createElement(s); js.id = id; |
| 704 | js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5"; |
| 705 | fjs.parentNode.insertBefore(js, fjs); |
| 706 | }(document, "script", "facebook-jssdk"));</script>'; |
| 707 | $html .= "<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script> |
| 708 | <script>window.___gcfg = { lang: 'en-US', parsetags: 'onload', };</script>"; |
| 709 | $html .= "<script src='https://apis.google.com/js/platform.js' async defer></script>"; |
| 710 | $html .= '<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>'; |
| 711 | $html .= '<script async defer src="//assets.pinterest.com/js/pinit.js"></script>'; |
| 712 | |
| 713 | return $html; |
| 714 | } |
| 715 | |
| 716 | public static function get_image_sizes() { |
| 717 | global $_wp_additional_image_sizes; |
| 718 | |
| 719 | $sizes = []; |
| 720 | $interSizes = get_intermediate_image_sizes(); |
| 721 | if ( ! empty( $interSizes ) ) { |
| 722 | foreach ( get_intermediate_image_sizes() as $_size ) { |
| 723 | if ( in_array( $_size, [ 'thumbnail', 'medium', 'large' ] ) ) { |
| 724 | $sizes[ $_size ]['width'] = get_option( "{$_size}_size_w" ); |
| 725 | $sizes[ $_size ]['height'] = get_option( "{$_size}_size_h" ); |
| 726 | $sizes[ $_size ]['crop'] = (bool) get_option( "{$_size}_crop" ); |
| 727 | } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) { |
| 728 | $sizes[ $_size ] = [ |
| 729 | 'width' => $_wp_additional_image_sizes[ $_size ]['width'], |
| 730 | 'height' => $_wp_additional_image_sizes[ $_size ]['height'], |
| 731 | 'crop' => $_wp_additional_image_sizes[ $_size ]['crop'], |
| 732 | ]; |
| 733 | } |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | $imgSize = []; |
| 738 | |
| 739 | if ( ! empty( $sizes ) ) { |
| 740 | $imgSize['full'] = esc_html__( 'Full Size', 'the-post-grid' ); |
| 741 | foreach ( $sizes as $key => $img ) { |
| 742 | $imgSize[ $key ] = ucfirst( $key ) . " ({$img['width']}*{$img['height']})"; |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | return apply_filters( 'tpg_image_sizes', $imgSize ); |
| 747 | } |
| 748 | |
| 749 | public static function getFeatureImageSrc( |
| 750 | $post_id = null, |
| 751 | $fImgSize = 'medium', |
| 752 | $mediaSource = 'feature_image', |
| 753 | $defaultImgId = null, |
| 754 | $customImgSize = [], |
| 755 | $img_Class = '' |
| 756 | ) { |
| 757 | global $post; |
| 758 | |
| 759 | $imgSrc = null; |
| 760 | $img_class = 'rt-img-responsive '; |
| 761 | |
| 762 | if ( $img_Class ) { |
| 763 | $img_class .= $img_Class; |
| 764 | } |
| 765 | |
| 766 | $post_id = ( $post_id ? absint( $post_id ) : $post->ID ); |
| 767 | $alt = get_the_title( $post_id ); |
| 768 | $image = null; |
| 769 | $cSize = false; |
| 770 | |
| 771 | if ( $fImgSize == 'rt_custom' ) { |
| 772 | $fImgSize = 'full'; |
| 773 | $cSize = true; |
| 774 | } |
| 775 | |
| 776 | if ( $mediaSource == 'feature_image' ) { |
| 777 | if ( $aID = get_post_thumbnail_id( $post_id ) ) { |
| 778 | $image = wp_get_attachment_image( |
| 779 | $aID, |
| 780 | $fImgSize, |
| 781 | '', |
| 782 | [ |
| 783 | 'class' => $img_class, |
| 784 | 'loading' => false, |
| 785 | ] |
| 786 | ); |
| 787 | $imgSrc = wp_get_attachment_image_src( $aID, $fImgSize ); |
| 788 | |
| 789 | if ( ! empty( $imgSrc ) && $img_Class == 'swiper-lazy' ) { |
| 790 | $image = '<img class="' . esc_attr( $img_class ) . '" data-src="' . esc_url( $imgSrc[0] ) . '" src="#none" width="' . absint( $imgSrc[1] ) . '" height="' . absint( $imgSrc[2] ) . '" alt="' . esc_attr( $alt ) . '"/><div class="lazy-overlay-wrap"><div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div></div>'; |
| 791 | } |
| 792 | |
| 793 | $imgSrc = ! empty( $imgSrc ) ? $imgSrc[0] : $imgSrc; |
| 794 | } |
| 795 | } elseif ( $mediaSource == 'first_image' ) { |
| 796 | if ( $img = preg_match_all( |
| 797 | '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', |
| 798 | get_the_content( $post_id ), |
| 799 | $matches |
| 800 | ) |
| 801 | ) { |
| 802 | $imgSrc = $matches[1][0]; |
| 803 | $size = ''; |
| 804 | |
| 805 | if ( strpos( $imgSrc, site_url() ) !== false ) { |
| 806 | $imgAbs = str_replace( trailingslashit( site_url() ), ABSPATH, $imgSrc ); |
| 807 | } else { |
| 808 | $imgAbs = ABSPATH . $imgSrc; |
| 809 | } |
| 810 | |
| 811 | $imgAbs = apply_filters( 'rt_tpg_sc_first_image_src', $imgAbs ); |
| 812 | |
| 813 | if ( file_exists( $imgAbs ) ) { |
| 814 | $info = getimagesize( $imgAbs ); |
| 815 | $size = isset( $info[3] ) ? $info[3] : ''; |
| 816 | } |
| 817 | |
| 818 | $image = '<img class="' . esc_attr( $img_class ) . '" src="' . esc_url( $imgSrc ) . '" ' . $size . ' alt="' . esc_attr( $alt ) . '">'; |
| 819 | |
| 820 | if ( $img_Class == 'swiper-lazy' ) { |
| 821 | $image = '<img class="' . esc_attr( $img_class ) . ' img-responsive" data-src="' . esc_url( $imgSrc ) . '" src="#none" ' . $size . ' alt="' . esc_attr( $alt ) . '"/><div class="lazy-overlay-wrap"><div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div></div>'; |
| 822 | } |
| 823 | } |
| 824 | } |
| 825 | |
| 826 | if ( ! $imgSrc && $defaultImgId ) { |
| 827 | $image = wp_get_attachment_image( $defaultImgId, $fImgSize ); |
| 828 | } |
| 829 | |
| 830 | if ( $imgSrc && $cSize ) { |
| 831 | $w = ( ! empty( $customImgSize[0] ) ? absint( $customImgSize[0] ) : null ); |
| 832 | $h = ( ! empty( $customImgSize[1] ) ? absint( $customImgSize[1] ) : null ); |
| 833 | $c = ( ! empty( $customImgSize[2] ) && $customImgSize[2] == 'soft' ? false : true ); |
| 834 | |
| 835 | if ( $w && $h ) { |
| 836 | $post_thumb_id = get_post_thumbnail_id( $post_id ); |
| 837 | |
| 838 | if ( $post_thumb_id ) { |
| 839 | $featured_image = wp_get_attachment_image_src( $post_thumb_id, 'full' ); |
| 840 | $w = $featured_image[1] < $w ? $featured_image[1] : $w; |
| 841 | $h = $featured_image[2] < $h ? $featured_image[2] : $h; |
| 842 | } |
| 843 | |
| 844 | $imgSrc = self::rtImageReSize( $imgSrc, $w, $h, $c ); |
| 845 | |
| 846 | if ( $img_Class !== 'swiper-lazy' ) { |
| 847 | $image = '<img class="' . esc_attr( $img_class ) . '" src="' . esc_url( $imgSrc ) . '" width="' . absint( $w ) . '" height="' . absint( $h ) . '" alt="' . esc_attr( $alt ) . '"/>'; |
| 848 | } else { |
| 849 | $image = '<img class="' . esc_attr( $img_class ) . ' img-responsive" data-src="' . esc_url( $imgSrc ) . '" src="#none" width="' . absint( $w ) . '" height="' . absint( $h ) . '" alt="' . esc_attr( $alt ) . '"/><div class="lazy-overlay-wrap"><div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div></div>'; |
| 850 | } |
| 851 | } |
| 852 | } |
| 853 | |
| 854 | return $image; |
| 855 | } |
| 856 | |
| 857 | public static function getFeatureImageUrl( $post_id = null, $fImgSize = 'medium' ) { |
| 858 | $image = $imgSrc = null; |
| 859 | |
| 860 | if ( $aID = get_post_thumbnail_id( $post_id ) ) { |
| 861 | $image = wp_get_attachment_image_src( $aID, $fImgSize ); |
| 862 | } |
| 863 | |
| 864 | if ( is_array( $image ) ) { |
| 865 | $imgSrc = $image[0]; |
| 866 | } |
| 867 | |
| 868 | return $imgSrc; |
| 869 | } |
| 870 | |
| 871 | public static function tpgCharacterLimit( $limit, $content ) { |
| 872 | $limit ++; |
| 873 | |
| 874 | $text = ''; |
| 875 | |
| 876 | if ( mb_strlen( $content ) > $limit ) { |
| 877 | $subex = mb_substr( $content, 0, $limit ); |
| 878 | $exwords = explode( ' ', $subex ); |
| 879 | $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) ); |
| 880 | |
| 881 | if ( $excut < 0 ) { |
| 882 | $text = mb_substr( $subex, 0, $excut ); |
| 883 | } else { |
| 884 | $text = $subex; |
| 885 | } |
| 886 | } else { |
| 887 | $text = $content; |
| 888 | } |
| 889 | |
| 890 | return $text; |
| 891 | } |
| 892 | |
| 893 | public static function get_the_excerpt( $post_id, $data = [] ) { |
| 894 | $type = $data['excerpt_type']; |
| 895 | $post = get_post( $post_id ); |
| 896 | |
| 897 | if ( empty( $post ) ) { |
| 898 | return ''; |
| 899 | } |
| 900 | |
| 901 | if ( $type == 'full' ) { |
| 902 | ob_start(); |
| 903 | the_content(); |
| 904 | $content = ob_get_clean(); |
| 905 | |
| 906 | return apply_filters( 'tpg_content_full', $content, $post_id, $data ); |
| 907 | } else { |
| 908 | if ( class_exists( 'ET_GB_Block_Layout' ) ) { |
| 909 | $defaultExcerpt = $post->post_excerpt ?: wp_trim_words( $post->post_content, 55 ); |
| 910 | } else { |
| 911 | $defaultExcerpt = get_the_excerpt( $post_id ); |
| 912 | } |
| 913 | |
| 914 | $limit = isset( $data['excerpt_limit'] ) && $data['excerpt_limit'] ? abs( $data['excerpt_limit'] ) : 0; |
| 915 | $more = $data['excerpt_more_text']; |
| 916 | $excerpt = preg_replace( '`\[[^\]]*\]`', '', $defaultExcerpt ); |
| 917 | $excerpt = strip_shortcodes( $excerpt ); |
| 918 | $excerpt = preg_replace( '`[[^]]*]`', '', $excerpt ); |
| 919 | $excerpt = str_replace( '…', '', $excerpt ); |
| 920 | |
| 921 | if ( $limit ) { |
| 922 | $excerpt = wp_strip_all_tags( $excerpt ); |
| 923 | |
| 924 | if ( $type == 'word' ) { |
| 925 | $limit = $limit + 1; |
| 926 | $rawExcerpt = $excerpt; |
| 927 | $excerpt = explode( ' ', $excerpt, $limit ); |
| 928 | |
| 929 | if ( count( $excerpt ) >= $limit ) { |
| 930 | array_pop( $excerpt ); |
| 931 | $excerpt = implode( ' ', $excerpt ); |
| 932 | } else { |
| 933 | $excerpt = $rawExcerpt; |
| 934 | } |
| 935 | } else { |
| 936 | $excerpt = self::tpgCharacterLimit( $limit, $excerpt ); |
| 937 | } |
| 938 | $excerpt = stripslashes( $excerpt ); |
| 939 | } else { |
| 940 | $allowed_html = [ |
| 941 | 'a' => [ |
| 942 | 'href' => [], |
| 943 | 'title' => [], |
| 944 | ], |
| 945 | 'strong' => [], |
| 946 | 'b' => [], |
| 947 | 'br' => [ [] ], |
| 948 | ]; |
| 949 | |
| 950 | $excerpt = nl2br( wp_kses( $excerpt, $allowed_html ) ); |
| 951 | } |
| 952 | |
| 953 | $excerpt = ( $more ? $excerpt . ' ' . $more : $excerpt ); |
| 954 | |
| 955 | return apply_filters( 'tpg_get_the_excerpt', $excerpt, $post_id, $data, $defaultExcerpt ); |
| 956 | } |
| 957 | } |
| 958 | |
| 959 | public static function get_the_title( $post_id, $data = [] ) { |
| 960 | $title = $originalTitle = get_the_title( $post_id ); |
| 961 | $limit = isset( $data['title_limit'] ) ? absint( $data['title_limit'] ) : 0; |
| 962 | $limit_type = isset( $data['title_limit_type'] ) ? trim( $data['title_limit_type'] ) : 'character'; |
| 963 | |
| 964 | if ( $limit ) { |
| 965 | if ( $limit_type == 'word' ) { |
| 966 | $limit = $limit + 1; |
| 967 | $title = explode( ' ', $title, $limit ); |
| 968 | |
| 969 | if ( count( $title ) >= $limit ) { |
| 970 | array_pop( $title ); |
| 971 | $title = implode( ' ', $title ); |
| 972 | } else { |
| 973 | $title = $originalTitle; |
| 974 | } |
| 975 | } else { |
| 976 | if ( $limit > 0 && strlen( $title ) > $limit ) { |
| 977 | $title = mb_substr( $title, 0, $limit, 'utf-8' ); |
| 978 | $title = preg_replace( '/\W\w+\s*(\W*)$/', '$1', $title ); |
| 979 | } |
| 980 | } |
| 981 | } |
| 982 | |
| 983 | return apply_filters( 'tpg_get_the_title', $title, $post_id, $data, $originalTitle ); |
| 984 | } |
| 985 | |
| 986 | |
| 987 | public static function rt_pagination( $postGrid, $range = 4, $ajax = false ) { |
| 988 | $html = $pages = null; |
| 989 | $showitems = ( $range * 2 ) + 1; |
| 990 | |
| 991 | $wpQuery = $postGrid; |
| 992 | |
| 993 | global $wp_query; |
| 994 | |
| 995 | if ( empty( $wpQuery ) ) { |
| 996 | $wpQuery = $wp_query; |
| 997 | } |
| 998 | |
| 999 | $pages = ! empty( $wpQuery->max_num_pages ) ? $wpQuery->max_num_pages : 1; |
| 1000 | $paged = ! empty( $wpQuery->query['paged'] ) ? $wpQuery->query['paged'] : 1; |
| 1001 | |
| 1002 | if ( is_front_page() ) { |
| 1003 | $paged = ! empty( $wp_query->query['paged'] ) ? $wp_query->query['paged'] : 1; |
| 1004 | } |
| 1005 | |
| 1006 | $ajaxClass = null; |
| 1007 | $dataAttr = null; |
| 1008 | |
| 1009 | if ( $ajax ) { |
| 1010 | $ajaxClass = ' rt-ajax'; |
| 1011 | $dataAttr = "data-paged='1'"; |
| 1012 | } |
| 1013 | |
| 1014 | if ( 1 != $pages ) { |
| 1015 | $html .= '<div class="rt-pagination' . $ajaxClass . '" ' . $dataAttr . '>'; |
| 1016 | $html .= '<ul class="pagination-list">'; |
| 1017 | if ( $paged > 2 && $paged > $range + 1 && $showitems < $pages && ! $ajax ) { |
| 1018 | $html .= "<li><a data-paged='1' href='" . get_pagenum_link( 1 ) . "' aria-label='First'>«</a></li>"; |
| 1019 | } |
| 1020 | |
| 1021 | if ( $paged > 1 && $showitems < $pages && ! $ajax ) { |
| 1022 | $p = $paged - 1; |
| 1023 | $html .= "<li><a data-paged='{$p}' href='" . get_pagenum_link( $p ) . "' aria-label='Previous'>‹</a></li>"; |
| 1024 | } |
| 1025 | |
| 1026 | if ( $ajax ) { |
| 1027 | for ( $i = 1; $i <= $pages; $i ++ ) { |
| 1028 | $html .= ( $paged == $i ) ? '<li class="active"><span>' . $i . '</span></li>' : "<li><a data-paged='{$i}' href='" . get_pagenum_link( $i ) . "'>" . $i . '</a></li>'; |
| 1029 | } |
| 1030 | } else { |
| 1031 | for ( $i = 1; $i <= $pages; $i ++ ) { |
| 1032 | if ( 1 != $pages && ( ! ( $i >= $paged + $range + 1 || $i <= $paged - $range - 1 ) || $pages <= $showitems ) ) { |
| 1033 | $html .= ( $paged == $i ) ? '<li class="active"><span>' . $i . '</span></li>' : "<li><a data-paged='{$i}' href='" . get_pagenum_link( $i ) . "'>" . $i . '</a></li>'; |
| 1034 | } |
| 1035 | } |
| 1036 | } |
| 1037 | |
| 1038 | if ( $paged < $pages && $showitems < $pages && ! $ajax ) { |
| 1039 | $p = $paged + 1; |
| 1040 | $html .= "<li><a data-paged='{$p}' href=\"" . get_pagenum_link( $paged + 1 ) . "\" aria-label='Next'>›</a></li>"; |
| 1041 | } |
| 1042 | |
| 1043 | if ( $paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages && ! $ajax ) { |
| 1044 | $html .= "<li><a data-paged='{$pages}' href='" . get_pagenum_link( $pages ) . "' aria-label='Last'>»</a></li>"; |
| 1045 | } |
| 1046 | |
| 1047 | $html .= '</ul>'; |
| 1048 | $html .= '</div>'; |
| 1049 | } |
| 1050 | |
| 1051 | return $html; |
| 1052 | } |
| 1053 | |
| 1054 | public static function rt_pagination_ajax( $scID, $range = 4, $pages = '' ) { |
| 1055 | $html = null; |
| 1056 | |
| 1057 | $html .= "<div class='rt-tpg-pagination-ajax' data-sc-id='{$scID}' data-paged='1'>"; |
| 1058 | $html .= '</div>'; |
| 1059 | |
| 1060 | return $html; |
| 1061 | } |
| 1062 | |
| 1063 | /** |
| 1064 | * Call the Image resize model for resize function |
| 1065 | * |
| 1066 | * @param $url |
| 1067 | * @param null $width |
| 1068 | * @param null $height |
| 1069 | * @param null $crop |
| 1070 | * @param bool|true $single |
| 1071 | * @param bool|false $upscale |
| 1072 | * |
| 1073 | * @return array|bool|string |
| 1074 | * @throws Exception |
| 1075 | * @throws Rt_Exception |
| 1076 | */ |
| 1077 | public static function rtImageReSize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) { |
| 1078 | $rtResize = new ReSizer(); |
| 1079 | |
| 1080 | return $rtResize->process( $url, $width, $height, $crop, $single, $upscale ); |
| 1081 | } |
| 1082 | |
| 1083 | |
| 1084 | /* Convert hexdec color string to rgb(a) string */ |
| 1085 | public static function rtHex2rgba( $color, $opacity = .5 ) { |
| 1086 | $default = 'rgb(0,0,0)'; |
| 1087 | |
| 1088 | // Return default if no color provided. |
| 1089 | if ( empty( $color ) ) { |
| 1090 | return $default; |
| 1091 | } |
| 1092 | |
| 1093 | // Sanitize $color if "#" is provided. |
| 1094 | if ( $color[0] == '#' ) { |
| 1095 | $color = substr( $color, 1 ); |
| 1096 | } |
| 1097 | |
| 1098 | // Check if color has 6 or 3 characters and get values. |
| 1099 | if ( strlen( $color ) == 6 ) { |
| 1100 | $hex = [ $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] ]; |
| 1101 | } elseif ( strlen( $color ) == 3 ) { |
| 1102 | $hex = [ $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] ]; |
| 1103 | } else { |
| 1104 | return $default; |
| 1105 | } |
| 1106 | |
| 1107 | // Convert hexadec to rgb. |
| 1108 | $rgb = array_map( 'hexdec', $hex ); |
| 1109 | |
| 1110 | // Check if opacity is set(rgba or rgb). |
| 1111 | if ( $opacity ) { |
| 1112 | if ( absint( $opacity ) > 1 ) { |
| 1113 | $opacity = 1.0; |
| 1114 | } |
| 1115 | |
| 1116 | $output = 'rgba(' . implode( ',', $rgb ) . ',' . $opacity . ')'; |
| 1117 | } else { |
| 1118 | $output = 'rgb(' . implode( ',', $rgb ) . ')'; |
| 1119 | } |
| 1120 | |
| 1121 | // Return rgb(a) color string. |
| 1122 | return $output; |
| 1123 | } |
| 1124 | |
| 1125 | public static function meta_exist( $meta_key, $post_id = null, $type = 'post' ) { |
| 1126 | if ( ! $post_id ) { |
| 1127 | return false; |
| 1128 | } |
| 1129 | |
| 1130 | return metadata_exists( $type, $post_id, $meta_key ); |
| 1131 | } |
| 1132 | |
| 1133 | |
| 1134 | public static function get_offset_col( $col ) { |
| 1135 | $return = [ |
| 1136 | 'big' => 6, |
| 1137 | 'small' => 6, |
| 1138 | ]; |
| 1139 | |
| 1140 | if ( $col ) { |
| 1141 | if ( $col == 12 ) { |
| 1142 | $return['big'] = 12; |
| 1143 | $return['small'] = 12; |
| 1144 | } elseif ( $col == 6 ) { |
| 1145 | $return['big'] = 6; |
| 1146 | $return['small'] = 6; |
| 1147 | } elseif ( $col == 4 ) { |
| 1148 | $return['big'] = 4; |
| 1149 | $return['small'] = 8; |
| 1150 | } |
| 1151 | } |
| 1152 | |
| 1153 | return $return; |
| 1154 | } |
| 1155 | |
| 1156 | public static function formatSpacing( $data = '' ) { |
| 1157 | if ( ! empty( $data ) ) { |
| 1158 | $spacing = array_filter( explode( ',', $data ), 'is_numeric' ); |
| 1159 | |
| 1160 | if ( count( $spacing ) > 4 ) { |
| 1161 | $spacing = array_slice( $spacing, 0, 4, true ); |
| 1162 | } |
| 1163 | |
| 1164 | $data = implode( 'px ', $spacing ); |
| 1165 | } |
| 1166 | |
| 1167 | return $data; |
| 1168 | } |
| 1169 | |
| 1170 | public static function layoutStyle( $layoutID, $scMeta, $layout, $scId = null ) { |
| 1171 | $css = null; |
| 1172 | $css .= "<style type='text/css' media='all'>"; |
| 1173 | // primary color |
| 1174 | if ( $scId ) { |
| 1175 | $primaryColor = ( isset( $scMeta['primary_color'][0] ) ? $scMeta['primary_color'][0] : null ); |
| 1176 | $button_bg_color = ( isset( $scMeta['button_bg_color'][0] ) ? $scMeta['button_bg_color'][0] : null ); |
| 1177 | $button_active_bg_color = ( isset( $scMeta['button_active_bg_color'][0] ) ? $scMeta['button_active_bg_color'][0] : null ); |
| 1178 | $button_hover_bg_color = ( isset( $scMeta['button_hover_bg_color'][0] ) ? $scMeta['button_hover_bg_color'][0] : null ); |
| 1179 | $button_text_color = ( isset( $scMeta['button_text_bg_color'][0] ) ? $scMeta['button_text_bg_color'][0] |
| 1180 | : ( isset( $scMeta['button_text_color'][0] ) ? $scMeta['button_text_color'][0] : null ) ); |
| 1181 | $button_hover_text_color = ( isset( $scMeta['button_hover_text_color'][0] ) ? $scMeta['button_hover_text_color'][0] : null ); |
| 1182 | $button_border_color = ( isset( $scMeta['button_border_color'][0] ) ? $scMeta['button_border_color'][0] : null ); |
| 1183 | $overlay_color = ( ! empty( $scMeta['overlay_color'][0] ) ? self::rtHex2rgba( |
| 1184 | $scMeta['overlay_color'][0], |
| 1185 | ! empty( $scMeta['overlay_opacity'][0] ) ? absint( $scMeta['overlay_opacity'][0] ) / 10 : .8 |
| 1186 | ) : null ); |
| 1187 | $overlay_padding = ( ! empty( $scMeta['overlay_padding'][0] ) ? absint( $scMeta['overlay_padding'][0] ) : null ); |
| 1188 | $gutter = ! empty( $scMeta['tgp_gutter'][0] ) ? absint( $scMeta['tgp_gutter'][0] ) : null; |
| 1189 | $read_more_button_border_radius = isset( $scMeta['tpg_read_more_button_border_radius'][0] ) ? $scMeta['tpg_read_more_button_border_radius'][0] : ''; |
| 1190 | // Section |
| 1191 | $sectionBg = ( isset( $scMeta['tpg_full_area_bg'][0] ) ? $scMeta['tpg_full_area_bg'][0] : null ); |
| 1192 | $sectionMargin = ( isset( $scMeta['tpg_full_area_margin'][0] ) ? $scMeta['tpg_full_area_margin'][0] : null ); |
| 1193 | $sectionMargin = self::formatSpacing( $sectionMargin ); |
| 1194 | $sectionPadding = ( isset( $scMeta['tpg_full_area_padding'][0] ) ? $scMeta['tpg_full_area_padding'][0] : null ); |
| 1195 | $sectionPadding = self::formatSpacing( $sectionPadding ); |
| 1196 | // Box |
| 1197 | $boxBg = ( isset( $scMeta['tpg_content_wrap_bg'][0] ) ? $scMeta['tpg_content_wrap_bg'][0] : null ); |
| 1198 | $boxBorder = ( isset( $scMeta['tpg_content_wrap_border'][0] ) ? $scMeta['tpg_content_wrap_border'][0] : null ); |
| 1199 | $boxBorderColor = ( isset( $scMeta['tpg_content_wrap_border_color'][0] ) ? $scMeta['tpg_content_wrap_border_color'][0] : null ); |
| 1200 | $boxBorderRadius = ( isset( $scMeta['tpg_content_wrap_border_radius'][0] ) ? $scMeta['tpg_content_wrap_border_radius'][0] : null ); |
| 1201 | $boxShadow = ( isset( $scMeta['tpg_content_wrap_shadow'][0] ) ? $scMeta['tpg_content_wrap_shadow'][0] : null ); |
| 1202 | $boxPadding = ( isset( $scMeta['tpg_box_padding'][0] ) ? $scMeta['tpg_box_padding'][0] : null ); |
| 1203 | $boxPadding = self::formatSpacing( $boxPadding ); |
| 1204 | $contentPadding = ( isset( $scMeta['tpg_content_padding'][0] ) ? $scMeta['tpg_content_padding'][0] : null ); |
| 1205 | $contentPadding = self::formatSpacing( $contentPadding ); |
| 1206 | // Heading |
| 1207 | $headingBg = ( isset( $scMeta['tpg_heading_bg'][0] ) ? $scMeta['tpg_heading_bg'][0] : null ); |
| 1208 | $headingColor = ( isset( $scMeta['tpg_heading_color'][0] ) ? $scMeta['tpg_heading_color'][0] : null ); |
| 1209 | $headingBorderColor = ( isset( $scMeta['tpg_heading_border_color'][0] ) ? $scMeta['tpg_heading_border_color'][0] : null ); |
| 1210 | $headingBorderSize = ( isset( $scMeta['tpg_heading_border_size'][0] ) ? $scMeta['tpg_heading_border_size'][0] : null ); |
| 1211 | $headingMargin = ( isset( $scMeta['tpg_heading_margin'][0] ) ? $scMeta['tpg_heading_margin'][0] : null ); |
| 1212 | $headingMargin = self::formatSpacing( $headingMargin ); |
| 1213 | $headingPadding = ( isset( $scMeta['tpg_heading_padding'][0] ) ? $scMeta['tpg_heading_padding'][0] : null ); |
| 1214 | $headingPadding = self::formatSpacing( $headingPadding ); |
| 1215 | // Category |
| 1216 | $catBg = ( isset( $scMeta['tpg_category_bg'][0] ) ? $scMeta['tpg_category_bg'][0] : null ); |
| 1217 | $catTextColor = ( isset( $scMeta['tpg_category_color'][0] ) ? $scMeta['tpg_category_color'][0] : null ); |
| 1218 | $catBorderRadius = ( isset( $scMeta['tpg_category_border_radius'][0] ) ? $scMeta['tpg_category_border_radius'][0] : null ); |
| 1219 | $catMargin = ( isset( $scMeta['tpg_category_margin'][0] ) ? $scMeta['tpg_category_margin'][0] : null ); |
| 1220 | $catMargin = self::formatSpacing( $catMargin ); |
| 1221 | $catPadding = ( isset( $scMeta['tpg_category_padding'][0] ) ? $scMeta['tpg_category_padding'][0] : null ); |
| 1222 | $catPadding = self::formatSpacing( $catPadding ); |
| 1223 | $categorySize = ( ! empty( $scMeta['rt_tpg_category_font_size'][0] ) ? absint( $scMeta['rt_tpg_category_font_size'][0] ) : null ); |
| 1224 | // Image |
| 1225 | $image_border_radius = isset( $scMeta['tpg_image_border_radius'][0] ) ? $scMeta['tpg_image_border_radius'][0] : ''; |
| 1226 | // Title |
| 1227 | $title_color = ( ! empty( $scMeta['title_color'][0] ) ? $scMeta['title_color'][0] : null ); |
| 1228 | $title_size = ( ! empty( $scMeta['title_size'][0] ) ? absint( $scMeta['title_size'][0] ) : null ); |
| 1229 | $title_weight = ( ! empty( $scMeta['title_weight'][0] ) ? $scMeta['title_weight'][0] : null ); |
| 1230 | $title_alignment = ( ! empty( $scMeta['title_alignment'][0] ) ? $scMeta['title_alignment'][0] : null ); |
| 1231 | |
| 1232 | $title_hover_color = ( ! empty( $scMeta['title_hover_color'][0] ) ? $scMeta['title_hover_color'][0] : null ); |
| 1233 | |
| 1234 | $excerpt_color = ( ! empty( $scMeta['excerpt_color'][0] ) ? $scMeta['excerpt_color'][0] : null ); |
| 1235 | $excerpt_size = ( ! empty( $scMeta['excerpt_size'][0] ) ? absint( $scMeta['excerpt_size'][0] ) : null ); |
| 1236 | $excerpt_weight = ( ! empty( $scMeta['excerpt_weight'][0] ) ? $scMeta['excerpt_weight'][0] : null ); |
| 1237 | $excerpt_alignment = ( ! empty( $scMeta['excerpt_alignment'][0] ) ? $scMeta['excerpt_alignment'][0] : null ); |
| 1238 | |
| 1239 | $meta_data_color = ( ! empty( $scMeta['meta_data_color'][0] ) ? $scMeta['meta_data_color'][0] : null ); |
| 1240 | $meta_data_size = ( ! empty( $scMeta['meta_data_size'][0] ) ? absint( $scMeta['meta_data_size'][0] ) : null ); |
| 1241 | $meta_data_weight = ( ! empty( $scMeta['meta_data_weight'][0] ) ? $scMeta['meta_data_weight'][0] : null ); |
| 1242 | $meta_data_alignment = ( ! empty( $scMeta['meta_data_alignment'][0] ) ? $scMeta['meta_data_alignment'][0] : null ); |
| 1243 | } else { |
| 1244 | $primaryColor = ( isset( $scMeta['primary_color'] ) ? $scMeta['primary_color'] : null ); |
| 1245 | $button_bg_color = ( isset( $scMeta['button_bg_color'] ) ? $scMeta['button_bg_color'] : null ); |
| 1246 | $button_active_bg_color = ( isset( $scMeta['button_active_bg_color'] ) ? $scMeta['button_active_bg_color'] : null ); |
| 1247 | $button_hover_bg_color = ( isset( $scMeta['button_hover_bg_color'] ) ? $scMeta['button_hover_bg_color'] : null ); |
| 1248 | $btn_text_color = get_post_meta( $scMeta['sc_id'], 'button_text_color', true ); |
| 1249 | $button_text_color = ( ! empty( $scMeta['button_text_bg_color'] ) ? $scMeta['button_text_bg_color'] |
| 1250 | : ( ! empty( $btn_text_color ) ? $btn_text_color : null ) ); |
| 1251 | $button_border_color = ( isset( $scMeta['button_border_color'] ) ? $scMeta['button_border_color'] : null ); |
| 1252 | $button_hover_text_color = ( isset( $scMeta['button_hover_text_color'] ) ? $scMeta['button_hover_text_color'] : null ); |
| 1253 | $overlay_color = ( ! empty( $scMeta['overlay_color'] ) ? self::rtHex2rgba( |
| 1254 | $scMeta['overlay_color'], |
| 1255 | ! empty( $scMeta['overlay_opacity'] ) ? absint( $scMeta['overlay_opacity'] ) / 10 : .8 |
| 1256 | ) : null ); |
| 1257 | $overlay_padding = ( ! empty( $scMeta['overlay_padding'] ) ? absint( $scMeta['overlay_padding'] ) : null ); |
| 1258 | $gutter = ! empty( $scMeta['tgp_gutter'] ) ? absint( $scMeta['tgp_gutter'] ) : null; |
| 1259 | $read_more_button_border_radius = isset( $scMeta['tpg_read_more_button_border_radius'] ) ? $scMeta['tpg_read_more_button_border_radius'] : ''; |
| 1260 | // Section |
| 1261 | $sectionBg = ( isset( $scMeta['tpg_full_area_bg'] ) ? $scMeta['tpg_full_area_bg'] : null ); |
| 1262 | $sectionMargin = ( isset( $scMeta['tpg_full_area_margin'] ) ? $scMeta['tpg_full_area_margin'] : null ); |
| 1263 | $sectionMargin = self::formatSpacing( $sectionMargin ); |
| 1264 | $sectionPadding = ( isset( $scMeta['tpg_full_area_padding'] ) ? $scMeta['tpg_full_area_padding'] : null ); |
| 1265 | $sectionPadding = self::formatSpacing( $sectionPadding ); |
| 1266 | // Box |
| 1267 | $boxBg = ( isset( $scMeta['tpg_content_wrap_bg'] ) ? $scMeta['tpg_content_wrap_bg'] : null ); |
| 1268 | $boxBorder = ( isset( $scMeta['tpg_content_wrap_border'] ) ? $scMeta['tpg_content_wrap_border'] : null ); |
| 1269 | $boxBorderColor = ( isset( $scMeta['tpg_content_wrap_border_color'] ) ? $scMeta['tpg_content_wrap_border_color'] : null ); |
| 1270 | $boxBorderRadius = ( isset( $scMeta['tpg_content_wrap_border_radius'] ) ? $scMeta['tpg_content_wrap_border_radius'] : null ); |
| 1271 | $boxShadow = ( isset( $scMeta['tpg_content_wrap_shadow'] ) ? $scMeta['tpg_content_wrap_shadow'] : null ); |
| 1272 | $boxPadding = ( isset( $scMeta['tpg_box_padding'] ) ? $scMeta['tpg_box_padding'] : null ); |
| 1273 | $boxPadding = self::formatSpacing( $boxPadding ); |
| 1274 | $contentPadding = ( isset( $scMeta['tpg_content_padding'] ) ? $scMeta['tpg_content_padding'] : null ); |
| 1275 | $contentPadding = self::formatSpacing( $contentPadding ); |
| 1276 | // Heading |
| 1277 | $headingBg = ( isset( $scMeta['tpg_heading_bg'] ) ? $scMeta['tpg_heading_bg'] : null ); |
| 1278 | $headingColor = ( isset( $scMeta['tpg_heading_color'] ) ? $scMeta['tpg_heading_color'] : null ); |
| 1279 | $headingBorderColor = ( isset( $scMeta['tpg_heading_border_color'] ) ? $scMeta['tpg_heading_border_color'] : null ); |
| 1280 | $headingBorderSize = ( isset( $scMeta['tpg_heading_border_size'] ) ? $scMeta['tpg_heading_border_size'] : null ); |
| 1281 | $headingMargin = ( isset( $scMeta['tpg_heading_margin'] ) ? $scMeta['tpg_heading_margin'] : null ); |
| 1282 | $headingMargin = self::formatSpacing( $headingMargin ); |
| 1283 | $headingPadding = ( isset( $scMeta['tpg_heading_padding'] ) ? $scMeta['tpg_heading_padding'] : null ); |
| 1284 | $headingPadding = self::formatSpacing( $headingPadding ); |
| 1285 | // Category |
| 1286 | $catBg = ( isset( $scMeta['tpg_category_bg'] ) ? $scMeta['tpg_category_bg'] : null ); |
| 1287 | $catTextColor = ( isset( $scMeta['tpg_category_color'] ) ? $scMeta['tpg_category_color'] : null ); |
| 1288 | $catBorderRadius = ( isset( $scMeta['tpg_category_border_radius'] ) ? $scMeta['tpg_category_border_radius'] : null ); |
| 1289 | $catMargin = ( isset( $scMeta['tpg_category_margin'] ) ? $scMeta['tpg_category_margin'] : null ); |
| 1290 | $catPadding = ( isset( $scMeta['tpg_category_padding'] ) ? $scMeta['tpg_category_padding'] : null ); |
| 1291 | $categorySize = ( ! empty( $scMeta['rt_tpg_category_font_size'] ) ? absint( $scMeta['rt_tpg_category_font_size'] ) : null ); |
| 1292 | // Image |
| 1293 | $image_border_radius = isset( $scMeta['tpg_image_border_radius'] ) ? $scMeta['tpg_image_border_radius'] : ''; |
| 1294 | // Title |
| 1295 | $title_color = ( ! empty( $scMeta['title_color'] ) ? $scMeta['title_color'] : null ); |
| 1296 | $title_size = ( ! empty( $scMeta['title_size'] ) ? absint( $scMeta['title_size'] ) : null ); |
| 1297 | $title_weight = ( ! empty( $scMeta['title_weight'] ) ? $scMeta['title_weight'] : null ); |
| 1298 | $title_alignment = ( ! empty( $scMeta['title_alignment'] ) ? $scMeta['title_alignment'] : null ); |
| 1299 | |
| 1300 | $title_hover_color = ( ! empty( $scMeta['title_hover_color'] ) ? $scMeta['title_hover_color'] : null ); |
| 1301 | |
| 1302 | $excerpt_color = ( ! empty( $scMeta['excerpt_color'] ) ? $scMeta['excerpt_color'] : null ); |
| 1303 | $excerpt_size = ( ! empty( $scMeta['excerpt_size'] ) ? absint( $scMeta['excerpt_size'] ) : null ); |
| 1304 | $excerpt_weight = ( ! empty( $scMeta['excerpt_weight'] ) ? $scMeta['excerpt_weight'] : null ); |
| 1305 | $excerpt_alignment = ( ! empty( $scMeta['excerpt_alignment'] ) ? $scMeta['excerpt_alignment'] : null ); |
| 1306 | |
| 1307 | $meta_data_color = ( ! empty( $scMeta['meta_data_color'] ) ? $scMeta['meta_data_color'] : null ); |
| 1308 | $meta_data_size = ( ! empty( $scMeta['meta_data_size'] ) ? absint( $scMeta['meta_data_size'] ) : null ); |
| 1309 | $meta_data_weight = ( ! empty( $scMeta['meta_data_weight'] ) ? $scMeta['meta_data_weight'] : null ); |
| 1310 | $meta_data_alignment = ( ! empty( $scMeta['meta_data_alignment'] ) ? $scMeta['meta_data_alignment'] : null ); |
| 1311 | } |
| 1312 | |
| 1313 | $id = str_replace( 'rt-tpg-container-', '', $layoutID ); |
| 1314 | |
| 1315 | if ( $primaryColor ) { |
| 1316 | $css .= "#{$layoutID} .rt-holder .rt-woo-info .price{"; |
| 1317 | $css .= 'color:' . $primaryColor . ';'; |
| 1318 | $css .= '}'; |
| 1319 | $css .= "body .rt-tpg-container .rt-tpg-isotope-buttons .selected, |
| 1320 | #{$layoutID} .layout12 .rt-holder:hover .rt-detail, |
| 1321 | #{$layoutID} .isotope8 .rt-holder:hover .rt-detail, |
| 1322 | #{$layoutID} .carousel8 .rt-holder:hover .rt-detail, |
| 1323 | #{$layoutID} .layout13 .rt-holder .overlay .post-info, |
| 1324 | #{$layoutID} .isotope9 .rt-holder .overlay .post-info, |
| 1325 | #{$layoutID}.rt-tpg-container .layout4 .rt-holder .rt-detail, |
| 1326 | .rt-modal-{$id} .md-content, |
| 1327 | .rt-modal-{$id} .md-content > .rt-md-content-holder .rt-md-content, |
| 1328 | .rt-popup-wrap-{$id}.rt-popup-wrap .rt-popup-navigation-wrap, |
| 1329 | #{$layoutID} .carousel9 .rt-holder .overlay .post-info{"; |
| 1330 | $css .= 'background-color:' . $primaryColor . ';'; |
| 1331 | $css .= '}'; |
| 1332 | |
| 1333 | $ocp = self::rtHex2rgba( |
| 1334 | $primaryColor, |
| 1335 | ! empty( $scMeta['overlay_opacity'][0] ) ? absint( $scMeta['overlay_opacity'][0] ) / 10 : .8 |
| 1336 | ); |
| 1337 | $css .= "#{$layoutID} .layout5 .rt-holder .overlay, #{$layoutID} .isotope2 .rt-holder .overlay, #{$layoutID} .carousel2 .rt-holder .overlay,#{$layoutID} .layout15 .rt-holder h3, #{$layoutID} .isotope11 .rt-holder h3, #{$layoutID} .carousel11 .rt-holder h3, #{$layoutID} .layout16 .rt-holder h3, |
| 1338 | #{$layoutID} .isotope12 .rt-holder h3, #{$layoutID} .carousel12 .rt-holder h3 {"; |
| 1339 | $css .= 'background-color:' . $ocp . ';'; |
| 1340 | $css .= '}'; |
| 1341 | } |
| 1342 | |
| 1343 | if ( $button_border_color ) { |
| 1344 | $css .= "#{$layoutID} .rt-filter-item-wrap.rt-filter-button-wrap span.rt-filter-button-item, |
| 1345 | #{$layoutID} .rt-layout-filter-container .rt-filter-sub-tax.sub-button-group .rt-filter-button-item, |
| 1346 | #{$layoutID}.rt-tpg-container .swiper-navigation .slider-btn, |
| 1347 | #{$layoutID} .rt-layout-filter-container .rt-filter-wrap .rt-filter-item-wrap.rt-sort-order-action, |
| 1348 | #{$layoutID} .rt-layout-filter-container .rt-filter-wrap .rt-filter-item-wrap.rt-filter-dropdown-wrap .rt-filter-dropdown .rt-filter-dropdown-item, |
| 1349 | #{$layoutID} .rt-layout-filter-container .rt-filter-wrap .rt-filter-item-wrap.rt-filter-dropdown-wrap{"; |
| 1350 | $css .= 'border-color:' . $button_border_color . ' !important;'; |
| 1351 | $css .= '}'; |
| 1352 | $css .= "#{$layoutID} .rt-holder .read-more a {"; |
| 1353 | $css .= 'border-color:' . $button_border_color . ';'; |
| 1354 | $css .= '}'; |
| 1355 | } |
| 1356 | |
| 1357 | if ( $button_bg_color ) { |
| 1358 | $css .= "#{$layoutID} .pagination-list li a, |
| 1359 | {$layoutID} .pagination-list li span, |
| 1360 | {$layoutID} .pagination li a, |
| 1361 | #{$layoutID} .rt-tpg-isotope-buttons button, |
| 1362 | #{$layoutID} .rt-tpg-utility .rt-tpg-load-more button, |
| 1363 | #{$layoutID}.rt-tpg-container .swiper-navigation .slider-btn, |
| 1364 | #{$layoutID}.rt-tpg-container .swiper-pagination-bullet, |
| 1365 | #{$layoutID} .wc1 .rt-holder .rt-img-holder .overlay .product-more ul li a, |
| 1366 | #{$layoutID} .wc2 .rt-detail .rt-wc-add-to-cart, |
| 1367 | #{$layoutID} .wc3 .rt-detail .rt-wc-add-to-cart, |
| 1368 | #{$layoutID} .wc4 .rt-detail .rt-wc-add-to-cart, |
| 1369 | #{$layoutID} .wc-carousel2 .rt-detail .rt-wc-add-to-cart, |
| 1370 | #{$layoutID} .wc-isotope2 .rt-detail .rt-wc-add-to-cart, |
| 1371 | #{$layoutID} .rt-layout-filter-container .rt-filter-wrap .rt-filter-item-wrap.rt-filter-dropdown-wrap .rt-filter-dropdown, |
| 1372 | #{$layoutID} .rt-layout-filter-container .rt-filter-sub-tax.sub-button-group .rt-filter-button-item, |
| 1373 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-page-numbers .paginationjs .paginationjs-pages ul li>a, |
| 1374 | #{$layoutID} .rt-filter-item-wrap.rt-filter-button-wrap span.rt-filter-button-item, |
| 1375 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-loadmore-btn, |
| 1376 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-cb-page-prev-next > *, |
| 1377 | #{$layoutID} .rt-read-more, |
| 1378 | #rt-tooltip-{$id}, #rt-tooltip-{$id} .rt-tooltip-bottom:after{"; |
| 1379 | $css .= 'background-color:' . $button_bg_color . ';'; |
| 1380 | $css .= '}'; |
| 1381 | $css .= "#{$layoutID} .rt-filter-item-wrap.rt-filter-button-wrap span.rt-filter-button-item, |
| 1382 | #{$layoutID} .rt-layout-filter-container .rt-filter-sub-tax.sub-button-group .rt-filter-button-item{"; |
| 1383 | $css .= 'border-color:' . $button_bg_color . ';'; |
| 1384 | $css .= '}'; |
| 1385 | $css .= "#{$layoutID}.rt-tpg-container .layout17 .rt-holder .overlay a.tpg-zoom .fa{"; |
| 1386 | $css .= 'color:' . $button_bg_color . ';'; |
| 1387 | $css .= '}'; |
| 1388 | |
| 1389 | $css .= "#{$layoutID} .rt-holder .read-more a {"; |
| 1390 | $css .= 'background-color:' . $button_bg_color . ';padding: 8px 15px;'; |
| 1391 | $css .= '}'; |
| 1392 | } |
| 1393 | |
| 1394 | // button active color. |
| 1395 | if ( $button_active_bg_color ) { |
| 1396 | $css .= "#{$layoutID} .pagination li.active span, |
| 1397 | #{$layoutID} .pagination-list li.active span, |
| 1398 | #{$layoutID} .rt-tpg-isotope-buttons button.selected, |
| 1399 | #{$layoutID} .rt-filter-item-wrap.rt-filter-button-wrap span.rt-filter-button-item.selected, |
| 1400 | #{$layoutID} .rt-layout-filter-container .rt-filter-sub-tax.sub-button-group .rt-filter-button-item.selected, |
| 1401 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-page-numbers .paginationjs .paginationjs-pages ul li.active>a, |
| 1402 | #{$layoutID}.rt-tpg-container .swiper-pagination-bullet.swiper-pagination-bullet-active-main{"; |
| 1403 | $css .= 'background-color:' . $button_active_bg_color . ';'; |
| 1404 | $css .= '}'; |
| 1405 | |
| 1406 | $css .= "#{$layoutID} .rt-filter-item-wrap.rt-filter-button-wrap span.rt-filter-button-item.selected, |
| 1407 | #{$layoutID} .rt-layout-filter-container .rt-filter-sub-tax.sub-button-group .rt-filter-button-item.selected, |
| 1408 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-page-numbers .paginationjs .paginationjs-pages ul li.active>a{"; |
| 1409 | $css .= 'border-color:' . $button_active_bg_color . ';'; |
| 1410 | $css .= '}'; |
| 1411 | } |
| 1412 | |
| 1413 | // Button hover bg color. |
| 1414 | if ( $button_hover_bg_color ) { |
| 1415 | $css .= "#{$layoutID} .pagination-list li a:hover, |
| 1416 | #{$layoutID} .pagination li a:hover, |
| 1417 | #{$layoutID} .rt-tpg-isotope-buttons button:hover, |
| 1418 | #{$layoutID} .rt-holder .read-more a:hover, |
| 1419 | #{$layoutID} .rt-tpg-utility .rt-tpg-load-more button:hover, |
| 1420 | #{$layoutID}.rt-tpg-container .swiper-pagination-bullet:hover, |
| 1421 | #{$layoutID}.rt-tpg-container .swiper-navigation .slider-btn:hover, |
| 1422 | #{$layoutID} .wc1 .rt-holder .rt-img-holder .overlay .product-more ul li a:hover, |
| 1423 | #{$layoutID} .wc2 .rt-detail .rt-wc-add-to-cart:hover, |
| 1424 | #{$layoutID} .wc3 .rt-detail .rt-wc-add-to-cart:hover, |
| 1425 | #{$layoutID} .wc4 .rt-detail .rt-wc-add-to-cart:hover, |
| 1426 | #{$layoutID} .wc-carousel2 .rt-detail .rt-wc-add-to-cart:hover, |
| 1427 | #{$layoutID} .wc-isotope2 .rt-detail .rt-wc-add-to-cart:hover, |
| 1428 | #{$layoutID} .rt-layout-filter-container .rt-filter-wrap .rt-filter-item-wrap.rt-filter-dropdown-wrap .rt-filter-dropdown .rt-filter-dropdown-item:hover, |
| 1429 | #{$layoutID} .rt-layout-filter-container .rt-filter-wrap .rt-filter-item-wrap.rt-filter-dropdown-wrap .rt-filter-dropdown .rt-filter-dropdown-item.selected, |
| 1430 | #{$layoutID} .rt-filter-item-wrap.rt-filter-button-wrap span.rt-filter-button-item:hover, |
| 1431 | #{$layoutID} .rt-layout-filter-container .rt-filter-sub-tax.sub-button-group .rt-filter-button-item:hover, |
| 1432 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-page-numbers .paginationjs .paginationjs-pages ul li>a:hover, |
| 1433 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-cb-page-prev-next > *:hover, |
| 1434 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-loadmore-btn:hover, |
| 1435 | #{$layoutID} .rt-read-more:hover, |
| 1436 | #{$layoutID} .rt-tpg-utility .rt-tpg-load-more button:hover{"; |
| 1437 | $css .= 'background-color:' . $button_hover_bg_color . ';'; |
| 1438 | $css .= '}'; |
| 1439 | |
| 1440 | $css .= "#{$layoutID} .rt-filter-item-wrap.rt-filter-button-wrap span.rt-filter-button-item:hover, |
| 1441 | #{$layoutID} .rt-layout-filter-container .rt-filter-sub-tax.sub-button-group .rt-filter-button-item:hover, |
| 1442 | #{$layoutID}.rt-tpg-container .swiper-navigation .slider-btn:hover, |
| 1443 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-page-numbers .paginationjs .paginationjs-pages ul li>a:hover{"; |
| 1444 | $css .= 'border-color:' . $button_hover_bg_color . ';'; |
| 1445 | $css .= '}'; |
| 1446 | $css .= "#{$layoutID}.rt-tpg-container .layout17 .rt-holder .overlay a.tpg-zoom:hover .fa{"; |
| 1447 | $css .= 'color:' . $button_hover_bg_color . ';'; |
| 1448 | $css .= '}'; |
| 1449 | } |
| 1450 | |
| 1451 | // Button text color. |
| 1452 | if ( $button_text_color ) { |
| 1453 | $css .= "#{$layoutID} .pagination-list li a, |
| 1454 | #{$layoutID} .pagination li a, |
| 1455 | #{$layoutID} .rt-tpg-isotope-buttons button, |
| 1456 | #{$layoutID} .rt-holder .read-more a, |
| 1457 | #{$layoutID} .rt-tpg-utility .rt-tpg-load-more button, |
| 1458 | #{$layoutID}.rt-tpg-container .swiper-navigation .slider-btn, |
| 1459 | #{$layoutID} .wc1 .rt-holder .rt-img-holder .overlay .product-more ul li a, |
| 1460 | #{$layoutID} .edd1 .rt-holder .rt-img-holder .overlay .product-more ul li a, |
| 1461 | #{$layoutID} .wc2 .rt-detail .rt-wc-add-to-cart, |
| 1462 | #{$layoutID} .wc3 .rt-detail .rt-wc-add-to-cart, |
| 1463 | #{$layoutID} .edd2 .rt-detail .rt-wc-add-to-cart, |
| 1464 | #{$layoutID} .wc4 .rt-detail .rt-wc-add-to-cart, |
| 1465 | #{$layoutID} .edd3 .rt-detail .rt-wc-add-to-cart, |
| 1466 | #{$layoutID} .wc-carousel2 .rt-detail .rt-wc-add-to-cart, |
| 1467 | #{$layoutID} .wc-isotope2 .rt-detail .rt-wc-add-to-cart, |
| 1468 | #{$layoutID} .rt-tpg-utility .rt-tpg-load-more button, |
| 1469 | #rt-tooltip-{$id}, |
| 1470 | #{$layoutID} .rt-filter-item-wrap.rt-filter-button-wrap span.rt-filter-button-item, |
| 1471 | #{$layoutID} .rt-layout-filter-container .rt-filter-sub-tax.sub-button-group .rt-filter-button-item, |
| 1472 | #{$layoutID} .rt-layout-filter-container .rt-filter-wrap .rt-filter-item-wrap.rt-sort-order-action, |
| 1473 | #{$layoutID} .rt-layout-filter-container .rt-filter-wrap .rt-filter-item-wrap.rt-filter-dropdown-wrap .rt-filter-dropdown .rt-filter-dropdown-item, |
| 1474 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-page-numbers .paginationjs .paginationjs-pages ul li>a, |
| 1475 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-cb-page-prev-next > *, |
| 1476 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-loadmore-btn, |
| 1477 | #{$layoutID} .rt-read-more, |
| 1478 | #rt-tooltip-{$id} .rt-tooltip-bottom:after{"; |
| 1479 | $css .= 'color:' . $button_text_color . ';'; |
| 1480 | $css .= '}'; |
| 1481 | } |
| 1482 | |
| 1483 | if ( $button_hover_text_color ) { |
| 1484 | $css .= "#{$layoutID} .rt-filter-item-wrap.rt-filter-button-wrap span.rt-filter-button-item:hover, |
| 1485 | #{$layoutID} .rt-holder .read-more a:hover, |
| 1486 | #{$layoutID}.rt-tpg-container .swiper-navigation .slider-btn:hover, |
| 1487 | #{$layoutID} .rt-layout-filter-container .rt-filter-sub-tax.sub-button-group .rt-filter-button-item:hover, |
| 1488 | #{$layoutID} .rt-layout-filter-container .rt-filter-wrap .rt-filter-item-wrap.rt-filter-dropdown-wrap .rt-filter-dropdown .rt-filter-dropdown-item:hover, |
| 1489 | #{$layoutID} .rt-layout-filter-container .rt-filter-wrap .rt-filter-item-wrap.rt-filter-dropdown-wrap .rt-filter-dropdown .rt-filter-dropdown-item.selected, |
| 1490 | #{$layoutID} .rt-layout-filter-container .rt-filter-wrap .rt-filter-item-wrap.rt-sort-order-action:hover, |
| 1491 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-page-numbers .paginationjs .paginationjs-pages ul li.active>a:hover, |
| 1492 | #{$layoutID} .rt-filter-item-wrap.rt-filter-button-wrap span.rt-filter-button-item.selected, |
| 1493 | #{$layoutID} .rt-layout-filter-container .rt-filter-wrap .rt-filter-item-wrap.rt-sort-order-action, |
| 1494 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-loadmore-btn:hover, |
| 1495 | #{$layoutID} .rt-read-more:hover, |
| 1496 | #{$layoutID}.rt-tpg-container .rt-pagination-wrap .rt-page-numbers .paginationjs .paginationjs-pages ul li.active>a{"; |
| 1497 | $css .= 'color:' . $button_hover_text_color . ';'; |
| 1498 | $css .= '}'; |
| 1499 | } |
| 1500 | |
| 1501 | if ( $overlay_color || $overlay_padding ) { |
| 1502 | if ( in_array( $layout, [ 'layout15', 'isotope11', 'carousel11' ] ) ) { |
| 1503 | $css .= "#{$layoutID} .{$layout} .rt-holder:hover .overlay .post-info{"; |
| 1504 | } elseif ( in_array( |
| 1505 | $layout, |
| 1506 | [ 'layout10', 'isotope7', 'carousel6', 'carousel7', 'layout9', 'offset04' ] |
| 1507 | ) |
| 1508 | ) { |
| 1509 | $css .= "#{$layoutID} .{$layout} .rt-holder .post-info{"; |
| 1510 | } elseif ( in_array( $layout, [ 'layout7', 'isotope4', 'carousel4' ] ) ) { |
| 1511 | $css .= "#{$layoutID} .{$layout} .rt-holder .overlay:hover{"; |
| 1512 | } elseif ( in_array( $layout, [ 'layout16', 'isotope12', 'carousel12' ] ) ) { |
| 1513 | $css .= "#{$layoutID} .{$layout} .rt-holder .overlay .post-info {"; |
| 1514 | } elseif ( in_array( $layout, [ 'offset03', 'carousel5' ] ) ) { |
| 1515 | $css .= "#{$layoutID} .{$layout} .rt-holder .overlay{"; |
| 1516 | } else { |
| 1517 | $css .= "#{$layoutID} .rt-post-overlay .post-img > a:first-of-type::after,"; |
| 1518 | $css .= "#{$layoutID} .rt-holder .overlay:hover{"; |
| 1519 | } |
| 1520 | |
| 1521 | if ( $overlay_color ) { |
| 1522 | $css .= 'background-image: none;'; |
| 1523 | $css .= 'background-color:' . $overlay_color . ';'; |
| 1524 | } |
| 1525 | |
| 1526 | if ( $overlay_padding ) { |
| 1527 | $css .= 'padding-top:' . $overlay_padding . '%;'; |
| 1528 | } |
| 1529 | |
| 1530 | $css .= '}'; |
| 1531 | } |
| 1532 | |
| 1533 | if ( $boxShadow ) { |
| 1534 | $css .= "#{$layoutID} .{$layout} .rt-holder {"; |
| 1535 | $css .= "box-shadow : 0px 0px 2px 0px {$boxShadow};"; |
| 1536 | $css .= '}'; |
| 1537 | } |
| 1538 | |
| 1539 | /* gutter */ |
| 1540 | if ( $gutter ) { |
| 1541 | $css .= "#{$layoutID} [class*='rt-col-'] {"; |
| 1542 | $css .= "padding-left : {$gutter}px !important;"; |
| 1543 | $css .= "padding-right : {$gutter}px !important;"; |
| 1544 | $css .= "margin-top : {$gutter}px;"; |
| 1545 | $css .= "margin-bottom : {$gutter}px;"; |
| 1546 | $css .= '}'; |
| 1547 | $css .= "#{$layoutID} .rt-row{"; |
| 1548 | $css .= "margin-left : -{$gutter}px !important;"; |
| 1549 | $css .= "margin-right : -{$gutter}px !important;"; |
| 1550 | $css .= '}'; |
| 1551 | $css .= "#{$layoutID}.rt-container-fluid,#{$layoutID}.rt-container{"; |
| 1552 | $css .= "padding-left : {$gutter}px;"; |
| 1553 | $css .= "padding-right : {$gutter}px;"; |
| 1554 | $css .= '}'; |
| 1555 | |
| 1556 | // remove inner row margin. |
| 1557 | $css .= "#{$layoutID} .rt-row .rt-row [class*='rt-col-'] {"; |
| 1558 | $css .= 'margin-top : 0;'; |
| 1559 | $css .= '}'; |
| 1560 | } |
| 1561 | |
| 1562 | // Read more button border radius. |
| 1563 | if ( isset( $read_more_button_border_radius ) || trim( $read_more_button_border_radius ) !== '' ) { |
| 1564 | $css .= "#{$layoutID} .read-more a{"; |
| 1565 | $css .= 'border-radius:' . $read_more_button_border_radius . 'px;'; |
| 1566 | $css .= '}'; |
| 1567 | } |
| 1568 | |
| 1569 | // Section. |
| 1570 | if ( $sectionBg ) { |
| 1571 | $css .= "#{$layoutID}.rt-tpg-container {"; |
| 1572 | $css .= 'background:' . $sectionBg . ';'; |
| 1573 | $css .= '}'; |
| 1574 | } |
| 1575 | |
| 1576 | if ( $sectionMargin ) { |
| 1577 | $css .= "#{$layoutID}.rt-tpg-container {"; |
| 1578 | $css .= 'margin:' . $sectionMargin . 'px;'; |
| 1579 | $css .= '}'; |
| 1580 | } |
| 1581 | |
| 1582 | if ( $sectionPadding ) { |
| 1583 | $css .= "#{$layoutID}.rt-tpg-container {"; |
| 1584 | $css .= 'padding:' . $sectionPadding . 'px;'; |
| 1585 | $css .= '}'; |
| 1586 | } |
| 1587 | |
| 1588 | // Box. |
| 1589 | if ( $boxBg ) { |
| 1590 | $css .= "#{$layoutID} .rt-holder, #{$layoutID} .rt-holder .rt-detail,#{$layoutID} .rt-post-overlay .post-img + .post-content {"; |
| 1591 | $css .= 'background-color:' . $boxBg . ';'; |
| 1592 | $css .= '}'; |
| 1593 | } |
| 1594 | |
| 1595 | if ( $boxBorderColor ) { |
| 1596 | $css .= "#{$layoutID} .rt-holder {"; |
| 1597 | $css .= 'border-color:' . $boxBorderColor . ';'; |
| 1598 | $css .= '}'; |
| 1599 | } |
| 1600 | |
| 1601 | if ( $boxBorder ) { |
| 1602 | $css .= "#{$layoutID} .rt-holder {"; |
| 1603 | $css .= 'border-style: solid;'; |
| 1604 | $css .= 'border-width:' . $boxBorder . 'px;'; |
| 1605 | $css .= '}'; |
| 1606 | } |
| 1607 | |
| 1608 | if ( $boxBorderRadius ) { |
| 1609 | $css .= "#{$layoutID} .rt-holder {"; |
| 1610 | $css .= 'border-radius:' . $boxBorderRadius . 'px;'; |
| 1611 | $css .= '}'; |
| 1612 | } |
| 1613 | |
| 1614 | if ( $boxPadding ) { |
| 1615 | $css .= "#{$layoutID} .rt-holder {"; |
| 1616 | $css .= 'padding:' . $boxPadding . 'px;'; |
| 1617 | $css .= '}'; |
| 1618 | } |
| 1619 | |
| 1620 | if ( $contentPadding ) { |
| 1621 | $css .= "#{$layoutID} .rt-holder .rt-detail {"; |
| 1622 | $css .= 'padding:' . $contentPadding . 'px;'; |
| 1623 | $css .= '}'; |
| 1624 | } |
| 1625 | |
| 1626 | // Widget heading. |
| 1627 | if ( $headingBg ) { |
| 1628 | $css .= "#{$layoutID} .tpg-widget-heading-wrapper.heading-style1 .tpg-widget-heading, #{$layoutID} .tpg-widget-heading-wrapper.heading-style2 .tpg-widget-heading, #{$layoutID} .tpg-widget-heading-wrapper.heading-style3 .tpg-widget-heading {"; |
| 1629 | $css .= 'background:' . $headingBg . ';'; |
| 1630 | $css .= '}'; |
| 1631 | |
| 1632 | $css .= "#{$layoutID} .tpg-widget-heading-wrapper.heading-style2 .tpg-widget-heading::after {"; |
| 1633 | $css .= 'border-top-color:' . $headingBg . ';'; |
| 1634 | $css .= '}'; |
| 1635 | } |
| 1636 | |
| 1637 | if ( $headingColor ) { |
| 1638 | $css .= "#{$layoutID} .tpg-widget-heading-wrapper.heading-style1 .tpg-widget-heading, #{$layoutID} .tpg-widget-heading-wrapper.heading-style1 .tpg-widget-heading a, #{$layoutID} .tpg-widget-heading-wrapper.heading-style2 .tpg-widget-heading, #{$layoutID} .tpg-widget-heading-wrapper.heading-style2 .tpg-widget-heading a, #{$layoutID} .tpg-widget-heading-wrapper.heading-style3 .tpg-widget-heading, #{$layoutID} .tpg-widget-heading-wrapper.heading-style3 .tpg-widget-heading a {"; |
| 1639 | $css .= 'color:' . $headingColor . ';'; |
| 1640 | $css .= '}'; |
| 1641 | $css .= "#{$layoutID} .tpg-widget-heading-wrapper.heading-style1 .tpg-widget-heading::before {"; |
| 1642 | $css .= 'background-color:' . $headingColor . ';'; |
| 1643 | $css .= '}'; |
| 1644 | } |
| 1645 | |
| 1646 | if ( $headingBorderSize ) { |
| 1647 | $css .= "#{$layoutID} .tpg-widget-heading-wrapper.heading-style1, #{$layoutID} .tpg-widget-heading-wrapper.heading-style2, #{$layoutID} .tpg-widget-heading-wrapper.heading-style3 {"; |
| 1648 | // $css .= "border-bottom-style: solid;"; |
| 1649 | $css .= 'border-bottom-width:' . $headingBorderSize . 'px;'; |
| 1650 | $css .= '}'; |
| 1651 | |
| 1652 | $css .= "#{$layoutID} .tpg-widget-heading-wrapper.heading-style1 .tpg-widget-heading-line {"; |
| 1653 | $css .= 'border-width:' . $headingBorderSize . 'px 0;'; |
| 1654 | $css .= '}'; |
| 1655 | } |
| 1656 | |
| 1657 | if ( $headingBorderColor ) { |
| 1658 | $css .= "#{$layoutID} .tpg-widget-heading-wrapper.heading-style1 .tpg-widget-heading-line, #{$layoutID} .tpg-widget-heading-wrapper.heading-style2, #{$layoutID} .tpg-widget-heading-wrapper.heading-style3 {"; |
| 1659 | $css .= 'border-color:' . $headingBorderColor . ';'; |
| 1660 | $css .= '}'; |
| 1661 | } |
| 1662 | |
| 1663 | if ( $headingMargin ) { |
| 1664 | $css .= "#{$layoutID} .tpg-widget-heading-wrapper {"; |
| 1665 | $css .= 'margin:' . $headingMargin . 'px;'; |
| 1666 | $css .= '}'; |
| 1667 | } |
| 1668 | |
| 1669 | if ( $headingPadding ) { |
| 1670 | $css .= "#{$layoutID} .tpg-widget-heading-wrapper .tpg-widget-heading {"; |
| 1671 | $css .= 'padding:' . $headingPadding . 'px;'; |
| 1672 | $css .= '}'; |
| 1673 | } |
| 1674 | |
| 1675 | // Image border. |
| 1676 | if ( isset( $image_border_radius ) || trim( $image_border_radius ) !== '' ) { |
| 1677 | $css .= "#{$layoutID} .rt-img-holder img.rt-img-responsive,#{$layoutID} .rt-img-holder, |
| 1678 | #{$layoutID} .rt-post-overlay .post-img, |
| 1679 | #{$layoutID} .post-sm .post-img, |
| 1680 | #{$layoutID} .rt-post-grid .post-img, |
| 1681 | #{$layoutID} .post-img img {"; |
| 1682 | $css .= 'border-radius:' . $image_border_radius . 'px;'; |
| 1683 | $css .= '}'; |
| 1684 | } |
| 1685 | |
| 1686 | // Title decoration. |
| 1687 | if ( $title_color || $title_size || $title_weight || $title_alignment ) { |
| 1688 | $css .= "#{$layoutID} .{$layout} .rt-holder h2.entry-title, |
| 1689 | #{$layoutID} .{$layout} .rt-holder h3.entry-title, |
| 1690 | #{$layoutID} .{$layout} .rt-holder h4.entry-title, |
| 1691 | #{$layoutID} .{$layout} .rt-holder h2.entry-title a, |
| 1692 | #{$layoutID} .{$layout} .rt-holder h3.entry-title a, |
| 1693 | #{$layoutID} .{$layout} .rt-holder h4.entry-title a, |
| 1694 | #{$layoutID} .rt-holder .rt-woo-info h2 a, |
| 1695 | #{$layoutID} .rt-holder .rt-woo-info h3 a, |
| 1696 | #{$layoutID} .rt-holder .rt-woo-info h4 a, |
| 1697 | #{$layoutID} .post-content .post-title, |
| 1698 | #{$layoutID} .rt-post-grid .post-title, |
| 1699 | #{$layoutID} .rt-post-grid .post-title a, |
| 1700 | #{$layoutID} .post-content .post-title a, |
| 1701 | #{$layoutID} .rt-holder .rt-woo-info h2, |
| 1702 | #{$layoutID} .rt-holder .rt-woo-info h3, |
| 1703 | #{$layoutID} .rt-holder .rt-woo-info h4{"; |
| 1704 | |
| 1705 | if ( $title_color ) { |
| 1706 | $css .= 'color:' . $title_color . ';'; |
| 1707 | } |
| 1708 | |
| 1709 | if ( $title_size ) { |
| 1710 | $lineHeight = $title_size + 10; |
| 1711 | $css .= 'font-size:' . $title_size . 'px;'; |
| 1712 | $css .= 'line-height:' . $lineHeight . 'px;'; |
| 1713 | } |
| 1714 | |
| 1715 | if ( $title_weight ) { |
| 1716 | $css .= 'font-weight:' . $title_weight . ';'; |
| 1717 | } |
| 1718 | |
| 1719 | if ( $title_alignment ) { |
| 1720 | $css .= 'text-align:' . $title_alignment . ';'; |
| 1721 | } |
| 1722 | |
| 1723 | $css .= '}'; |
| 1724 | |
| 1725 | if ( $title_size ) { |
| 1726 | $css .= "#{$layoutID} .post-grid-lg-style-1 .post-title, |
| 1727 | #{$layoutID} .post-grid-lg-style-1 .post-title a, |
| 1728 | #{$layoutID} .big-layout .post-title, |
| 1729 | #{$layoutID} .big-layout .post-title a, |
| 1730 | #{$layoutID} .post-grid-lg-style-1 .post-title, |
| 1731 | #{$layoutID} .post-grid-lg-style-1 .post-title a {"; |
| 1732 | $css .= 'font-size:' . ( $title_size + 8 ) . 'px;'; |
| 1733 | $css .= 'line-height:' . ( $lineHeight + 8 ) . 'px;'; |
| 1734 | $css .= '}'; |
| 1735 | } |
| 1736 | } |
| 1737 | |
| 1738 | // Title hover color. |
| 1739 | if ( $title_hover_color ) { |
| 1740 | $css .= "#{$layoutID} .{$layout} .rt-holder h2.entry-title:hover, |
| 1741 | #{$layoutID} .{$layout} .rt-holder h3.entry-title:hover, |
| 1742 | #{$layoutID} .{$layout} .rt-holder h4.entry-title:hover, |
| 1743 | #{$layoutID} .{$layout} .rt-holder h2.entry-title a:hover, |
| 1744 | #{$layoutID} .{$layout} .rt-holder h3.entry-title a:hover, |
| 1745 | #{$layoutID} .{$layout} .rt-holder h4.entry-title a:hover, |
| 1746 | #{$layoutID} .post-content .post-title a:hover, |
| 1747 | #{$layoutID} .rt-post-grid .post-title a:hover, |
| 1748 | #{$layoutID} .rt-holder .rt-woo-info h2 a:hover, |
| 1749 | #{$layoutID} .rt-holder .rt-woo-info h3 a:hover, |
| 1750 | #{$layoutID} .rt-holder .rt-woo-info h4 a:hover, |
| 1751 | #{$layoutID} .rt-holder .rt-woo-info h2:hover, |
| 1752 | #{$layoutID} .rt-holder .rt-woo-info h3:hover, |
| 1753 | #{$layoutID} .rt-holder .rt-woo-info h4:hover{"; |
| 1754 | $css .= 'color:' . $title_hover_color . ' !important;'; |
| 1755 | $css .= '}'; |
| 1756 | } |
| 1757 | // Excerpt decoration. |
| 1758 | if ( $excerpt_color || $excerpt_size || $excerpt_weight || $excerpt_alignment ) { |
| 1759 | $css .= "#{$layoutID} .{$layout} .rt-holder .tpg-excerpt,#{$layoutID} .{$layout} .tpg-excerpt,#{$layoutID} .{$layout} .rt-holder .post-content,#{$layoutID} .rt-holder .rt-woo-info p,#{$layoutID} .post-content p {"; |
| 1760 | |
| 1761 | if ( $excerpt_color ) { |
| 1762 | $css .= 'color:' . $excerpt_color . ';'; |
| 1763 | } |
| 1764 | |
| 1765 | if ( $excerpt_size ) { |
| 1766 | $css .= 'font-size:' . $excerpt_size . 'px;'; |
| 1767 | } |
| 1768 | |
| 1769 | if ( $excerpt_weight ) { |
| 1770 | $css .= 'font-weight:' . $excerpt_weight . ';'; |
| 1771 | } |
| 1772 | |
| 1773 | if ( $excerpt_alignment ) { |
| 1774 | $css .= 'text-align:' . $excerpt_alignment . ';'; |
| 1775 | } |
| 1776 | |
| 1777 | $css .= '}'; |
| 1778 | } |
| 1779 | |
| 1780 | // Post meta decoration. |
| 1781 | if ( $meta_data_color || $meta_data_size || $meta_data_weight || $meta_data_alignment ) { |
| 1782 | $css .= "#{$layoutID} .{$layout} .rt-holder .post-meta-user, |
| 1783 | #{$layoutID} .{$layout} .rt-meta, |
| 1784 | #{$layoutID} .{$layout} .rt-meta a, |
| 1785 | #{$layoutID} .{$layout} .rt-holder .post-meta-user .meta-data, |
| 1786 | #{$layoutID} .{$layout} .rt-holder .post-meta-user a, |
| 1787 | #{$layoutID} .{$layout} .rt-holder .rt-detail .post-meta .rt-tpg-social-share, |
| 1788 | #{$layoutID} .rt-post-overlay .post-meta-user span, |
| 1789 | #{$layoutID} .rt-post-overlay .post-meta-user, |
| 1790 | #{$layoutID} .rt-post-overlay .post-meta-user a, |
| 1791 | #{$layoutID} .rt-post-grid .post-meta-user, |
| 1792 | #{$layoutID} .rt-post-grid .post-meta-user a, |
| 1793 | #{$layoutID} .rt-post-box-media-style .post-meta-user, |
| 1794 | #{$layoutID} .rt-post-box-media-style .post-meta-user a, |
| 1795 | #{$layoutID} .{$layout} .post-meta-user i, |
| 1796 | #{$layoutID} .rt-detail .post-meta-category a, |
| 1797 | #{$layoutID} .{$layout} .post-meta-user a |
| 1798 | #{$layoutID} .{$layout} .post-meta-user a {"; |
| 1799 | |
| 1800 | if ( $meta_data_color ) { |
| 1801 | $css .= 'color:' . $meta_data_color . ';'; |
| 1802 | } |
| 1803 | |
| 1804 | if ( $meta_data_size ) { |
| 1805 | $css .= 'font-size:' . $meta_data_size . 'px;'; |
| 1806 | } |
| 1807 | |
| 1808 | if ( $meta_data_weight ) { |
| 1809 | $css .= 'font-weight:' . $meta_data_weight . ';'; |
| 1810 | } |
| 1811 | |
| 1812 | if ( $meta_data_alignment ) { |
| 1813 | $css .= 'text-align:' . $meta_data_alignment . ';'; |
| 1814 | } |
| 1815 | |
| 1816 | $css .= '}'; |
| 1817 | } |
| 1818 | |
| 1819 | // Category. |
| 1820 | if ( $catBg ) { |
| 1821 | $css .= "#{$layoutID} .cat-over-image.style2 .categories-links a, |
| 1822 | #{$layoutID} .cat-over-image.style3 .categories-links a, |
| 1823 | #{$layoutID} .cat-above-title.style2 .categories-links a, |
| 1824 | #{$layoutID} .cat-above-title.style3 .categories-links a, |
| 1825 | #{$layoutID} .rt-tpg-category > a { |
| 1826 | background-color: {$catBg}; |
| 1827 | }"; |
| 1828 | |
| 1829 | $css .= "#{$layoutID} .cat-above-title.style3 .categories-links a:after, |
| 1830 | .cat-over-image.style3 .categories-links a:after, |
| 1831 | #{$layoutID} .rt-tpg-category > a, |
| 1832 | #{$layoutID} .rt-tpg-category.style3 > a:after { |
| 1833 | border-top-color: {$catBg} ; |
| 1834 | }"; |
| 1835 | |
| 1836 | $css .= "#{$layoutID} .rt-tpg-category:not(style1) i { |
| 1837 | color: {$catBg}; |
| 1838 | }"; |
| 1839 | } |
| 1840 | |
| 1841 | if ( $catTextColor ) { |
| 1842 | $css .= "#{$layoutID} .cat-over-image .categories-links a, |
| 1843 | #{$layoutID} .cat-above-title .categories-links a, |
| 1844 | #{$layoutID} .rt-tpg-category.style1 > i, |
| 1845 | #{$layoutID} .rt-tpg-category > a {"; |
| 1846 | $css .= 'color:' . $catTextColor . ';'; |
| 1847 | $css .= '}'; |
| 1848 | } |
| 1849 | |
| 1850 | if ( $catBorderRadius ) { |
| 1851 | $css .= "#{$layoutID} .cat-over-image .categories-links a,#{$layoutID} .cat-above-title .categories-links a,#{$layoutID} .rt-tpg-category > a{"; |
| 1852 | $css .= 'border-radius:' . $catBorderRadius . 'px;'; |
| 1853 | $css .= '}'; |
| 1854 | } |
| 1855 | |
| 1856 | if ( $catPadding ) { |
| 1857 | $css .= "#{$layoutID} .cat-over-image .categories-links a,#{$layoutID} .cat-above-title .categories-links a,#{$layoutID} .rt-tpg-category > a{"; |
| 1858 | $css .= 'padding:' . $catPadding . 'px;'; |
| 1859 | $css .= '}'; |
| 1860 | } |
| 1861 | |
| 1862 | if ( $catMargin ) { |
| 1863 | $css .= "#{$layoutID} .categories-links,#{$layoutID} .rt-tpg-category > a{"; |
| 1864 | $css .= 'margin:' . $catMargin . 'px;'; |
| 1865 | $css .= '}'; |
| 1866 | } |
| 1867 | |
| 1868 | if ( $categorySize ) { |
| 1869 | $css .= "#{$layoutID} .categories-links,#{$layoutID} .rt-tpg-category > a {"; |
| 1870 | $css .= 'font-size:' . $categorySize . 'px;'; |
| 1871 | $css .= '}'; |
| 1872 | } |
| 1873 | |
| 1874 | $css .= '</style>'; |
| 1875 | |
| 1876 | return $css; |
| 1877 | } |
| 1878 | |
| 1879 | public static function get_meta_keys( $post_type ) { |
| 1880 | $meta_keys = self::generate_meta_keys( $post_type ); |
| 1881 | |
| 1882 | return $meta_keys; |
| 1883 | } |
| 1884 | |
| 1885 | public static function generate_meta_keys( $post_type ) { |
| 1886 | $meta_keys = []; |
| 1887 | |
| 1888 | if ( $post_type ) { |
| 1889 | global $wpdb; |
| 1890 | |
| 1891 | $query = "SELECT DISTINCT($wpdb->postmeta.meta_key) |
| 1892 | FROM $wpdb->posts |
| 1893 | LEFT JOIN $wpdb->postmeta |
| 1894 | ON $wpdb->posts.ID = $wpdb->postmeta.post_id |
| 1895 | WHERE $wpdb->posts.post_type = '%s' |
| 1896 | AND $wpdb->postmeta.meta_key != '' |
| 1897 | AND $wpdb->postmeta.meta_key NOT RegExp '(^[_0-9].+$)' |
| 1898 | AND $wpdb->postmeta.meta_key NOT RegExp '(^[0-9]+$)'"; |
| 1899 | $meta_keys = $wpdb->get_col( $wpdb->prepare( $query, $post_type ) ); |
| 1900 | } |
| 1901 | |
| 1902 | return $meta_keys; |
| 1903 | } |
| 1904 | |
| 1905 | public static function remove_all_shortcode( $content ) { |
| 1906 | return preg_replace( '#\[[^\]]+\]#', '', $content ); |
| 1907 | } |
| 1908 | |
| 1909 | public static function remove_divi_shortcodes( $content ) { |
| 1910 | $content = preg_replace( '/\[\/?et_pb.*?\]/', '', $content ); |
| 1911 | |
| 1912 | return $content; |
| 1913 | } |
| 1914 | |
| 1915 | public static function is_acf() { |
| 1916 | $plugin = null; |
| 1917 | |
| 1918 | if ( class_exists( 'acf' ) ) { |
| 1919 | $plugin = 'acf'; |
| 1920 | } |
| 1921 | |
| 1922 | return $plugin; |
| 1923 | } |
| 1924 | |
| 1925 | public static function get_groups_by_post_type( $post_type ) { |
| 1926 | $post_type = $post_type ? $post_type : 'post'; |
| 1927 | $groups = []; |
| 1928 | $plugin = self::is_acf(); |
| 1929 | |
| 1930 | switch ( $plugin ) { |
| 1931 | case 'acf': |
| 1932 | $groups = self::get_groups_by_post_type_acf( $post_type ); |
| 1933 | break; |
| 1934 | } |
| 1935 | |
| 1936 | return $groups; |
| 1937 | } |
| 1938 | |
| 1939 | /** |
| 1940 | * Get ACF post group |
| 1941 | * |
| 1942 | * @param $post_type |
| 1943 | * |
| 1944 | * @return array |
| 1945 | */ |
| 1946 | public static function get_groups_by_post_type_acf( $post_type ) { |
| 1947 | $groups = []; |
| 1948 | $groups_q = get_posts( |
| 1949 | [ |
| 1950 | 'post_type' => 'acf-field-group', |
| 1951 | 'posts_per_page' => - 1, |
| 1952 | ] |
| 1953 | ); |
| 1954 | |
| 1955 | if ( ! empty( $groups_q ) ) { |
| 1956 | foreach ( $groups_q as $group ) { |
| 1957 | $c = $group->post_content ? unserialize( $group->post_content ) : []; |
| 1958 | $flag = false; |
| 1959 | |
| 1960 | if ( ! empty( $c['location'] ) ) { |
| 1961 | foreach ( $c['location'] as $rules ) { |
| 1962 | foreach ( $rules as $rule ) { |
| 1963 | if ( 'all' === $post_type ) { |
| 1964 | if ( ( ! empty( $rule['param'] ) && $rule['param'] == 'post_type' ) && ( ! empty( $rule['operator'] ) && $rule['operator'] == '==' ) |
| 1965 | ) { |
| 1966 | $flag = true; |
| 1967 | } |
| 1968 | } else { |
| 1969 | if ( ( ! empty( $rule['param'] ) && ( $rule['param'] == 'post_type' || ( $rule['param'] == 'post_category' && 'post' == $post_type ) ) ) && ( ! empty( $rule['operator'] ) && $rule['operator'] == '==' ) && ( ! empty( $rule['value'] ) && ( $rule['value'] == $post_type || ( $rule['param'] == 'post_category' && 'post' == $post_type ) ) ) |
| 1970 | |
| 1971 | ) { |
| 1972 | $flag = true; |
| 1973 | } |
| 1974 | } |
| 1975 | } |
| 1976 | } |
| 1977 | } |
| 1978 | if ( $flag ) { |
| 1979 | $groups[ $group->ID ] = $group->post_title; |
| 1980 | } |
| 1981 | } |
| 1982 | } |
| 1983 | |
| 1984 | return $groups; |
| 1985 | } |
| 1986 | |
| 1987 | /** |
| 1988 | * Get Post view count meta key |
| 1989 | * |
| 1990 | * @return string |
| 1991 | */ |
| 1992 | public static function get_post_view_count_meta_key() { |
| 1993 | $count_key = 'tpg-post-view-count'; |
| 1994 | |
| 1995 | return apply_filters( 'tpg_post_view_count', $count_key ); |
| 1996 | } |
| 1997 | |
| 1998 | |
| 1999 | /** |
| 2000 | * Elementor Functionality |
| 2001 | * ************************************************ |
| 2002 | */ |
| 2003 | |
| 2004 | |
| 2005 | /** |
| 2006 | * Default layout style check |
| 2007 | * |
| 2008 | * @param $data |
| 2009 | * |
| 2010 | * @return bool |
| 2011 | */ |
| 2012 | public static function el_ignore_layout( $data ) { |
| 2013 | if ( isset( $data['category'] ) && 'category' == $data['category'] ) { |
| 2014 | return true; |
| 2015 | } |
| 2016 | |
| 2017 | if ( 'default' == $data['category_position'] |
| 2018 | && in_array( |
| 2019 | $data['layout'], |
| 2020 | [ |
| 2021 | 'grid-layout4', |
| 2022 | 'grid-layout5', |
| 2023 | 'grid-layout5-2', |
| 2024 | 'grid-layout6', |
| 2025 | 'grid-layout6-2', |
| 2026 | 'list-layout4', |
| 2027 | 'list-layout5', |
| 2028 | 'grid_hover-layout5', |
| 2029 | 'grid_hover-layout6', |
| 2030 | 'grid_hover-layout7', |
| 2031 | 'grid_hover-layout8', |
| 2032 | 'grid_hover-layout9', |
| 2033 | 'grid_hover-layout10', |
| 2034 | 'grid_hover-layout5-2', |
| 2035 | 'grid_hover-layout6-2', |
| 2036 | 'grid_hover-layout7-2', |
| 2037 | 'grid_hover-layout9-2', |
| 2038 | 'slider-layout5', |
| 2039 | 'slider-layout6', |
| 2040 | 'slider-layout7', |
| 2041 | 'slider-layout8', |
| 2042 | 'slider-layout9', |
| 2043 | 'slider-layout11', |
| 2044 | 'slider-layout12', |
| 2045 | ] |
| 2046 | ) |
| 2047 | ) { |
| 2048 | return false; |
| 2049 | } |
| 2050 | |
| 2051 | return true; |
| 2052 | } |
| 2053 | |
| 2054 | /** |
| 2055 | * Get Post Link |
| 2056 | * |
| 2057 | * @param $data |
| 2058 | * @param $pID |
| 2059 | * |
| 2060 | * @return array |
| 2061 | */ |
| 2062 | public static function get_post_link( $pID, $data ) { |
| 2063 | $link_class = $link_start = $link_end = $readmore_link_start = $readmore_link_end = null; |
| 2064 | |
| 2065 | if ( 'default' == $data['post_link_type'] ) { |
| 2066 | $link_class = 'tpg-post-link'; |
| 2067 | $link_start = $readmore_link_start = sprintf( |
| 2068 | '<a data-id="%s" href="%s" class="%s" target="%s">', |
| 2069 | absint( $pID ), |
| 2070 | esc_url( get_permalink() ), |
| 2071 | esc_attr( $link_class ), |
| 2072 | esc_attr( $data['link_target'] ) |
| 2073 | ); |
| 2074 | $link_end = $readmore_link_end = '</a>'; |
| 2075 | } elseif ( 'popup' == $data['post_link_type'] ) { |
| 2076 | $link_class = 'tpg-single-popup tpg-post-link'; |
| 2077 | |
| 2078 | if ( \Elementor\Plugin::$instance->editor->is_edit_mode() ) { |
| 2079 | $link_class = 'tpg-post-link'; |
| 2080 | } |
| 2081 | |
| 2082 | $link_start = $readmore_link_start = sprintf( |
| 2083 | '<a data-id="%s" href="%s" class="%s" target="%s">', |
| 2084 | absint( $pID ), |
| 2085 | esc_url( get_permalink() ), |
| 2086 | esc_attr( $link_class ), |
| 2087 | esc_attr( $data['link_target'] ) |
| 2088 | ); |
| 2089 | $link_end = $readmore_link_end = '</a>'; |
| 2090 | } elseif ( 'multi_popup' == $data['post_link_type'] ) { |
| 2091 | $link_class = 'tpg-multi-popup tpg-post-link'; |
| 2092 | $link_start = $readmore_link_start = sprintf( |
| 2093 | '<a data-id="%s" href="%s" class="%s" target="%s">', |
| 2094 | absint( $pID ), |
| 2095 | esc_url( get_permalink() ), |
| 2096 | esc_attr( $link_class ), |
| 2097 | esc_attr( $data['link_target'] ) |
| 2098 | ); |
| 2099 | $link_end = $readmore_link_end = '</a>'; |
| 2100 | } else { |
| 2101 | $link_class = 'tpg-post-link'; |
| 2102 | $readmore_link_start = sprintf( |
| 2103 | '<a data-id="%s" href="%s" class="%s" target="%s">', |
| 2104 | absint( $pID ), |
| 2105 | esc_url( get_permalink() ), |
| 2106 | esc_attr( $link_class ), |
| 2107 | esc_attr( $data['link_target'] ) |
| 2108 | ); |
| 2109 | $readmore_link_end = '</a>'; |
| 2110 | } |
| 2111 | |
| 2112 | return [ |
| 2113 | 'link_start' => $link_start, |
| 2114 | 'link_end' => $link_end, |
| 2115 | 'readmore_link_start' => $readmore_link_start, |
| 2116 | 'readmore_link_end' => $readmore_link_end, |
| 2117 | ]; |
| 2118 | } |
| 2119 | |
| 2120 | /** |
| 2121 | * Get Post Type |
| 2122 | * |
| 2123 | * @return string[]|\WP_Post_Type[] |
| 2124 | */ |
| 2125 | public static function get_post_types() { |
| 2126 | $post_types = get_post_types( |
| 2127 | [ |
| 2128 | 'public' => true, |
| 2129 | 'show_in_nav_menus' => true, |
| 2130 | ], |
| 2131 | 'objects' |
| 2132 | ); |
| 2133 | $post_types = wp_list_pluck( $post_types, 'label', 'name' ); |
| 2134 | |
| 2135 | $exclude = [ 'attachment', 'revision', 'nav_menu_item', 'elementor_library', 'tpg_builder' ]; |
| 2136 | |
| 2137 | foreach ( $exclude as $ex ) { |
| 2138 | unset( $post_types[ $ex ] ); |
| 2139 | } |
| 2140 | |
| 2141 | if ( ! rtTPG()->hasPro() ) { |
| 2142 | $post_types = [ |
| 2143 | 'post' => $post_types['post'], |
| 2144 | 'page' => $post_types['page'], |
| 2145 | ]; |
| 2146 | } |
| 2147 | |
| 2148 | return $post_types; |
| 2149 | } |
| 2150 | |
| 2151 | /** |
| 2152 | * Get Post Meta HTML for Elementor |
| 2153 | * |
| 2154 | * @param $post_id |
| 2155 | * @param $data |
| 2156 | * |
| 2157 | * @return html markup |
| 2158 | */ |
| 2159 | public static function get_post_meta_html( $post_id, $data ) { |
| 2160 | global $post; |
| 2161 | |
| 2162 | $author_id = $post->post_author; |
| 2163 | $author_name = get_the_author_meta( 'display_name', $post->post_author ); |
| 2164 | $author = apply_filters( 'rttpg_author_link', sprintf( '<a href="%s">%s</a>', get_author_posts_url( $author_id ), $author_name ) ); |
| 2165 | |
| 2166 | $comments_number = get_comments_number( $post_id ); |
| 2167 | $comment_label = ''; |
| 2168 | |
| 2169 | if ( isset( $data['show_comment_count_label'] ) && $data['show_comment_count_label'] ) { |
| 2170 | $comment_label = $data['comment_count_label_singular']; |
| 2171 | |
| 2172 | if ( $comments_number > 1 ) { |
| 2173 | $comment_label = $data['comment_count_label_plural']; |
| 2174 | } |
| 2175 | } |
| 2176 | |
| 2177 | $comments_text = sprintf( '%s (%s)', esc_html( $comment_label ), number_format_i18n( $comments_number ) ); |
| 2178 | $date = get_the_date(); |
| 2179 | |
| 2180 | // Category and Tags Management. |
| 2181 | $_cat_id = isset( $data['post_type'] ) ? $data['post_type'] . '_taxonomy' : 'category'; |
| 2182 | $_tag_id = isset( $data['post_type'] ) ? $data['post_type'] . '_tags' : 'post_tag'; |
| 2183 | $categories = get_the_term_list( $post_id, $data[ $_cat_id ], null, '<span class="rt-separator">,</span>' ); |
| 2184 | $tags = get_the_term_list( $post_id, $data[ $_tag_id ], null, '<span class="rt-separator">,</span>' ); |
| 2185 | |
| 2186 | $count_key = self::get_post_view_count_meta_key(); |
| 2187 | $get_view_count = get_post_meta( $post_id, $count_key, true ); |
| 2188 | |
| 2189 | $meta_separator = ( $data['meta_separator'] && 'default' !== $data['meta_separator'] ) ? sprintf( "<span class='separator'>%s</span>", $data['meta_separator'] ) : null; |
| 2190 | |
| 2191 | // Author Meta. |
| 2192 | |
| 2193 | $post_meta_html = []; |
| 2194 | |
| 2195 | ob_start(); |
| 2196 | if ( '' !== $data['show_author'] ) { |
| 2197 | $is_author_avatar = null; |
| 2198 | |
| 2199 | if ( '' !== $data['show_author_image'] ) { |
| 2200 | $is_author_avatar = 'has-author-avatar'; |
| 2201 | } |
| 2202 | ?> |
| 2203 | <span class='author <?php echo esc_attr( $is_author_avatar ); ?>'> |
| 2204 | |
| 2205 | <?php |
| 2206 | if ( '' !== $data['show_author_image'] ) { |
| 2207 | echo get_avatar( $author_id, 80 ); |
| 2208 | } else { |
| 2209 | if ( $data['show_meta_icon'] === 'yes' ) { |
| 2210 | if ( isset( $data['user_icon']['value'] ) && $data['user_icon']['value'] ) { |
| 2211 | \Elementor\Icons_Manager::render_icon( $data['user_icon'], [ 'aria-hidden' => 'true' ] ); |
| 2212 | } else { |
| 2213 | echo "<i class='fa fa-user'></i>"; |
| 2214 | } |
| 2215 | } |
| 2216 | } |
| 2217 | |
| 2218 | if ( $data['author_prefix'] ) { |
| 2219 | echo "<span class='author-prefix'>" . esc_html( $data['author_prefix'] ) . '</span>'; |
| 2220 | } |
| 2221 | echo wp_kses( $author, self::allowedHtml() ); |
| 2222 | ?> |
| 2223 | </span> |
| 2224 | <?php |
| 2225 | echo wp_kses( $meta_separator, self::allowedHtml() ); |
| 2226 | } |
| 2227 | |
| 2228 | $post_meta_html['author'] = ob_get_clean(); |
| 2229 | |
| 2230 | ob_start(); |
| 2231 | // Category Meta. |
| 2232 | |
| 2233 | $category_condition = ( $categories && 'show' == $data['show_category'] && self::el_ignore_layout( $data ) && in_array( $data['category_position'], [ 'default', 'with_meta' ] ) ); |
| 2234 | |
| 2235 | if ( ! rtTPG()->hasPro() ) { |
| 2236 | $category_condition = ( $categories && 'show' == $data['show_category'] ); |
| 2237 | } |
| 2238 | |
| 2239 | if ( $category_condition ) { |
| 2240 | ?> |
| 2241 | <span class='categories-links'> |
| 2242 | <?php |
| 2243 | if ( $data['show_meta_icon'] === 'yes' ) { |
| 2244 | if ( isset( $data['cat_icon']['value'] ) && $data['cat_icon']['value'] ) { |
| 2245 | \Elementor\Icons_Manager::render_icon( $data['cat_icon'], [ 'aria-hidden' => 'true' ] ); |
| 2246 | } else { |
| 2247 | echo "<i class='fa fa-user'></i>"; |
| 2248 | } |
| 2249 | } |
| 2250 | echo wp_kses( $categories, self::allowedHtml() ); |
| 2251 | ?> |
| 2252 | </span> |
| 2253 | <?php |
| 2254 | echo wp_kses( $meta_separator, self::allowedHtml() ); |
| 2255 | } |
| 2256 | $post_meta_html['category'] = ob_get_clean(); |
| 2257 | |
| 2258 | ob_start(); |
| 2259 | // Date Meta. |
| 2260 | if ( '' !== $data['show_date'] ) { |
| 2261 | $archive_year = get_the_date( 'Y' ); |
| 2262 | $archive_month = get_the_date( 'm' ); |
| 2263 | $archive_day = get_the_date( 'j' ); |
| 2264 | |
| 2265 | ?> |
| 2266 | <span class='date'> |
| 2267 | |
| 2268 | <?php |
| 2269 | if ( $data['show_meta_icon'] === 'yes' ) { |
| 2270 | if ( isset( $data['date_icon']['value'] ) && $data['date_icon']['value'] ) { |
| 2271 | \Elementor\Icons_Manager::render_icon( $data['date_icon'], [ 'aria-hidden' => 'true' ] ); |
| 2272 | } else { |
| 2273 | echo "<i class='fa fa-user'></i>"; |
| 2274 | } |
| 2275 | } |
| 2276 | ?> |
| 2277 | <a href="<?php echo esc_url( get_day_link( $archive_year, $archive_month, $archive_day ) ); ?>"> |
| 2278 | <?php echo esc_html( $date ); ?> |
| 2279 | </a> |
| 2280 | </span> |
| 2281 | <?php |
| 2282 | echo wp_kses( $meta_separator, self::allowedHtml() ); |
| 2283 | } |
| 2284 | |
| 2285 | $post_meta_html['date'] = ob_get_clean(); |
| 2286 | |
| 2287 | ob_start(); |
| 2288 | // Tags Meta. |
| 2289 | if ( $tags && 'show' == $data['show_tags'] ) { |
| 2290 | ?> |
| 2291 | <span class='post-tags-links'> |
| 2292 | <?php |
| 2293 | if ( $data['show_meta_icon'] === 'yes' ) { |
| 2294 | if ( isset( $data['tag_icon']['value'] ) && $data['tag_icon']['value'] ) { |
| 2295 | \Elementor\Icons_Manager::render_icon( $data['tag_icon'], [ 'aria-hidden' => 'true' ] ); |
| 2296 | } else { |
| 2297 | echo "<i class='fa fa-user'></i>"; |
| 2298 | } |
| 2299 | } |
| 2300 | echo wp_kses( $tags, self::allowedHtml() ); |
| 2301 | ?> |
| 2302 | </span> |
| 2303 | <?php |
| 2304 | echo wp_kses( $meta_separator, self::allowedHtml() ); |
| 2305 | } |
| 2306 | $post_meta_html['tags'] = ob_get_clean(); |
| 2307 | |
| 2308 | ob_start(); |
| 2309 | // Comment Meta. |
| 2310 | if ( 'show' == $data['show_comment_count'] ) { |
| 2311 | ?> |
| 2312 | <span class="comment-count"> |
| 2313 | <?php |
| 2314 | if ( $data['show_meta_icon'] === 'yes' ) { |
| 2315 | if ( isset( $data['comment_icon']['value'] ) && $data['comment_icon']['value'] ) { |
| 2316 | \Elementor\Icons_Manager::render_icon( $data['comment_icon'], [ 'aria-hidden' => 'true' ] ); |
| 2317 | } else { |
| 2318 | echo "<i class='fa fa-user'></i>"; |
| 2319 | } |
| 2320 | } |
| 2321 | echo wp_kses( $comments_text, self::allowedHtml() ); |
| 2322 | ?> |
| 2323 | </span> |
| 2324 | <?php |
| 2325 | echo wp_kses( $meta_separator, self::allowedHtml() ); |
| 2326 | } |
| 2327 | |
| 2328 | $post_meta_html['comment_count'] = ob_get_clean(); |
| 2329 | |
| 2330 | ob_start(); |
| 2331 | // Post Count. |
| 2332 | if ( rtTPG()->hasPro() && 'show' == $data['show_post_count'] && ! empty( $get_view_count ) ) { |
| 2333 | ?> |
| 2334 | <span class="post-count"> |
| 2335 | <?php |
| 2336 | if ( $data['show_meta_icon'] === 'yes' ) { |
| 2337 | if ( isset( $data['post_count_icon']['value'] ) && $data['post_count_icon']['value'] ) { |
| 2338 | \Elementor\Icons_Manager::render_icon( $data['post_count_icon'], [ 'aria-hidden' => 'true' ] ); |
| 2339 | } else { |
| 2340 | echo "<i class='fa fa-eye'></i>"; |
| 2341 | } |
| 2342 | } |
| 2343 | echo wp_kses( $get_view_count, self::allowedHtml() ); |
| 2344 | ?> |
| 2345 | </span> |
| 2346 | <?php |
| 2347 | echo wp_kses( $meta_separator, self::allowedHtml() ); |
| 2348 | } |
| 2349 | |
| 2350 | $post_meta_html['post_count'] = ob_get_clean(); |
| 2351 | |
| 2352 | $meta_orering = isset( $data['meta_ordering'] ) && is_array( $data['meta_ordering'] ) ? $data['meta_ordering'] : []; |
| 2353 | |
| 2354 | foreach ( $meta_orering as $val ) { |
| 2355 | if ( isset( $post_meta_html[ $val['meta_name'] ] ) ) { |
| 2356 | echo wp_kses_post( $post_meta_html[ $val['meta_name'] ] ); |
| 2357 | } |
| 2358 | } |
| 2359 | } |
| 2360 | |
| 2361 | /** |
| 2362 | * Custom wp_kses |
| 2363 | * |
| 2364 | * @param $string |
| 2365 | * |
| 2366 | * @return string |
| 2367 | */ |
| 2368 | public static function wp_kses( $string ) { |
| 2369 | $allowed_html = [ |
| 2370 | 'a' => [ |
| 2371 | 'href' => [], |
| 2372 | 'title' => [], |
| 2373 | 'data-id' => [], |
| 2374 | 'target' => [], |
| 2375 | 'class' => [], |
| 2376 | ], |
| 2377 | 'strong' => [], |
| 2378 | 'b' => [], |
| 2379 | 'br' => [ [] ], |
| 2380 | ]; |
| 2381 | |
| 2382 | return wp_kses( $string, $allowed_html ); |
| 2383 | } |
| 2384 | |
| 2385 | |
| 2386 | /** |
| 2387 | * Get Elementor Post Title for Elementor |
| 2388 | * |
| 2389 | * @param $title_tag |
| 2390 | * @param $title |
| 2391 | * @param $link_start |
| 2392 | * @param $link_end |
| 2393 | * @param $data |
| 2394 | */ |
| 2395 | |
| 2396 | public static function get_el_post_title( $title_tag, $title, $link_start, $link_end, $data ) { |
| 2397 | echo '<div class="entry-title-wrapper">'; |
| 2398 | |
| 2399 | if ( rtTPG()->hasPro() && 'above_title' === $data['category_position'] || ! self::el_ignore_layout( $data ) ) { |
| 2400 | self::get_el_thumb_cat( $data, 'cat-above-title' ); |
| 2401 | } |
| 2402 | |
| 2403 | printf( '<%s class="entry-title">', esc_attr( $title_tag ) ); |
| 2404 | self::print_html( $link_start ); |
| 2405 | self::print_html( $title ); |
| 2406 | self::print_html( $link_end ); |
| 2407 | printf( '</%s>', esc_attr( $title_tag ) ); |
| 2408 | echo '</div>'; |
| 2409 | } |
| 2410 | |
| 2411 | static function get_el_thumb_cat( $data, $class = 'cat-over-image' ) { |
| 2412 | if ( ! ( 'show' == $data['show_meta'] && 'show' == $data['show_category'] ) ) { |
| 2413 | return; |
| 2414 | } |
| 2415 | |
| 2416 | $pID = get_the_ID(); |
| 2417 | $_cat_id = $data['post_type'] . '_taxonomy'; |
| 2418 | $categories = get_the_term_list( $pID, $data[ $_cat_id ], null, '<span class="rt-separator">,</span>' ); |
| 2419 | $category_position = $data['category_position']; |
| 2420 | |
| 2421 | if ( in_array( $data['layout'], [ 'grid-layout4' ] ) && 'default' === $data['category_position'] ) { |
| 2422 | $category_position = 'top_left'; |
| 2423 | } |
| 2424 | ?> |
| 2425 | <div class="tpg-separate-category <?php echo esc_attr( $data['category_style'] . ' ' . $category_position . ' ' . $class ); ?>"> |
| 2426 | <span class='categories-links'> |
| 2427 | <?php echo ( 'yes' === $data['show_cat_icon'] ) ? "<i class='fas fa-folder-open'></i>" : null; ?> |
| 2428 | <?php echo wp_kses( $categories, self::allowedHtml() ); ?> |
| 2429 | </span> |
| 2430 | </div> |
| 2431 | <?php |
| 2432 | } |
| 2433 | |
| 2434 | |
| 2435 | /** |
| 2436 | * Get first image from the content |
| 2437 | * |
| 2438 | * @param $post_id |
| 2439 | * @param string $type |
| 2440 | * |
| 2441 | * @return mixed|string |
| 2442 | */ |
| 2443 | public static function get_content_first_image( $post_id, $type = 'markup', $imgClass = '' ) { |
| 2444 | if ( $img = preg_match_all( |
| 2445 | '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', |
| 2446 | get_the_content( $post_id ), |
| 2447 | $matches |
| 2448 | ) |
| 2449 | ) { |
| 2450 | $imgSrc = $matches[1][0]; |
| 2451 | $size = ''; |
| 2452 | |
| 2453 | $imgAbs = str_replace( trailingslashit( site_url() ), ABSPATH, $imgSrc ); |
| 2454 | |
| 2455 | if ( file_exists( $imgAbs ) ) { |
| 2456 | $info = getimagesize( $imgAbs ); |
| 2457 | $size = isset( $info[3] ) ? $info[3] : ''; |
| 2458 | } |
| 2459 | |
| 2460 | $attachment_id = attachment_url_to_postid( $imgSrc ); |
| 2461 | $alt_text = null; |
| 2462 | |
| 2463 | if ( ! empty( $attachment_id ) ) { |
| 2464 | $alt_text = trim( wp_strip_all_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) ); |
| 2465 | } |
| 2466 | |
| 2467 | $alt = $alt_text ? $alt_text : get_the_title( $post_id ); |
| 2468 | |
| 2469 | if ( $type == 'markup' ) { |
| 2470 | if ( $imgClass !== 'swiper-lazy' ) { |
| 2471 | return "<img class='rt-img-responsive' src='{$imgSrc}' {$size} alt='{$alt}'>"; |
| 2472 | } else { |
| 2473 | return "<img class='{$imgClass}' data-src='{$imgSrc}' alt='{$alt}'>"; |
| 2474 | } |
| 2475 | } else { |
| 2476 | return $imgSrc; |
| 2477 | } |
| 2478 | } |
| 2479 | } |
| 2480 | |
| 2481 | /** |
| 2482 | * Get post thumbnail html |
| 2483 | * |
| 2484 | * @param $pID |
| 2485 | * @param $data |
| 2486 | * @param $link_start |
| 2487 | * @param $link_end |
| 2488 | * @param false $offset_size |
| 2489 | */ |
| 2490 | public static function get_post_thumbnail( $pID, $data, $link_start, $link_end, $offset_size = false ) { |
| 2491 | $thumb_cat_condition = ( ! ( 'above_title' === $data['category_position'] || 'default' === $data['category_position'] ) ); |
| 2492 | |
| 2493 | if ( 'grid-layout4' === $data['layout'] && 'default' === $data['category_position'] ) { |
| 2494 | $thumb_cat_condition = true; |
| 2495 | } elseif ( in_array( |
| 2496 | $data['layout'], |
| 2497 | [ |
| 2498 | 'grid-layout4', |
| 2499 | 'grid_hover-layout11', |
| 2500 | ] |
| 2501 | ) && 'default' === $data['category_position'] ) { |
| 2502 | $thumb_cat_condition = true; |
| 2503 | } |
| 2504 | |
| 2505 | if ( rtTPG()->hasPro() && $data['show_category'] == 'show' && $thumb_cat_condition && 'with_meta' !== $data['category_position'] ) { |
| 2506 | self::get_el_thumb_cat( $data ); |
| 2507 | } |
| 2508 | |
| 2509 | $img_link = get_the_post_thumbnail_url( $pID, 'full' ); |
| 2510 | $img_size_key = 'image'; |
| 2511 | |
| 2512 | if ( $offset_size ) { |
| 2513 | $img_size_key = 'image_offset'; |
| 2514 | } |
| 2515 | |
| 2516 | $lazy_load = ( $data['prefix'] == 'slider' && $data['lazy_load'] == 'yes' ) ? true : false; |
| 2517 | $lazy_class = 'rt-img-responsive'; |
| 2518 | |
| 2519 | if ( $lazy_load ) { |
| 2520 | $lazy_class = 'swiper-lazy'; |
| 2521 | } |
| 2522 | |
| 2523 | echo 'yes' === $data['is_thumb_linked'] ? wp_kses( $link_start, self::allowedHtml() ) : null; |
| 2524 | |
| 2525 | if ( has_post_thumbnail() && 'feature_image' === $data['media_source'] ) { |
| 2526 | $fImgSize = $data['image_size']; |
| 2527 | |
| 2528 | if ( $offset_size ) { |
| 2529 | echo get_the_post_thumbnail( $pID, $data['image_offset'] ); |
| 2530 | } else { |
| 2531 | if ( $data['image_size'] !== 'custom' ) { |
| 2532 | $attachment_id = get_post_thumbnail_id( $pID ); |
| 2533 | $thumb_info = wp_get_attachment_image_src( $attachment_id, $fImgSize ); |
| 2534 | $thumb_alt = trim( wp_strip_all_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) ); |
| 2535 | if ( $lazy_load ) { |
| 2536 | ?> |
| 2537 | <img data-src="<?php echo esc_url( $thumb_info[0] ); ?>" |
| 2538 | src="#none" |
| 2539 | class="<?php echo esc_attr( $lazy_class ); ?>" |
| 2540 | width="<?php echo esc_attr( $thumb_info[1] ); ?>" |
| 2541 | height="<?php echo esc_attr( $thumb_info[2] ); ?>" |
| 2542 | alt="<?php echo esc_attr( $thumb_alt ? $thumb_alt : the_title() ); ?>"> |
| 2543 | <?php |
| 2544 | } else { |
| 2545 | ?> |
| 2546 | <img src="<?php echo esc_url( $thumb_info[0] ); ?>" |
| 2547 | class="<?php echo esc_attr( $lazy_class ); ?>" |
| 2548 | width="<?php echo esc_attr( $thumb_info[1] ); ?>" |
| 2549 | height="<?php echo esc_attr( $thumb_info[2] ); ?>" |
| 2550 | alt="<?php echo esc_attr( $thumb_alt ? $thumb_alt : the_title() ); ?>"> |
| 2551 | <?php |
| 2552 | } |
| 2553 | ?> |
| 2554 | |
| 2555 | <?php |
| 2556 | } else { |
| 2557 | $fImgSize = 'rt_custom'; |
| 2558 | $mediaSource = 'feature_image'; |
| 2559 | $defaultImgId = null; |
| 2560 | $customImgSize = []; |
| 2561 | |
| 2562 | if ( isset( $data['image_custom_dimension'] ) ) { |
| 2563 | $post_thumb_id = get_post_thumbnail_id( $pID ); |
| 2564 | $default_image_dimension = wp_get_attachment_image_src( $post_thumb_id, 'full' ); |
| 2565 | |
| 2566 | if ( $default_image_dimension[1] <= $data['image_custom_dimension']['width'] || $default_image_dimension[2] <= $data['image_custom_dimension']['height'] ) { |
| 2567 | $customImgSize = []; |
| 2568 | } else { |
| 2569 | $customImgSize[0] = $data['image_custom_dimension']['width']; |
| 2570 | $customImgSize[1] = $data['image_custom_dimension']['height']; |
| 2571 | $customImgSize[2] = $data['img_crop_style']; |
| 2572 | } |
| 2573 | } |
| 2574 | |
| 2575 | echo wp_kses_post( self::getFeatureImageSrc( $pID, $fImgSize, $mediaSource, $defaultImgId, $customImgSize, $lazy_class ) ); |
| 2576 | } |
| 2577 | } |
| 2578 | } elseif ( 'first_image' === $data['media_source'] && self::get_content_first_image( $pID ) ) { |
| 2579 | echo wp_kses_post( self::get_content_first_image( $pID, 'markup', $lazy_class ) ); |
| 2580 | $img_link = self::get_content_first_image( $pID, 'url' ); |
| 2581 | } elseif ( 'yes' === $data['is_default_img'] || 'grid_hover' == $data['prefix'] ) { |
| 2582 | echo \Elementor\Group_Control_Image_Size::get_attachment_image_html( $data, $img_size_key, 'default_image' ); |
| 2583 | |
| 2584 | if ( ! empty( $data['default_image'] ) && isset( $data['default_image']['url'] ) ) { |
| 2585 | $img_link = $data['default_image']['url']; |
| 2586 | } |
| 2587 | } |
| 2588 | |
| 2589 | ?> |
| 2590 | <?php if ( $lazy_load ) : ?> |
| 2591 | <div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div> |
| 2592 | <?php endif; ?> |
| 2593 | |
| 2594 | <?php echo 'yes' === $data['is_thumb_linked'] ? wp_kses( $link_end, self::allowedHtml() ) : null; ?> |
| 2595 | |
| 2596 | <?php |
| 2597 | if ( 'show' === $data['is_thumb_lightbox'] || ( in_array( $data['layout'], [ 'grid-layout7', 'slider-layout4' ] ) && in_array( $data['is_thumb_lightbox'], [ 'default', 'show' ] ) ) ) : |
| 2598 | ?> |
| 2599 | <a class="tpg-zoom" |
| 2600 | data-elementor-open-lightbox="yes" |
| 2601 | data-elementor-lightbox-slideshow="<?php echo esc_attr( $data['layout'] ); ?>" |
| 2602 | title="<?php echo esc_attr( get_the_title() ); ?>" |
| 2603 | href="<?php echo esc_url( $img_link ); ?>"> |
| 2604 | |
| 2605 | <?php |
| 2606 | if ( isset( $data['light_box_icon']['value'] ) && $data['light_box_icon']['value'] ) { |
| 2607 | \Elementor\Icons_Manager::render_icon( $data['light_box_icon'], [ 'aria-hidden' => 'true' ] ); |
| 2608 | } else { |
| 2609 | echo "<i class='fa fa-plus'></i>"; |
| 2610 | } |
| 2611 | ?> |
| 2612 | </a> |
| 2613 | <?php endif; ?> |
| 2614 | <div class="overlay grid-hover-content"></div> |
| 2615 | <?php |
| 2616 | } |
| 2617 | |
| 2618 | |
| 2619 | /** |
| 2620 | * Get ACF data for elementor |
| 2621 | * |
| 2622 | * @param $data |
| 2623 | * @param $pID |
| 2624 | * |
| 2625 | * @return bool |
| 2626 | */ |
| 2627 | public static function tpg_get_acf_data_elementor( $data, $pID, $return_type = true ) { |
| 2628 | if ( ! ( rtTPG()->hasPro() && self::is_acf() ) ) { |
| 2629 | return; |
| 2630 | } |
| 2631 | |
| 2632 | if ( isset( $data['show_acf'] ) && 'show' == $data['show_acf'] ) { |
| 2633 | $cf_group = $data['cf_group']; |
| 2634 | |
| 2635 | $format = [ |
| 2636 | 'hide_empty' => ( isset( $data['cf_hide_empty_value'] ) && $data['cf_hide_empty_value'] ) ? 'yes' : '', |
| 2637 | 'show_value' => ( isset( $data['cf_show_only_value'] ) && $data['cf_show_only_value'] ) ? '' : 'yes', |
| 2638 | 'hide_group_title' => ( isset( $data['cf_hide_group_title'] ) && $data['cf_hide_group_title'] ) ? '' : 'yes', |
| 2639 | ]; |
| 2640 | |
| 2641 | if ( ! empty( $cf_group ) ) { |
| 2642 | $acf_html = "<div class='acf-custom-field-wrap'>"; |
| 2643 | $acf_html .= Functions::get_cf_formatted_fields( $cf_group, $format, $pID ); |
| 2644 | $acf_html .= '</div>'; |
| 2645 | |
| 2646 | if ( $return_type ) { |
| 2647 | self::print_html( $acf_html, true ); |
| 2648 | } else { |
| 2649 | return $acf_html; |
| 2650 | } |
| 2651 | } |
| 2652 | } |
| 2653 | } |
| 2654 | |
| 2655 | |
| 2656 | /** |
| 2657 | * Check is filter enable or not |
| 2658 | * |
| 2659 | * @param $data |
| 2660 | * |
| 2661 | * @return bool |
| 2662 | */ |
| 2663 | public static function is_filter_enable( $data ) { |
| 2664 | if ( rtTPG()->hasPro() |
| 2665 | && ( $data['show_taxonomy_filter'] == 'show' |
| 2666 | || $data['show_author_filter'] == 'show' |
| 2667 | || $data['show_order_by'] == 'show' |
| 2668 | || $data['show_sort_order'] == 'show' |
| 2669 | || $data['show_search'] == 'show' |
| 2670 | || ( $data['show_pagination'] == 'show' && $data['pagination_type'] != 'pagination' ) ) |
| 2671 | ) { |
| 2672 | return true; |
| 2673 | } |
| 2674 | |
| 2675 | return false; |
| 2676 | } |
| 2677 | |
| 2678 | /** |
| 2679 | * Prints HTML. |
| 2680 | * |
| 2681 | * @param string $html HTML. |
| 2682 | * @param bool $allHtml All HTML. |
| 2683 | * |
| 2684 | * @return mixed |
| 2685 | */ |
| 2686 | public static function print_html( $html, $allHtml = false ) { |
| 2687 | if ( $allHtml ) { |
| 2688 | echo stripslashes_deep( $html ); |
| 2689 | } else { |
| 2690 | echo wp_kses_post( stripslashes_deep( $html ) ); |
| 2691 | } |
| 2692 | } |
| 2693 | |
| 2694 | /** |
| 2695 | * Allowed HTML for wp_kses. |
| 2696 | * |
| 2697 | * @param string $level Tag level. |
| 2698 | * |
| 2699 | * @return mixed |
| 2700 | */ |
| 2701 | public static function allowedHtml( $level = 'basic' ) { |
| 2702 | $allowed_html = []; |
| 2703 | |
| 2704 | switch ( $level ) { |
| 2705 | case 'basic': |
| 2706 | $allowed_html = [ |
| 2707 | 'b' => [ |
| 2708 | 'class' => [], |
| 2709 | 'id' => [], |
| 2710 | ], |
| 2711 | 'i' => [ |
| 2712 | 'class' => [], |
| 2713 | 'id' => [], |
| 2714 | ], |
| 2715 | 'u' => [ |
| 2716 | 'class' => [], |
| 2717 | 'id' => [], |
| 2718 | ], |
| 2719 | 'br' => [ |
| 2720 | 'class' => [], |
| 2721 | 'id' => [], |
| 2722 | ], |
| 2723 | 'em' => [ |
| 2724 | 'class' => [], |
| 2725 | 'id' => [], |
| 2726 | ], |
| 2727 | 'span' => [ |
| 2728 | 'class' => [], |
| 2729 | 'id' => [], |
| 2730 | ], |
| 2731 | 'strong' => [ |
| 2732 | 'class' => [], |
| 2733 | 'id' => [], |
| 2734 | ], |
| 2735 | 'hr' => [ |
| 2736 | 'class' => [], |
| 2737 | 'id' => [], |
| 2738 | ], |
| 2739 | 'a' => [ |
| 2740 | 'href' => [], |
| 2741 | 'title' => [], |
| 2742 | 'class' => [], |
| 2743 | 'id' => [], |
| 2744 | 'target' => [], |
| 2745 | ], |
| 2746 | 'div' => [ |
| 2747 | 'class' => [], |
| 2748 | 'id' => [], |
| 2749 | ], |
| 2750 | ]; |
| 2751 | break; |
| 2752 | |
| 2753 | case 'advanced': |
| 2754 | $allowed_html = [ |
| 2755 | 'b' => [ |
| 2756 | 'class' => [], |
| 2757 | 'id' => [], |
| 2758 | ], |
| 2759 | 'i' => [ |
| 2760 | 'class' => [], |
| 2761 | 'id' => [], |
| 2762 | ], |
| 2763 | 'u' => [ |
| 2764 | 'class' => [], |
| 2765 | 'id' => [], |
| 2766 | ], |
| 2767 | 'br' => [ |
| 2768 | 'class' => [], |
| 2769 | 'id' => [], |
| 2770 | ], |
| 2771 | 'em' => [ |
| 2772 | 'class' => [], |
| 2773 | 'id' => [], |
| 2774 | ], |
| 2775 | 'span' => [ |
| 2776 | 'class' => [], |
| 2777 | 'id' => [], |
| 2778 | ], |
| 2779 | 'strong' => [ |
| 2780 | 'class' => [], |
| 2781 | 'id' => [], |
| 2782 | ], |
| 2783 | 'hr' => [ |
| 2784 | 'class' => [], |
| 2785 | 'id' => [], |
| 2786 | ], |
| 2787 | 'a' => [ |
| 2788 | 'href' => [], |
| 2789 | 'title' => [], |
| 2790 | 'class' => [], |
| 2791 | 'id' => [], |
| 2792 | 'data-id' => [], |
| 2793 | 'target' => [], |
| 2794 | ], |
| 2795 | 'input' => [ |
| 2796 | 'type' => [], |
| 2797 | 'name' => [], |
| 2798 | 'class' => [], |
| 2799 | 'value' => [], |
| 2800 | ], |
| 2801 | ]; |
| 2802 | break; |
| 2803 | |
| 2804 | case 'image': |
| 2805 | $allowed_html = [ |
| 2806 | 'img' => [ |
| 2807 | 'src' => [], |
| 2808 | 'data-src' => [], |
| 2809 | 'alt' => [], |
| 2810 | 'height' => [], |
| 2811 | 'width' => [], |
| 2812 | 'class' => [], |
| 2813 | 'id' => [], |
| 2814 | 'style' => [], |
| 2815 | 'srcset' => [], |
| 2816 | 'loading' => [], |
| 2817 | 'sizes' => [], |
| 2818 | ], |
| 2819 | 'div' => [ |
| 2820 | 'class' => [], |
| 2821 | ], |
| 2822 | ]; |
| 2823 | break; |
| 2824 | |
| 2825 | case 'anchor': |
| 2826 | $allowed_html = [ |
| 2827 | 'a' => [ |
| 2828 | 'href' => [], |
| 2829 | 'title' => [], |
| 2830 | 'class' => [], |
| 2831 | 'id' => [], |
| 2832 | 'style' => [], |
| 2833 | ], |
| 2834 | ]; |
| 2835 | break; |
| 2836 | |
| 2837 | default: |
| 2838 | // code... |
| 2839 | break; |
| 2840 | } |
| 2841 | |
| 2842 | return $allowed_html; |
| 2843 | } |
| 2844 | |
| 2845 | /** |
| 2846 | * Definition for wp_kses. |
| 2847 | * |
| 2848 | * @param string $string String to check. |
| 2849 | * @param string $level Tag level. |
| 2850 | * |
| 2851 | * @return mixed |
| 2852 | */ |
| 2853 | public static function htmlKses( $string, $level ) { |
| 2854 | if ( empty( $string ) ) { |
| 2855 | return; |
| 2856 | } |
| 2857 | |
| 2858 | return wp_kses( $string, self::allowedHtml( $level ) ); |
| 2859 | } |
| 2860 | } |
| 2861 |