Plugin Directory

Changeset 1703145


Ignore:
Timestamp:
07/26/2017 01:58:43 PM (9 years ago)
Author:
wp_media
Message:

Imagify 1.6.8 hotfix before public release.

Location:
imagify
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • imagify/tags/1.6.8/inc/admin/ui/notices.php

    r1702448 r1703145  
    354354    }
    355355
    356     $filesystem     = imagify_get_filesystem();
    357     $has_backup_dir = wp_mkdir_p( get_imagify_backup_dir_path() );
    358 
    359     if ( $has_backup_dir && $filesystem->is_writable( get_imagify_backup_dir_path() ) ) {
    360         return;
    361     }
    362 
    363     $backup_path = imagify_make_file_path_replative( get_imagify_backup_dir_path() );
     356    if ( imagify_backup_dir_is_writable() ) {
     357        return;
     358    }
     359
     360    $filesystem = imagify_get_filesystem();
     361
     362    if ( $filesystem->exists( get_imagify_backup_dir_path() ) ) {
     363        /* translators: %s is a file path. */
     364        $message = __( 'The backup folder %s is not writable by the server, original images cannot be saved!', 'imagify' );
     365    } else {
     366        /* translators: %s is a file path. */
     367        $message = __( 'The backup folder %s cannot be created. Is its parent directory writable by the server? Original images cannot be saved!', 'imagify' );
     368    }
     369
     370    $backup_path = imagify_make_file_path_replative( get_imagify_backup_dir_path( true ) );
    364371    ?>
    365372    <div class="clear"></div>
     
    369376        </div>
    370377        <div class="imagify-notice-content">
    371             <p><?php
    372             /* translators: %s is a file path. */
    373             printf( __( 'The backup folder %s can\'t be created, original images can\'t be saved!', 'imagify' ), "<code>$backup_path</code>" );
    374             ?></p>
     378            <p><?php printf( $message, "<code>$backup_path</code>" ); ?></p>
    375379        </div>
    376380    </div>
  • imagify/tags/1.6.8/inc/admin/ui/options.php

    r1702448 r1703145  
    213213                                    <br/><strong id="backup-dir-is-writable" class="imagify-error<?php echo $backup_error_class; ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'imagify_check_backup_dir_is_writable' ) ); ?>">
    214214                                        <?php
    215                                         $backup_path = imagify_make_file_path_replative( get_imagify_backup_dir_path() );
     215                                        $backup_path = imagify_make_file_path_replative( get_imagify_backup_dir_path( true ) );
    216216                                        /* translators: %s is a file path. */
    217                                         printf( __( 'The backup folder %s can\'t be created, original images can\'t be saved!', 'imagify' ), "<code>$backup_path</code>" );
     217                                        printf( __( 'The backup folder %s cannot be created or is not writable by the server, original images cannot be saved!', 'imagify' ), "<code>$backup_path</code>" );
    218218                                        ?>
    219219                                    </strong>
  • imagify/tags/1.6.8/inc/functions/attachments.php

    r1702448 r1703145  
    5151 * @author Grégory Viguier
    5252 *
    53  * @return string|bool Path to the backups directory. False on failure.
    54  */
    55 function get_imagify_backup_dir_path() {
     53 * @param  bool $bypass_error True to return the path even if there is an error. This is used when we want to display this path in a message for example.
     54 * @return string|bool        Path to the backups directory. False on failure.
     55 */
     56function get_imagify_backup_dir_path( $bypass_error = false ) {
    5657    static $backup_dir;
    5758
     
    6061    }
    6162
    62     $upload_basedir = get_imagify_upload_basedir();
     63    $upload_basedir = get_imagify_upload_basedir( $bypass_error );
    6364
    6465    if ( ! $upload_basedir ) {
     
    224225 *
    225226 * @since  1.6.7
    226  * @author Grégory Viguier
    227  *
    228  * @return string|bool The path. False on failure.
    229  */
    230 function get_imagify_upload_basedir() {
     227 * @since  1.6.8 Added the $bypass_error parameter.
     228 * @author Grégory Viguier
     229 *
     230 * @param  bool $bypass_error True to return the path even if there is an error. This is used when we want to display this path in a message for example.
     231 * @return string|bool        The path. False on failure.
     232 */
     233function get_imagify_upload_basedir( $bypass_error = false ) {
    231234    static $upload_basedir;
     235    static $upload_basedir_or_error;
    232236
    233237    if ( isset( $upload_basedir ) ) {
    234         return $upload_basedir;
    235     }
    236 
    237     $uploads = wp_upload_dir();
     238        return $bypass_error ? $upload_basedir : $upload_basedir_or_error;
     239    }
     240
     241    $uploads        = wp_upload_dir();
     242    $upload_basedir = trailingslashit( wp_normalize_path( $uploads['basedir'] ) );
    238243
    239244    if ( false !== $uploads['error'] ) {
    240         $upload_basedir = false;
    241         return $upload_basedir;
    242     }
    243 
    244     $upload_basedir = trailingslashit( wp_normalize_path( $uploads['basedir'] ) );
    245 
    246     return $upload_basedir;
     245        $upload_basedir_or_error = false;
     246    } else {
     247        $upload_basedir_or_error = $upload_basedir;
     248    }
     249
     250    return $bypass_error ? $upload_basedir : $upload_basedir_or_error;
    247251}
    248252
  • imagify/trunk/inc/admin/ui/notices.php

    r1702451 r1703145  
    354354    }
    355355
    356     $filesystem     = imagify_get_filesystem();
    357     $has_backup_dir = wp_mkdir_p( get_imagify_backup_dir_path() );
    358 
    359     if ( $has_backup_dir && $filesystem->is_writable( get_imagify_backup_dir_path() ) ) {
    360         return;
    361     }
    362 
    363     $backup_path = imagify_make_file_path_replative( get_imagify_backup_dir_path() );
     356    if ( imagify_backup_dir_is_writable() ) {
     357        return;
     358    }
     359
     360    $filesystem = imagify_get_filesystem();
     361
     362    if ( $filesystem->exists( get_imagify_backup_dir_path() ) ) {
     363        /* translators: %s is a file path. */
     364        $message = __( 'The backup folder %s is not writable by the server, original images cannot be saved!', 'imagify' );
     365    } else {
     366        /* translators: %s is a file path. */
     367        $message = __( 'The backup folder %s cannot be created. Is its parent directory writable by the server? Original images cannot be saved!', 'imagify' );
     368    }
     369
     370    $backup_path = imagify_make_file_path_replative( get_imagify_backup_dir_path( true ) );
    364371    ?>
    365372    <div class="clear"></div>
     
    369376        </div>
    370377        <div class="imagify-notice-content">
    371             <p><?php
    372             /* translators: %s is a file path. */
    373             printf( __( 'The backup folder %s can\'t be created, original images can\'t be saved!', 'imagify' ), "<code>$backup_path</code>" );
    374             ?></p>
     378            <p><?php printf( $message, "<code>$backup_path</code>" ); ?></p>
    375379        </div>
    376380    </div>
  • imagify/trunk/inc/admin/ui/options.php

    r1702451 r1703145  
    213213                                    <br/><strong id="backup-dir-is-writable" class="imagify-error<?php echo $backup_error_class; ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'imagify_check_backup_dir_is_writable' ) ); ?>">
    214214                                        <?php
    215                                         $backup_path = imagify_make_file_path_replative( get_imagify_backup_dir_path() );
     215                                        $backup_path = imagify_make_file_path_replative( get_imagify_backup_dir_path( true ) );
    216216                                        /* translators: %s is a file path. */
    217                                         printf( __( 'The backup folder %s can\'t be created, original images can\'t be saved!', 'imagify' ), "<code>$backup_path</code>" );
     217                                        printf( __( 'The backup folder %s cannot be created or is not writable by the server, original images cannot be saved!', 'imagify' ), "<code>$backup_path</code>" );
    218218                                        ?>
    219219                                    </strong>
  • imagify/trunk/inc/functions/attachments.php

    r1702451 r1703145  
    5151 * @author Grégory Viguier
    5252 *
    53  * @return string|bool Path to the backups directory. False on failure.
    54  */
    55 function get_imagify_backup_dir_path() {
     53 * @param  bool $bypass_error True to return the path even if there is an error. This is used when we want to display this path in a message for example.
     54 * @return string|bool        Path to the backups directory. False on failure.
     55 */
     56function get_imagify_backup_dir_path( $bypass_error = false ) {
    5657    static $backup_dir;
    5758
     
    6061    }
    6162
    62     $upload_basedir = get_imagify_upload_basedir();
     63    $upload_basedir = get_imagify_upload_basedir( $bypass_error );
    6364
    6465    if ( ! $upload_basedir ) {
     
    224225 *
    225226 * @since  1.6.7
    226  * @author Grégory Viguier
    227  *
    228  * @return string|bool The path. False on failure.
    229  */
    230 function get_imagify_upload_basedir() {
     227 * @since  1.6.8 Added the $bypass_error parameter.
     228 * @author Grégory Viguier
     229 *
     230 * @param  bool $bypass_error True to return the path even if there is an error. This is used when we want to display this path in a message for example.
     231 * @return string|bool        The path. False on failure.
     232 */
     233function get_imagify_upload_basedir( $bypass_error = false ) {
    231234    static $upload_basedir;
     235    static $upload_basedir_or_error;
    232236
    233237    if ( isset( $upload_basedir ) ) {
    234         return $upload_basedir;
    235     }
    236 
    237     $uploads = wp_upload_dir();
     238        return $bypass_error ? $upload_basedir : $upload_basedir_or_error;
     239    }
     240
     241    $uploads        = wp_upload_dir();
     242    $upload_basedir = trailingslashit( wp_normalize_path( $uploads['basedir'] ) );
    238243
    239244    if ( false !== $uploads['error'] ) {
    240         $upload_basedir = false;
    241         return $upload_basedir;
    242     }
    243 
    244     $upload_basedir = trailingslashit( wp_normalize_path( $uploads['basedir'] ) );
    245 
    246     return $upload_basedir;
     245        $upload_basedir_or_error = false;
     246    } else {
     247        $upload_basedir_or_error = $upload_basedir;
     248    }
     249
     250    return $bypass_error ? $upload_basedir : $upload_basedir_or_error;
    247251}
    248252
Note: See TracChangeset for help on using the changeset viewer.