WordPress.org

Plugin Directory

Changeset 1707025


Ignore:
Timestamp:
08/02/17 14:15:52 (7 weeks ago)
Author:
freediver
Message:
  • fix 5.2 compatibility
Location:
broken-link-checker
Files:
161 added
6 edited

Legend:

Unmodified
Added
Removed
  • broken-link-checker/trunk/broken-link-checker.php

    r1706472 r1707025  
    44Plugin URI: https://wordpress.org/plugins/broken-link-checker/ 
    55Description: Checks your blog for broken links and missing images and notifies you on the dashboard if any are found. 
    6 Version: 1.11.4 
     6Version: 1.11.5 
    77Author: Janis Elsts, Vladimir Prelovac 
    88Text Domain: broken-link-checker 
  • broken-link-checker/trunk/core/core.php

    r1706472 r1707025  
    107107    function cron_add_every_10_minutes( $schedules ) { 
    108108        // Adds once weekly to the existing schedules. 
    109         $schedules['10min'] = [ 
     109        $schedules['10min'] = array( 
    110110            'interval' => 600, 
    111111            'display' => __('Every 10 minutes') 
    112         ]; 
     112        ); 
    113113 
    114114        return $schedules; 
  • broken-link-checker/trunk/modules/containers/acf_field.php

    r1706472 r1707025  
    240240        //      error_log(print_r('ui_get_action_links', true)); 
    241241 
    242         $actions = []; 
     242        $actions = array(); 
    243243        if (!post_type_exists(get_post_type($this->container_id))) { 
    244244            return $actions; 
     
    367367} 
    368368 
     369class blcAcfExtractedFieldWalker 
     370{ 
     371    private $keys; 
     372 
     373    private $selected_fields; 
     374 
     375    private $url_fields; 
     376 
     377    private $html_fields; 
     378 
     379    public function __construct(&$keys, $selected_fields, $url_fields, $html_fields) 
     380    { 
     381        $this->keys            = $keys; 
     382        $this->selected_fields = $selected_fields; 
     383        $this->url_fields      = $url_fields; 
     384        $this->html_fields     = $html_fields; 
     385    } 
     386 
     387    public function walk_function($item, $key) 
     388    { 
     389        $key = explode('|', str_replace('_field', '|field', $key)); 
     390 
     391        if (is_array($key)) { 
     392            $key = $key[count($key) - 1]; 
     393        } 
     394 
     395        if (in_array($key, $this->url_fields)) { 
     396            if (!filter_var($item, FILTER_VALIDATE_URL) === false) { 
     397                $this->keys[] = $key; 
     398            } 
     399        } 
     400 
     401        if (in_array($key, $this->html_fields)) { 
     402            if ($item != '') { 
     403                $this->keys[] = $key; 
     404            } 
     405        } 
     406    } 
     407} 
     408 
    369409class blcAcfMetaManager extends blcContainerManager { 
    370410 
    371411    var $container_class_name = 'blcAcfMeta'; 
    372412 
    373     protected $selected_fields = []; 
     413    protected $selected_fields = array(); 
    374414 
    375415    function init() { 
     
    378418        //Figure out which custom fields we're interested in. 
    379419        if (is_array($this->plugin_conf->options['acf_fields'])) { 
    380             $prefix_formats = [ 
     420            $prefix_formats = array( 
    381421                'html' => 'html', 
    382422                'acf_field' => 'acf_field', 
    383             ]; 
     423            ); 
    384424            foreach ($this->plugin_conf->options['acf_fields'] as $meta_name) { 
    385425                //The user can add an optional "format:" prefix to specify the format of the custom field. 
     
    395435 
    396436        //Intercept 2.9+ style metadata modification actions 
    397         add_action("acf/save_post", [$this, 'acf_save'], 10, 4); 
     437        add_action("acf/save_post", array($this, 'acf_save'), 10, 4); 
    398438 
    399439        //When a post is deleted, also delete the custom field container associated with it. 
    400         add_action('delete_post', [$this, 'post_deleted']); 
    401         add_action('trash_post', [$this, 'post_deleted']); 
     440        add_action('delete_post', array($this, 'post_deleted')); 
     441        add_action('trash_post', array($this, 'post_deleted')); 
    402442 
    403443        //Re-parse custom fields when a post is restored from trash 
    404         add_action('untrashed_post', [$this, 'post_untrashed']); 
     444        add_action('untrashed_post', array($this, 'post_untrashed')); 
    405445 
    406446    } 
     
    413453    function get_parseable_fields() { 
    414454        return $this->selected_fields; 
     455    } 
     456 
     457    function filterHtmlExtract($value) { 
     458        if ($value == 'html') { 
     459            return true; 
     460        } 
     461        return false; 
    415462    } 
    416463 
     
    441488        */ 
    442489 
    443         $preload = $load_wrapped_objects || in_array($purpose, [BLC_FOR_DISPLAY]); 
     490        $preload = $load_wrapped_objects || in_array($purpose, array(BLC_FOR_DISPLAY)); 
    444491        if ($preload) { 
    445             $post_ids = []; 
     492            $post_ids = array(); 
    446493            foreach ($containers as $container) { 
    447494                $post_ids[] = $container->container_id; 
    448495            } 
    449496 
    450             $args = ['include' => implode(',', $post_ids)]; 
     497            $args = array('include' => implode(',', $post_ids)); 
    451498            get_posts($args); 
    452499        } 
     
    454501        $selected_fields = $this->selected_fields; 
    455502 
    456         $html_fields = array_filter($selected_fields, function ($value) { 
    457             if ($value == 'html') { 
    458                 return true; 
    459             } 
    460             return false; 
    461         }); 
     503        $html_fields = array_filter($selected_fields, array($this, 'filterHtmlExtract')); 
    462504 
    463505        $url_fields = array_keys(array_diff($selected_fields, $html_fields)); 
     
    467509 
    468510            $meta = get_metadata('post', $container->container_id); 
    469             $fields = []; 
     511            $fields = array(); 
    470512 
    471513            foreach ($meta as $field => $value) { 
     
    518560 
    519561        //Only check custom fields on selected post types. By default, that's "post" and "page". 
    520         $post_types = ['post', 'page']; 
     562        $post_types = array('post', 'page'); 
    521563        if (class_exists('blcPostTypeOverlord')) { 
    522564            $overlord = blcPostTypeOverlord::getInstance(); 
     
    605647        $selected_fields = $this->selected_fields; 
    606648 
    607         $html_fields = array_filter($selected_fields, function ($value) { 
    608             if ($value == 'html') { 
    609                 return true; 
    610             } 
    611  
    612             return false; 
    613         }); 
     649        $html_fields = array_filter($selected_fields, array($this, 'filterHtmlExtract')); 
    614650 
    615651        $url_fields = array_keys(array_diff($selected_fields, $html_fields)); 
     
    618654        $selected_fields = array_keys($selected_fields); 
    619655 
    620         $keys = []; 
     656        $keys = array(); 
    621657        $fields = $_POST['acf']; 
    622658 
    623         array_walk_recursive($fields, function ($item, $key) use (&$keys, $selected_fields, $url_fields, $html_fields) { 
    624  
    625             $key = explode('|', str_replace('_field', '|field', $key)); 
    626  
    627             if (is_array($key)) { 
    628                 $key = $key[ count($key) - 1 ]; 
    629             } 
    630  
    631             if (in_array($key, $url_fields)) { 
    632                 if (!filter_var($item, FILTER_VALIDATE_URL) === false) { 
    633                     $keys[] = $key; 
    634                 } 
    635             } 
    636  
    637             if (in_array($key, $html_fields)) { 
    638                 if ($item != '') { 
    639                     $keys[] = $key; 
    640                 } 
    641             } 
    642         }); 
     659        $acfWalk = new blcAcfExtractedFieldWalker($keys, $selected_fields, $url_fields, $html_fields); 
     660 
     661        array_walk_recursive($fields, array($acfWalk, 'walk_function')); 
    643662 
    644663        if (empty($keys)) { 
     
    646665        } 
    647666 
    648         $container = blcContainerHelper::get_container([$this->container_type, $post_id]); 
     667        $container = blcContainerHelper::get_container(array($this->container_type, $post_id)); 
    649668        $container->mark_as_unsynched(); 
    650669 
     
    661680        //Get the associated container object 
    662681 
    663         $container = blcContainerHelper::get_container([$this->container_type, intval($post_id) ]); 
     682        $container = blcContainerHelper::get_container(array($this->container_type, intval($post_id))); 
    664683 
    665684        if ($container != null) { 
     
    681700    function post_untrashed($post_id) { 
    682701        //Get the associated container object 
    683         $container = blcContainerHelper::get_container([$this->container_type, intval($post_id)]); 
     702        $container = blcContainerHelper::get_container(array($this->container_type, intval($post_id))); 
    684703        $container->mark_as_unsynched(); 
    685704    } 
  • broken-link-checker/trunk/modules/containers/custom_field.php

    r1706472 r1707025  
    592592        //Get the associated container object 
    593593 
    594         $container = blcContainerHelper::get_container([$this->container_type, intval($post_id)]); 
     594        $container = blcContainerHelper::get_container(array($this->container_type, intval($post_id))); 
    595595        if ($container != null) { 
    596596            //Delete it 
  • broken-link-checker/trunk/modules/parsers/acf_field.php

    r1706472 r1707025  
    1717class blcACFParser extends blcParser { 
    1818 
    19     var $supported_formats = ['acf_field']; 
    20     var $supported_containers = []; 
     19    var $supported_formats = array('acf_field'); 
     20    var $supported_containers = array(); 
    2121 
    2222    /** 
     
    2929   */ 
    3030    function parse($content, $base_url = '', $default_link_text = ''){ 
    31         $instances = []; 
     31        $instances = array(); 
    3232 
    3333        if ( !is_array($content) ){ 
    34             $content = [$content]; 
     34            $content = array($content); 
    3535        } 
    3636 
  • broken-link-checker/trunk/readme.txt

    r1706472 r1707025  
    55Requires at least: 3.2 
    66Tested up to: 4.8 
    7 Stable tag: 1.11.4 
     7Stable tag: 1.11.5 
    88 
    99This plugin will check your posts, comments and other content for broken links and missing images, and notify you if any are found. 
     
    102102== Changelog == 
    103103 
     104= 1.11.5 = 
     105* Fixed a PHP 5.2 compatibility issue 
     106 
    104107= 1.11.4 = 
    105108* Fixed a few more PHP 7.x/5.6 compatibility issues 
Note: See TracChangeset for help on using the changeset viewer.