Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -r -u simple-image-sizes/classes/admin/main.php simple-image-sizes/classes/admin/main.php
- --- simple-image-sizes/classes/admin/main.php 2018-02-08 13:54:52.000000000 -0500
- +++ simple-image-sizes/classes/admin/main.php 2018-02-08 14:01:36.000000000 -0500
- @@ -3,7 +3,7 @@
- Class SIS_Admin_Main {
- public function __construct() {
- - add_action( 'admin_init', [ __CLASS__, 'register_assets' ] );
- + add_action( 'admin_init', array( __CLASS__, 'register_assets' ) );
- }
- /**
- @@ -12,18 +12,18 @@
- public static function register_assets() {
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG === true ? '' : '.min';
- // Add javascript.
- - wp_register_script( 'sis_js', SIS_URL . 'assets/js/dist/app' . $suffix . '.js', [
- + wp_register_script( 'sis_js', SIS_URL . 'assets/js/dist/app' . $suffix . '.js', array(
- 'jquery',
- 'jquery-ui-button',
- 'jquery-ui-progressbar',
- 'underscore',
- - ], SIS_VERSION );
- + ), SIS_VERSION );
- // Add javascript translations.
- wp_localize_script( 'sis_js', 'sis', self::localize_vars() );
- // Add CSS.
- - wp_enqueue_style( 'sis_css', SIS_URL . 'assets/css/sis-style' . $suffix . '.css', [], SIS_VERSION );
- + wp_enqueue_style( 'sis_css', SIS_URL . 'assets/css/sis-style' . $suffix . '.css', array(), SIS_VERSION );
- }
- @@ -86,10 +86,10 @@
- // Check Id.
- if ( (int) $att_id <= 0 ) {
- - return [
- + return array(
- 'time' => timer_stop( false, 4 ),
- 'error' => __( 'No id given in POST datas.', 'simple-image-sizes' ),
- - ];
- + );
- }
- // Get the path.
- @@ -98,7 +98,7 @@
- // Regen the attachment.
- if ( false !== $fullsizepath && file_exists( $fullsizepath ) ) {
- if ( false == wp_update_attachment_metadata( $att_id, self::wp_generate_attachment_metadata_custom( $att_id, $fullsizepath, $thumbnails ) ) ) {
- - return [
- + return array(
- 'src' => wp_get_attachment_thumb_url( $att_id ),
- 'time' => timer_stop( false, 4 ),
- 'message' => sprintf(
- @@ -106,10 +106,10 @@
- get_edit_post_link( $att_id ),
- get_the_title( $att_id )
- ),
- - ];
- + );
- }
- } else {
- - return [
- + return array(
- 'src' => wp_get_attachment_thumb_url( $att_id ),
- 'time' => timer_stop( false, 4 ),
- 'error' => sprintf(
- @@ -117,16 +117,16 @@
- get_edit_post_link( $att_id ),
- get_the_title( $att_id )
- ),
- - ];
- + );
- }
- // Display the attachment url for feedback.
- - return [
- + return array(
- 'time' => timer_stop( false, 4 ),
- 'src' => wp_get_attachment_thumb_url( $att_id ),
- 'title' => get_the_title( $att_id ),
- - ];
- + );
- }
- /**
- @@ -159,28 +159,28 @@
- // Return the only possible.
- if ( version_compare( $wp_version, '3.9', '<' ) ) {
- - return [];
- + return array();
- }
- - $x = [
- + $x = array(
- 'left' => __( 'Left', 'simple-image-sizes' ),
- 'center' => __( 'Center', 'simple-image-sizes' ),
- 'right' => __( 'Right', 'simple-image-sizes' ),
- - ];
- + );
- - $y = [
- + $y = array(
- 'top' => __( 'top', 'simple-image-sizes' ),
- 'center' => __( 'center', 'simple-image-sizes' ),
- 'bottom' => __( 'bottom', 'simple-image-sizes' ),
- - ];
- + );
- /**
- * Base crops
- */
- - $crops = [
- + $crops = array(
- 0 => __( 'No', 'simple-image-sizes' ),
- 1 => __( 'Yes', 'simple-image-sizes' ),
- - ];
- + );
- foreach ( $x as $x_pos => $x_pos_label ) {
- foreach ( $y as $y_pos => $y_pos_label ) {
- @@ -239,7 +239,7 @@
- $meta_datas = get_post_meta( $attachment_id, '_wp_attachment_metadata', true );
- - $metadata = [];
- + $metadata = array();
- if ( preg_match( '!^image/!', get_post_mime_type( $attachment ) ) && file_is_displayable_image( $file ) ) {
- $imagesize = getimagesize( $file );
- $metadata['width'] = $imagesize[0];
- @@ -254,11 +254,11 @@
- global $_wp_additional_image_sizes;
- foreach ( get_intermediate_image_sizes() as $s ) {
- - $sizes[ $s ] = [
- + $sizes[ $s ] = array(
- 'width' => '',
- 'height' => '',
- 'crop' => false,
- - ];
- + );
- if ( isset( $_wp_additional_image_sizes[ $s ]['width'] ) ) {
- $sizes[ $s ]['width'] = intval( $_wp_additional_image_sizes[ $s ]['width'] );
- } // For theme-added sizes
- diff -r -u simple-image-sizes/classes/admin/media.php simple-image-sizes/classes/admin/media.php
- --- simple-image-sizes/classes/admin/media.php 2018-02-08 13:54:52.000000000 -0500
- +++ simple-image-sizes/classes/admin/media.php 2018-02-08 14:10:20.000000000 -0500
- @@ -7,26 +7,26 @@
- *
- * @var array
- */
- - public static $original = [
- + public static $original = array(
- 'thumbnail',
- 'medium',
- 'large',
- - ];
- + );
- public function __construct() {
- // Init.
- - add_action( 'admin_menu', [ __CLASS__, 'init' ] );
- - add_action( 'admin_enqueue_scripts', [ __CLASS__, 'enqueue_assets' ], 11 );
- + add_action( 'admin_menu', array( __CLASS__, 'init' ) );
- + add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ), 11 );
- // Add ajax action.
- - add_action( 'wp_ajax_sis_get_list', [ __CLASS__, 'a_get_list' ] );
- - add_action( 'wp_ajax_sis_rebuild_images', [ __CLASS__, 'a_thumbnails_rebuild' ] );
- - add_action( 'wp_ajax_sis_get_sizes', [ __CLASS__, 'a_get_sizes' ] );
- - add_action( 'wp_ajax_sis_add_size', [ __CLASS__, 'a_add_size' ] );
- - add_action( 'wp_ajax_sis_remove_size', [ __CLASS__, 'a_remove_size' ] );
- + add_action( 'wp_ajax_sis_get_list', array( __CLASS__, 'a_get_list' ) );
- + add_action( 'wp_ajax_sis_rebuild_images', array( __CLASS__, 'a_thumbnails_rebuild' ) );
- + add_action( 'wp_ajax_sis_get_sizes', array( __CLASS__, 'a_get_sizes' ) );
- + add_action( 'wp_ajax_sis_add_size', array( __CLASS__, 'a_add_size' ) );
- + add_action( 'wp_ajax_sis_remove_size', array( __CLASS__, 'a_remove_size' ) );
- // Add link in plugins list.
- - add_filter( 'plugin_action_links', [ __CLASS__, 'add_settings_link' ], 10, 2 );
- + add_filter( 'plugin_action_links', array( __CLASS__, 'add_settings_link' ), 10, 2 );
- }
- /**
- @@ -43,7 +43,7 @@
- return;
- }
- - $suffixes = [ 'options-media.php', 'settings_page_media' ];
- + $suffixes = array( 'options-media.php', 'settings_page_media' );
- if ( ! in_array( $hook_suffix, $suffixes, true ) ) {
- return;
- }
- @@ -55,7 +55,7 @@
- wp_enqueue_style( 'sis_css' );
- // Add underscore template.
- - add_action( 'admin_footer', [ 'SIS_Admin_Main', 'add_template' ] );
- + add_action( 'admin_footer', array( 'SIS_Admin_Main', 'add_template' ) );
- }
- @@ -115,15 +115,15 @@
- $crop = isset( $_wp_additional_image_sizes[ $s ]['crop'] ) ? intval( $_wp_additional_image_sizes[ $s ]['crop'] ) : get_option( "{$s}_crop" );
- // Add the setting field for this size.
- - add_settings_field( 'image_size_' . $s, sprintf( __( '%s size', 'simple-image-sizes' ), $s ), [
- + add_settings_field( 'image_size_' . $s, sprintf( __( '%s size', 'simple-image-sizes' ), $s ), array(
- __CLASS__,
- 'image_sizes',
- - ], 'media', 'default', [
- + ), 'media', 'default', array(
- 'name' => $s,
- 'width' => $width,
- 'height' => $height,
- 'c' => $crop,
- - ]
- + )
- );
- }
- @@ -131,22 +131,22 @@
- register_setting( 'media', SIS_OPTION );
- // Add the button.
- - add_settings_field( 'add_size_button', __( 'Add a new size', 'simple-image-sizes' ), [
- + add_settings_field( 'add_size_button', __( 'Add a new size', 'simple-image-sizes' ), array(
- __CLASS__,
- 'addSizeButton',
- - ], 'media' );
- + ), 'media' );
- // Add php button.
- - add_settings_field( 'get_php_button', __( 'Get php for theme', 'simple-image-sizes' ), [
- + add_settings_field( 'get_php_button', __( 'Get php for theme', 'simple-image-sizes' ), array(
- __CLASS__,
- 'getPhpButton',
- - ], 'media' );
- + ), 'media' );
- // Add section for the thumbnail regeneration.
- - add_settings_section( 'thumbnail_regenerate', __( 'Thumbnail regeneration', 'simple-image-sizes' ), [
- + add_settings_section( 'thumbnail_regenerate', __( 'Thumbnail regeneration', 'simple-image-sizes' ), array(
- __CLASS__,
- 'thumbnailRegenerate',
- - ], 'media' );
- + ), 'media' );
- }
- /**
- @@ -166,7 +166,7 @@
- }
- // Get the options.
- - $sizes = (array) get_option( SIS_OPTION, [] );
- + $sizes = (array) get_option( SIS_OPTION, array() );
- // Get the vars.
- $height = isset( $sizes[ $args['name'] ]['h'] ) ? $sizes[ $args['name'] ]['h'] : $args['height'];
- @@ -287,7 +287,7 @@
- $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
- // Get old options
- - $sizes = (array) get_option( SIS_OPTION, [] );
- + $sizes = (array) get_option( SIS_OPTION, array() );
- $croppings = SIS_Admin_Main::get_available_crop();
- $croppings[ true ] = '';
- $croppings[ false ] = '';
- @@ -311,14 +311,14 @@
- }
- // Make values
- - $values = [
- + $values = array(
- 'custom' => 1,
- 'w' => $width,
- 'h' => $height,
- 'c' => $crop,
- 's' => $show,
- 'n' => $cn,
- - ];
- + );
- // If the size have not changed return 2
- if ( isset( $sizes[ $name ] ) && $sizes[ $name ] === $values ) {
- @@ -343,7 +343,7 @@
- public static function a_remove_size() {
- // Get old options
- - $sizes = (array) get_option( SIS_OPTION, [] );
- + $sizes = (array) get_option( SIS_OPTION, array() );
- // Get the nonce and name
- $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
- @@ -424,7 +424,7 @@
- // Check the nonce
- if ( ! wp_verify_nonce( $nonce, 'getList' ) ) {
- - wp_send_json( [] );
- + wp_send_json( array() );
- }
- if ( isset( $_POST['post_types'] ) && ! empty( $_POST['post_types'] ) ) {
- @@ -436,7 +436,7 @@
- }
- if ( empty( $_POST['post_types'][ $key ] ) ) {
- - wp_send_json( [] );
- + wp_send_json( array() );
- }
- // Get image medias.
- @@ -454,19 +454,19 @@
- WHERE post_type IN ('" . implode( "', '", $_POST['post_types'] ) . "')
- )" );
- // Return the Id's and Title of medias
- - wp_send_json( [ 'total' => $attachments ] );
- + wp_send_json( array( 'total' => $attachments ) );
- } else {
- - $attachments = get_children( [
- + $attachments = get_children( array(
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image',
- 'numberposts' => - 1,
- 'post_status' => null,
- 'post_parent' => null, // any parent
- 'output' => 'ids',
- - ] );
- + ) );
- // Return the Id's and Title of medias
- - wp_send_json( [ 'total' => count( $attachments ) ] );
- + wp_send_json( array( 'total' => count( $attachments ) ) );
- }
- }
- @@ -492,7 +492,7 @@
- // Check the nonce
- if ( ! wp_verify_nonce( $nonce, 'regen' ) ) {
- - wp_send_json( [ 'error' => __( 'Trying to cheat ?', 'simple-image-sizes' ) ] );
- + wp_send_json( array( 'error' => __( 'Trying to cheat ?', 'simple-image-sizes' ) ) );
- }
- if ( 'any' !== $post_types ) {
- @@ -504,7 +504,7 @@
- }
- if ( empty( $_POST['post_types'] ) ) {
- - wp_send_json( [] );
- + wp_send_json( array() );
- }
- // Get image medias
- @@ -525,22 +525,22 @@
- ", $offset ) );
- } else {
- - $attachment = get_posts( [
- + $attachment = get_posts( array(
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image',
- 'numberposts' => 1,
- 'post_status' => 'any',
- 'output' => 'object',
- 'offset' => $offset,
- - ] );
- + ) );
- $attachment = ! empty( $attachment ) ? $attachment[0]->ID : 0;
- }
- if ( empty( $attachment ) ) {
- - wp_send_json( [
- + wp_send_json( array(
- 'message' => __( 'Regeneration ended', 'simple-image-sizes' )
- - ] );
- + ) );
- }
- wp_send_json( SIS_Admin_Main::thumbnail_rebuild( $attachment, $thumbnails ) );
- }
- diff -r -u simple-image-sizes/classes/admin/post.php simple-image-sizes/classes/admin/post.php
- --- simple-image-sizes/classes/admin/post.php 2018-02-08 13:54:52.000000000 -0500
- +++ simple-image-sizes/classes/admin/post.php 2018-02-08 14:05:11.000000000 -0500
- @@ -3,24 +3,24 @@
- Class SIS_Admin_Post {
- public function __construct() {
- - add_filter( 'image_size_names_choose', [ __CLASS__, 'add_thumbnail_name' ] );
- + add_filter( 'image_size_names_choose', array( __CLASS__, 'add_thumbnail_name' ) );
- - add_action( 'admin_enqueue_scripts', [ __CLASS__, 'enqueue_assets' ], 11 );
- + add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ), 11 );
- // Rebuilt the image.
- - add_action( 'wp_ajax_sis_rebuild_image', [ __CLASS__, 'a_thumbnail_rebuild' ] );
- + add_action( 'wp_ajax_sis_rebuild_image', array( __CLASS__, 'a_thumbnail_rebuild' ) );
- // Rebuild featured.
- - add_action( 'wp_ajax_sis_rebuild_featured', [ __CLASS__, 'a_featured_rebuild' ] );
- + add_action( 'wp_ajax_sis_rebuild_featured', array( __CLASS__, 'a_featured_rebuild' ) );
- // Add action in media row quick actions.
- - add_filter( 'media_row_actions', [ __CLASS__, 'add_actions_list' ], 10, 2 );
- + add_filter( 'media_row_actions', array( __CLASS__, 'add_actions_list' ), 10, 2 );
- // Add filter for the Media single.
- - add_filter( 'attachment_fields_to_edit', [ __CLASS__, 'add_field_regenerate' ], 9, 2 );
- + add_filter( 'attachment_fields_to_edit', array( __CLASS__, 'add_field_regenerate' ), 9, 2 );
- // Media regenerate on admin featured.
- - add_filter( 'admin_post_thumbnail_html', [ __CLASS__, 'admin_post_thumbnail_html' ], 10, 2 );
- + add_filter( 'admin_post_thumbnail_html', array( __CLASS__, 'admin_post_thumbnail_html' ), 10, 2 );
- }
- /**
- @@ -69,13 +69,13 @@
- // Check the nonce.
- if ( ! wp_verify_nonce( $nonce, 'sis-regenerate-featured-' . $id ) ) {
- - wp_send_json( [ 'error' => __( 'Trying to cheat ?', 'simple-image-sizes' ) ] );
- + wp_send_json( array( 'error' => __( 'Trying to cheat ?', 'simple-image-sizes' ) ) );
- }
- $attachment_id = get_post_thumbnail_id( $id );
- if ( ! has_post_thumbnail( $id ) || is_null( $attachment_id ) ) {
- - wp_send_json( [ 'error' => __( 'There is no media attached to this content.', 'simple-image-sizes' ) ] );
- + wp_send_json( array( 'error' => __( 'There is no media attached to this content.', 'simple-image-sizes' ) ) );
- }
- // Get the id.
- @@ -99,7 +99,7 @@
- /**
- * Enqueue the assets for the featured image only on the edit pages and the post types that supports it
- */
- - if ( in_array( $hook_suffix, [ 'post-new.php', 'post.php' ] ) ) {
- + if ( in_array( $hook_suffix, array( 'post-new.php', 'post.php' ) ) ) {
- if ( post_type_supports( get_post_type( get_post() ), 'thumbnail' ) ) {
- // Add javascript.
- wp_enqueue_script( 'sis_js' );
- @@ -111,7 +111,7 @@
- wp_enqueue_script( 'sis_js' );
- // Add underscore template.
- - add_action( 'admin_footer', [ 'SIS_Admin_Main', 'add_template' ] );
- + add_action( 'admin_footer', array( 'SIS_Admin_Main', 'add_template' ) );
- }
- }
- @@ -131,7 +131,7 @@
- // Check the nonce.
- if ( ! wp_verify_nonce( $nonce, 'regen' ) ) {
- - wp_send_json( [ 'error' => __( 'Trying to cheat ?', 'simple-image-sizes' ) ] );
- + wp_send_json( array( 'error' => __( 'Trying to cheat ?', 'simple-image-sizes' ) ) );
- }
- // Get the id.
- @@ -153,10 +153,10 @@
- */
- public static function add_thumbnail_name( array $sizes ) {
- // Get options.
- - $sizes_custom = get_option( SIS_OPTION, [] );
- + $sizes_custom = get_option( SIS_OPTION, array() );
- // init size array.
- - $add_sizes = [];
- + $add_sizes = array();
- // check there is custom sizes.
- if ( is_array( $sizes_custom ) && ! empty( $sizes_custom ) ) {
- @@ -248,7 +248,7 @@
- return $fields;
- }
- - $fields['sis-regenerate'] = [
- + $fields['sis-regenerate'] = array(
- 'label' => __( 'Regenerate Thumbnails', 'simple-image-sizes' ),
- 'input' => 'html',
- 'html' => sprintf( '
- @@ -262,8 +262,8 @@
- ),
- 'show_in_edit' => true,
- 'show_in_modal' => false,
- - ];
- + );
- return $fields;
- }
- -}
- \ No newline at end of file
- +}
- diff -r -u simple-image-sizes/classes/main.php simple-image-sizes/classes/main.php
- --- simple-image-sizes/classes/main.php 2018-02-08 13:54:52.000000000 -0500
- +++ simple-image-sizes/classes/main.php 2018-02-08 13:57:13.000000000 -0500
- @@ -4,10 +4,10 @@
- public function __construct() {
- // Make new image sizes.
- - add_action( 'init', [ __CLASS__, 'after_setup_theme' ], 1 );
- + add_action( 'init', array( __CLASS__, 'after_setup_theme' ), 1 );
- // Add translation.
- - add_action( 'init', [ __CLASS__, 'init_translation' ], 2 );
- + add_action( 'init', array( __CLASS__, 'init_translation' ), 2 );
- }
- /**
- @@ -19,7 +19,7 @@
- */
- public static function after_setup_theme() {
- // Get initial options.
- - $sizes = get_option( SIS_OPTION, [] );
- + $sizes = get_option( SIS_OPTION, array() );
- // Return false if empty.
- if ( empty( $sizes ) || ! is_array( $sizes ) ) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement