Plugin Directory

Changeset 2925170


Ignore:
Timestamp:
06/13/2023 09:26:58 AM (3 years ago)
Author:
sukellos
Message:

PHP 8 and WP 6.2.2

Location:
sukellos-enable-classic-editor/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • sukellos-enable-classic-editor/trunk/readme.txt

    r2784637 r2925170  
    44Tags: admin, admin builder, custom admin panel, custom admin pages, option, user meta, post meta, gutenberg, classic editor
    55Requires at least: 5.2
    6 Tested up to: 6.0.2
    7 Stable tag: 1.1.2
     6Tested up to: 6.2.2
     7Stable tag: 1.1.4
    88Requires PHP: 7.0
    99License: GPLv2 or later
     
    126126== Changelog ==
    127127
     128= 1.1.4 =
     129* WordPress 6.2.2 compatibility
     130* Basic Sukellos Fw evolutions 1.2.0
     131
     132= 1.1.3 =
     133* WordPress 6.0.3 compatibility
     134
    128135= 1.1.2 =
    129136* WordPress 6.0.2 compatibility
  • sukellos-enable-classic-editor/trunk/sukellos-enable-classic-editor.php

    r2784637 r2925170  
    44 * Plugin URI: https://wp-adminbuilder.com/enable-classic-editor/
    55 * Description: Sukellos Framework Tools - Enable Classic Editor
    6  * Version: 1.1.2
     6 * Version: 1.1.4
    77 * Requires at least: 5.2
    88 * Requires PHP:      7.2
  • sukellos-enable-classic-editor/trunk/vendor/wp-sukellos-fw/admin-builder/class-admin-builder.php

    r2705157 r2925170  
    150150            case self::ADMIN_PAGE:
    151151
    152                 WP_Log::debug('Admin_Builder->create_container', ['use_tabs' => $settings[ 'use_tabs' ], 'is true? '=> ( $settings[ 'use_tabs' ] !== TRUE )?'false':'true']);
    153 
    154152                // Type is depending on 'use_tabs' setting
    155153                if ( array_key_exists( 'use_tabs', $settings ) && ( $settings[ 'use_tabs' ] === TRUE ) ) {
  • sukellos-enable-classic-editor/trunk/vendor/wp-sukellos-fw/admin-builder/class-item-factory.php

    r2763350 r2925170  
    134134            // Determine handler
    135135            $handler = null;
     136            $default = ( array_key_exists( 'default', $settings ) ? $settings['default'] : '' );
    136137            switch( $handler_type ) {
    137138                case self::OPTION:
    138                     $handler = new Option_Handler( $item_id, $settings['default'] );
     139                    $handler = new Option_Handler( $item_id, $default );
    139140                    break;
    140141                default:
  • sukellos-enable-classic-editor/trunk/vendor/wp-sukellos-fw/admin-builder/inc/edd-licensing/EDD_SL_Plugin_Updater.php

    r2705165 r2925170  
    5252        $this->beta                     = ! empty( $this->api_data['beta'] ) ? true : false;
    5353        $this->failed_request_cache_key = 'edd_sl_failed_http_' . md5( $this->api_url );
    54         $this->use_basic_authorization  = $_api_data['use_basic_authorization'];
    55         $this->basic_authorization_name  = $_api_data['basic_authorization_name'];
    56         $this->basic_authorization_password  = $_api_data['basic_authorization_password'];
     54        $this->use_basic_authorization  = ( array_key_exists( 'use_basic_authorization', $_api_data ) ? $_api_data['use_basic_authorization'] : false );
     55        $this->basic_authorization_name  = ( array_key_exists( 'basic_authorization_name', $_api_data ) ? $_api_data['basic_authorization_name'] : '' );
     56        $this->basic_authorization_password  = ( array_key_exists( 'basic_authorization_password', $_api_data ) ? $_api_data['basic_authorization_password'] : '' );
    5757
    5858        $edd_plugin_data[ $this->slug ] = $this->api_data;
  • sukellos-enable-classic-editor/trunk/vendor/wp-sukellos-fw/admin-builder/items/fields/abstract-choices-field.php

    r2705157 r2925170  
    6363
    6464    /**
     65     * Get field value depending on its specific type
     66     * Handler implementation
     67     */
     68    public function get_value() {
     69
     70        if ( is_null( $this->handler ) ) {
     71
     72            return array();
     73        }
     74        $value = $this->handler->get_value();
     75        if ( !is_array( $value ) ) {
     76
     77            return array();
     78        }
     79        return $this->handler->get_value();
     80    }
     81
     82    /**
    6583     *          ===============
    6684     *      =======================
  • sukellos-enable-classic-editor/trunk/vendor/wp-sukellos-fw/admin-builder/items/fields/class-upload-field.php

    r2705157 r2925170  
    8080        // Gives us an array with the first element as the src or false on fail.
    8181        $image_infos = wp_get_attachment_image_src( $value, array( 150, 150 ) );
    82         $url = $image_infos[0];
     82        $url = '';
     83        if ( $image_infos !== false ) {
     84
     85            $url = $image_infos[0];
     86        }
    8387
    8488        $preview_image = '';
  • sukellos-enable-classic-editor/trunk/vendor/wp-sukellos-fw/utils/class-wp-helper.php

    r2705165 r2925170  
    3232
    3333        return utf8_encode(strftime($format, $datetime->getTimestamp()));
     34    }
     35
     36
     37    /**
     38     * Function which can be used in array_walk_recursive as callback to reduced huge string values in an array
     39     *
     40     * @param $string
     41     * @param $index
     42     * @return void
     43     */
     44    public static function reduce_array_value ( &$string, $index ) {
     45
     46        if ( is_string( $string ) && ( strlen( $string ) > 2048 ) ) {
     47
     48            $string = substr( $string, 0, 4800 ).' [HUGE STRING REDUCED...]';
     49        }
    3450    }
    3551
     
    136152    }
    137153
     154
     155    /**
     156     * Allow to remove method for an hook when, it's a class method used and class don't have global for instanciation !
     157     */
     158    public static function remove_filters_with_method_name( $hook_name = '', $method_name = '', $priority = 0 ) {
     159        global $wp_filter;
     160
     161        // Take only filters on right hook name and priority
     162        if ( ! isset( $wp_filter[ $hook_name ][ $priority ] ) || ! is_array( $wp_filter[ $hook_name ][ $priority ] ) ) {
     163            return false;
     164        }
     165
     166        // Loop on filters registered
     167        foreach ( (array) $wp_filter[ $hook_name ][ $priority ] as $unique_id => $filter_array ) {
     168            // Test if filter is an array ! (always for class/method)
     169            if ( isset( $filter_array['function'] ) && is_array( $filter_array['function'] ) ) {
     170                // Test if object is a class and method is equal to param !
     171                if ( is_object( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) && $filter_array['function'][1] == $method_name ) {
     172                    // Test for WordPress >= 4.7 WP_Hook class (https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/)
     173                    if ( is_a( $wp_filter[ $hook_name ], 'WP_Hook' ) ) {
     174                        unset( $wp_filter[ $hook_name ]->callbacks[ $priority ][ $unique_id ] );
     175                    } else {
     176                        unset( $wp_filter[ $hook_name ][ $priority ][ $unique_id ] );
     177                    }
     178                }
     179            }
     180
     181        }
     182
     183        return false;
     184    }
     185
     186    /**
     187     * Allow to remove method for an hook when, it's a class method used and class don't have variable, but you know the class name :)
     188     */
     189    public static function remove_filters_for_anonymous_class( $hook_name = '', $class_name = '', $method_name = '', $priority = 0 ) {
     190        global $wp_filter;
     191
     192        // Take only filters on right hook name and priority
     193        if ( ! isset( $wp_filter[ $hook_name ][ $priority ] ) || ! is_array( $wp_filter[ $hook_name ][ $priority ] ) ) {
     194            return false;
     195        }
     196
     197        // Loop on filters registered
     198        foreach ( (array) $wp_filter[ $hook_name ][ $priority ] as $unique_id => $filter_array ) {
     199            // Test if filter is an array ! (always for class/method)
     200            if ( isset( $filter_array['function'] ) && is_array( $filter_array['function'] ) ) {
     201                // Test if object is a class, class and method is equal to param !
     202                if ( is_object( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) == $class_name && $filter_array['function'][1] == $method_name ) {
     203                    // Test for WordPress >= 4.7 WP_Hook class (https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/)
     204                    if ( is_a( $wp_filter[ $hook_name ], 'WP_Hook' ) ) {
     205                        unset( $wp_filter[ $hook_name ]->callbacks[ $priority ][ $unique_id ] );
     206                    } else {
     207                        unset( $wp_filter[ $hook_name ][ $priority ][ $unique_id ] );
     208                    }
     209                }
     210            }
     211
     212        }
     213
     214        return false;
     215    }
     216
     217
    138218    /**
    139219     * Check if a image already exist in media
     
    142222     * @return type
    143223     */
    144     public static function media_file_already_exists( $filename ) {
    145         global $wpdb;
    146 
    147         $query = "SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE meta_value LIKE '%/$filename' ";
     224    public static function media_file_already_exists( $filename, $boolean_response=true ) {
    148225
    149226        // Must consider a -1.jpeg or -2.jpeg in file name, for example
     
    154231
    155232                $filename = str_replace($ext, "", $filename);
     233            }
     234        }
     235        require_once( ABSPATH . 'wp-admin/includes/post.php' );
     236        $image_exists = post_exists( $filename, '', '', 'attachment' );
     237        if ( $boolean_response ) return ( $image_exists > 0 );
     238        else return $image_exists;
     239        /*
     240        global $wpdb;
     241
     242        $select = '*';
     243        if ( $boolean_response ) {
     244            $select = 'COUNT(*)';
     245        }
     246        // Very slow query -> Better search in posts on KEY post_name
     247        //$query = "SELECT ".$select." FROM {$wpdb->postmeta} WHERE meta_value LIKE '%$filename' ";
     248        // Image is stored as post :
     249        // - post_name -> name without extension .png or .jpeg ...
     250        // - post_type -> attachment
     251
     252        // Must consider a -1.jpeg or -2.jpeg in file name, for example
     253        $exts = array(".png", ".jpg", ".gif", ".jpeg");
     254        foreach ( $exts as $ext ) {
     255
     256            if ( FALSE !== strpos( $filename, $ext ) ) {
     257
     258                $filename = str_replace($ext, "", $filename);
    156259                $query .= " OR meta_value LIKE '%/$filename-%".$ext."'";
    157260            }
    158261        }
    159         $result = $wpdb->get_var($query);
    160         return ($result  > 0) ;
    161     }
    162    
     262
     263        if ( $boolean_response ) {
     264            $result = $wpdb->get_var($query);
     265            return ( $result > 0 );
     266        } else {
     267
     268            $result = $wpdb->get_results($query);
     269            return $result ;
     270        }
     271        */
     272    }
     273
     274
     275    /**
     276     * Replace accent characters with non accentued ones
     277     * Eg. é becomes e
     278     * @param $string
     279     * @return array|string|string[]
     280     */
     281    public static function replace_accents( $string ) {
     282
     283        $search  = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'à', 'á', 'â', 'ã', 'ä', 'å', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ò', 'ó', 'ô', 'õ', 'ö', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ');
     284        $replace = array('A', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y');
     285        $string = str_replace($search, $replace, $string);
     286        return $string;
     287    }
     288
    163289    /**
    164290     * Get the filename from the URL, without that after ?
Note: See TracChangeset for help on using the changeset viewer.