function slider_filter($output) { $display_header_slider = get_theme_mod('display_header_slider', ''); $slides = get_uploaded_header_images(); $js_loaded = FastfoodOptions::get_opt('fastfood_jsani'); if ($display_header_slider && $slides && $js_loaded) { $output = $this->build_slider($slides); } return $output; }
/** * Choose a header image, selected from existing uploaded and default headers, * or provide an array of uploaded header data (either new, or from media library). * * @param mixed $choice Which header image to select. Allows for values of 'random-default-image', * for randomly cycling among the default images; 'random-uploaded-image', for randomly cycling * among the uploaded images; the key of a default image registered for that theme; and * the key of an image uploaded for that theme (the basename of the URL). * Or an array of arguments: attachment_id, url, width, height. All are required. * * @since 3.4.0 */ public final function set_header_image($choice) { if (is_array($choice) || is_object($choice)) { $choice = (array) $choice; if (!isset($choice['attachment_id']) || !isset($choice['url'])) { return; } $choice['url'] = esc_url_raw($choice['url']); $header_image_data = (object) array('attachment_id' => $choice['attachment_id'], 'url' => $choice['url'], 'thumbnail_url' => $choice['url'], 'height' => $choice['height'], 'width' => $choice['width']); update_post_meta($choice['attachment_id'], '_wp_attachment_is_custom_header', get_stylesheet()); set_theme_mod('header_image', $choice['url']); set_theme_mod('header_image_data', $header_image_data); return; } if (in_array($choice, array('remove-header', 'random-default-image', 'random-uploaded-image'))) { set_theme_mod('header_image', $choice); remove_theme_mod('header_image_data'); return; } $uploaded = get_uploaded_header_images(); if ($uploaded && isset($uploaded[$choice])) { $header_image_data = $uploaded[$choice]; } else { $this->process_default_headers(); if (isset($this->default_headers[$choice])) { $header_image_data = $this->default_headers[$choice]; } else { return; } } set_theme_mod('header_image', esc_url_raw($header_image_data['url'])); set_theme_mod('header_image_data', $header_image_data); }
/** * Function to register the theme settings */ function xili_register_settings() { global $wp_registered_sidebars, $xili_language; $xili_language->get_lang_slug_ids('edited'); // 2.12 - refresh and flush permalinks if (false === get_option($this->settings_name, false)) { add_option($this->settings_name, $this->get_default_theme_xili_options()); } // Register the settings with Validation callback $options = $this->get_theme_xili_options(); register_setting($this->settings_name, $this->settings_name, array($this, 'xili_validate_settings')); // Add settings section add_settings_section('xili_option_section_1', __('Look and feel of theme on visitors side', 'xili-language'), array($this, 'xili_display_one_section'), $this->settings_name); if (!current_theme_supports('custom_xili_flag')) { // 2.15 $field_args = array('option_name' => $this->settings_name, 'title' => __('Hide Flags', 'xili-language'), 'type' => 'checkbox', 'id' => 'no_flags', 'name' => 'no_flags', 'desc' => __('If checked, default flags are hidden...', 'xili-language'), 'std' => '1', 'label_for' => 'no_flags', 'class' => 'css_class'); add_settings_field($field_args['id'], $field_args['title'], array($this, 'xili_display_one_setting'), $this->settings_name, 'xili_option_section_1', $field_args); } $field_args = array('option_name' => $this->settings_name, 'title' => __('Show linked posts', 'xili-language'), 'type' => 'checkbox', 'id' => 'linked_posts', 'name' => 'linked_posts', 'desc' => __('Show Other Posts links in meta in single (even if menu or widget languages list).', 'xili-language'), 'std' => '1', 'label_for' => 'linked_posts', 'class' => 'css_class'); add_settings_field($field_args['id'], $field_args['title'], array($this, 'xili_display_one_setting'), $this->settings_name, 'xili_option_section_1', $field_args); $field_args = array('option_name' => $this->settings_name, 'title' => __('Text of link title', 'xili-language'), 'type' => 'text', 'id' => 'linked_title', 'name' => 'linked_title', 'desc' => __('The text before the links of linked posts in other language', 'xili-language'), 'std' => 'Read this post in', 'label_for' => 'linked_title', 'class' => 'css_class'); add_settings_field($field_args['id'], $field_args['title'], array($this, 'xili_display_one_setting'), $this->settings_name, 'xili_option_section_1', $field_args); // section #2 $menu_locations = get_registered_nav_menus(); $navmenu_count = 0; foreach ($menu_locations as $one_key => $one_location) { if (false === strpos($one_key, $this->menu_lang_sep)) { $navmenu_count++; } // only core nav menu } if ($navmenu_count > 0) { add_settings_section('xili_option_section_2', '<hr />' . __('Navigation Menus', 'xili-language'), array($this, 'xili_display_one_section'), $this->settings_name); $field_args = array('option_name' => $this->settings_name, 'title' => __('Instancing nav menus', 'xili-language'), 'type' => 'checkbox', 'id' => 'nav_menus', 'name' => 'nav_menus', 'desc' => __('Instantiation of nav menu for each language.', 'xili-language'), 'std' => 'nav_menus', 'label_for' => 'nav_menus', 'class' => 'css_class menus_instancing'); add_settings_field($field_args['id'], $field_args['title'], array($this, 'xili_display_one_setting'), $this->settings_name, 'xili_option_section_2', $field_args); if ($navmenu_count > 1) { foreach ($menu_locations as $one_key => $one_location) { if (false === strpos($one_key, $this->menu_lang_sep)) { $indice = 'nav_menu_' . $one_key; $nav_value = isset($options[$indice]) ? $options[$indice] : ""; $field_args = array('option_name' => $this->settings_name, 'title' => sprintf('- ' . __('Instancing menu named %s:', 'xili-language'), '<strong> ' . $one_location . '</strong>'), 'type' => 'checkbox', 'id' => $indice, 'name' => $indice, 'desc' => sprintf(' ' . __('Instantiation nav menu named %s for each language.', 'xili-language'), '<strong> ' . $one_location . '</strong>'), 'std' => 'nav_menu', 'label_for' => $indice, 'class' => 'css_class menu_locations'); add_settings_field($field_args['id'], $field_args['title'], array($this, 'xili_display_one_setting'), $this->settings_name, 'xili_option_section_2', $field_args); } } } } // section #3 - widgets if ($this->customize_clone_widget_containers) { add_settings_section('xili_option_section_3', __('Sidebars', 'xili-language'), array($this, 'xili_display_one_section'), $this->settings_name); foreach ($wp_registered_sidebars as $one_key => $one_sidebar) { if (false === strpos($one_key, '_')) { $indice = 'sidebar_' . $one_key; $field_args = array('option_name' => $this->settings_name, 'title' => sprintf(__('Instancing widget named %s:', 'xili-language'), '<strong> ' . $one_sidebar['name'] . '</strong>'), 'type' => 'checkbox', 'id' => $indice, 'name' => $indice, 'desc' => sprintf(__('Instantiation widget named %s for each language.', 'xili-language'), '<strong> ' . $one_sidebar['name'] . '</strong>'), 'std' => 'sidebar_clone', 'label_for' => $indice, 'class' => 'css_class'); add_settings_field($field_args['id'], $field_args['title'], array($this, 'xili_display_one_setting'), $this->settings_name, 'xili_option_section_3', $field_args); } } } // Header Images // 2.9.10 - 1.3 - add_settings_section('xili_option_section_5', '<hr />' . __('Header image options', $this->admin_ui_domain), array($this, 'xili_display_one_section'), $this->settings_name); $field_args = array('option_name' => $this->settings_name, 'title' => __('Multilingual header', 'xili-language'), 'type' => 'checkbox', 'id' => 'xl_header', 'name' => 'xl_header', 'desc' => __('If checked, one header per language can be selected', 'xili-language'), 'std' => '1', 'label_for' => 'xl_header', 'class' => 'css_class'); add_settings_field($field_args['id'], $field_args['title'], array($this, 'xili_display_one_setting'), $this->settings_name, 'xili_option_section_5', $field_args); add_settings_section('xili_option_section_6', __('Header image assignment', $this->admin_ui_domain), array($this, 'xili_display_one_section'), $this->settings_name); $section = 0; // list the images if (get_uploaded_header_images()) { // add fields and language pop-up $this_upload_headers = get_uploaded_header_images(); $this->show_header_assignment_fields($this_upload_headers); $section++; } $this_default_headers = $this->get_processed_default_headers(); if (!empty($this_default_headers)) { $this->show_header_assignment_fields($this_default_headers); $section++; } if ($section == 0) { $header_setting_url = admin_url('/themes.php?page=custom-header'); $field_args = array('option_name' => $this->settings_name, 'title' => __('Message:', $this->admin_ui_domain), 'type' => 'message', 'id' => 'no_header_image', 'name' => 'no_header_image', 'desc' => __('This theme does not contains header image !', $this->admin_ui_domain) . '<br />' . sprintf(__('The images must be uploaded (and cropped) in the %1$sheader settings%2$s page.', $this->admin_ui_domain), '<a href="' . $header_setting_url . '">', '</a>'), 'label_for' => 'no_header_image', 'class' => 'css_class'); add_settings_field($field_args['id'], $field_args['title'], array($this, 'xili_display_one_setting'), $this->settings_name, 'xili_option_section_6', $field_args); } // Permalinks option $language_xili_settings = get_option('xili_language_settings'); if ($xili_language->is_permalink && version_compare($language_xili_settings['version'], '2.17', '>=')) { add_settings_section('xili_option_section_7', '<hr />' . __('Permalinks for languages', $this->admin_ui_domain), array($this, 'xili_display_one_section'), $this->settings_name); $field_args = array('option_name' => $this->settings_name, 'title' => __('Activate Permalinks', $this->admin_ui_domain), 'type' => 'message', 'id' => 'perma_ok', 'desc' => sprintf(__('Now, language in permalink is set in language settings page %s', $this->admin_ui_domain), '<a href="options-general.php?page=language_expert" >' . __('here', 'xili-language') . '</a>'), 'class' => 'css_class permalinks-set'); add_settings_field($field_args['id'], $field_args['title'], array($this, 'xili_display_one_setting'), $this->settings_name, 'xili_option_section_7', $field_args); } else { $xili_functionsfolder = get_stylesheet_directory() . '/functions-xili'; if (file_exists($xili_functionsfolder . '/multilingual-permalinks.php') && $xili_language->is_permalink) { add_settings_section('xili_option_section_7', '<hr />' . __('Permalinks for languages', $this->admin_ui_domain), array($this, 'xili_display_one_section'), $this->settings_name); $field_args = array('option_name' => $this->settings_name, 'title' => __('Activate Permalinks', $this->admin_ui_domain), 'type' => 'checkbox', 'id' => 'perma_ok', 'name' => 'perma_ok', 'desc' => __('If checked, xili-language incorporate language in permalinks... (premium services for donators, see docs)', $this->admin_ui_domain), 'std' => '1', 'label_for' => 'perma_ok', 'class' => 'css_class permalinks-set'); add_settings_field($field_args['id'], $field_args['title'], array($this, 'xili_display_one_setting'), $this->settings_name, 'xili_option_section_7', $field_args); } } }
/** * Get random header image from registered images in theme. * * @since 3.2.0 * * @return string Path to header image */ function get_random_header_image() { global $_wp_default_headers; $header_image_mod = get_theme_mod('header_image', ''); $headers = array(); if ('random-uploaded-image' == $header_image_mod) { $headers = get_uploaded_header_images(); } elseif (!empty($_wp_default_headers)) { if ('random-default-image' == $header_image_mod) { $headers = $_wp_default_headers; } else { $is_random = get_theme_support('custom-header'); if (isset($is_random[0]) && !empty($is_random[0]['random-default'])) { $headers = $_wp_default_headers; } } } if (empty($headers)) { return ''; } $random_image = array_rand($headers); $header_url = sprintf($headers[$random_image]['url'], get_template_directory_uri(), get_stylesheet_directory_uri()); return $header_url; }
/** * Inline script will load the full screen background image after all other images * on the page have loaded. */ function politics_basic_backstretch_inline_script() { if (is_page_template('front-page-template.php')) { ?> <script> jQuery( window ).load( function() { jQuery(".page-template-front-page-template .home-header-bg").backstretch([ <?php /** * Get our customizer options variables. */ $home_duration = get_theme_mod('home_duration', customizer_library_get_default('home_duration')); $home_fade = get_theme_mod('home_fade', customizer_library_get_default('home_fade')); $headers = get_uploaded_header_images(); /** * Display demo image if custom images haven't been uploaded yet */ if (empty($headers)) { $demoimage = get_template_directory_uri() . '/img/hero-bg.jpg'; ?> "<?php echo esc_url($demoimage); ?> ", <?php } else { /** * Loop through header images */ foreach ($headers as $header) { ?> "<?php echo $header['url']; ?> ", <?php } } ?> ], {duration: <?php echo esc_html($home_duration); ?> , fade: <?php echo esc_html($home_fade); ?> }); }); </script> <?php } // end is_front_page ?> <?php }
/** * Get random header image data from registered images in theme. * * @since 3.4.0 * * @access private * * @return string Path to header image */ function _get_random_header_data() { static $_wp_random_header; if (empty($_wp_random_header)) { global $_wp_default_headers; $header_image_mod = get_theme_mod('header_image', ''); $headers = array(); if ('random-uploaded-image' == $header_image_mod) { $headers = get_uploaded_header_images(); } elseif (!empty($_wp_default_headers)) { if ('random-default-image' == $header_image_mod) { $headers = $_wp_default_headers; } else { if (current_theme_supports('custom-header', 'random-default')) { $headers = $_wp_default_headers; } } } if (empty($headers)) { return new stdClass(); } $_wp_random_header = (object) $headers[array_rand($headers)]; $_wp_random_header->url = sprintf($_wp_random_header->url, get_template_directory_uri(), get_stylesheet_directory_uri()); $_wp_random_header->thumbnail_url = sprintf($_wp_random_header->thumbnail_url, get_template_directory_uri(), get_stylesheet_directory_uri()); } return $_wp_random_header; }
public function render_meta_box_content($post) { do_action(' raindrops_custom_css_pre'); $form = ''; wp_nonce_field('raindrops_inner_custom_box', 'raindrops_inner_custom_box_nonce'); $value = get_post_meta($post->ID, '_css', true); //$value = str_replace( array( '{', '}', ), array( "{\n", "\n}\n", ), $value ); $value = str_replace(array('{', '}', "\t"), array("{\r\n\t", "}\r\n", ' '), $value); $value = str_replace('![^(\\"|\')];!', ";\r\n", $value); /** * 1/307 * test */ $value = str_replace(';', ";\r\n ", $value); $value = str_replace(" }", "}", $value); $value = preg_replace("!^\\s!msi", '', $value); $raindrops_restore_check = get_theme_mod('header_image', get_theme_support('custom-header', 'default-image')); $current_value_header = get_post_meta($post->ID, '_raindrops_this_header_image', true); $form .= '<label for="%1$s">%2$s</label>' . '<textarea id="%1$s" name="%1$s" %4$s>%3$s</textarea>'; /* * 1.295 commentout Unnatural behavior * $form .= '<div id="contextual-help-link-wrap-2" class="hide-if-no-js screen-meta-toggle button button-large"> <a href="#contextual-help-wrap" id="contextual-help-link-2" class="show-settings" aria-controls="contextual-help-wrap" aria-expanded="false" style="text-decoration:none;">Help</a> </div>';*/ $raindrops_show_on_front = get_option('show_on_front'); // val posts or page $raindrops_static_front_page_id = get_option('page_on_front'); $raindrops_static_front_page_template_slug = basename(get_page_template_slug($raindrops_static_front_page_id)); $raindrops_current_screen = get_current_screen(); $current_value = get_post_meta($post->ID, '_add-to-front', true); $page_page_auto_include_template = apply_filters('raindrops_page_auto_include_template', 'front-page.php'); if ($raindrops_static_front_page_template_slug == $page_page_auto_include_template && $raindrops_current_screen->post_type == 'page') { $form .= '<h4>' . esc_html__('Add Front Page', 'raindrops') . '</h4>'; $form .= '<p><input type="radio" name="add-to-front" id="add-to-front" value="add" ' . checked('add', $current_value, false) . ' />' . __('Add Front Page This Content', 'raindrops') . '</p>'; $form .= '<p><input type="radio" name="add-to-front" id="add-to-front" value="default" ' . checked('', $current_value, false) . checked('default', $current_value, false) . ' />' . __('No Need', 'raindrops') . '</p>'; } /** * 1.295 change conditional test * if ( 'remove-header' !== $raindrops_restore_check && $raindrops_static_front_page_template_slug !== 'front-page.php' ) { */ if ('remove-header' !== $raindrops_restore_check && $raindrops_show_on_front !== 'page') { $form .= '<h4>' . esc_html__('Override header Image', 'raindrops') . '</h4>'; $images = get_uploaded_header_images(); $form .= '<p><input type="radio" name="header-image-file" id="header-image-file" value="hide" ' . checked('hide', $current_value_header, false) . ' />' . __('Hide Header Image', 'raindrops') . '</p>'; $form .= '<p><input type="radio" name="header-image-file" id="header-image-file" value="default" ' . checked('', $current_value_header, false) . checked('default', $current_value_header, false) . ' />' . __('Default Image', 'raindrops') . '</p>'; $form .= '<div class="header-image-wrapper" style="max-height:320px;overflow-y:scroll;overflow-x:hidden;">'; $header_image_html = '<p %1$s>' . '<input %2$s type="radio" name="header-image-file" id="header-image-file-%3$s" value="%3$s" %4$s />' . '<label for="header-image-file-%3$s"><img src="%5$s" width="160" alt="header image %3$s" /></label>' . '</p>'; foreach ($images as $image) { $form .= sprintf($header_image_html, 'style="display:inline-block;"', 'style="position:relative;top:-1em;"', $image['attachment_id'], checked($image['attachment_id'], $current_value_header, false), $image['url']); } $form .= '</div>'; $form .= '<p><a class="button button-large" href="' . admin_url('themes.php?page=custom-header') . '">' . esc_html__('Add Custom Header', 'raindrops') . '</a></p>'; } if ($raindrops_static_front_page_template_slug == 'front-page.php' && 'page' == get_option('show_on_front')) { $form .= '<h4>' . esc_html__('Override header Image', 'raindrops') . '</h4>'; $form .= '<p>' . esc_html__('Now Selected Front Page template,You can use Featured Image for override header image', 'raindrops') . '</p>'; } printf($form, 'raindrops_custom_css_field', __('The Custom CSS Field only for the current post', 'raindrops'), esc_textarea($value), 'style="width:100%;height:13em;font-size:1.3em;"'); do_action(' raindrops_custom_css_after'); }
/** * Display first step of custom header image page. * * @since 2.1.0 */ function step_1() { $this->process_default_headers(); ?> <div class="wrap"> <?php screen_icon(); ?> <h2><?php _e('Custom Header'); ?> </h2> <?php if (!empty($this->updated)) { ?> <div id="message" class="updated"> <p><?php printf(__('Header updated. <a href="%s">Visit your site</a> to see how it looks.'), home_url('/')); ?> </p> </div> <?php } ?> <h3><?php _e('Header Image'); ?> </h3> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row"><?php _e('Preview'); ?> </th> <td> <?php if ($this->admin_image_div_callback) { call_user_func($this->admin_image_div_callback); } else { ?> <div id="headimg" style="background-image:url(<?php esc_url(header_image()); ?> );max-width:<?php echo get_custom_header()->width; ?> px;height:<?php echo get_custom_header()->height; ?> px;"> <?php if (display_header_text()) { $style = ' style="color:#' . get_header_textcolor() . ';"'; } else { $style = ' style="display:none;"'; } ?> <h1><a id="name" class="displaying-header-text" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?> "><?php bloginfo('name'); ?> </a></h1> <div id="desc" class="displaying-header-text" <?php echo $style; ?> ><?php bloginfo('description'); ?> </div> </div> <?php } ?> </td> </tr> <?php if (current_theme_supports('custom-header', 'uploads')) { ?> <tr valign="top"> <th scope="row"><?php _e('Upload Image'); ?> </th> <td> <p><?php _e('You can upload a custom header image to be shown at the top of your site instead of the default one. On the next screen you will be able to crop the image.'); ?> <br /> <?php if (!current_theme_supports('custom-header', 'flex-height') && !current_theme_supports('custom-header', 'flex-width')) { printf(__('Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.') . '<br />', get_theme_support('custom-header', 'width'), get_theme_support('custom-header', 'height')); } elseif (current_theme_supports('custom-header', 'flex-height')) { if (!current_theme_supports('custom-header', 'flex-width')) { printf(__('Images should be at least <strong>%1$d pixels</strong> wide.') . ' ', get_theme_support('custom-header', 'width')); } } elseif (current_theme_supports('custom-header', 'flex-width')) { if (!current_theme_supports('custom-header', 'flex-height')) { printf(__('Images should be at least <strong>%1$d pixels</strong> tall.') . ' ', get_theme_support('custom-header', 'height')); } } if (current_theme_supports('custom-header', 'flex-height') || current_theme_supports('custom-header', 'flex-width')) { if (current_theme_supports('custom-header', 'width')) { printf(__('Suggested width is <strong>%1$d pixels</strong>.') . ' ', get_theme_support('custom-header', 'width')); } if (current_theme_supports('custom-header', 'height')) { printf(__('Suggested height is <strong>%1$d pixels</strong>.') . ' ', get_theme_support('custom-header', 'height')); } } ?> </p> <form enctype="multipart/form-data" id="upload-form" method="post" action="<?php echo esc_attr(add_query_arg('step', 2)); ?> "> <p> <label for="upload"><?php _e('Choose an image from your computer:'); ?> </label><br /> <input type="file" id="upload" name="import" /> <input type="hidden" name="action" value="save" /> <?php wp_nonce_field('custom-header-upload', '_wpnonce-custom-header-upload'); ?> <?php submit_button(__('Upload'), 'button', 'submit', false); ?> </p> </form> <?php $image_library_url = get_upload_iframe_src('image', null, 'library'); $image_library_url = remove_query_arg('TB_iframe', $image_library_url); $image_library_url = add_query_arg(array('context' => 'custom-header', 'TB_iframe' => 1), $image_library_url); ?> <span class="howto"><?php _ex('or', 'Custom Header: Choose an image from your computer - or - Choose from image library'); ?> </span> <a class="thickbox" href="<?php echo $image_library_url; ?> "><?php _e('Choose from image library'); ?> </a> </td> </tr> <?php } ?> </tbody> </table> <form method="post" action="<?php echo esc_attr(add_query_arg('step', 1)); ?> "> <table class="form-table"> <tbody> <?php if (get_uploaded_header_images()) { ?> <tr valign="top"> <th scope="row"><?php _e('Uploaded Images'); ?> </th> <td> <p><?php _e('You can choose one of your previously uploaded headers, or show a random one.'); ?> </p> <?php $this->show_header_selector('uploaded'); ?> </td> </tr> <?php } if (!empty($this->default_headers)) { ?> <tr valign="top"> <th scope="row"><?php _e('Default Images'); ?> </th> <td> <?php if (current_theme_supports('custom-header', 'uploads')) { ?> <p><?php _e('If you don‘t want to upload your own image, you can use one of these cool headers, or show a random one.'); ?> </p> <?php } else { ?> <p><?php _e('You can use one of these cool headers or show a random one on each page.'); ?> </p> <?php } ?> <?php $this->show_header_selector('default'); ?> </td> </tr> <?php } if (get_header_image()) { ?> <tr valign="top"> <th scope="row"><?php _e('Remove Image'); ?> </th> <td> <p><?php _e('This will remove the header image. You will not be able to restore any customizations.'); ?> </p> <?php submit_button(__('Remove Header Image'), 'button', 'removeheader', false); ?> </td> </tr> <?php } if (current_theme_supports('custom-header', 'default-image')) { ?> <tr valign="top"> <th scope="row"><?php _e('Reset Image'); ?> </th> <td> <p><?php _e('This will restore the original header image. You will not be able to restore any customizations.'); ?> </p> <?php submit_button(__('Restore Original Header Image'), 'button', 'resetheader', false); ?> </td> </tr> <?php } ?> </tbody> </table> <?php if (current_theme_supports('custom-header', 'header-text')) { ?> <h3><?php _e('Header Text'); ?> </h3> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row"><?php _e('Header Text'); ?> </th> <td> <p> <label><input type="checkbox" name="display-header-text" id="display-header-text"<?php checked(display_header_text()); ?> /> <?php _e('Show header text with your image.'); ?> </label> </p> </td> </tr> <tr valign="top" class="displaying-header-text"> <th scope="row"><?php _e('Text Color'); ?> </th> <td> <p> <?php if (display_header_text()) { ?> <input type="text" name="text-color" id="text-color" value="#<?php echo esc_attr(get_header_textcolor()); ?> " /> <?php } else { ?> <input type="text" name="text-color" id="text-color" value="#<?php echo esc_attr(get_theme_support('custom-header', 'default-text-color')); ?> " /> <?php } ?> <a href="#" class="hide-if-no-js" id="pickcolor"><?php _e('Select a Color'); ?> </a> </p> <div id="color-picker" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div> </td> </tr> <?php if (current_theme_supports('custom-header', 'default-text-color') && get_theme_mod('header_textcolor')) { ?> <tr valign="top"> <th scope="row"><?php _e('Reset Text Color'); ?> </th> <td> <p><?php _e('This will restore the original header text. You will not be able to restore any customizations.'); ?> </p> <?php submit_button(__('Restore Original Header Text'), 'button', 'resettext', false); ?> </td> </tr> <?php } ?> </tbody> </table> <?php } do_action('custom_header_options'); wp_nonce_field('custom-header-options', '_wpnonce-custom-header-options'); ?> <?php submit_button(null, 'primary', 'save-header-options'); ?> </form> </div> <?php }
/** * Default image property, using the post-thumbnail and any attached images. */ function opengraph_default_image($image) { if ($image) { return $image; } // As of July 2014, Facebook seems to only let you select from the first 3 images $max_images = apply_filters('opengraph_max_images', 3); if (is_singular()) { $id = get_queried_object_id(); $image_ids = array(); // list post thumbnail first if this post has one if (function_exists('has_post_thumbnail') && has_post_thumbnail($id)) { $image_ids[] = get_post_thumbnail_id($id); } // then list any image attachments $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID')); foreach ($attachments as $attachment) { if (!in_array($attachment->ID, $image_ids)) { $image_ids[] = $attachment->ID; if (sizeof($image_ids) >= $max_images) { break; } } } // get URLs for each image $image = array(); foreach ($image_ids as $id) { $thumbnail = wp_get_attachment_image_src($id, 'full'); if ($thumbnail) { $image[] = $thumbnail[0]; } } } elseif (is_attachment() && wp_attachment_is_image()) { $id = get_queried_object_id(); $image = array(wp_get_attachment_url($id)); } if (empty($image)) { $image = array(); // add site icon if (function_exists('get_site_icon_url') && has_site_icon()) { $image[] = get_site_icon_url(512); } // add header images if (function_exists('get_uploaded_header_images')) { if (is_random_header_image()) { foreach (get_uploaded_header_images() as $header_image) { $image[] = $header_image['url']; if (sizeof($image) >= $max_images) { break; } } } elseif (get_header_image()) { $image[] = get_header_image(); } } } return $image; }
<?php /** * The default template for displaying Home page Slider * * @package WPlook * @subpackage Morning Time Lite * @since Morning Time Lite 1.0 */ ?> <?php $headers = get_uploaded_header_images(); ?> <?php if (get_theme_mod('wplook_rev_slider') != '' && function_exists('putRevSlider')) { putRevSlider(get_theme_mod('wplook_rev_slider')); } else { ?> <section class="section-slider"> <div class="slider-home loading"> <div class="slider-clip"> <ul class="slides"> <?php foreach ($headers as $header) { ?> <li class="slide">
public function tab_uploaded() { $headers = get_uploaded_header_images(); ?> <div class="uploaded-target"></div><?php foreach ($headers as $header) { ?> <a href="#" class="thumbnail" data-customize-image-value="<?php echo esc_url($header['url']); ?> "> <img src="<?php echo esc_url($header['thumbnail_url']); ?> " /> </a> <?php } }
public function tab_uploaded() { $headers = get_uploaded_header_images(); ?><div class="uploaded-target"></div><?php foreach ( $headers as $header ) $this->print_tab_image( $header['url'], $header['thumbnail_url'] ); }
function raindrops_detect_header_image_size_clone($xy = 'width') { global $raindrops_custom_header_args, $raindrops_header_image_default_ratio; $all_header_images = array(); $header_image = get_custom_header(); $header_image_uri = $header_image->url; $header_image_basename = basename($header_image_uri); $page_width = raindrops_warehouse_clone('raindrops_page_width'); $all_header_images = get_uploaded_header_images(); if ('width' == $xy) { if (!empty($header_image->width)) { return absint($header_image->width); } } elseif ('height' == $xy) { if (!empty($header_image->height)) { return absint($header_image->height); } } if ('width' == $xy) { if (isset($all_header_images[$header_image_basename]['width'])) { if (false !== $all_header_images[$header_image_basename]['width']) { return $all_header_images[$header_image_basename]['width']; } } else { if (false !== $header_image->width) { return $header_image->width; } } } elseif ('height' == $xy) { if (isset($all_header_images[$header_image_basename]['height'])) { if (false !== $all_header_images[$header_image_basename]['height']) { return $all_header_images[$header_image_basename]['height']; } } else { if (false !== $header_image->height) { return $header_image->height; } } } switch ($page_width) { case "doc": $custom_header_width = 750; $custom_header_height = round($custom_header_width * $raindrops_header_image_default_ratio); break; case "doc2": $custom_header_width = 950; $custom_header_height = round($custom_header_width * $raindrops_header_image_default_ratio); break; case "doc3": $custom_header_width = raindrops_warehouse_clone('raindrops_fluid_max_width'); $custom_header_height = round($custom_header_width * $raindrops_header_image_default_ratio); break; case "doc4": $custom_header_width = 974; $custom_header_height = round($custom_header_width * $raindrops_header_image_default_ratio); break; case "doc5": $custom_header_width = raindrops_warehouse_clone('raindrops_full_width_limit_window_width'); $custom_header_height = round($custom_header_width * $raindrops_header_image_default_ratio); break; } if ($xy == 'width') { return $custom_header_width; } if ($xy == 'height') { return $custom_header_height; } return false; }
/** * Returns all registered headers. * * If there are uploaded headers via the WP Save Custom Header Plugin, they * will be loaded, too. * * @author Konstantin Obenland * @since 1.0 - 23.03.2011 * @access public * @global $_wp_default_headers * * @return array */ protected function get_headers() { global $_wp_default_headers; $headers = array_merge((array) $_wp_default_headers, get_uploaded_header_images()); return (array) apply_filters('wpdh_get_headers', $headers); }
/** * Prepares the control. * * If no tabs exist, removes the control from the manager. * * @since 3.4.2 */ public function prepare_control() { global $custom_image_header; if (empty($custom_image_header)) { return parent::prepare_control(); } // Process default headers and uploaded headers. $custom_image_header->process_default_headers(); $this->default_headers = $custom_image_header->default_headers; $this->uploaded_headers = get_uploaded_header_images(); if ($this->default_headers) { $this->add_tab('default', __('Default'), array($this, 'tab_default_headers')); } if (!$this->uploaded_headers) { $this->remove_tab('uploaded'); } return parent::prepare_control(); }
/** * @since 3.4.0 */ public function tab_uploaded() { $headers = get_uploaded_header_images(); ?> <div class="uploaded-target"></div><?php foreach ($headers as $choice => $header) { $this->print_header_image($choice, $header); } }
/** * * @return array */ public function get_uploaded_header_images() { $header_images = get_uploaded_header_images(); $timestamp_key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); $alt_text_key = '_wp_attachment_image_alt'; foreach ($header_images as &$header_image) { $header_meta = get_post_meta($header_image['attachment_id']); $header_image['timestamp'] = isset($header_meta[$timestamp_key]) ? $header_meta[$timestamp_key] : ''; $header_image['alt_text'] = isset($header_meta[$alt_text_key]) ? $header_meta[$alt_text_key] : ''; } return $header_images; }
function pictorio_get_header_image() { $default = get_header_image(); $headers = get_uploaded_header_images(); if (is_404()) { return pictorio_find_special_header($default, $headers, '404'); } elseif (is_search()) { return pictorio_find_special_header($default, $headers, 'search'); } return $default; }
/** * Manually set the header type as slider if user has chosen it * * @since 0.1 * @return void */ function set_theme_mod() { if (isset($_POST['default-header'])) { if ($_POST['default-header'] == 'boom-slider-default') { set_theme_mod('header_image', 'boom-slider-default'); } elseif ($_POST['default-header'] == 'boom-slider-uploaded') { set_theme_mod('header_image', 'boom-slider-uploaded'); if (empty($_POST['images'])) { $available_headers = array(); $headers = get_uploaded_header_images(); foreach ($headers as $header) { $available_headers[] = $header['url']; } update_option('boom_available_headers', $available_headers); } else { update_option('boom_available_headers', $_POST['images']); } } } }
<div id="scrolldown"> <a href=""><i class="fa fa-angle-down"></i></a> </div> <?php if ($header_images = get_uploaded_header_images()) { ?> <div id="slideshow"> <?php foreach ($header_images as $header_image) { ?> <figure class="pattern"> <?php $data = wp_prepare_attachment_for_js($header_image['attachment_id']); ?> <img src="/wp-includes/images/blank.gif" style="background-image: url(<?php echo esc_url($header_image['url']); ?> )"/> <figcaption> <h1 class="entry-title"><?php echo $data['title']; ?> </h1> <h2><?php echo $data['caption']; ?> </h2>
/** * * @param WP_Post $post */ function _media_states($post) { $media_states = array(); $stylesheet = get_option('stylesheet'); if (current_theme_supports('custom-header')) { $meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true); if (is_random_header_image()) { $header_images = wp_list_pluck(get_uploaded_header_images(), 'attachment_id'); if ($meta_header == $stylesheet && in_array($post->ID, $header_images)) { $media_states[] = __('Header Image'); } } else { $header_image = get_header_image(); // Display "Header Image" if the image was ever used as a header image if (!empty($meta_header) && $meta_header == $stylesheet && $header_image !== wp_get_attachment_url($post->ID)) { $media_states[] = __('Header Image'); } // Display "Current Header Image" if the image is currently the header image if ($header_image && $header_image == wp_get_attachment_url($post->ID)) { $media_states[] = __('Current Header Image'); } } } if (current_theme_supports('custom-background')) { $meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true); if (!empty($meta_background) && $meta_background == $stylesheet) { $media_states[] = __('Background Image'); $background_image = get_background_image(); if ($background_image && $background_image == wp_get_attachment_url($post->ID)) { $media_states[] = __('Current Background Image'); } } } if ($post->ID == get_option('site_icon')) { $media_states[] = __('Site Icon'); } if ($post->ID == get_theme_mod('site_logo')) { $media_states[] = __('Logo'); } /** * Filters the default media display states for items in the Media list table. * * @since 3.2.0 * * @param array $media_states An array of media states. Default 'Header Image', * 'Background Image', 'Site Icon', 'Logo'. */ $media_states = apply_filters('display_media_states', $media_states); if (!empty($media_states)) { $state_count = count($media_states); $i = 0; echo ' — '; foreach ($media_states as $state) { ++$i; $i == $state_count ? $sep = '' : ($sep = ', '); echo "<span class='post-state'>{$state}{$sep}</span>"; } } }
function manduca_get_header_image_alt() { $attachment_id = 0; if (is_random_header_image() && ($header_url = get_header_image())) { // For a random header, we have to search for a match against all headers. foreach (get_uploaded_header_images() as $header) { if ($header['url'] == $header_url) { $attachment_id = $header['attachment_id']; break; } } } elseif ($data = get_custom_header()) { // For static headers, less intensive approach. $attachment_id = $data->attachment_id; } if ($attachment_id) { $alt = trim(strip_tags(get_post_meta($attachment_id, '_wp_attachment_image_alt', true))); if (!$alt) { $alt = trim(strip_tags(get_post_field('post_excerpt', $attachment_id))); } if (!$alt) { $alt = trim(strip_tags(get_post_field('post_title', $attachment_id))); } } else { $alt = ''; } return $alt; }
/** * Display first step of custom header image page. * * @since 2.1.0 */ function step_1() { $this->process_default_headers(); ?> <div class="wrap"> <?php screen_icon(); ?> <h2><?php _e('Custom Header'); ?> </h2> <?php if (!empty($this->updated)) { ?> <div id="message" class="updated"> <p><?php printf(__('Header updated. <a href="%s">Visit your site</a> to see how it looks.'), home_url('/')); ?> </p> </div> <?php } ?> <table class="form-table"> <tbody> <tr valign="top"> <th scope="row"><?php _e('Preview'); ?> </th> <td > <?php if ($this->admin_image_div_callback) { call_user_func($this->admin_image_div_callback); } else { ?> <div id="headimg" style="max-width:<?php echo HEADER_IMAGE_WIDTH; ?> px;height:<?php echo HEADER_IMAGE_HEIGHT; ?> px;background-image:url(<?php esc_url(header_image()); ?> );"> <?php if ('blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || '' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || !$this->header_text()) { $style = ' style="display:none;"'; } else { $style = ' style="color:#' . get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) . ';"'; } ?> <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?> "><?php bloginfo('name'); ?> </a></h1> <div id="desc"<?php echo $style; ?> ><?php bloginfo('description'); ?> </div> </div> <?php } ?> </td> </tr> <?php if (current_theme_supports('custom-header-uploads')) { ?> <tr valign="top"> <th scope="row"><?php _e('Upload Image'); ?> </th> <td> <p><?php _e('You can upload a custom header image to be shown at the top of your site instead of the default one. On the next screen you will be able to crop the image.'); ?> <br /> <?php printf(__('Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.'), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); ?> </p> <form enctype="multipart/form-data" id="upload-form" method="post" action="<?php echo esc_attr(add_query_arg('step', 2)); ?> "> <p> <label for="upload"><?php _e('Choose an image from your computer:'); ?> </label><br /> <input type="file" id="upload" name="import" /> <input type="hidden" name="action" value="save" /> <?php wp_nonce_field('custom-header-upload', '_wpnonce-custom-header-upload'); ?> <?php submit_button(__('Upload'), 'button', 'submit', false); ?> </p> </form> </td> </tr> <?php } ?> </tbody> </table> <form method="post" action="<?php echo esc_attr(add_query_arg('step', 1)); ?> "> <table class="form-table"> <tbody> <?php if (get_uploaded_header_images()) { ?> <tr valign="top"> <th scope="row"><?php _e('Uploaded Images'); ?> </th> <td> <p><?php _e('You can choose one of your previously uploaded headers, or show a random one.'); ?> </p> <?php $this->show_header_selector('uploaded'); ?> </td> </tr> <?php } if (!empty($this->default_headers)) { ?> <tr valign="top"> <th scope="row"><?php _e('Default Images'); ?> </th> <td> <?php if (current_theme_supports('custom-header-uploads')) { ?> <p><?php _e('If you don‘t want to upload your own image, you can use one of these cool headers, or show a random one.'); ?> </p> <?php } else { ?> <p><?php _e('You can use one of these cool headers or show a random one on each page.'); ?> </p> <?php } ?> <?php $this->show_header_selector('default'); ?> </td> </tr> <?php } if (get_header_image()) { ?> <tr valign="top"> <th scope="row"><?php _e('Remove Image'); ?> </th> <td> <p><?php _e('This will remove the header image. You will not be able to restore any customizations.'); ?> </p> <?php submit_button(__('Remove Header Image'), 'button', 'removeheader', false); ?> </td> </tr> <?php } if (defined('HEADER_IMAGE') && '' != HEADER_IMAGE) { ?> <tr valign="top"> <th scope="row"><?php _e('Reset Image'); ?> </th> <td> <p><?php _e('This will restore the original header image. You will not be able to restore any customizations.'); ?> </p> <?php submit_button(__('Restore Original Header Image'), 'button', 'resetheader', false); ?> </td> </tr> <?php } ?> </tbody> </table> <?php if ($this->header_text()) { ?> <table class="form-table"> <tbody> <tr valign="top" class="hide-if-no-js"> <th scope="row"><?php _e('Display Text'); ?> </th> <td> <p> <?php $hidetext = get_theme_mod('header_textcolor', HEADER_TEXTCOLOR); ?> <label><input type="radio" value="1" name="hidetext" id="hidetext"<?php checked('blank' == $hidetext || empty($hidetext) ? true : false); ?> /> <?php _e('No'); ?> </label> <label><input type="radio" value="0" name="hidetext" id="showtext"<?php checked('blank' == $hidetext || empty($hidetext) ? false : true); ?> /> <?php _e('Yes'); ?> </label> </p> </td> </tr> <tr valign="top" id="text-color-row"> <th scope="row"><?php _e('Text Color'); ?> </th> <td> <p> <input type="text" name="text-color" id="text-color" value="#<?php echo esc_attr(get_theme_mod('header_textcolor', HEADER_TEXTCOLOR)); ?> " /> <span class="description hide-if-js"><?php _e('If you want to hide header text, add <strong>#blank</strong> as text color.'); ?> </span> <input type="button" class="button hide-if-no-js" value="<?php esc_attr_e('Select a Color'); ?> " id="pickcolor" /> </p> <div id="color-picker" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div> </td> </tr> <?php if (defined('HEADER_TEXTCOLOR') && get_theme_mod('header_textcolor')) { ?> <tr valign="top"> <th scope="row"><?php _e('Reset Text Color'); ?> </th> <td> <p><?php _e('This will restore the original header text. You will not be able to restore any customizations.'); ?> </p> <?php submit_button(__('Restore Original Header Text'), 'button', 'resettext', false); ?> </td> </tr> <?php } ?> </tbody> </table> <?php } do_action('custom_header_options'); wp_nonce_field('custom-header-options', '_wpnonce-custom-header-options'); ?> <?php submit_button(null, 'primary', 'save-header-options'); ?> </form> </div> <?php }
function wp_customize_print_uploaded_headers() { $headers = get_uploaded_header_images(); foreach ($headers as $header) { ?> <a href="<?php echo esc_url($header['url']); ?> "> <img src="<?php echo esc_url($header['thumbnail_url']); ?> " /> </a> <?php } }