123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296 |
- <?php
- /**
- * Common functions.
- *
- * @package Pen
- */
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
- if ( ! function_exists( 'pen_setup' ) ) {
- /**
- * Sets up theme defaults and registers support for various WordPress features.
- *
- * Note that this function is hooked into the after_setup_theme hook, which
- * runs before the init hook. The init hook is too late for some features, such
- * as indicating support for post thumbnails.
- */
- function pen_setup() {
- if ( pen_filter_input( 'GET', 'pen_preview_color' ) || pen_filter_input( 'GET', 'pen_preview_font' ) ) {
- // Disables the "Autoptimize" plugin.
- define( 'DONOTMINIFY', true );
- // Disables the "WP Super Cache" plugin.
- define( 'DONOTCACHEPAGE', true );
- }
- /**
- * Make theme available for translation.
- * Translations can be filed in the /languages/ directory.
- * If you're building a theme based on Pen, use a find and replace
- * to change 'pen' to the name of your theme in all the template files.
- */
- load_theme_textdomain( 'pen', get_template_directory() . '/languages' );
- add_theme_support( 'editor-styles' );
- /**
- * Let WordPress manage the document title.
- * By adding theme support, we declare that this theme does not use a
- * hard-coded <title> tag in the document head, and expect WordPress to
- * provide it for us.
- */
- add_theme_support( 'title-tag' );
- /**
- * Enable support for custom logo.
- */
- add_theme_support(
- 'custom-logo',
- array(
- 'height' => 512,
- 'width' => 512,
- 'flex-height' => true,
- )
- );
- /**
- * Enable support for Post Thumbnails on posts and pages.
- */
- add_theme_support( 'post-thumbnails' );
- set_post_thumbnail_size( 225, 225, true );
- /**
- * Adds default RSS feed links to the <head>.
- */
- add_theme_support( 'automatic-feed-links' );
- // This theme uses wp_nav_menu() in one location.
- register_nav_menus(
- array(
- 'primary' => esc_html__( 'Header', 'pen' ),
- 'secondary' => esc_html__( 'Footer', 'pen' ),
- )
- );
- /**
- * Switch default core markup for search form to output valid HTML5.
- */
- add_theme_support(
- 'html5',
- array(
- 'search-form',
- 'gallery',
- 'caption',
- 'comment-form',
- 'comment-list',
- )
- );
- // Add theme support for selective refresh for widgets.
- add_theme_support( 'customize-selective-refresh-widgets' );
- /**
- * Enable support for Post Formats.
- * See https://developer.wordpress.org/themes/functionality/post-formats/
- */
- add_theme_support(
- 'post-formats',
- array(
- 'aside',
- 'image',
- 'video',
- 'quote',
- 'link',
- )
- );
- // Set up the WordPress core custom background feature.
- add_theme_support(
- 'custom-background',
- apply_filters(
- 'pen_custom_background_args',
- array(
- 'default-color' => '333333',
- 'default-image' => '',
- )
- )
- );
- $theme = wp_get_theme( 'pen' );
- define( 'PEN_THEME_VERSION', $theme->get( 'Version' ) );
- define( 'PEN_PRESET_COLOR', get_theme_mod( 'pen_preset_color', 'preset_1' ) );
- define( 'PEN_PRESET_FONT', get_theme_mod( 'pen_preset_font', 'preset_1' ) );
- define( 'PEN_SUPPORT_URL', 'https://wordpress.org/support/theme/pen/' );
- add_action( 'wp_ajax_pen_post_meta', 'pen_post_meta_ajax' );
- }
- add_action( 'after_setup_theme', 'pen_setup' );
- }
- if ( ! function_exists( 'pen_archive_title_override' ) ) {
- /**
- * Adds extra markup to archive titles.
- *
- * @param string $title The title.
- * @since Pen 1.0.5
- * @return string
- */
- function pen_archive_title_override( $title ) {
- $output = $title;
- if ( false !== strpos( $title, ': ' ) ) {
- $title = explode( ': ', $title );
- $output = '<span class="pen_heading_main">';
- $output .= $title[0] . ':';
- $output .= '</span>';
- unset( $title[0] );
- $output .= implode( '', $title );
- }
- return $output;
- }
- add_filter( 'get_the_archive_title', 'pen_archive_title_override' );
- }
- if ( ! function_exists( 'pen_content_width' ) ) {
- /**
- * Set the content width in pixels, based on the theme's design and stylesheet.
- *
- * Priority 0 to make it available to lower priority callbacks.
- *
- * @global int $content_width
- */
- function pen_content_width() {
- $GLOBALS['content_width'] = apply_filters( 'pen_content_width', 1140 );
- }
- add_action( 'after_setup_theme', 'pen_content_width', 0 );
- }
- if ( ! function_exists( 'pen_header_background' ) ) {
- /**
- * Set up the WordPress core custom header feature.
- *
- * @since Pen 1.0.0
- * @return void
- */
- function pen_header_background() {
- add_theme_support(
- 'custom-header',
- apply_filters(
- 'pen_custom_header_args',
- array(
- 'default-image' => '',
- 'default-text-color' => '333333',
- 'header-text' => false,
- 'width' => 1800,
- 'height' => 250,
- 'flex-height' => true,
- )
- )
- );
- }
- add_action( 'after_setup_theme', 'pen_header_background' );
- }
- if ( ! function_exists( 'pen_body_classes' ) ) {
- /**
- * Adds custom classes to the array of body_class filter.
- *
- * @global object $post
- *
- * @param array $classes Classes for the body element.
- *
- * @since Pen 1.0.0
- * @return array
- */
- function pen_body_classes( $classes ) {
- global $post;
- if ( ! is_home() && ! is_front_page() ) {
- $classes[] = 'not-home';
- }
- $sidebars = array(
- 'sidebar-header-primary',
- 'sidebar-header-secondary',
- 'sidebar-top',
- 'sidebar-search-top',
- 'sidebar-search-left',
- 'sidebar-search-right',
- 'sidebar-search-bottom',
- 'sidebar-left',
- 'sidebar-right',
- 'sidebar-bottom',
- 'sidebar-footer-top',
- 'sidebar-footer-left',
- 'sidebar-footer-right',
- 'sidebar-footer-bottom',
- );
- foreach ( $sidebars as $sidebar ) {
- if ( pen_sidebar_check( $sidebar ) && is_active_sidebar( $sidebar ) ) {
- $classes[] = 'visible-' . sanitize_html_class( $sidebar );
- } else {
- $classes[] = 'invisible-' . sanitize_html_class( $sidebar );
- }
- }
- if ( pen_option_get( 'header_logo_display' ) ) {
- $classes[] = 'pen_header_logo_size_' . pen_option_get( 'header_logo_size' );
- }
- if ( is_multi_author() ) {
- $classes[] = 'group-blog';
- }
- if ( pen_option_get( 'color_site_shadow_display' ) ) {
- $classes[] = 'pen_drop_shadow';
- }
- if ( pen_option_get( 'background_lights_dim' ) ) {
- $classes[] = 'pen_background_lights_dim';
- }
- if ( pen_option_get( 'header_sticky' ) ) {
- $classes[] = 'pen_header_sticky';
- }
- if ( pen_option_get( 'round_corners' ) ) {
- $classes[] = 'pen_round_corners';
- }
- $header_logo = pen_option_get( 'header_logo_display' );
- if ( 'none' !== $header_logo ) {
- $classes[] = 'pen_header_logo_size_' . pen_option_get( 'header_logo_size' );
- }
- $classes[] = 'pen_list_effect_' . pen_option_get( 'list_effect' );
- $classes[] = 'pen_header_alignment_' . pen_option_get( 'header_alignment' );
- $classes[] = 'pen_navigation_alignment_' . pen_option_get( 'navigation_alignment' );
- $classes[] = 'pen_footer_alignment_' . pen_option_get( 'footer_alignment' );
- $classes[] = 'pen_main_container_' . pen_option_get( 'container_position' );
- if ( is_sticky() ) {
- $classes[] = 'sticky';
- }
- if ( is_singular() ) {
- $post_id = (int) get_queried_object_id(); // $post->ID doesn't return the correct post ID.
- // Hiding parts of the content with Web accessibility and SEO in mind.
- $options_content = array(
- 'content_header_display' => 'content_header_hide',
- 'content_title_display' => 'content_title_hide',
- 'content_author_display' => 'content_author_hide',
- 'content_date_display' => 'content_date_hide',
- 'content_category_display' => 'content_category_hide',
- 'content_thumbnail_display' => 'content_thumbnail_hide',
- 'content_share_display' => 'content_share_hide',
- 'content_tags_display' => 'content_tags_hide',
- 'content_footer_display' => 'content_footer_hide',
- );
- foreach ( $options_content as $option => $class ) {
- $display = get_post_meta( $post_id, 'pen_' . $option . '_override', true );
- if ( ! $display || 'default' === $display ) {
- $display = pen_option_get( $option );
- }
- if ( ! $display || 'no' === $display ) {
- $classes[] = 'pen_' . $class;
- }
- }
- $site_width = get_post_meta( $post_id, 'pen_site_width_override', true );
- if ( ! $site_width || 'default' === $site_width ) {
- $site_width = pen_option_get( 'site_width' );
- }
- $classes[] = 'pen_width_' . $site_width;
- $header_alignment = get_post_meta( $post_id, 'pen_content_header_alignment_override', true );
- if ( ! $header_alignment || 'default' === $header_alignment ) {
- $header_alignment = pen_option_get( 'content_header_alignment' );
- }
- if ( $header_alignment && 'no' !== $header_alignment ) {
- $classes[] = 'pen_content_header_center';
- }
- $title_alignment = get_post_meta( $post_id, 'pen_content_title_alignment_override', true );
- if ( ! $title_alignment || 'default' === $title_alignment ) {
- $title_alignment = pen_option_get( 'content_title_alignment' );
- }
- if ( $title_alignment && 'no' !== $title_alignment ) {
- $classes[] = 'pen_content_title_center';
- }
- $thumbnail_rotate = get_post_meta( $post_id, 'pen_content_thumbnail_rotate_override', true );
- if ( ! $thumbnail_rotate || 'default' === $thumbnail_rotate ) {
- $thumbnail_rotate = pen_option_get( 'content_thumbnail_rotate' );
- }
- if ( $thumbnail_rotate && 'no' !== $thumbnail_rotate ) {
- $classes[] = 'pen_content_thumbnail_rotate';
- }
- $thumbnail_frame = get_post_meta( $post_id, 'pen_content_thumbnail_frame_override', true );
- if ( ! $thumbnail_frame || 'default' === $thumbnail_frame ) {
- $thumbnail_frame = pen_option_get( 'content_thumbnail_frame' );
- }
- if ( $thumbnail_frame && 'no' !== $thumbnail_frame ) {
- $classes[] = 'pen_content_thumbnail_frame';
- }
- $thumbnail_frame_color = get_post_meta( $post_id, 'pen_color_content_thumbnail_frame_override', true );
- if ( ! $thumbnail_frame_color || 'default' === $thumbnail_frame_color ) {
- $thumbnail_frame_color = pen_option_get( 'color_content_thumbnail_frame' );
- }
- if ( '#000000' === $thumbnail_frame_color ) {
- $classes[] = 'pen_thumbnail_frame_dark';
- }
- $thumbnail_alignment = get_post_meta( $post_id, 'pen_content_thumbnail_alignment_override', true );
- if ( ! $thumbnail_alignment || 'default' === $thumbnail_alignment ) {
- $thumbnail_alignment = pen_option_get( 'content_thumbnail_alignment' );
- }
- $classes[] = 'pen_content_thumbnail_' . $thumbnail_alignment;
- $classes[] = 'pen_content_thumbnail_' . pen_option_get( 'content_thumbnail_resize' );
- $classes[] = 'pen_singular';
- } else {
- // Hiding parts of the content with Web accessibility and SEO in mind.
- $options_list = array(
- 'list_header_display' => 'list_header_hide',
- 'list_title_display' => 'list_title_hide',
- 'list_author_display' => 'list_author_hide',
- 'list_date_display' => 'list_date_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',
- );
- foreach ( $options_list as $option => $class ) {
- if ( ! pen_option_get( $option ) ) {
- $classes[] = 'pen_' . $class;
- }
- }
- $classes[] = 'pen_width_' . pen_option_get( 'site_width' );
- if ( pen_option_get( 'list_post_header_alignment' ) ) {
- $classes[] = 'pen_list_header_center';
- }
- if ( pen_option_get( 'list_title_alignment' ) ) {
- $classes[] = 'pen_list_title_center';
- }
- if ( 'none' !== pen_option_get( 'list_animation_reveal' ) ) {
- $classes[] = 'pen_has_animation';
- } else {
- $classes[] = 'pen_no_animation';
- }
- $classes[] = 'pen_multiple';
- $classes[] = 'hfeed';
- }
- $list_type = pen_list_type();
- $classes[] = 'pen_list_' . $list_type;
- if ( ! is_singular() ) {
- if ( 'masonry' === $list_type ) {
- $classes[] = 'pen_masonry_columns_' . pen_option_get( 'list_masonry_columns' );
- $classes[] = 'pen_thumbnail_' . pen_option_get( 'list_masonry_thumbnail_effect' );
- } else {
- // The following apply to all the posts in the list.
- if ( '#000000' === pen_option_get( 'color_list_thumbnail_frame' ) ) {
- $classes[] = 'pen_thumbnail_frame_dark';
- }
- $classes[] = 'pen_list_thumbnail_' . pen_option_get( 'list_thumbnail_alignment' );
- $classes[] = 'pen_list_thumbnail_' . pen_option_get( 'list_thumbnail_resize' );
- if ( pen_option_get( 'list_thumbnail_rotate' ) ) {
- $classes[] = 'pen_list_thumbnail_rotate';
- }
- if ( pen_option_get( 'list_thumbnail_frame' ) ) {
- $classes[] = 'pen_list_thumbnail_frame';
- }
- }
- }
- if ( class_exists( 'HPCF' ) && is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'HPCF' ) ) {
- $classes[] = 'pen_has_contact_form';
- }
- return $classes;
- }
- add_filter( 'body_class', 'pen_body_classes' );
- }
- if ( ! function_exists( 'pen_content_classes' ) ) {
- /**
- * Content classes.
- *
- * @since Pen 1.0.3
- * @return string
- */
- function pen_content_classes() {
- $classes = 'site-main';
- $animation = get_post_meta( get_the_ID(), 'pen_content_animation_reveal_override', true );
- if ( ! $animation || 'default' === $animation ) {
- $animation = pen_option_get( 'content_animation_reveal' );
- }
- if ( $animation ) {
- $classes .= ' pen_custom_animation_' . $animation;
- }
- return $classes;
- }
- }
- if ( ! function_exists( 'pen_categorized_blog' ) ) {
- /**
- * Returns true if a blog has more than 1 category.
- *
- * @since Pen 1.0.0
- * @return bool
- */
- function pen_categorized_blog() {
- $all_the_cool_cats = get_transient( 'pen_categories' );
- if ( false === $all_the_cool_cats ) {
- // Create an array of all the categories that are attached to posts.
- $all_the_cool_cats = get_categories(
- array(
- 'fields' => 'ids',
- 'hide_empty' => 1,
- // We only need to know if there is more than one category.
- 'number' => 2,
- )
- );
- // Count the number of categories that are attached to the posts.
- $all_the_cool_cats = count( $all_the_cool_cats );
- set_transient( 'pen_categories', $all_the_cool_cats );
- }
- if ( $all_the_cool_cats > 1 ) {
- // This blog has more than 1 category so pen_categorized_blog should return true.
- return true;
- } else {
- // This blog has only 1 category so pen_categorized_blog should return false.
- return false;
- }
- }
- }
- if ( ! function_exists( 'pen_category_transient_flusher' ) ) {
- /**
- * Flush out the transients used in pen_categorized_blog.
- *
- * @since Pen 1.0.0
- * @return void|string
- */
- function pen_category_transient_flusher() {
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
- return;
- }
- // Like, beat it. Dig?
- delete_transient( 'pen_categories' );
- }
- add_action( 'edit_category', 'pen_category_transient_flusher' );
- add_action( 'save_post', 'pen_category_transient_flusher' );
- }
- if ( ! function_exists( 'pen_editor_styles' ) ) {
- /**
- * Adds theme stylesheet to the visual editor.
- *
- * @uses add_editor_style() Links a stylesheet to visual editor
- * @uses get_template_directory_uri() Returns URI of theme directory
- * @since Pen 1.0.0
- */
- function pen_editor_styles() {
- add_editor_style( get_template_directory_uri() . '/assets/css/pen-editor.css' );
- }
- add_action( 'admin_init', 'pen_editor_styles' );
- }
- if ( ! function_exists( 'pen_class_lists' ) ) {
- /**
- * Creates a class name for hidden elements.
- *
- * @param string $option The option ID.
- *
- * @since Pen 1.0.0
- * @return string
- */
- function pen_class_lists( $option ) {
- $hidden = '';
- $option = 'pen_list_' . $option;
- if ( ! is_singular() ) {
- $display = get_post_meta( get_the_ID(), $option, true );
- if ( 'no' === $display ) {
- $hidden = ' pen_element_hidden';
- } elseif ( 'yes' === $display ) {
- $hidden = ' pen_element_visible';
- } else {
- $hidden = ' pen_element_default';
- }
- }
- return $hidden;
- }
- }
- if ( ! function_exists( 'pen_filter_input' ) ) {
- /**
- * Sanitization function similar to filter_input and filter_input_array.
- *
- * @param string $source The input source, can be GET, POST, or SERVER.
- * @param string $name The input name, false returns an array similar to $_GET etc.
- *
- * @since Pen 1.0.0
- * @return mixed Returns null when source is not provided or input does not exist.
- */
- function pen_filter_input( $source, $name = false ) {
- if ( 'GET' !== $source && 'POST' !== $source && 'SERVER' !== $source ) {
- return null;
- }
- // Gets the sources.
- /* phpcs:disable */
- if ( 'GET' === $source ) {
- $source = $_GET;
- } elseif ( 'POST' === $source ) {
- $source = $_POST;
- } else {
- $source = $_SERVER;
- }
- /* phpcs:enable */
- // Sanitization.
- if ( ! $name ) {
- array_walk_recursive( $source, 'pen_filter_input_help' );
- if ( $source ) {
- return $source;
- } else {
- return null;
- }
- } elseif ( ! isset( $source[ $name ] ) ) {
- return null;
- } elseif ( is_array( $source[ $name ] ) ) {
- array_walk_recursive( $source[ $name ], 'pen_filter_input_help' );
- return $source[ $name ];
- } else {
- return htmlspecialchars( trim( stripslashes( $source[ $name ] ) ), ENT_NOQUOTES, 'UTF-8' );
- }
- return null;
- }
- }
- if ( ! function_exists( 'pen_filter_input_help' ) ) {
- /**
- * Helper function necessary for array_walk_recursive on older PHP versions.
- *
- * @param mixed $value The value to be processed.
- *
- * @since Pen 1.0.0
- * @return void
- */
- function pen_filter_input_help( &$value ) {
- $value = htmlspecialchars( trim( stripslashes( $value ) ), ENT_NOQUOTES, 'UTF-8' );
- }
- }
- if ( ! function_exists( 'pen_list_type' ) ) {
- /**
- * Returns the content list type.
- *
- * @since Pen 1.0.5
- * @return string
- */
- function pen_list_type() {
- return pen_option_get( 'list_type' );
- }
- }
- if ( ! function_exists( 'pen_animations' ) ) {
- /**
- * Returns a list of the available animations.
- *
- * @since Pen 1.0.5
- * @return string
- */
- function pen_animations() {
- return array(
- 'none' => __( 'None', 'pen' ),
- 'bounce' => 'bounce',
- 'flash' => 'flash',
- 'pulse' => 'pulse',
- 'rubberBand' => 'rubberBand',
- 'shake' => 'shake',
- 'headShake' => 'headShake',
- 'swing' => 'swing',
- 'tada' => 'tada',
- 'wobble' => 'wobble',
- 'jello' => 'jello',
- 'bounceIn' => 'bounceIn',
- 'bounceInDown' => 'bounceInDown',
- 'bounceInLeft' => 'bounceInLeft',
- 'bounceInRight' => 'bounceInRight',
- 'bounceInUp' => 'bounceInUp',
- 'fadeIn' => 'fadeIn',
- 'fadeInDown' => 'fadeInDown',
- 'fadeInDownBig' => 'fadeInDownBig',
- 'fadeInLeft' => 'fadeInLeft',
- 'fadeInLeftBig' => 'fadeInLeftBig',
- 'fadeInRight' => 'fadeInRight',
- 'fadeInRightBig' => 'fadeInRightBig',
- 'fadeInUp' => 'fadeInUp',
- 'fadeInUpBig' => 'fadeInUpBig',
- 'flipInX' => 'flipInX',
- 'flipInY' => 'flipInY',
- 'lightSpeedIn' => 'lightSpeedIn',
- 'rotateIn' => 'rotateIn',
- 'rotateInDownLeft' => 'rotateInDownLeft',
- 'rotateInDownRight' => 'rotateInDownRight',
- 'rotateInUpLeft' => 'rotateInUpLeft',
- 'rotateInUpRight' => 'rotateInUpRight',
- 'jackInTheBox' => 'jackInTheBox',
- 'rollIn' => 'rollIn',
- 'zoomIn' => 'zoomIn',
- 'zoomInDown' => 'zoomInDown',
- 'zoomInLeft' => 'zoomInLeft',
- 'zoomInRight' => 'zoomInRight',
- 'zoomInUp' => 'zoomInUp',
- 'slideInDown' => 'slideInDown',
- 'slideInLeft' => 'slideInLeft',
- 'slideInRight' => 'slideInRight',
- 'slideInUp' => 'slideInUp',
- );
- }
- }
- if ( ! function_exists( 'pen_class_navigation' ) ) {
- /**
- * Generates class names for the navigation menu.
- *
- * @since Pen 1.0.8
- * @return string
- */
- function pen_class_navigation() {
- $hover = pen_option_get( 'navigation_hover' );
- $arrows = pen_option_get( 'navigation_arrows' );
- $separator = pen_option_get( 'navigation_separator' );
- $separator_submenu = pen_option_get( 'navigation_separator_submenu' );
- $classes = trim(
- implode(
- ' ',
- array(
- 'main-navigation',
- 'pen_hover_' . ( $hover ? $hover : 'none' ),
- 'pen_arrows_' . ( $arrows ? $arrows : 'none' ),
- 'pen_separator_' . ( $separator ? $separator : 'none' ),
- 'pen_separator_submenu_' . ( $separator_submenu ? $separator_submenu : 'none' ),
- )
- )
- );
- return $classes;
- }
- }
- if ( ! function_exists( 'pen_class_animation' ) ) {
- /**
- * Generates animation class names.
- *
- * @param string $option_id The option ID.
- * @param boolean $echo Whether to echo or return.
- *
- * @since Pen 1.0.7
- * @return void|string
- */
- function pen_class_animation( $option_id, $echo = true ) {
- $animation = pen_option_get( $option_id . '_animation_reveal' );
- if ( $animation && 'none' !== $animation ) {
- $class = sprintf(
- 'pen_animate_on_scroll pen_custom_animation_%s',
- sanitize_html_class( $animation )
- );
- if ( $echo ) {
- echo $class; /* phpcs:ignore */
- } else {
- return $class;
- }
- }
- }
- }
- if ( ! function_exists( 'pen_url_customizer' ) ) {
- /**
- * Generates a URL for the customizer.
- *
- * @param string $focus Focus on specific option.
- * @param string $page The active page.
- *
- * @since Pen 1.0.8
- * @return string
- */
- function pen_url_customizer( $focus = '', $page = '' ) {
- if ( is_customize_preview() ) {
- return '#';
- }
- $query['return'] = rawurlencode( pen_filter_input( 'SERVER', 'REQUEST_URI' ) );
- if ( $focus && false !== strpos( $focus, ',' ) ) {
- list( $container_type, $container_name ) = explode( ',', $focus );
- $generic = array(
- 'background_image',
- 'header_image',
- 'nav_menus',
- 'title_tagline',
- 'widgets',
- );
- if ( ! in_array( $container_name, $generic, true ) && false === strpos( $container_name, 'sidebar-widgets-' ) ) {
- $container_name = 'pen_' . $container_type . '_' . $container_name;
- }
- $query[ 'autofocus[' . $container_type . ']' ] = $container_name;
- }
- if ( $page ) {
- $query['url'] = rawurlencode( $page );
- } elseif ( ! is_admin() ) {
- $query['url'] = rawurlencode( pen_filter_input( 'SERVER', 'REQUEST_URI' ) );
- }
- return esc_url( add_query_arg( $query, wp_customize_url() ) );
- }
- }
- if ( ! function_exists( 'pen_jump_menu' ) ) {
- /**
- * Provides easier access to various parts of the back-end.
- *
- * @param string $element Target element.
- *
- * @since Pen 1.0.8
- * @return string
- */
- function pen_jump_menu( $element ) {
- /* phpcs:disable */
- switch ( $element ) {
- case 'color_schemes':
- $preset_color_current = (int) str_replace( 'preset_', '', pen_preset_get( 'color' ) );
- $items = array();
- for ( $i = 1; $i <= 15; $i++ ) {
- $url_customizer = esc_url( add_query_arg( 'url', rawurlencode( pen_filter_input( 'SERVER', 'REQUEST_URI' ) ), wp_customize_url() ) . '&autofocus[panel]=pen_panel_colors&pen_preview_color=' . (int) $i );
- $items[ $url_customizer ] = sprintf( __( 'Style %d', 'pen' ), $i );
- if ( $i === $preset_color_current ) {
- $items[ $url_customizer ] .= sprintf( ' (%s)', __( 'Current', 'pen' ) );
- }
- }
- $menu = array(
- 'name' => __( 'Color Schemes', 'pen' ),
- 'items' => $items,
- );
- return $menu;
- case 'font_presets':
- $preset_font_current = (int) str_replace( 'preset_', '', pen_preset_get( 'font_family' ) );
- $items = array();
- for ( $i = 1; $i <= 10; $i++ ) {
- $url_customizer = esc_url( add_query_arg( 'url', rawurlencode( pen_filter_input( 'SERVER', 'REQUEST_URI' ) ), wp_customize_url() ) . '&autofocus[panel]=pen_panel_typography&pen_preview_font=' . (int) $i );
- $items[ $url_customizer ] = sprintf( __( 'Font Preset %d', 'pen' ), $i );
- if ( $i === $preset_font_current ) {
- $items[ $url_customizer ] .= sprintf( ' (%s)', __( 'Current', 'pen' ) );
- }
- }
- $menu = array(
- 'name' => __( 'Font Presets', 'pen' ),
- 'items' => $items,
- );
- return $menu;
- case 'site':
- $menu = array(
- 'name' => __( 'General Settings', 'pen' ),
- 'items' => array(
- 'section,background_image' => __( '<span>Site </span>Background Image', 'pen' ),
- 'section,colors_general' => __( 'Colors', 'pen' ),
- 'section,typography_general' => __( 'Typography', 'pen' ),
- 'section,layout' => __( '<span>Site </span>Layout', 'pen' ),
- ),
- );
- if ( is_home() || is_front_page() ) {
- $menu['items'][ ( 'panel,front' ) ] = __( 'Front Page', 'pen' );
- }
- return $menu;
- case 'header':
- return array(
- 'name' => __( 'Header', 'pen' ),
- 'items' => array(
- 'section,header_general' => __( 'General<span> Header Settings</span>', 'pen' ),
- 'section,header_image' => __( '<span>Header </span>Background Image', 'pen' ),
- 'section,title_tagline' => __( 'Logo', 'pen' ),
- 'section,header_search' => __( 'Search', 'pen' ),
- 'section,colors_header' => __( '<span>Header </span>Colors', 'pen' ),
- 'section,typography_header' => __( '<span>Header </span>Typography', 'pen' ),
- 'panel,contact' => __( '<span>Site </span>Contacts', 'pen' ),
- ),
- );
- case 'navigation':
- return array(
- 'name' => __( 'Navigation', 'pen' ),
- 'items' => array(
- 'section,header_navigation' => __( 'General<span> Navigation Settings</span>', 'pen' ),
- 'panel,nav_menus' => __( 'Menus', 'pen' ),
- 'section,background_image_navigation' => __( '<span>Navigation </span>Background Image', 'pen' ),
- 'section,colors_navigation' => __( '<span>Navigation </span>Colors', 'pen' ),
- 'section,typography_navigation' => __( '<span>Navigation </span>Typography', 'pen' ),
- ),
- );
- case 'search_bar':
- return array(
- 'name' => __( 'Search Bar', 'pen' ),
- 'items' => array(
- 'section,header_search' => __( 'General<span> Search Settings</span>', 'pen' ),
- 'section,background_image_search' => __( '<span>Search Bar </span>Background Image', 'pen' ),
- 'section,colors_search' => __( '<span>Search Bar </span>Colors', 'pen' ),
- ),
- );
- case 'content':
- $menu = array(
- 'name' => __( 'Content Area', 'pen' ),
- 'items' => array(
- 'section,content' => __( 'General<span> Content Area Settings</span>', 'pen' ),
- 'section,colors_content' => __( '<span>Content Area </span>Colors', 'pen' ),
- 'section,layout' => __( '<span>Site </span>Layout', 'pen' ),
- ),
- );
- $post_id = get_the_ID();
- if ( $post_id ) {
- $url_post_edit = self_admin_url(
- sprintf(
- 'post.php?post=%d&action=edit',
- esc_attr( $post_id )
- )
- );
- $menu['items'][ $url_post_edit ] = sprintf(
- /* Translators: %s: post type. */
- __( '<span>Edit </span>This %s', 'pen' ),
- ucwords( get_post_type() )
- );
- }
- return $menu;
- case 'list':
- return array(
- 'name' => __( 'List Views', 'pen' ),
- 'items' => array(
- 'section,list' => __( 'General<span> List Views Settings</span>', 'pen' ),
- 'section,colors_list' => __( '<span>Content List </span>Colors', 'pen' ),
- 'section,layout' => __( '<span>Site </span>Layout', 'pen' ),
- ),
- );
- case 'sidebar-header-primary':
- return array(
- 'name' => __( 'Header - Primary', 'pen' ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-header-primary' => sprintf(
- '<span>%1$s </span>%2$s',
- __( 'Header - Primary', 'pen' ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-header-secondary':
- return array(
- 'name' => __( 'Header - Secondary', 'pen' ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-header-secondary' => sprintf(
- '<span>%1$s </span>%2$s',
- __( 'Header - Secondary', 'pen' ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-top':
- return array(
- 'name' => sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Top', 'pen' )
- ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-top' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Top', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-search-top':
- return array(
- 'name' => sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Search - Top', 'pen' )
- ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-search-top' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Search - Top', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-search-left':
- return array(
- 'name' => sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Search - Left', 'pen' )
- ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-search-left' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Search - Left', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-search-right':
- return array(
- 'name' => sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Search - Right', 'pen' )
- ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-search-right' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Search - Right', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-search-bottom':
- return array(
- 'name' => sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Search - Bottom', 'pen' )
- ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-search-bottom' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Search - Bottom', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-content-top':
- return array(
- 'name' => sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Content - Top', 'pen' )
- ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-content-top' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Content - Top', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-content-bottom':
- return array(
- 'name' => sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Content - Bottom', 'pen' )
- ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-content-bottom' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Content - Bottom', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-left':
- return array(
- 'name' => sprintf(
- __( '"%s" Sidebar', 'pen' ),
- __( 'Left', 'pen' )
- ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-left' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Sidebar', 'pen' ),
- __( 'Left', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-right':
- return array(
- 'name' => sprintf(
- __( '"%s" Sidebar', 'pen' ),
- __( 'Right', 'pen' )
- ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-right' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Sidebar', 'pen' ),
- __( 'Right', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-bottom':
- return array(
- 'name' => __( 'Bottom', 'pen' ),
- 'items' => array(
- 'section,background_image_bottom' => __( '<span>Bottom Widget Area - </span>Background Image', 'pen' ),
- 'section,colors_bottom' => __( '<span>Bottom Widget Area - </span>Colors', 'pen' ),
- 'section,sidebar-widgets-sidebar-bottom' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Bottom', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-footer-top':
- return array(
- 'name' => __( 'Footer - Top', 'pen' ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-footer-top' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Footer - Top', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-footer-left':
- return array(
- 'name' => __( 'Footer - Left', 'pen' ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-footer-left' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Footer - Left', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-footer-right':
- return array(
- 'name' => __( 'Footer - Right', 'pen' ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-footer-right' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Footer - Right', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'sidebar-footer-bottom':
- return array(
- 'name' => __( 'Footer - Bottom', 'pen' ),
- 'items' => array(
- 'section,sidebar-widgets-sidebar-footer-bottom' => sprintf(
- '<span>%1$s </span>%2$s',
- sprintf(
- __( '"%s" Widget Area', 'pen' ),
- __( 'Footer - Bottom', 'pen' )
- ),
- __( 'Configure Widgets', 'pen' )
- ),
- ),
- );
- case 'footer':
- return array(
- 'name' => __( 'Footer', 'pen' ),
- 'items' => array(
- 'section,footer' => __( 'General<span> - Footer Settings</span>', 'pen' ),
- 'section,background_image_footer' => __( '<span>Footer - </span>Background Image', 'pen' ),
- 'section,colors_footer' => __( '<span>Footer - </span>Colors', 'pen' ),
- 'section,typography_footer' => __( '<span>Footer - </span>Typography', 'pen' ),
- 'panel,contact' => __( '<span>Site </span>Contacts', 'pen' ),
- ),
- );
- }
- /* phpcs:enable */
- }
- }
- if ( ! function_exists( 'pen_post_meta_options' ) ) {
- /**
- * Returns a list of post meta options.
- *
- * @param string $group Which group of options to return.
- *
- * @since Pen 1.0.5
- * @return array
- */
- function pen_post_meta_options( $group = 'all' ) {
- /* phpcs:disable */
- $options_list = array(
- // Do not reorder alphabetically.
- 'pen_list_post_header_alignment_override' => __( 'Center-align content header', 'pen' ),
- 'pen_list_title_alignment_override' => __( 'Center-align content title', 'pen' ),
- 'pen_list_title_display_override' => __( 'Content title', 'pen' ),
- 'pen_list_animation_reveal_override' => __( 'Content animation', 'pen' ),
- 'pen_list_author_display_override' => __( 'Content author', 'pen' ),
- 'pen_list_date_display_override' => __( 'Content date', 'pen' ),
- 'pen_list_date_location_override' => __( 'Content date location', 'pen' ),
- 'pen_list_footer_display_override' => __( 'Content footer', 'pen' ),
- 'pen_list_header_display_override' => __( 'Content header', 'pen' ),
- 'pen_list_summary_display_override' => __( 'Content summary', 'pen' ),
- 'pen_list_tags_display_override' => __( 'Content tags', 'pen' ),
- 'pen_list_thumbnail_animation_reveal_override' => __( 'Content animation', 'pen' ),
- 'pen_list_category_display_override' => __( 'Category links', 'pen' ),
- 'pen_list_category_location_override' => __( 'Category links location', 'pen' ),
- 'pen_list_profile_display_override' => __( 'Author profile', 'pen' ),
- 'pen_list_author_location_override' => __( 'Author link location', 'pen' ),
- 'pen_list_share_location_override' => __( 'Share buttons location', 'pen' ),
- 'pen_list_background_image_content_title_dynamic_override' => __( 'Featured image as title background', 'pen' ),
- 'pen_list_thumbnail_display_override' => __( 'Thumbnail', 'pen' ),
- 'pen_list_thumbnail_alignment_override' => __( 'Thumbnail alignment', 'pen' ),
- 'pen_color_list_thumbnail_frame_override' => __( 'Thumbnail frame color', 'pen' ),
- 'pen_list_thumbnail_frame_override' => __( 'Thumbnail frame', 'pen' ),
- 'pen_list_thumbnail_resize_override' => __( 'Thumbnail size', 'pen' ),
- 'pen_list_thumbnail_rotate_override' => __( 'Thumbnail rotate', 'pen' ),
- 'pen_list_masonry_thumbnail_style_override' => __( 'Thumbnail style', 'pen' ),
- 'pen_list_button_comment_display_override' => __( 'Comment button', 'pen' ),
- 'pen_list_button_edit_display_override' => __( 'Edit button', 'pen' ),
- );
- $options_content = array(
- // Do not reorder alphabetically.
- 'pen_site_width_override' => __( 'Site Width', 'pen' ),
- 'pen_content_header_alignment_override' => __( 'Center-align content header', 'pen' ),
- 'pen_content_title_alignment_override' => __( 'Center-align content title', 'pen' ),
- 'pen_content_title_display_override' => __( 'Content title', 'pen' ),
- 'pen_content_animation_reveal_override' => __( 'Content area animation', 'pen' ),
- 'pen_content_author_display_override' => __( 'Content author', 'pen' ),
- 'pen_content_date_display_override' => __( 'Content date', 'pen' ),
- 'pen_content_date_location_override' => __( 'Content date location', 'pen' ),
- 'pen_content_footer_display_override' => __( 'Content footer', 'pen' ),
- 'pen_content_header_display_override' => __( 'Content header', 'pen' ),
- 'pen_content_tags_display_override' => __( 'Content tags', 'pen' ),
- 'pen_content_profile_display_override' => __( 'Author profile', 'pen' ),
- 'pen_content_author_location_override' => __( 'Author link location', 'pen' ),
- 'pen_content_share_display_override' => __( 'Share buttons', 'pen' ),
- 'pen_content_share_location_override' => __( 'Share buttons location', 'pen' ),
- 'pen_content_category_display_override' => __( 'Category links', 'pen' ),
- 'pen_content_category_location_override' => __( 'Category links location', 'pen' ),
- 'pen_content_search_display_override' => __( 'Search box', 'pen' ),
- 'pen_content_search_location_override' => __( 'Search box location', 'pen' ),
- 'pen_content_background_image_content_title_dynamic_override' => __( 'Featured image as title background', 'pen' ),
- 'pen_content_thumbnail_display_override' => __( 'Thumbnail', 'pen' ),
- 'pen_color_content_thumbnail_frame_override' => __( 'Thumbnail frame color', 'pen' ),
- 'pen_content_thumbnail_alignment_override' => __( 'Thumbnail alignment', 'pen' ),
- 'pen_content_thumbnail_animation_reveal_override' => __( 'Thumbnail animation', 'pen' ),
- 'pen_content_thumbnail_frame_override' => __( 'Thumbnail frame', 'pen' ),
- 'pen_content_thumbnail_resize_override' => __( 'Thumbnail size', 'pen' ),
- 'pen_content_thumbnail_rotate_override' => __( 'Thumbnail rotate', 'pen' ),
- );
- $options_sidebar = array(
- 'pen_sidebar_header_primary_display' => __( 'Header - Primary', 'pen' ),
- 'pen_sidebar_header_secondary_display' => __( 'Header - Secondary', 'pen' ),
- 'pen_sidebar_search_top_display' => __( 'Search - Top', 'pen' ),
- 'pen_sidebar_search_left_display' => __( 'Search - Left', 'pen' ),
- 'pen_sidebar_search_right_display' => __( 'Search - Right', 'pen' ),
- 'pen_sidebar_search_bottom_display' => __( 'Search - Bottom', 'pen' ),
- 'pen_sidebar_top_display' => __( 'Top', 'pen' ),
- 'pen_sidebar_left_display' => __( 'Left', 'pen' ),
- 'pen_sidebar_right_display' => __( 'Right', 'pen' ),
- 'pen_sidebar_content_top_display' => __( 'Content - Top', 'pen' ),
- 'pen_sidebar_content_bottom_display' => __( 'Content - Bottom', 'pen' ),
- 'pen_sidebar_bottom_display' => __( 'Bottom', 'pen' ),
- 'pen_sidebar_footer_top_display' => __( 'Footer - Top', 'pen' ),
- 'pen_sidebar_footer_left_display' => __( 'Footer - Left', 'pen' ),
- 'pen_sidebar_footer_right_display' => __( 'Footer - Right', 'pen' ),
- 'pen_sidebar_footer_bottom_display' => __( 'Footer - Bottom', 'pen' ),
- );
- /* phpcs:enable */
- if ( ! $group || 'all' === $group ) {
- return array_merge( $options_list, $options_content, $options_sidebar );
- }
- if ( 'list' === $group ) {
- return $options_list;
- }
- if ( 'content' === $group ) {
- return $options_content;
- }
- if ( 'sidebar' === $group ) {
- return $options_sidebar;
- }
- }
- }
|