Plugin Directory

Changeset 3469357


Ignore:
Timestamp:
02/25/2026 10:59:08 AM (5 weeks ago)
Author:
jamesdlow
Message:

1.5.1

  • Further updates/fixes for Wordpress best practices
Location:
pageapp
Files:
18 added
6 edited

Legend:

Unmodified
Added
Removed
  • pageapp/trunk/inc/cachelib.php

    r3469312 r3469357  
    5454            global $wpdb;
    5555            $table = $this->table();
    56             $query = $wpdb->prepare("DELETE FROM $table WHERE %d = %d;", 1, 1);
    57             $wpdb->query($query);
     56            $wpdb->query($wpdb->prepare("DELETE FROM $table WHERE %d = %d;", 1, 1));
    5857        }
    5958    }
     
    6362            global $wpdb;
    6463            $table = $this->table();
    65             $query = $wpdb->prepare("DELETE FROM $table WHERE expires < DATE_ADD(NOW(), INTERVAL %d SECOND);", 0);
    66             $wpdb->query($query);
     64            $wpdb->query($wpdb->prepare("DELETE FROM $table WHERE expires < DATE_ADD(NOW(), INTERVAL %d SECOND);", 0));
    6765        }
    6866    }
     
    7169            global $wpdb;
    7270            $table = $this->table();
    73             $query = $wpdb->prepare("DELETE FROM $table WHERE name = %s;", $name);
    74             $wpdb->query($query);
     71            $wpdb->query($wpdb->prepare("DELETE FROM $table WHERE name = %s;", $name));
    7572        }
    7673    }
     
    7976            global $wpdb;
    8077            $table = $this->table();
    81             $query = $wpdb->prepare("SELECT data FROM $table WHERE name = %s AND expires > NOW();", $name);
    82             return $wpdb->get_var($query);
     78            return $wpdb->get_var($wpdb->prepare("SELECT data FROM $table WHERE name = %s AND expires > NOW();", $name));
    8379        }
    8480    }
     
    8884            $table = $this->table();
    8985            $expiry = esc_sql($expiry ? $expiry : $this->expiry);
    90             $query = $wpdb->prepare(
     86            $wpdb->query($wpdb->prepare(
    9187                "INSERT INTO $table (name, expires, data)
    9288                    VALUES (%s, DATE_ADD(NOW(), INTERVAL $expiry), %s)
     
    9692                $value,
    9793                $value
    98             );
    99             $wpdb->query($query);
     94            ));
    10095        }
    10196        return $value;
  • pageapp/trunk/inc/jsonlib.php

    r3469278 r3469357  
    9696        */
    9797    public static function strip($value) {
    98         return strip_tags(str_replace('?>','',str_replace('<?php','',stripslashes($value))));
     98        return wp_strip_all_tags(str_replace('?>','',str_replace('<?php','',stripslashes($value))));
    9999    }
    100100    public static function get_param($key, $default = null) {
     
    107107            return self::strip($value);
    108108        } else {
    109             throw new Exception(($description?$description:$key).' is required.');
     109            throw new Exception(esc_html($description?$description:$key).' is required.');
    110110        }
    111111    }
  • pageapp/trunk/inc/restlib.php

    r3469278 r3469357  
    55 * Author: James D. Low
    66 * URL: http://jameslow.com
    7  * About: Helper class for creating Wordpress REST end points
     7 * About: Helper class for creating REST end points for use with and without Wordpress
    88 */
    99class RestLib {
  • pageapp/trunk/pageapp-json.php

    r3469278 r3469357  
    164164        }
    165165        foreach ($list as $url) {
    166             //This is echoing a list of raw URLs over an API endpoint, it does not need to be escaped
    167             echo $url."\n";
     166            echo esc_url($url)."\n";
    168167        }
    169168        exit();
     
    178177    protected function fire_links() {
    179178        $list = preg_split("/[\s,]+/", get_option('pageapp_firetv_feeds'));
    180         //This is echoing a list of raw URLs over an API endpoint, it does not need to be escaped
    181179        foreach ($list as $url) {
    182             echo $url."\n";
     180            echo esc_url($url)."\n";
    183181        }
    184182        exit();
  • pageapp/trunk/pageapp.php

    r3469312 r3469357  
    44Plugin URI: https://wordpress.org/plugins/pageapp/
    55Description: Extensions to Wordpress wp-json for the PageApp API and mobile framework
    6 Version: 1.5.0
     6Version: 1.5.1
    77Author: PageApp
    88Author URI: https://www.thirteen.com/
    9 License: MIT License
     9License: MIT
    1010*/
    1111if (!defined( 'ABSPATH')) exit;
     
    226226        if (get_option('pageapp_password') == '1') {
    227227            if (empty($_POST['password'])) {
    228                 $errors->add('empty_password', __('Please enter a password.'));
     228                $errors->add('empty_password', 'Please enter a password.');
    229229            }
    230230        }
     
    362362                'meta_value'       => '',
    363363                'post_type'        => $details->object_type[0],
    364                 'suppress_filters' => true,
     364                //'suppress_filters' => true,
    365365                'tax_query' => array(
    366366                    array(
     
    462462    public static function register_options() {
    463463        //Whitelist Meta
    464         register_setting(self::$prefix, 'pageapp_postmeta');
     464        register_setting(self::$prefix, 'pageapp_postmeta', array(
     465            'sanitize_callback' => array(self::class, 'sanitize_postmeta_json')
     466        ));
     467    }
     468    public static function sanitize_postmeta_json($value) {
     469        if (is_array($value)) {
     470            return wp_json_encode($value);
     471        }
     472        if (!is_string($value)) {
     473            return '[]';
     474        }
     475        $decoded = json_decode(wp_unslash($value), true);
     476        if (json_last_error() === JSON_ERROR_NONE) {
     477            return wp_json_encode($decoded);
     478        }
     479        return '[]';
    465480    }
    466481    public static function max_results() {
     
    503518    public static function get_post_meta() {
    504519        global $wpdb;
    505         $prefix = $wpdb->prefix;
    506         $sql = "SELECT DISTINCT meta_key FROM {$prefix}postmeta
     520        return $wpdb->get_results($wpdb->prepare("SELECT DISTINCT meta_key FROM {$wpdb->postmeta}
    507521            WHERE SUBSTRING(meta_key,1,1) != '_' AND SUBSTRING(meta_key,1,6) != 'field_'
    508             ORDER BY meta_key ASC";
    509         return $wpdb->get_results($sql);
     522            ORDER BY meta_key ASC"));
    510523    }
    511524    public static function meta_checkbox($key, $option, $param) {
     
    574587            }
    575588        }
    576 
     589        $allow = array(
     590            'tr' => array(
     591                'valign' => array(),
     592                'class' => array()
     593            ),
     594            'th' => array(
     595                'scope' => array()
     596            ),
     597            'td' => array(),
     598            'div' => array(
     599                'style' => array()
     600            ),
     601            'select' => array(
     602                'id' => array(),
     603                'name' => array()
     604            ),
     605            'input' => array(
     606                'id' => array(),
     607                'name' => array(),
     608                'type' => array(),
     609                'checked' => array(),
     610                'value' => array(),
     611                'style' => array(),
     612                'placeholder' => array()
     613            ),
     614            'textarea' => array(
     615                'id' => array(),
     616                'name' => array(),
     617                'rows' => array(),
     618                'cols' => array()
     619            ),
     620            'option' => array(
     621                'value' => array(),
     622                'selected' => array()
     623            ),
     624            'label' => array(
     625                'for' => array(),
     626                'name' => array()
     627            )
     628        );
    577629        foreach($allmeta as $meta) {
    578630            echo "<tr>
    579                 <td>$meta".self::meta_hidden($meta)."</td>
    580                 <td>".self::meta_checkbox($meta, $option, 'restapi')."</td>
    581                 <td>".self::meta_checkbox($meta, $option, 'single')."</td>
    582                 <td>".self::meta_select($meta, $option, 'type')."</td>
     631                <td>".esc_html($meta).wp_kses(self::meta_hidden($meta), $allow)."</td>
     632                <td>".wp_kses(self::meta_checkbox($meta, $option, 'restapi'), $allow)."</td>
     633                <td>".wp_kses(self::meta_checkbox($meta, $option, 'single'), $allow)."</td>
     634                <td>".wp_kses(self::meta_select($meta, $option, 'type'), $allow)."</td>
    583635            </tr>";
    584636        }
     
    665717            $result = trim(get_url($url));
    666718            if (strpos($result, '<?xml') !== false) {
    667                 $rand = rand(24, 48);
     719                $rand = wp_rand(24, 48);
    668720                self::$ValueCache->put($url, $result, $rand.' HOUR');
    669721                return new SimpleXmlElement($result);
     
    681733            $json = json_decode($result, true);;
    682734            if ($json !== null) {
    683                 $rand = rand(24, 48);
     735                $rand = wp_rand(24, 48);
    684736                self::$ValueCache->put($url, $result, $rand.' HOUR');
    685737                return $json;
  • pageapp/trunk/readme.txt

    r3469312 r3469357  
    33Tags: pageapp, wp-json, relevanssi, search, rest, post meta
    44Requires at least: 4.0
    5 Tested up to: 6.9.1
    6 Stable tag: 1.5.0
    7 License: MIT License
     5Tested up to: 6.9
     6Stable tag: 1.5.1
     7License: MIT
    88Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=K6VKWB3HZB2T2&item_name=Donation%20to%20jameslow%2ecom&currency_code=USD&bn=PP%2dDonationsBF&charset=UTF%2d8
    99
     
    2828
    2929== Changelog ==
     30
     31= 1.5.1 =
     32* Further updates/fixes for Wordpress best practices
    3033
    3134= 1.5.0 =
Note: See TracChangeset for help on using the changeset viewer.