Plugin Directory

Changeset 1282510


Ignore:
Timestamp:
11/09/2015 12:59:50 PM (10 years ago)
Author:
CodeBrothers
Message:

Minor fixes

Location:
awesome-photo-gallery/trunk/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • awesome-photo-gallery/trunk/core/class-updater.php

    r1282502 r1282510  
    5656        }
    5757
    58         foreach ( $this->licenses as $addon => $license ) {
    59             if ( $license['status'] != 'active' ) {
    60                 // License is inactive, skip this one.
    61                 continue;
    62             }
     58        if( is_array( $this->licenses ) ) {
     59            foreach ( $this->licenses as $addon => $license ) {
     60                if ( $license['status'] != 'active' ) {
     61                    // License is inactive, skip this one.
     62                    continue;
     63                }
    6364
    64             if ( isset( $this->extensions[ $addon ]['metadata']['version'] ) ) {
    65                 $this->check_addon_update( $addon, $license['key'], $this->extensions[ $addon ]['metadata']['version'] );
     65                if ( isset( $this->extensions[ $addon ]['metadata']['version'] ) ) {
     66                    $this->check_addon_update( $addon, $license['key'], $this->extensions[ $addon ]['metadata']['version'] );
     67                }
    6668            }
    6769        }
  • awesome-photo-gallery/trunk/core/class-viewer.php

    r1282502 r1282510  
    2626
    2727        if( isset( $stored_value ) && ! empty( $stored_value ) ) {
    28             $photo_index = array_flip( array_column( $media['photos'], 'id' ) );
     28            $photo_index = array_flip( $this->arrayColumn( $media['photos'], 'id' ) );
    2929            $stored_value = explode( ',', $stored_value );
    3030
     
    5555    }
    5656
     57    /**
     58     * Fallback for array column
     59     *
     60     * @param array $array
     61     * @param $column_key
     62     * @param null $index_key
     63     *
     64     * @return array
     65     */
     66    protected function arrayColumn( array $array, $column_key, $index_key = null ) {
     67        if ( function_exists( 'array_column ' ) ) {
     68            return array_column( $array, $column_key, $index_key );
     69        }
     70        $result = [ ];
     71        foreach ( $array as $arr ) {
     72            if ( ! is_array( $arr ) ) {
     73                continue;
     74            }
     75
     76            if ( is_null( $column_key ) ) {
     77                $value = $arr;
     78            } else {
     79                $value = $arr[ $column_key ];
     80            }
     81
     82            if ( ! is_null( $index_key ) ) {
     83                $key            = $arr[ $index_key ];
     84                $result[ $key ] = $value;
     85            } else {
     86                $result[] = $value;
     87            }
     88
     89        }
     90
     91        return $result;
     92    }
     93
    5794}
Note: See TracChangeset for help on using the changeset viewer.