plate included */ do_action( 'jet-elements/shortcodes/jet-posts/loop-item-start' ); include $loop_item; /** * Hook after loop item template included */ do_action( 'jet-elements/shortcodes/jet-posts/loop-item-end' ); } include $loop_end; /** * Hook after loop end template included */ do_action( 'jet-elements/shortcodes/jet-posts/loop-end' ); wp_reset_postdata(); return ob_get_clean(); } /** * Add box background image */ public function add_box_bg() { if ( 'yes' !== $this->get_attr( 'show_image' ) ) { return; } if ( 'background' !== $this->get_attr( 'show_image_as' ) ) { return; } if ( ! has_post_thumbnail() ) { return; } $thumb_id = get_post_thumbnail_id(); $thumb_size = $this->get_attr( 'bg_thumb_size' ); $thumb_url = wp_get_attachment_image_url( $thumb_id, $thumb_size ); printf( ' style="background-image: url(\'%1$s\'); background-repeat: no-repeat; background-size: %2$s; background-position: %3$s;"', $thumb_url, $this->get_attr( 'bg_size' ), $this->get_attr( 'bg_position' ) ); } /** * Render meta for passed position * * @param string $position * @param string $base * @param array $context * @return void */ public function render_meta( $position = '', $base = '', $context = array( 'before' ) ) { $config_key = $position . '_meta'; $show_key = 'show_' . $position . '_meta'; $position_key = 'meta_' . $position . '_position'; $meta_show = $this->get_attr( $show_key ); $meta_position = $this->get_attr( $position_key ); $meta_config = $this->get_attr( $config_key ); if ( 'yes' !== $meta_show ) { return; } if ( ! $meta_position || ! in_array( $meta_position, $context ) ) { return; } if ( empty( $meta_config ) ) { return; } $result = ''; foreach ( $meta_config as $meta ) { if ( empty( $meta['meta_key'] ) ) { continue; } $key = $meta['meta_key']; $callback = ! empty( $meta['meta_callback'] ) ? $meta['meta_callback'] : false; $value = get_post_meta( get_the_ID(), $key, false ); if ( ! $value ) { continue; } $callback_args = array( $value[0] ); if ( $callback ) { switch ( $callback ) { case 'wp_get_attachment_image': $callback_args[] = 'full'; break; case 'date': case 'date_i18n': $timestamp = $value[0]; $valid_timestamp = jet_elements_tools()->is_valid_timestamp( $timestamp ); if ( ! $valid_timestamp ) { $timestamp = strtotime( $timestamp ); } $format = ! empty( $meta['date_format'] ) ? $meta['date_format'] : 'F j, Y'; $callback_args = array( $format, $timestamp ); break; } } if ( ! empty( $callback ) && is_callable( $callback ) ) { $meta_val = call_user_func_array( $callback, $callback_args ); } else { $meta_val = $value[0]; } $meta_val = sprintf( $meta['meta_format'], $meta_val ); $label = ! empty( $meta['meta_label'] ) ? sprintf( '
%2$s
', $base, $meta['meta_label'] ) : ''; $result .= sprintf( '
%2$s
%3$s
', $base, $label, $meta_val, esc_attr( $key ) ); } if ( empty( $result ) ) { return; } printf( '
%2$s
', $base, $result ); } /** * Render post terms. * * @return void */ public function render_post_terms() { $show = $this->get_attr( 'show_terms' ); if ( 'yes' !== $show ) { return; } $tax = $this->get_attr( 'show_terms_tax' ); $terms = wp_get_post_terms( get_the_ID(), esc_attr( $tax ) ); if ( empty( $terms ) || is_wp_error( $terms ) ) { return; } $num = $this->get_attr( 'show_terms_num' ); if ( 'all' !== $num ) { $num = absint( $num ); $terms = array_slice( $terms, 0, $num ); } $format = apply_filters( 'jet-elements/shortcodes/jet-posts/post-term-format', '%1$s' ); $result = ''; foreach ( $terms as $term ) { $result .= sprintf( $format, $term->name, get_term_link( (int) $term->term_id, $tax ) ); } printf( '
%s
', $result ); } } 180-95-215 – تک ظرف پلاستیک