File manager - Edit - /home/contenidosenred/public_html/OD/wp-content/themes/streamit/functions.php
Back
<?php /** * streamit functions and definitions * * @link https://developer.wordpress.org/themes/basics/theme-functions/ * * @package WordPress * @subpackage streamit * @since 1.0 */ define('STREAMIT_DIR', get_template_directory()); // template directory define('STREAMIT_URI', get_template_directory_uri()); // template directory uri define('STREAMIT_ADMIN', admin_url()); // admin directory uri /** * streamit only works in WordPress 4.7 or later. */ if (version_compare($GLOBALS['wp_version'], '4.7-alpha', '<')) { require get_template_directory() . '/inc/back-compat.php'; return; } /** * 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 streamit_setup() { /* * Make theme available for translation. * Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/streamit * If you're building a theme based on streamit, use a find and replace * to change 'streamit' to the name of your theme in all the template files. */ load_theme_textdomain('streamit', get_template_directory() . '/languages'); // Add default posts and comments RSS feed links to head. add_theme_support('automatic-feed-links'); /* * 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 Post Thumbnails on posts and pages. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support('post-thumbnails'); add_image_size('streamit-featured-image', 2000, 1200, true); add_image_size('streamit-thumbnail-avatar', 100, 100, true); // Set the default content width. $GLOBALS['content_width'] = 525; // This theme uses wp_nav_menu() in two locations. register_nav_menus(array( 'top' => esc_html__('Top Menu', 'streamit'), 'social' => esc_html__('Social Links Menu', 'streamit'), )); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support('html5', array( 'comment-form', 'comment-list', 'gallery', 'caption', )); /* * Enable support for Post Formats. * * See: https://codex.wordpress.org/Post_Formats */ add_theme_support('post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'gallery', 'audio', )); // Add theme support for Custom Logo. add_theme_support('custom-logo', array( 'width' => 250, 'height' => 250, 'flex-width' => true, )); // Add theme support for selective refresh for widgets. add_theme_support('customize-selective-refresh-widgets'); /* * This theme styles the visual editor to resemble the theme style, * specifically font, colors, and column width. */ // Define and register starter content to showcase the theme on new sites. $starter_content = array( 'widgets' => array( // Place three core-defined widgets in the sidebar area. 'sidebar-1' => array( 'text_business_info', 'search', 'text_about', ), // Add the core-defined business info widget to the footer 1 area. 'sidebar-2' => array( 'text_business_info', ), // Put two core-defined widgets in the footer 2 area. 'sidebar-3' => array( 'text_about', 'search', ), ), // Specify the core-defined pages to create and add custom thumbnails to some of them. 'posts' => array( 'home', 'about' => array( 'thumbnail' => '{{image-sandwich}}', ), 'contact' => array( 'thumbnail' => '{{image-espresso}}', ), 'blog' => array( 'thumbnail' => '{{image-coffee}}', ), 'homepage-section' => array( 'thumbnail' => '{{image-espresso}}', ), ), // Create the custom image attachments used as post thumbnails for pages. 'attachments' => array( 'image-espresso' => array( 'post_title' => esc_html_x('Espresso', 'Theme starter content', 'streamit'), 'file' => '/assets/images/espresso.jpg', // URL relative to the template directory. ), 'image-sandwich' => array( 'post_title' => esc_html_x('Sandwich', 'Theme starter content', 'streamit'), 'file' => '/assets/images/sandwich.jpg', ), 'image-coffee' => array( 'post_title' => esc_html_x('Coffee', 'Theme starter content', 'streamit'), 'file' => '/assets/images/coffee.jpg', ), ), // Default to a static front page and assign the front and posts pages. 'options' => array( 'show_on_front' => 'page', 'page_on_front' => '{{home}}', 'page_for_posts' => '{{blog}}', ), // Set the front page section theme mods to the IDs of the core-registered pages. 'theme_mods' => array( 'panel_1' => '{{homepage-section}}', 'panel_2' => '{{about}}', 'panel_3' => '{{blog}}', 'panel_4' => '{{contact}}', ), // Set up nav menus for each of the two areas registered in the theme. 'nav_menus' => array( // Assign a menu to the "top" location. 'top' => array( 'name' => esc_html__('Top Menu', 'streamit'), 'items' => array( 'link_home', // Note that the core "home" page is actually a link in case a static front page is not used. 'page_about', 'page_blog', 'page_contact', ), ), // Assign a menu to the "social" location. 'social' => array( 'name' => esc_html__('Social Links Menu', 'streamit'), 'items' => array( 'link_yelp', 'link_facebook', 'link_twitter', 'link_instagram', 'link_email', ), ), ), ); /** * Filters streamit array of starter content. * * @since streamit 1.1 * * @param array $starter_content Array of starter content. */ $starter_content = apply_filters('streamit_starter_content', $starter_content); add_theme_support('starter-content', $starter_content); } add_action('after_setup_theme', 'streamit_setup'); /** * 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 streamit_content_width() { $content_width = $GLOBALS['content_width']; // Get layout. $page_layout = get_theme_mod('page_layout'); // Check if layout is one column. if ('one-column' === $page_layout) { if (streamit_is_frontpage()) { $content_width = 644; } elseif (is_page()) { $content_width = 740; } } // Check if is single post and there is no sidebar. if (is_single() && !is_active_sidebar('sidebar-1')) { $content_width = 740; } /** * Filter streamit content width of the theme. * * @since streamit 1.0 * * @param int $content_width Content width in pixels. */ $GLOBALS['content_width'] = apply_filters('streamit_content_width', $content_width); } add_action('template_redirect', 'streamit_content_width', 0); /** * Register custom fonts. */ function streamit_fonts_url() { $fonts_url = ''; /* * Translators: If there are characters in your language that are not * supported by Libre Franklin, translate this to 'off'. Do not translate * into your own language. */ $libre_franklin = esc_html_x('on', 'Libre Franklin font: on or off', 'streamit'); if ('off' !== $libre_franklin) { $font_families = array(); $font_families[] = 'Libre Franklin:300,300i,400,400i,600,600i,800,800i'; $query_args = array( 'family' => urlencode(implode('|', $font_families)), 'subset' => urlencode('latin,latin-ext'), ); $fonts_url = add_query_arg($query_args, '//fonts.googleapis.com/css'); } return esc_url_raw($fonts_url); } /** * Add preconnect for Google Fonts. * * @since streamit 1.0 * * @param array $urls URLs to print for resource hints. * @param string $relation_type The relation type the URLs are printed. * @return array $urls URLs to print for resource hints. */ function streamit_resource_hints($urls, $relation_type) { if (wp_style_is('fonts', 'queue') && 'preconnect' === $relation_type) { $urls[] = array( 'href' => '//fonts.gstatic.com', 'crossorigin', ); } return $urls; } add_filter('wp_resource_hints', 'streamit_resource_hints', 10, 2); /** * Register widget area. * * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar */ function streamit_widgets_init() { register_sidebar(array( 'name' => esc_html__('Blog Sidebar', 'streamit'), 'id' => 'sidebar-1', 'description' => esc_html__('Add widgets here to appear in your sidebar on blog posts and archive pages.', 'streamit'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h5 class="widget-title">', 'after_title' => '</h5>', )); } add_action('widgets_init', 'streamit_widgets_init'); /** * Handles JavaScript detection. * * Adds a `js` class to the root `<html>` element when JavaScript is detected. * * @since streamit 1.0 */ function streamit_javascript_detection() { $js_detect = "(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);\n"; wp_register_script('dummy-handle-header', ''); wp_enqueue_script('dummy-handle-header'); wp_add_inline_script('dummy-handle-header', $js_detect); } add_action('wp_enqueue_scripts', 'streamit_javascript_detection', 0); /** * Add a pingback url auto-discovery header for singularly identifiable articles. */ function streamit_pingback_header() { if (is_singular() && pings_open()) { printf('<link rel="pingback" href="%s">' . "\n", get_bloginfo('pingback_url')); } } add_action('wp_head', 'streamit_pingback_header'); /** * Display custom color CSS. */ function streamit_colors_css_wrap() { if ('custom' !== get_theme_mod('colorscheme') && !is_customize_preview()) { return; } require_once(get_parent_theme_file_path('/inc/color-patterns.php')); $hue = absint(get_theme_mod('colorscheme_hue', 250)); ?> <style type="text/css" id="custom-theme-colors" <?php if (is_customize_preview()) { echo 'data-hue="' . $hue . '"'; } ?>> <?php echo streamit_custom_colors_css(); ?> </style> <?php } add_action('wp_head', 'streamit_colors_css_wrap'); /** * Enqueue scripts and styles. */ function streamit_scripts() { // Add custom fonts, used in the main stylesheet. // Load the dark colorscheme. if ('dark' === get_theme_mod('colorscheme', 'light') || is_customize_preview()) { wp_enqueue_style('colors-dark', get_theme_file_uri('/assets/css/colors-dark.css'), array('style'), '1.0'); } // Load the html5 shiv. wp_enqueue_script('html5', get_theme_file_uri('/assets/js/html5.js'), array(), '3.7.3'); wp_script_add_data('html5', 'conditional', 'lt IE 9'); $streamit_l10n = array( 'quote' => streamit_get_svg(array('icon' => 'quote-right')), ); if (has_nav_menu('top')) { $streamit_l10n['expand'] = esc_html__('Expand child menu', 'streamit'); $streamit_l10n['collapse'] = esc_html__('Collapse child menu', 'streamit'); $streamit_l10n['icon'] = streamit_get_svg(array('icon' => 'angle-down', 'fallback' => true)); } wp_localize_script('streamit-skip-link-focus-fix', 'streamitScreenReaderText', $streamit_l10n); if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } } add_action('wp_enqueue_scripts', 'streamit_scripts'); /** * Add custom image sizes attribute to enhance responsive image functionality * for content images. * * @since streamit 1.0 * * @param string $sizes A source size value for use in a 'sizes' attribute. * @param array $size Image size. Accepts an array of width and height * values in pixels (in that order). * @return string A source size value for use in a content image 'sizes' attribute. */ function streamit_content_image_sizes_attr($sizes, $size) { $width = $size[0]; if (740 <= $width) { $sizes = '(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px'; } if (is_active_sidebar('sidebar-1') || is_archive() || is_search() || is_home() || is_page()) { if (!(is_page() && 'one-column' === get_theme_mod('page_options')) && 767 <= $width) { $sizes = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px'; } } return $sizes; } add_filter('wp_calculate_image_sizes', 'streamit_content_image_sizes_attr', 10, 2); /** * Filter the `sizes` value in the header image markup. * * @since streamit 1.0 * * @param string $html The HTML image tag markup being filtered. * @param object $header The custom header object returned by 'get_custom_header()'. * @param array $attr Array of the attributes for the image tag. * @return string The filtered header image HTML. */ function streamit_header_image_tag($html, $header, $attr) { if (isset($attr['sizes'])) { $html = str_replace($attr['sizes'], '100vw', $html); } return $html; } add_filter('get_header_image_tag', 'streamit_header_image_tag', 10, 3); /** * Add custom image sizes attribute to enhance responsive image functionality * for post thumbnails. * * @since streamit 1.0 * * @param array $attr Attributes for the image markup. * @param int $attachment Image attachment ID. * @param array $size Registered image size or flat array of height and width dimensions. * @return array The filtered attributes for the image markup. */ function streamit_post_thumbnail_sizes_attr($attr, $attachment, $size) { if (is_archive() || is_search() || is_home()) { $attr['sizes'] = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px'; } else { $attr['sizes'] = '100vw'; } return $attr; } add_filter('wp_get_attachment_image_attributes', 'streamit_post_thumbnail_sizes_attr', 10, 3); /** * Use front-page.php when Front page displays is set to a static page. * * @since streamit 1.0 * * @param string $template front-page.php. * * @return string The template to be used: blank if is_home() is true (defaults to index.php), else $template. */ function streamit_front_page_template($template) { return is_home() ? '' : $template; } add_filter('frontpage_template', 'streamit_front_page_template'); /** * Modifies tag cloud widget arguments to display all tags in the same font size * and use list format for better accessibility. * * @since streamit 1.4 * * @param array $args Arguments for tag cloud widget. * @return array The filtered arguments for tag cloud widget. */ function streamit_widget_tag_cloud_args($args) { $args['largest'] = 1; $args['smallest'] = 1; $args['unit'] = 'em'; $args['format'] = 'list'; return $args; } add_filter('widget_tag_cloud_args', 'streamit_widget_tag_cloud_args'); /** * Implement the Custom Header feature. */ require get_parent_theme_file_path('/inc/custom-header.php'); /** * Custom template tags for this theme. */ require get_parent_theme_file_path('/inc/template-tags.php'); /** * Additional features to allow styling of the templates. */ require get_parent_theme_file_path('/inc/template-functions.php'); /** * Customizer additions. */ require get_parent_theme_file_path('/inc/customizer.php'); /** * SVG icons functions and filters. */ require get_parent_theme_file_path('/inc/icon-functions.php'); require_once STREAMIT_DIR . '/inc/custom/custom-code.php'; // Redux Framework if (class_exists('ReduxFramework')) { require_once(STREAMIT_DIR . '/inc/frame-work/theme-options/option-set.php'); } //Metabox Custom Field Framework if (class_exists('RW_Meta_Box')) { require_once(STREAMIT_DIR . '/inc/meta-box/meta-box.php'); } add_action('wp_loaded', 'streamit_output_buffer_start'); function streamit_output_buffer_start() { ob_start("streamit_output_callback"); } function streamit_output_callback($buffer) { return preg_replace("%[ ]type=[\'\"]text\/(javascript|css)[\'\"]%", '', $buffer); } function streamit_mime_types($mimes) { $mimes['svg'] = 'image/svg+xml'; return $mimes; } add_filter('upload_mimes', 'streamit_mime_types'); add_filter( 'avatar_defaults', 'custom_avatar' ); function custom_avatar($avatar_defaults){ $custom_avatar = get_stylesheet_directory_uri() . '/images/custom-avatar.png'; $avatar_defaults[$custom_avatar] = "My Default Avatar"; return $avatar_defaults; }
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings