From 7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 7 Jan 2020 13:06:14 +0100 Subject: Added wordpress --- .../class-wp-customize-header-image-control.php | 259 +++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 srcs/wordpress/wp-includes/customize/class-wp-customize-header-image-control.php (limited to 'srcs/wordpress/wp-includes/customize/class-wp-customize-header-image-control.php') diff --git a/srcs/wordpress/wp-includes/customize/class-wp-customize-header-image-control.php b/srcs/wordpress/wp-includes/customize/class-wp-customize-header-image-control.php new file mode 100644 index 0000000..739a10b --- /dev/null +++ b/srcs/wordpress/wp-includes/customize/class-wp-customize-header-image-control.php @@ -0,0 +1,259 @@ + __( 'Header Image' ), + 'settings' => array( + 'default' => 'header_image', + 'data' => 'header_image_data', + ), + 'section' => 'header_image', + 'removed' => 'remove-header', + 'get_url' => 'get_header_image', + ) + ); + + } + + /** + */ + public function enqueue() { + wp_enqueue_media(); + wp_enqueue_script( 'customize-views' ); + + $this->prepare_control(); + + wp_localize_script( + 'customize-views', + '_wpCustomizeHeader', + array( + 'data' => array( + 'width' => absint( get_theme_support( 'custom-header', 'width' ) ), + 'height' => absint( get_theme_support( 'custom-header', 'height' ) ), + 'flex-width' => absint( get_theme_support( 'custom-header', 'flex-width' ) ), + 'flex-height' => absint( get_theme_support( 'custom-header', 'flex-height' ) ), + 'currentImgSrc' => $this->get_current_image_src(), + ), + 'nonces' => array( + 'add' => wp_create_nonce( 'header-add' ), + 'remove' => wp_create_nonce( 'header-remove' ), + ), + 'uploads' => $this->uploaded_headers, + 'defaults' => $this->default_headers, + ) + ); + + parent::enqueue(); + } + + /** + * @global Custom_Image_Header $custom_image_header + */ + public function prepare_control() { + global $custom_image_header; + if ( empty( $custom_image_header ) ) { + return; + } + + add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_header_image_template' ) ); + + // Process default headers and uploaded headers. + $custom_image_header->process_default_headers(); + $this->default_headers = $custom_image_header->get_default_header_images(); + $this->uploaded_headers = $custom_image_header->get_uploaded_header_images(); + } + + /** + */ + public function print_header_image_template() { + ?> + + + + value(); + if ( isset( $this->get_url ) ) { + $src = call_user_func( $this->get_url, $src ); + return $src; + } + } + + /** + */ + public function render_content() { + $visibility = $this->get_current_image_src() ? '' : ' style="display:none" '; + $width = absint( get_theme_support( 'custom-header', 'width' ) ); + $height = absint( get_theme_support( 'custom-header', 'height' ) ); + ?> +
+ ' . $this->label . ''; + } + ?> +
+

+ %s × %s', $width, $height ) + ); + } elseif ( $width ) { + printf( + /* translators: %s: Header width in pixels. */ + __( 'Click “Add new image” to upload an image file from your computer. Your theme works best with an image with a header width of %s pixels — you’ll be able to crop your image once you upload it for a perfect fit.' ), + sprintf( '%s', $width ) + ); + } else { + printf( + /* translators: %s: Header height in pixels. */ + __( 'Click “Add new image” to upload an image file from your computer. Your theme works best with an image with a header height of %s pixels — you’ll be able to crop your image once you upload it for a perfect fit.' ), + sprintf( '%s', $height ) + ); + } + ?> +

+
+ +
+
+
+
+ + + + +
+
+ + + +
+
+
+
+ + + +
+
+
+
+
+
+