'list_header_hide', 'list_title_display' => 'list_title_hide', 'list_author_display' => 'list_author_hide', 'list_date_display' => 'list_date_hide', 'list_date_updated_display' => 'list_date_updated_hide', 'list_category_display' => 'list_category_hide', 'list_thumbnail_display' => 'list_thumbnail_hide', 'list_summary_display' => 'list_summary_hide', 'list_footer_display' => 'list_footer_hide', 'list_tags_display' => 'list_tags_hide', 'list_button_comment_display' => 'list_button_comment_hide', 'list_button_edit_display' => 'list_button_edit_hide', 'list_button_read_more_display' => 'list_button_read_more_hide', ); foreach ( $visibility_options as $option => $class ) { $value = get_post_meta( $content_id, 'pen_' . $option . '_override', true ); if ( $value && 'default' !== $value ) { $classes[] = 'pen_' . $class; } } $classes[] = pen_class_animation( 'list', false, $content_id ); $header_alignment = get_post_meta( $content_id, 'pen_list_header_alignment_override', true ); if ( ! $header_alignment || 'default' === $header_alignment ) { $header_alignment = pen_option_get( 'list_header_alignment' ); } if ( $header_alignment && 'no' !== $header_alignment ) { $classes[] = 'pen_list_header_center'; } $title_alignment = get_post_meta( $content_id, 'pen_list_title_alignment_override', true ); if ( ! $title_alignment || 'default' === $title_alignment ) { $title_alignment = pen_option_get( 'list_title_alignment' ); } if ( $title_alignment && 'no' !== $title_alignment ) { $classes[] = 'pen_list_title_center'; } if ( 'masonry' === $list_type || 'tiles' === $list_type ) { $type = ( 'tiles' === $list_type ) ? 'tile' : $list_type; $classes[] = 'list_' . $list_type; $thumbnail_style = pen_option_get( 'list_' . $type . '_thumbnail_style' ); // The customize.php applies some CSS to this one. $classes[] = 'pen_thumbnail_style_' . $thumbnail_style; $thumbnail_style = get_post_meta( $content_id, 'pen_list_' . $type . '_thumbnail_style_override', true ); if ( $thumbnail_style && 'default' !== $thumbnail_style ) { $classes[] = 'pen_thumbnail_style_' . $thumbnail_style; } } } /** * Adding this class just to apply a larger border-radius to the top left * and top right corners of the
element. This is to hide the * light background of the
when the header has a dark background. */ if ( $single ) { $option = 'content_header_display'; } else { $option = 'list_header_display'; } $display = get_post_meta( $content_id, 'pen_' . $option . '_override', true ); if ( ! $display || 'default' === $display ) { $display = pen_option_get( $option ); } if ( ! $display || 'no' === $display ) { $classes[] = 'pen_header_hide'; } else { $classes[] = 'pen_header_show'; } $classes = array_unique( array_filter( $classes ) ); if ( 'return_array' === $output_type ) { return get_post_class( $classes, $content_id ); } return post_class( $classes ); } } if ( ! function_exists( 'pen_thumbnail_classes' ) ) { /** * Generates class names for posts. * (Turned into a separate function since v1.2.8) * * @param string $view Whether full content or summary. * @param int $content_id Content ID. * * @return string */ function pen_thumbnail_classes( $view, $content_id = null ) { if ( ! in_array( $view, array( 'content', 'list' ), true ) ) { return; } if ( is_null( $content_id ) ) { $content_id = pen_post_id(); } $classes = array( 'post-thumbnail', 'pen_image_thumbnail', 'pen_thumbnail_size_' . sanitize_html_class( pen_content_thumbnail_size( $view, $content_id ) ), ); $animation = get_post_meta( $content_id, 'pen_' . $view . '_thumbnail_animation_reveal_override', true ); if ( ! $animation || 'default' === $animation ) { $animation = pen_option_get( $view . '_thumbnail_animation_reveal' ); } if ( $animation && 'none' !== $animation ) { $classes[] = 'pen_animate_on_scroll'; $classes[] = 'pen_custom_animation_' . sanitize_html_class( $animation ); $animation_delay = get_post_meta( $content_id, 'pen_' . $view . '_thumbnail_animation_delay_reveal_override', true ); if ( ! $animation_delay || 'default' === $animation_delay ) { $animation_delay = pen_option_get( $view . '_thumbnail_animation_delay_reveal' ); } if ( (int) $animation_delay ) { $classes[] = 'pen_custom_animation_delay_' . $animation_delay; } } return implode( ' ', array_filter( $classes ) ); } } if ( ! function_exists( 'pen_content_thumbnail_size' ) ) { /** * Calculates the thumbnail size. * (Turned into a separate function since v1.2.8) * * @param string $view Whether full content or summary. * @param int $content_id Content ID. * * @return int */ function pen_content_thumbnail_size( $view, $content_id = null ) { if ( ! in_array( $view, array( 'content', 'list' ), true ) ) { return; } if ( is_null( $content_id ) ) { $content_id = pen_post_id(); } $thumbnail_size = get_post_meta( $content_id, 'pen_' . $view . '_thumbnail_resize_override', true ); if ( ! $thumbnail_size || 'default' === $thumbnail_size ) { $thumbnail_size = pen_option_get( $view . '_thumbnail_resize' ); } if ( 'content' === $view ) { if ( 'none' === $thumbnail_size ) { if ( 'image' === get_post_type() ) { $thumbnail_size = 'large'; } else { $thumbnail_size = 'medium'; } } } else { if ( 'none' === $thumbnail_size || in_array( pen_option_get( 'list_type' ), array( 'tiles', 'masonry' ), true ) ) { $thumbnail_size = 'large'; } } return $thumbnail_size; } } if ( ! function_exists( 'pen_read_more_link' ) ) { /** * Tweaks the "Continue Reading" links. * * @since Pen 1.0.0 * @return string */ function pen_read_more_link() { $content_id = pen_post_id(); $classes = array( 'more-link', ( 'button' === pen_option_get( 'list_button_read_more_type' ) ) ? 'pen_button' : '', pen_class_lists( 'button_read_more_display_override', $content_id ), 'pen_icon_' . sanitize_html_class( pen_option_get( 'list_button_read_more_icon' ) ), ); $classes = implode( ' ', array_filter( $classes ) ); $link = sprintf( '%3$s', esc_url( get_permalink( $content_id ) ), esc_attr( $classes ), pen_read_more_text( $content_id ) ); return sprintf( ' …
%s', $link ); } if ( ! is_admin() ) { add_filter( 'excerpt_more', 'pen_read_more_link' ); add_filter( 'the_content_more_link', 'pen_read_more_link' ); } } if ( ! function_exists( 'pen_read_more_text' ) ) { /** * Changes the "Continue Reading" text. * * @param int $content_id The content ID. * * @since Pen 1.3.8 * @return string */ function pen_read_more_text( $content_id ) { $text = get_post_meta( $content_id, 'pen_list_button_read_more_text_override', true ); if ( ! $text || 'default' === $text ) { $text = pen_option_get( 'list_button_read_more_text' ); } $choices = array( 'buy_now' => __( 'Buy Now', 'pen' ), 'details' => __( 'Details', 'pen' ), 'download' => __( 'Download', 'pen' ), 'enrol_now' => __( 'Enroll Now', 'pen' ), 'free_download' => __( 'Free Download', 'pen' ), 'join_now' => __( 'Join Now', 'pen' ), 'know_more' => __( 'Know More', 'pen' ), 'members_only' => __( 'Members Only', 'pen' ), 'more' => __( 'More', 'pen' ), 'order_now' => __( 'Order Now', 'pen' ), 'read' => __( 'Read', 'pen' ), 'read_more' => __( 'Read More', 'pen' ), 'register_now' => __( 'Register Now', 'pen' ), 'view' => __( 'View', 'pen' ), ); if ( ! empty( $choices[ $text ] ) ) { $text = $choices[ $text ]; } else { $text = sprintf( /* Translators: Content title. */ __( 'Continue reading %s', 'pen' ), sprintf( '%s', get_the_title( $content_id ) ) ); } return wp_kses_post( $text ); } } if ( ! function_exists( 'pen_post_sticky' ) ) { /** * Sends sticky posts to the top of the lists. * * @param WP_Posts $posts An instance of WP_Post. * * @since Pen 1.0.0 */ function pen_post_sticky( $posts ) { $is_sticky = array(); foreach ( $posts as $key => $post ) { if ( is_sticky( $post->ID ) ) { $is_sticky[] = $post; unset( $posts[ $key ] ); } } return array_merge( $is_sticky, $posts ); } add_filter( 'the_posts', 'pen_post_sticky' ); } if ( ! function_exists( 'pen_post_sticky_exclude' ) ) { /** * Filtering out Sticky posts for the Infinite Scrolling feature. * * @param object $query An instance of the $query. * * @since Pen 1.3.9 * @return void */ function pen_post_sticky_exclude( $query ) { if ( is_home() && $query->is_main_query() ) { $query->set( 'post__not_in', get_option( 'sticky_posts' ) ); } } if ( pen_filter_input( 'GET', 'pen_sticky_exclude' ) ) { add_action( 'pre_get_posts', 'pen_post_sticky_exclude' ); } } if ( ! function_exists( 'pen_post_meta' ) ) { /** * Custom post meta data fields. * * @param object $post An instance of the $post. * * @since Pen 1.0.0 * @return void */ function pen_post_meta( $post ) { $post_type = get_post_type(); $options_animation = pen_animations(); $options_animation_delay = pen_animations_delay(); $options_image_size = pen_wp_image_sizes(); ob_start(); ?>

ID ); } else { ?>

%2$s', esc_url( self_admin_url( 'themes.php?page=pen-theme-install-plugins' ) ), esc_html__( 'Install Now', 'pen' ) ); ?>

fields. * * @param int $content_id The content ID. * @param string $setting_id The setting ID. * @param array $choices Choices. * @param mixed $default The default. * @param string $label Field label. * @param array $label_prefix Label prefix. Only visible to screen readers. * * @since Pen 1.0.8 * @return void */ function pen_post_meta_select( $content_id, $setting_id, $choices, $default, $label, $label_prefix = '' ) { $setting_id = 'pen_' . $setting_id . '_override'; $current_value = get_post_meta( $content_id, $setting_id, true ); $setting_id = esc_attr( $setting_id ); ?> ID ) ) { return; } if ( ! current_user_can( 'edit_post', $post->ID ) ) { return; } // Honey pot. if ( pen_filter_input( 'POST', md5( NONCE_SALT . $post->ID . gmdate( 'd' ) ) ) ) { return; } $options = pen_post_meta_options(); foreach ( $options as $option => $label ) { $new = pen_filter_input( 'POST', $option ); if ( $new ) { update_post_meta( $post->ID, $option, $new ); } else { delete_post_meta( $post->ID, $option ); } } // Plugin option. $meta_name = pen_filter_input( 'POST', 'pen_meta_name' ); if ( $meta_name ) { update_post_meta( $post->ID, 'pen_meta_name', $meta_name ); } else { delete_post_meta( $post->ID, 'pen_meta_name' ); } } add_action( 'save_post', 'pen_post_meta_save' ); } if ( ! function_exists( 'pen_post_meta_box' ) ) { /** * Adds the meta box. * * @param object $post An instance of the $post. * * @since Pen 1.0.0 * @return void */ function pen_post_meta_box( $post ) { if ( in_array( (string) get_post_type(), array( 'page', 'post', 'product' ), true ) ) { add_meta_box( 'pen_meta_box', __( 'Options', 'pen' ), 'pen_post_meta', get_post_type(), 'normal', 'high' ); } } add_action( 'add_meta_boxes', 'pen_post_meta_box' ); } if ( ! function_exists( 'pen_post_meta_scripts' ) ) { /** * Adds post meta JavaScripts. * * @param string $hook_suffix The file name. * * @since Pen 1.0.0 * @return void */ function pen_post_meta_scripts( $hook_suffix ) { if ( 'post.php' === $hook_suffix || 'post-new.php' === $hook_suffix ) { wp_enqueue_script( 'pen-postmeta-js', PEN_THEME_DIRECTORY_URI . '/assets/js/pen-postmeta.js', array( 'jquery' ), PEN_THEME_VERSION, true ); wp_localize_script( 'pen-postmeta-js', 'pen_postmeta_js', array( 'text' => array( 'pen_theme' => esc_html__( 'Pen', 'pen' ), 'nothing_selected' => esc_html__( 'Please select an item.', 'pen' ), 'toggle' => esc_attr( sprintf( /* Translators: Just some words. */ __( '%1$s: %2$s', 'pen' ), _x( 'Toggle Panel', 'verb', 'pen' ), sprintf( /* Translators: Just some words. */ __( '%1$s - %2$s', 'pen' ), __( 'Pen', 'pen' ), __( 'Options', 'pen' ) ) ) ), ), ) ); wp_enqueue_style( 'pen-postmeta-css', PEN_THEME_DIRECTORY_URI . '/assets/css/pen-postmeta.css', array(), PEN_THEME_VERSION ); } } add_action( 'admin_enqueue_scripts', 'pen_post_meta_scripts' ); } if ( ! function_exists( 'pen_content_title_background' ) ) { /** * Returns background image URL for content header. * * @param bool $single Result of is_singular(), for better performance. * @param int $content_id Content ID. * * @since Pen 1.1.1 * @return string */ function pen_content_title_background( $single, $content_id ) { $background_image_dynamic = ''; if ( $single ) { $thumbnail_as_background = get_post_meta( $content_id, 'pen_content_background_image_content_title_dynamic_override', true ); if ( ! $thumbnail_as_background || 'default' === $thumbnail_as_background ) { $thumbnail_as_background = pen_option_get( 'background_image_content_title_dynamic' ); } } else { $thumbnail_as_background = get_post_meta( $content_id, 'pen_list_background_image_content_title_dynamic_override', true ); if ( ! $thumbnail_as_background || 'default' === $thumbnail_as_background ) { $thumbnail_as_background = pen_option_get( 'background_image_content_title_dynamic' ); } } if ( 'none' !== $thumbnail_as_background ) { $thumbnail = esc_url( get_the_post_thumbnail_url( $content_id, 'large' ) ); if ( $thumbnail ) { $background_image_dynamic = $thumbnail; } } return $background_image_dynamic; } }