/** * Configure settings and controls for the Site Title & Tagline section. * * @since 1.0.0. * * @return void */ function ttfmake_customizer_sitetitletagline() { global $wp_customize; $priority = new TTFMAKE_Prioritizer(10, 1); $control_prefix = 'ttfmake_'; $section = 'title_tagline'; // Site title color $setting_id = 'color-site-title'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'maybe_hash_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Site Title Color', 'make'), 'priority' => $priority->add()))); // Change priority for Site Title $site_title = $wp_customize->get_control('blogname'); $site_title->priority = $priority->add(); // Hide Site Title $setting_id = 'hide-site-title'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Hide Site Title', 'make'), 'type' => 'checkbox', 'priority' => $priority->add())); // Change priority for Tagline $site_description = $wp_customize->get_control('blogdescription'); $site_description->priority = $priority->add(); // Hide Tagline $setting_id = 'hide-tagline'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Hide Tagline', 'make'), 'type' => 'checkbox', 'priority' => $priority->add())); }
/** * Configure settings and controls for the Logo section. * * @since 1.0.0. * * @param object $wp_customize The global customizer object. * @param string $section The section name. * @return void */ function ttfmake_customizer_logo($wp_customize, $section) { $priority = new TTFMAKE_Prioritizer(); $control_prefix = 'ttfmake_'; $setting_prefix = str_replace($control_prefix, '', $section); // Regular Logo $setting_id = $setting_prefix . '-regular'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'esc_url_raw')); $wp_customize->add_control(new TTFMAKE_Customize_Image_Control($wp_customize, $control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Regular Logo', 'make'), 'priority' => $priority->add(), 'context' => $control_prefix . $setting_id))); // Retina Logo $setting_id = $setting_prefix . '-retina'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'esc_url_raw')); $wp_customize->add_control(new TTFMAKE_Customize_Image_Control($wp_customize, $control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Retina Logo (2x)', 'make'), 'priority' => $priority->add(), 'context' => $control_prefix . $setting_id))); // Retina info $setting_id = $setting_prefix . '-retina-info'; $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'text', 'description' => __('The Retina Logo should be twice the size of the Regular Logo.', 'make'), 'priority' => $priority->add()))); // Favicon $setting_id = $setting_prefix . '-favicon'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'esc_url_raw')); $wp_customize->add_control(new TTFMAKE_Customize_Image_Control($wp_customize, $control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Favicon', 'make'), 'priority' => $priority->add(), 'context' => $control_prefix . $setting_id, 'extensions' => array('png', 'ico')))); // Favicon info $setting_id = $setting_prefix . '-favicon-info'; $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'text', 'description' => __('File must be <strong>.png</strong> or <strong>.ico</strong> format. Optimal dimensions: <strong>32px x 32px</strong>.', 'make'), 'priority' => $priority->add()))); // Apple Touch Icon $setting_id = $setting_prefix . '-apple-touch'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'esc_url_raw')); $wp_customize->add_control(new TTFMAKE_Customize_Image_Control($wp_customize, $control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Apple Touch Icon', 'make'), 'priority' => $priority->add(), 'context' => $control_prefix . $setting_id, 'extensions' => array('png')))); // Apple Touch Icon info $setting_id = $setting_prefix . '-apple-touch-info'; $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'text', 'description' => __('File must be <strong>.png</strong> format. Optimal dimensions: <strong>152px x 152px</strong>.', 'make'), 'priority' => $priority->add()))); }
/** * Configure settings and controls for the Main section. * * @since 1.0.0. * * @param object $wp_customize The global customizer object. * @param string $section The section name. * @return void */ function ttfmake_customizer_main($wp_customize, $section) { $priority = new TTFMAKE_Prioritizer(); $control_prefix = 'ttfmake_'; $setting_prefix = str_replace($control_prefix, '', $section); // Background color $setting_id = $setting_prefix . '-background-color'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'maybe_hash_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Background Color', 'make'), 'priority' => $priority->add()))); // Background Image $setting_id = $setting_prefix . '-background-image'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'esc_url_raw')); $wp_customize->add_control(new TTFMAKE_Customize_Image_Control($wp_customize, $control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Background Image', 'make'), 'priority' => $priority->add(), 'context' => $control_prefix . $setting_id))); // Background Repeat $setting_id = $setting_prefix . '-background-repeat'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_choice')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Background Repeat', 'make'), 'type' => 'radio', 'choices' => ttfmake_get_choices($setting_id), 'priority' => $priority->add())); // Background Position $setting_id = $setting_prefix . '-background-position'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_choice')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Background Position', 'make'), 'type' => 'radio', 'choices' => ttfmake_get_choices($setting_id), 'priority' => $priority->add())); // Background Size $setting_id = $setting_prefix . '-background-size'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_choice')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Background Size', 'make'), 'type' => 'radio', 'choices' => ttfmake_get_choices($setting_id), 'priority' => $priority->add())); // Content options heading $setting_id = $setting_prefix . '-content-heading'; $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'heading', 'label' => __('Content Options', 'make'), 'priority' => $priority->add()))); // Underline content links $setting_id = $setting_prefix . '-content-link-underline'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Underline links in content', 'make'), 'type' => 'checkbox', 'priority' => $priority->add())); }
/** * Add a class to the bounding div if a post uses an avatar with the author byline. * * @since 1.0.11. * * @param array $classes An array of post classes. * @param string $class A comma-separated list of additional classes added to the post. * @param int $post_ID The post ID. * @return array The modified post class array. */ function ttfmake_maybe_add_with_avatar_class($classes, $class, $post_ID) { $author_key = 'layout-' . ttfmake_get_view() . '-post-author'; $author_option = ttfmake_sanitize_choice(get_theme_mod($author_key, ttfmake_get_default($author_key)), $author_key); if ('avatar' === $author_option) { $classes[] = 'has-author-avatar'; } return $classes; }
/** * Configure settings and controls for the Navigation section. * * @since 1.0.0. * * @return void */ function ttfmake_customizer_navigation() { global $wp_customize; $priority = new TTFMAKE_Prioritizer(); $control_prefix = 'ttfmake_'; $section = 'nav'; // Menu Label $setting_id = 'navigation-mobile-label'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'esc_html', 'theme_supports' => 'menus', 'transport' => 'postMessage')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Mobile Menu Label', 'make'), 'type' => 'text', 'priority' => $priority->add())); // Menu Label info $setting_id = 'navigation-mobile-lable-info'; $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'text', 'description' => __('Resize your browser window to preview the mobile menu label.', 'make'), 'priority' => $priority->add()))); }
/** * Configure settings and controls for the General section * * @since 1.0.0. * * @param object $wp_customize The global customizer object. * @param string $section The section name. * @return void */ function ttfmake_customizer_general($wp_customize, $section) { $priority = new TTFMAKE_Prioritizer(); $control_prefix = 'ttfmake_'; $setting_prefix = str_replace($control_prefix, '', $section); // Site Layout $setting_id = $setting_prefix . '-layout'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_choice')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Site Layout', 'make'), 'type' => 'radio', 'choices' => ttfmake_get_choices($setting_id), 'priority' => $priority->add())); // Sticky label $setting_id = $setting_prefix . '-sticky-label'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'esc_html', 'transport' => 'postMessage')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Sticky Label', 'make'), 'type' => 'text', 'priority' => $priority->add())); }
/** * Output the site region (header or footer) markup if the current view calls for it. * ADD some hooks that I can use before and after * * @since 1.0.0. * * @param string $region Region to maybe show. * @return void */ function ttfmake_maybe_show_site_region($region) { if (!in_array($region, array('header', 'footer'))) { return; } // Get the view $view = ttfmake_get_view(); // Get the relevant option $hide_region = (bool) get_theme_mod('layout-' . $view . '-hide-' . $region, ttfmake_get_default('layout-' . $view . '-hide-' . $region)); do_action('ttfmake_before_' . $region, $hide_region); if (true !== $hide_region) { get_template_part('partials/' . $region . '-layout', get_theme_mod($region . '-layout', ttfmake_get_default($region . '-layout'))); } do_action('ttfmake_after_' . $region, $hide_region); }
/** * Determine whether any footer widgets are actually showing. * * @since 1.0.0. * * @return bool Whether or not infinite scroll has footer widgets. */ function ttfmake_jetpack_infinite_scroll_has_footer_widgets() { // Get the view $view = ttfmake_get_view(); // Get the relevant options $hide_footer = (bool) get_theme_mod('layout-' . $view . '-hide-footer', ttfmake_get_default('layout-' . $view . '-hide-footer')); $widget_areas = (int) get_theme_mod('footer-widget-areas', ttfmake_get_default('footer-widget-areas')); // No widget areas are visible if (true === $hide_footer || $widget_areas < 1) { return false; } // Check for active widgets in visible widget areas $i = 1; while ($i <= $widget_areas) { if (is_active_sidebar('footer-' . $i)) { return true; } $i++; } // Still here? No footer widgets. return false; }
/** * Configure settings and controls for the Colors section. * * @since 1.0.0. * * @param object $wp_customize The global customizer object. * @param string $section The section name. * @return void */ function ttfmake_customizer_color($wp_customize, $section) { $priority = new TTFMAKE_Prioritizer(); $control_prefix = 'ttfmake_'; $setting_prefix = str_replace($control_prefix, '', $section); // Primary Color $setting_id = $setting_prefix . '-primary'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'maybe_hash_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Primary Color', 'make'), 'priority' => $priority->add()))); // Secondary Color $setting_id = $setting_prefix . '-secondary'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'maybe_hash_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Secondary Color', 'make'), 'priority' => $priority->add()))); // Text Color $setting_id = $setting_prefix . '-text'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'maybe_hash_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Text Color', 'make'), 'priority' => $priority->add()))); // Detail Color $setting_id = $setting_prefix . '-detail'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'maybe_hash_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Detail Color', 'make'), 'priority' => $priority->add()))); }
/** * Configure settings and controls for the Background section. * * @since 1.0.0. * * @return void */ function ttfmake_customizer_background() { global $wp_customize; $priority = new TTFMAKE_Prioritizer(10, 5); $control_prefix = 'ttfmake_'; $section = 'background_image'; // Rename Background Image section to Background $wp_customize->get_section($section)->title = __('Background', 'make'); // Move Background Color to Background section $wp_customize->get_control('background_color')->section = $section; // Background note $setting_id = 'background-info'; $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'text', 'description' => __('With the Site Layout option (under <em>General</em>) set to "Full Width", the background color and image will not be visible.', 'make'), 'priority' => $priority->add()))); // Reset priorities on existing controls $wp_customize->get_control('background_color')->priority = $priority->add(); $wp_customize->get_control('background_image')->priority = $priority->add(); $wp_customize->get_control('background_repeat')->priority = $priority->add(); $wp_customize->get_control('background_position_x')->priority = $priority->add(); $wp_customize->get_control('background_attachment')->priority = $priority->add(); // Background Size $setting_id = 'background_size'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_choice')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Background Size', 'make'), 'type' => 'radio', 'choices' => ttfmake_get_choices($setting_id), 'priority' => $priority->add())); }
<?php /** * @package Make */ $taxonomy_view = ttfmake_get_view(); $category_key = 'layout-' . $taxonomy_view . '-show-categories'; $tag_key = 'layout-' . $taxonomy_view . '-show-tags'; $category_option = (bool) get_theme_mod($category_key, ttfmake_get_default($category_key)); $tag_option = (bool) get_theme_mod($tag_key, ttfmake_get_default($tag_key)); ?> <?php if (($category_option || $tag_option) && (has_category() && ttfmake_categorized_blog() || has_tag())) { ?> <?php $category_list = get_the_category_list(); $tag_list = get_the_tag_list('<ul class="post-tags"><li>', "</li>\n<li>", '</li></ul>'); // Replicates category output $taxonomy_output = ''; // Categories if ($category_option && $category_list) { $taxonomy_output .= __('<i class="fa fa-file"></i> ', 'make') . '%1$s'; } // Tags if ($tag_option && $tag_list) { $taxonomy_output .= __('<i class="fa fa-tag"></i> ', 'make') . '%2$s'; } // Output printf($taxonomy_output, $category_list, $tag_list); }
/** * Register settings and controls for a section. * * @since 1.3.0. * * @param string $section Section ID * @param array $args Array of setting and control definitions * @param int $initial_priority The initial priority to use for controls * @return int The last priority value assigned */ function ttfmake_customizer_add_section_options($section, $args, $initial_priority = 100) { global $wp_customize; $priority = new TTFMAKE_Prioritizer($initial_priority, 5); $theme_prefix = 'ttfmake_'; foreach ($args as $setting_id => $option) { // Add setting if (isset($option['setting'])) { $defaults = array('type' => 'theme_mod', 'capability' => 'edit_theme_options', 'theme_supports' => '', 'default' => ttfmake_get_default($setting_id), 'transport' => 'refresh', 'sanitize_callback' => '', 'sanitize_js_callback' => ''); $setting = wp_parse_args($option['setting'], $defaults); // Add the setting arguments inline so Theme Check can verify the presence of sanitize_callback $wp_customize->add_setting($setting_id, array('type' => $setting['type'], 'capability' => $setting['capability'], 'theme_supports' => $setting['theme_supports'], 'default' => $setting['default'], 'transport' => $setting['transport'], 'sanitize_callback' => $setting['sanitize_callback'], 'sanitize_js_callback' => $setting['sanitize_js_callback'])); } // Add control if (isset($option['control'])) { $control_id = $theme_prefix . $setting_id; $defaults = array('settings' => $setting_id, 'section' => $section, 'priority' => $priority->add()); if (!isset($option['setting'])) { unset($defaults['settings']); } $control = wp_parse_args($option['control'], $defaults); // Check for a specialized control class if (isset($control['control_type'])) { $class = $control['control_type']; $control_path = apply_filters('make_customizer_control_path', get_template_directory() . '/inc/customizer/controls/', $control); $control_file = $control_path . $class . '.php'; if (file_exists($control_file)) { require_once $control_file; } if (class_exists($class)) { unset($control['control_type']); // Dynamically generate a new class instance $reflection = new ReflectionClass($class); $class_instance = $reflection->newInstanceArgs(array($wp_customize, $control_id, $control)); $wp_customize->add_control($class_instance); } } else { $wp_customize->add_control($control_id, $control); } } } return $priority->get(); }
/** * Register settings and controls for a section. * * @since 1.3.0. * * @param string $section Section ID * @param array $args Array of setting and control definitions * @param int $initial_priority The initial priority to use for controls * @return int The last priority value assigned */ function ttfmake_customizer_add_section_options($section, $args, $initial_priority = 100) { global $wp_customize; $priority = new TTFMAKE_Prioritizer($initial_priority, 5); $theme_prefix = 'ttfmake_'; foreach ($args as $setting_id => $option) { // Add setting if (isset($option['setting'])) { $defaults = array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod'); $setting = wp_parse_args($option['setting'], $defaults); $wp_customize->add_setting($setting_id, $setting); } // Add control if (isset($option['control'])) { $control_id = $theme_prefix . $setting_id; $defaults = array('settings' => $setting_id, 'section' => $section, 'priority' => $priority->add()); if (!isset($option['setting'])) { unset($defaults['settings']); } $control = wp_parse_args($option['control'], $defaults); // Check for a specialized control class if (isset($control['control_type'])) { $class = $control['control_type']; unset($control['control_type']); $wp_customize->add_control(new $class($wp_customize, $control_id, $control)); } else { $wp_customize->add_control($control_id, $control); } } } return $priority->get(); }
/** * Show the social links markup if the theme options and/or menus are configured for it. * * @since 1.0.0. * * @param string $region The site region (header or footer). * @return void */ function ttfmake_maybe_show_social_links($region) { if (!in_array($region, array('header', 'footer'))) { return; } $show_social = (bool) get_theme_mod($region . '-show-social', ttfmake_get_default($region . '-show-social')); if (true === $show_social) { // First look for the alternate custom menu method if (has_nav_menu('social')) { wp_nav_menu(array('theme_location' => 'social', 'container' => false, 'menu_id' => '', 'menu_class' => 'social-menu social-links ' . $region . '-social-links', 'depth' => 1, 'fallback_cb' => '')); } else { $social_links = ttfmake_get_social_links(); if (!empty($social_links)) { ?> <ul class="social-customizer social-links <?php echo $region; ?> -social-links"> <?php foreach ($social_links as $key => $link) { ?> <li class="<?php echo esc_attr($key); ?> "> <a href="<?php echo esc_url($link['url']); ?> "> <i class="fa fa-fw <?php echo esc_attr($link['class']); ?> "> <span><?php echo esc_html($link['title']); ?> </span> </i> </a> </li> <?php } ?> </ul> <?php } } } }
/** * Enqueue formatting scripts for Post/Page editing screens in the admin. * * @since 1.4.1. * * @param $hook_suffix */ public function enqueue_admin_scripts($hook_suffix) { if (in_array($hook_suffix, array('post.php', 'post-new.php'))) { /** * Admin styles */ wp_enqueue_style('ttfmake-formatting', trailingslashit(get_template_directory_uri()) . 'inc/formatting/formatting.css', array(), TTFMAKE_VERSION); /** * Format Builder */ $dependencies = array('backbone', 'underscore', 'jquery'); // Core wp_enqueue_script('ttfmake-format-builder-core', trailingslashit(get_template_directory_uri()) . 'inc/formatting/format-builder/format-builder.js', $dependencies, TTFMAKE_VERSION); wp_localize_script('ttfmake-format-builder-core', 'ttfmakeFormatBuilderVars', array('userSettings' => array('fontSizeBody' => get_theme_mod('font-size-body', ttfmake_get_default('font-size-body')), 'colorPrimary' => get_theme_mod('color-primary', ttfmake_get_default('color-primary')), 'colorSecondary' => get_theme_mod('color-secondary', ttfmake_get_default('color-secondary'))))); // Base model wp_enqueue_script('ttfmake-format-builder-model-base', trailingslashit(get_template_directory_uri()) . 'inc/formatting/format-builder/models/base.js', $dependencies, TTFMAKE_VERSION); $dependencies[] = 'ttfmake-format-builder-model-base'; // Format models $default_uri = trailingslashit(get_template_directory_uri()) . 'inc/formatting/format-builder/models'; /** * Filter the format model definitions and their script locations. * * model => URI of the model's script file * * @since 1.4.1 * * @param array $models The array of format models. */ $models = apply_filters('make_format_builder_format_models', array('button' => array('uri' => $default_uri), 'list' => array('uri' => $default_uri), 'notice' => array('uri' => $default_uri))); foreach ($models as $model => $atts) { $handle = 'ttfmake-format-builder-model-' . $model; $url = trailingslashit($atts['uri']) . "{$model}.js"; wp_enqueue_script($handle, $url, $dependencies, TTFMAKE_VERSION); $dependencies[] = $handle; } /** * Dynamic Stylesheet */ wp_enqueue_script('ttfmake-dynamic-stylesheet', trailingslashit(get_template_directory_uri()) . 'inc/formatting/dynamic-stylesheet/dynamic-stylesheet.js', array('jquery', 'editor'), TTFMAKE_VERSION, true); wp_localize_script('ttfmake-dynamic-stylesheet', 'ttfmakeDynamicStylesheetVars', array('tinymce' => true)); /** * Icon Picker */ // Icon styles wp_enqueue_style('font-awesome', get_template_directory_uri() . '/css/font-awesome' . TTFMAKE_SUFFIX . '.css', array(), '4.5.0'); // Icon definitions wp_enqueue_script('ttfmake-icon-picker-list', trailingslashit(get_template_directory_uri()) . 'inc/formatting/icon-picker/icons.js', array(), TTFMAKE_VERSION); // Icon Picker wp_enqueue_script('ttfmake-icon-picker', trailingslashit(get_template_directory_uri()) . 'inc/formatting/icon-picker/icon-picker.js', array('ttfmake-icon-picker-list', 'jquery'), TTFMAKE_VERSION); } }
/** * Get the social links from options. * * @since 1.0.0. * * @return array Keys are service names and the values are links. */ function ttfmake_get_social_links() { // Define default services; note that these are intentionally non-translatable $default_services = array('facebook-official' => array('title' => 'Facebook', 'class' => 'fa-facebook-official'), 'twitter' => array('title' => 'Twitter', 'class' => 'fa-twitter'), 'google-plus-square' => array('title' => 'Google+', 'class' => 'fa-google-plus-square'), 'linkedin' => array('title' => 'LinkedIn', 'class' => 'fa-linkedin'), 'instagram' => array('title' => 'Instagram', 'class' => 'fa-instagram'), 'flickr' => array('title' => 'Flickr', 'class' => 'fa-flickr'), 'youtube' => array('title' => 'YouTube', 'class' => 'fa-youtube'), 'vimeo-square' => array('title' => 'Vimeo', 'class' => 'fa-vimeo-square'), 'pinterest' => array('title' => 'Pinterest', 'class' => 'fa-pinterest'), 'email' => array('title' => __('Email', 'make'), 'class' => 'fa-envelope'), 'rss' => array('title' => __('RSS', 'make'), 'class' => 'fa-rss')); // Set up the collector array $services_with_links = array(); // Get the links for these services foreach ($default_services as $service => $details) { $url = get_theme_mod('social-' . $service, ttfmake_get_default('social-' . $service)); if ('' !== $url) { $services_with_links[$service] = array('title' => $details['title'], 'url' => $url, 'class' => $details['class']); } } // Special handling for RSS $hide_rss = (int) get_theme_mod('social-hide-rss', ttfmake_get_default('social-hide-rss')); if (0 === $hide_rss) { $custom_rss = get_theme_mod('social-custom-rss', ttfmake_get_default('social-custom-rss')); if (!empty($custom_rss)) { $services_with_links['rss']['url'] = $custom_rss; } else { $services_with_links['rss']['url'] = get_feed_link(); } } else { unset($services_with_links['rss']); } // Properly set the email if (isset($services_with_links['email']['url'])) { $services_with_links['email']['url'] = 'mailto:' . $services_with_links['email']['url']; } /** * Filter the social links added to the site. * * @since 1.2.3. * * @param array $services_with_links The social services and links. */ return apply_filters('make_social_links', $services_with_links); }
/** * Sanitize the Character Subset choice. * * @since 1.0.0 * * @param string $value The value to sanitize. * @return array The sanitized value. */ function ttfmake_sanitize_font_subset($value) { if (!array_key_exists($value, ttfmake_get_google_font_subsets())) { $value = ttfmake_get_default('font-subset'); } /** * Filter the sanitized subset choice. * * @since 1.2.3. * * @param string $value The chosen subset value. */ return apply_filters('make_sanitize_font_subset', $value); }
<?php /** * @package Make */ // Header Options $header_text = get_theme_mod('header-text', false); $social_links = ttfmake_get_social_links(); $show_social = (int) get_theme_mod('header-show-social', ttfmake_get_default('header-show-social')); $show_search = (int) get_theme_mod('header-show-search', ttfmake_get_default('header-show-search')); $subheader_class = 1 === $show_social || 1 === $show_search ? ' right-content' : ''; $hide_site_title = (int) get_theme_mod('hide-site-title', ttfmake_get_default('hide-site-title')); $hide_tagline = (int) get_theme_mod('hide-tagline', ttfmake_get_default('hide-tagline')); $menu_label = get_theme_mod('navigation-mobile-label', ttfmake_get_default('navigation-mobile-label')); $header_bar_menu = wp_nav_menu(array('theme_location' => 'header-bar', 'container_class' => 'header-bar-menu', 'depth' => 1, 'fallback_cb' => false, 'echo' => false)); ?> <header id="site-header" class="<?php echo esc_attr(ttfmake_get_site_header_class()); ?> " role="banner"> <?php // Only show Sub Header if it has content if (!empty($header_text) || 1 === $show_search || !empty($social_links) && 1 === $show_social || !empty($header_bar_menu)) { ?> <div class="header-bar<?php echo esc_attr($subheader_class); ?> "> <div class="container"> <a class="skip-link screen-reader-text" href="#site-content"><?php
<?php /** * @package Make */ // Footer Options $footer_layout = (int) get_theme_mod('footer-layout', ttfmake_get_default('footer-layout')); $sidebar_count = (int) get_theme_mod('footer-widget-areas', ttfmake_get_default('footer-widget-areas')); $social_links = ttfmake_get_social_links(); $show_social = (int) get_theme_mod('footer-show-social', ttfmake_get_default('footer-show-social')); // Test for enabled sidebars that contain widgets $has_active_sidebar = false; if ($sidebar_count > 0) { $i = 1; while ($i <= $sidebar_count) { if (is_active_sidebar('footer-' . $i)) { $has_active_sidebar = true; break; } $i++; } } ?> <footer id="site-footer" class="site-footer footer-layout-<?php echo esc_attr($footer_layout); ?> " role="contentinfo"> <div class="container"> <?php // Footer widget areas
/** * Utility function for getting information about the theme logos. * * @since 1.0.0. * * @param bool $force Update the dimension cache. * @return array Array containing image file, width, and height for each logo. */ function get_logo_information($force = false) { // If the logo information is cached to an instance var, pull from there if (!empty($this->logo_information)) { return $this->logo_information; } // Set the logo slugs $logos = array('logo-regular', 'logo-retina'); // For each logo slug, get the image, width and height foreach ($logos as $logo) { $this->logo_information[$logo]['image'] = get_theme_mod($logo, ttfmake_get_default($logo)); // Set the defaults $this->logo_information[$logo]['width'] = ''; $this->logo_information[$logo]['height'] = ''; // If there is an image, get the dimensions if (!empty($this->logo_information[$logo]['image'])) { $dimensions = $this->get_logo_dimensions($this->logo_information[$logo]['image'], $force); // Set the dimensions to the array if all information is present if (!empty($dimensions) && isset($dimensions['width']) && isset($dimensions['height'])) { $this->logo_information[$logo]['width'] = $dimensions['width']; $this->logo_information[$logo]['height'] = $dimensions['height']; } } } /** * Filter the URL and dimensions of the custom logo. * * This filter may be useful if you encounter problems getting your custom * logo to appear. Note, however, that using this filter will hard-code the logo * information and settings in the Logo interface in the Customizer won't be * reflected. * * @since 1.0.0. * * @param array $logo_information The array of information. */ $this->logo_information = apply_filters('ttfmake_custom_logo_information', $this->logo_information); return $this->logo_information; }
<?php /** * @package Make */ // Posts and Pages if (is_singular()) { the_content(); // Blog, Archives, Search Results } else { $content_key = 'layout-' . ttfmake_get_view() . '-auto-excerpt'; $content_option = (bool) get_theme_mod($content_key, ttfmake_get_default($content_key)); if ($content_option || has_excerpt()) { echo wpautop(get_the_excerpt() . "\n\n" . ttfmake_get_read_more()); } else { the_content(ttfmake_get_read_more('', '')); } }
/** * Sanitize a value from a list of allowed values. * * @since 1.0.0. * * @param mixed $value The value to sanitize. * @param mixed $setting The setting for which the sanitizing is occurring. * @return mixed The sanitized value. */ function ttfmake_sanitize_choice($value, $setting) { if (is_object($setting)) { $setting = $setting->id; } $choices = ttfmake_get_choices($setting); $allowed_choices = array_keys($choices); if (!in_array($value, $allowed_choices)) { $value = ttfmake_get_default($setting); } /** * Filter the sanitized value. * * @since 1.2.3. * * @param mixed $value The sanitized value. * @param string $setting The key for the setting. */ return apply_filters('make_sanitize_choice', $value, $setting); }
/** * Generate a CSS rule definition array for an element's link underline property. * * @since 1.5.0. * * @param string $element The element to look up in the theme options. * @param array $selectors The base selectors to use for the rule. * @return array A CSS rule definition array. */ function ttfmake_parse_link_underline($element, $selectors) { $setting_id = 'link-underline-' . $element; $value = get_theme_mod($setting_id, ttfmake_get_default($setting_id)); if (false !== $value && $value !== ttfmake_get_default($setting_id)) { $sanitized_value = ttfmake_sanitize_choice($value, $setting_id); // Declarations $declarations = array('text-decoration' => 'underline'); if ('never' === $sanitized_value) { $declarations['text-decoration'] = 'none'; } // Selectors $parsed_selectors = $selectors; if ('hover' === $sanitized_value) { foreach ($selectors as $key => $selector) { $parsed_selectors[$key] = $selector . ':hover'; $parsed_selectors[] = $selector . ':focus'; } } // Return CSS rule array return array('selectors' => $parsed_selectors, 'declarations' => $declarations); } return array(); }
<?php /** * @package Make */ $date_key = 'layout-' . ttfmake_get_view() . '-post-date'; $date_option = ttfmake_sanitize_choice(get_theme_mod($date_key, ttfmake_get_default($date_key)), $date_key); // Get date string $date_string = get_the_date(); if ('relative' === $date_option) { $date_string = sprintf(__('%s ago', 'make'), human_time_diff(get_the_time('U'), current_time('timestamp'))); } // Add permalink if not single view if (!is_singular()) { $date_string = '<a href="' . get_permalink() . '" rel="bookmark">' . $date_string . '</a>'; } ?> <?php if ('none' !== $date_option) { ?> <time class="entry-date published" datetime="<?php the_time('c'); ?> "><?php echo $date_string; ?> </time> <?php }
<?php /** * @package Make */ global $ttfmake_current_location; $author_layout_key = 'layout-' . ttfmake_get_view() . '-post-author-location'; $author_option = ttfmake_sanitize_choice(get_theme_mod($author_layout_key, ttfmake_get_default($author_layout_key)), $author_layout_key); $date_layout_key = 'layout-' . ttfmake_get_view() . '-post-date-location'; $date_option = ttfmake_sanitize_choice(get_theme_mod($date_layout_key, ttfmake_get_default($date_layout_key)), $date_layout_key); $comment_count_layout_key = 'layout-' . ttfmake_get_view() . '-comment-count-location'; $comment_count_option = ttfmake_sanitize_choice(get_theme_mod($comment_count_layout_key, ttfmake_get_default($comment_count_layout_key)), $comment_count_layout_key); if ($ttfmake_current_location === $author_option) { get_template_part('partials/entry', 'author'); } if ($ttfmake_current_location === $comment_count_option) { get_template_part('partials/entry', 'comment-count'); } if ($ttfmake_current_location === $date_option) { get_template_part('partials/entry', 'date'); }
<?php /** * @package Make */ ?> <?php if (is_sticky() && ($sticky_label = get_theme_mod('general-sticky-label', ttfmake_get_default('general-sticky-label')))) { ?> <div class="sticky-post-label-wrapper"> <span class="sticky-post-label"> <?php echo esc_html(wp_strip_all_tags($sticky_label)); ?> </span> </div> <?php }
<?php /** * @package Make */ $thumb_key = 'layout-' . ttfmake_get_view() . '-featured-images'; $thumb_option = ttfmake_sanitize_choice(get_theme_mod($thumb_key, ttfmake_get_default($thumb_key)), $thumb_key); // Header ob_start(); get_template_part('partials/entry', 'meta-top'); get_template_part('partials/entry', 'sticky'); if ('post-header' === $thumb_option) { get_template_part('partials/entry', 'thumbnail'); } get_template_part('partials/entry', 'title'); get_template_part('partials/entry', 'meta-before-content'); $entry_header = trim(ob_get_clean()); // Footer ob_start(); get_template_part('partials/entry', 'meta-post-footer'); get_template_part('partials/entry', 'taxonomy'); get_template_part('partials/entry', 'sharing'); $entry_footer = trim(ob_get_clean()); ?> <article id="post-<?php the_ID(); ?> " <?php post_class(); ?>
/** * Add the Yoast SEO breadcrumb, if the plugin is activated. * * @since 1.6.4. * * @return void */ function ttfmake_yoast_seo_breadcrumb() { if (function_exists('yoast_breadcrumb')) { $key = 'layout-' . ttfmake_get_view() . '-yoast-breadcrumb'; $option = absint(get_theme_mod($key, ttfmake_get_default($key))); if (1 === $option || is_404()) { yoast_breadcrumb('<p class="yoast-seo-breadcrumb">', '</p>'); } } }
/** * Configure settings and controls for the Layout: Archives section. * * @since 1.0.0. * * @param object $wp_customize The global customizer object. * @param string $section The section name. * @return void */ function ttfmake_customizer_layout_archive($wp_customize, $section) { $priority = new TTFMAKE_Prioritizer(); $control_prefix = 'ttfmake_'; $setting_prefix = str_replace($control_prefix, '', $section); // Header, Footer, Sidebars heading $setting_id = $setting_prefix . '-heading-sidebars'; $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'heading', 'label' => __('Header, Footer, Sidebars', 'make'), 'priority' => $priority->add()))); // Hide site header $setting_id = $setting_prefix . '-hide-header'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Hide site header', 'make'), 'type' => 'checkbox', 'priority' => $priority->add())); // Hide site footer $setting_id = $setting_prefix . '-hide-footer'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Hide site footer', 'make'), 'type' => 'checkbox', 'priority' => $priority->add())); // Left sidebar $setting_id = $setting_prefix . '-sidebar-left'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Show left sidebar', 'make'), 'type' => 'checkbox', 'priority' => $priority->add())); // Right sidebar $setting_id = $setting_prefix . '-sidebar-right'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Show right sidebar', 'make'), 'type' => 'checkbox', 'priority' => $priority->add())); // Featured images $setting_id = $setting_prefix . '-featured-images'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_choice')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Featured Images', 'make'), 'type' => 'select', 'choices' => ttfmake_get_choices($setting_id), 'priority' => $priority->add())); // Featured images alignment $setting_id = $setting_prefix . '-featured-images-alignment'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_choice')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Featured Images Alignment', 'make'), 'type' => 'select', 'choices' => ttfmake_get_choices($setting_id), 'priority' => $priority->add())); // Post date $setting_id = $setting_prefix . '-post-date'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_choice')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Post Date', 'make'), 'type' => 'select', 'choices' => ttfmake_get_choices($setting_id), 'priority' => $priority->add())); // Post date location $setting_id = $setting_prefix . '-post-date-location'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_choice')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Post Date Location', 'make'), 'type' => 'select', 'choices' => ttfmake_get_choices($setting_id), 'priority' => $priority->add())); // Post author $setting_id = $setting_prefix . '-post-author'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_choice')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Post Author', 'make'), 'type' => 'select', 'choices' => ttfmake_get_choices($setting_id), 'priority' => $priority->add())); // Post author location $setting_id = $setting_prefix . '-post-author-location'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_choice')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Post Author Location', 'make'), 'type' => 'select', 'choices' => ttfmake_get_choices($setting_id), 'priority' => $priority->add())); // Content heading $setting_id = $setting_prefix . '-heading-content'; $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'heading', 'label' => __('Content', 'make'), 'priority' => $priority->add()))); // Auto excerpt $setting_id = $setting_prefix . '-auto-excerpt'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Generate excerpts automatically', 'make'), 'type' => 'checkbox', 'priority' => $priority->add())); // Post meta heading $setting_id = $setting_prefix . '-heading-postmeta'; $wp_customize->add_control(new TTFMAKE_Customize_Misc_Control($wp_customize, $control_prefix . $setting_id, array('section' => $section, 'type' => 'heading', 'label' => __('Post Meta', 'make'), 'priority' => $priority->add()))); // Show categories $setting_id = $setting_prefix . '-show-categories'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Show categories', 'make'), 'type' => 'checkbox', 'priority' => $priority->add())); // Show tags $setting_id = $setting_prefix . '-show-tags'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'absint')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Show tags', 'make'), 'type' => 'checkbox', 'priority' => $priority->add())); // Comment count $setting_id = $setting_prefix . '-comment-count'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_choice')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Comment Count', 'make'), 'type' => 'select', 'choices' => ttfmake_get_choices($setting_id), 'priority' => $priority->add())); // Comment count location $setting_id = $setting_prefix . '-comment-count-location'; $wp_customize->add_setting($setting_id, array('default' => ttfmake_get_default($setting_id), 'type' => 'theme_mod', 'sanitize_callback' => 'ttfmake_sanitize_choice')); $wp_customize->add_control($control_prefix . $setting_id, array('settings' => $setting_id, 'section' => $section, 'label' => __('Comment Count Location', 'make'), 'type' => 'select', 'choices' => ttfmake_get_choices($setting_id), 'priority' => $priority->add())); }
/** * Add additional items to the end of the wp_head section of the document head. * * @since 1.0.0. * * @return void */ function ttfmake_head_late() { // Pingback link ?> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?> "> <?php // Core Site Icon option overrides Make's deprecated Favicon and Apple Touch Icon settings if (false === get_option('site_icon', false)) { // Favicon $logo_favicon = get_theme_mod('logo-favicon', ttfmake_get_default('logo-favicon')); if (!empty($logo_favicon)) { ?> <link rel="icon" href="<?php echo esc_url($logo_favicon); ?> " /> <?php } // Apple Touch icon $logo_apple_touch = get_theme_mod('logo-apple-touch', ttfmake_get_default('logo-apple-touch')); if (!empty($logo_apple_touch)) { ?> <link rel="apple-touch-icon" href="<?php echo esc_url($logo_apple_touch); ?> " /> <?php } } }