diff --git a/src/class-tiny-settings.php b/src/class-tiny-settings.php index e595b52..290b8b0 100644 --- a/src/class-tiny-settings.php +++ b/src/class-tiny-settings.php @@ -661,85 +661,6 @@ public function render_size_checkboxes_description( echo '

'; } - public function render_resize() { - $strong = array( - 'strong' => array(), - ); - - echo ''; - - $id = self::get_prefixed_name( 'resize_original_enabled' ); - $name = self::get_prefixed_name( 'resize_original[enabled]' ); - $checked = ( $this->get_resize_enabled() ? ' checked="checked"' : '' ); - - $label = esc_html__( - 'Resize the original image', - 'tiny-compress-images' - ); - - echo '
'; - echo ''; - echo '
'; - - echo '
'; - echo ''; - echo wp_kses( - __( - // phpcs:ignore Generic.Files.LineLength - 'Save space by setting a maximum width and height for all images uploaded.', - 'tiny-compress-images' - ), - $strong - ); - echo '
'; - echo wp_kses( - __( - // phpcs:ignore Generic.Files.LineLength - 'Resizing takes 1 additional compression for each image that is larger.', - 'tiny-compress-images' - ), - $strong - ); - echo '
'; - echo '
'; - printf( '%s: ', esc_html__( 'Max Width', 'tiny-compress-images' ) ); - $this->render_resize_input( 'width' ); - printf( '%s: ', esc_html__( 'Max Height', 'tiny-compress-images' ) ); - $this->render_resize_input( 'height' ); - echo '
'; - - $this->render_preserve_input( - 'creation', - esc_html__( - 'Preserve creation date and time in the original image', - 'tiny-compress-images' - ) - ); - - $this->render_preserve_input( - 'copyright', - esc_html__( - 'Preserve copyright information in the original image', - 'tiny-compress-images' - ) - ); - - $this->render_preserve_input( - 'location', - esc_html__( - 'Preserve GPS location in the original image', - 'tiny-compress-images' - ) . ' ' . - esc_html__( '(JPEG only)', 'tiny-compress-images' ) - ); - } - public function render_compression_timing_radiobutton( $name, $label, @@ -776,25 +697,23 @@ public function render_compression_timing_radiobutton( } public function render_preserve_input( $name, $description ) { - echo '

'; - $id = sprintf( self::get_prefixed_name( 'preserve_data_%s' ), $name ); - $field = sprintf( self::get_prefixed_name( 'preserve_data[%s]' ), $name ); - $checked = ( $this->get_preserve_enabled( $name ) ? ' checked="checked"' : '' ); - $label = esc_html( $description, 'tiny-compress-images' ); - echo ''; - echo ''; - echo '
'; - echo '

'; + $data = array( + 'id' => sprintf( self::get_prefixed_name( 'preserve_data_%s' ), $name ), + 'field' => sprintf( self::get_prefixed_name( 'preserve_data[%s]' ), $name ), + 'checked' => $this->get_preserve_enabled( $name ), + 'label' => $description, + ); + include plugin_dir_path( __FILE__ ) . 'views/settings-original-image-preserve.php'; } public function render_resize_input( $name ) { - $id = sprintf( self::get_prefixed_name( 'resize_original_%s' ), $name ); - $field = sprintf( self::get_prefixed_name( 'resize_original[%s]' ), $name ); $settings = get_option( self::get_prefixed_name( 'resize_original' ) ); - $value = isset( $settings[ $name ] ) ? $settings[ $name ] : '2048'; - echo ''; + $data = array( + 'id' => sprintf( self::get_prefixed_name( 'resize_original_%s' ), $name ), + 'field' => sprintf( self::get_prefixed_name( 'resize_original[%s]' ), $name ), + 'value' => isset( $settings[ $name ] ) ? $settings[ $name ] : '2048', + ); + include plugin_dir_path( __FILE__ ) . 'views/settings-original-image-original.php'; } public function get_compression_count() { diff --git a/src/views/settings-original-image-original.php b/src/views/settings-original-image-original.php new file mode 100644 index 0000000..9607a2f --- /dev/null +++ b/src/views/settings-original-image-original.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/src/views/settings-original-image-preserve.php b/src/views/settings-original-image-preserve.php new file mode 100644 index 0000000..60399e0 --- /dev/null +++ b/src/views/settings-original-image-preserve.php @@ -0,0 +1,11 @@ +

+ + value="on" + /> + +

\ No newline at end of file diff --git a/src/views/settings-original-image.php b/src/views/settings-original-image.php new file mode 100644 index 0000000..261dd8d --- /dev/null +++ b/src/views/settings-original-image.php @@ -0,0 +1,97 @@ + array(), +); + +?> + + + + + +
+ get_resize_enabled(); + ?> + /> +
+
+ + Save space by setting a maximum width and height for all images uploaded.', + 'tiny-compress-images' + ), + $strong + ); + ?> +
+ 1 additional compression for each image that is larger.', + 'tiny-compress-images' + ), + $strong + ); + ?> +
+ +
+ : + render_resize_input( 'width' ); ?> + : + render_resize_input( 'height' ); ?> +
+
+ + render_preserve_input( + 'creation', + esc_html__( + 'Preserve creation date and time in the original image', + 'tiny-compress-images' + ) + ); + $this->render_preserve_input( + 'copyright', + esc_html__( + 'Preserve copyright information in the original image', + 'tiny-compress-images' + ) + ); + $this->render_preserve_input( + 'location', + esc_html__( + 'Preserve GPS location in the original image', + 'tiny-compress-images' + ) . ' ' . + esc_html__( '(JPEG only)', 'tiny-compress-images' ) + ); + ?> +
+ + \ No newline at end of file diff --git a/src/views/settings.php b/src/views/settings.php index 1f70b2a..c12d4a6 100644 --- a/src/views/settings.php +++ b/src/views/settings.php @@ -51,12 +51,7 @@ render_format_conversion(); ?> - - - - render_resize(); ?> - - +