Plugin Directory

Changeset 2900239


Ignore:
Timestamp:
04/17/2023 02:47:54 PM (3 years ago)
Author:
daggerhart
Message:

Update to version 1.5.51 from GitHub

Location:
query-wrangler
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • query-wrangler/tags/1.5.51/admin/admin.php

    r2245280 r2900239  
    156156    } // update for widgets
    157157    else {
    158         $wpdb->query( $wpdb->prepare( "UPDATE {$table_name} SET data = %s WHERE id = %d LIMIT 1", 
    159             $new_data, 
     158        $wpdb->query( $wpdb->prepare( "UPDATE {$table_name} SET data = %s WHERE id = %d LIMIT 1",
     159            $new_data,
    160160            $query_id ) );
     161    }
     162
     163    // Refresh meta_keys_cache.
     164    $settings = QW_Settings::get_instance();
     165    if ($settings->get('meta_key_cache_life') !== 'none') {
     166        delete_transient('query_wrangler_meta_keys_cache');
     167        qw_get_meta_keys();
    161168    }
    162169}
     
    408415        $results = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT(`meta_key`) FROM {$wpdb->postmeta} WHERE `meta_key` LIKE '%s' LIMIT 15",
    409416            '%' . $meta_key . '%' ) );
    410        
     417
    411418        //foreach ($query)
    412419        wp_send_json( array(
  • query-wrangler/tags/1.5.51/admin/query-admin-pages.php

    r1822973 r2900239  
    223223    $meta_value_field_handler = ( isset( $post['qw-meta-value-field-handler'] ) ) ? $post['qw-meta-value-field-handler'] : '';
    224224    $shortcode_compat = isset( $post['qw-shortcode-compat'] ) ? $post['qw-shortcode-compat'] : '';
     225    $meta_key_cache_life = $post['qw-meta-keys-cache-life'] ?? 'forever';
    225226
    226227    $settings = QW_Settings::get_instance();
     
    231232    $settings->set( 'meta_value_field_handler', $meta_value_field_handler );
    232233    $settings->set( 'shortcode_compat', $shortcode_compat );
     234    $settings->set('meta_key_cache_life', $meta_key_cache_life);
    233235    $settings->save();
    234236}
  • query-wrangler/tags/1.5.51/admin/templates/form-settings.php

    r1571900 r2900239  
     1<?php
     2/**
     3 * @var string $edit_theme
     4 * @var bool $widget_theme_compat
     5 * @var bool $live_preview
     6 * @var bool $show_silent_meta
     7 * @var bool $shortcode_compat
     8 * @var string $meta_value_field_handler
     9 * @var string $meta_key_cache_life
     10 * @var array[] $edit_themes
     11 * @var array $meta_value_field_options
     12 */
     13?>
    114<form id="qw-edit-settings"
    215      action="<?php print admin_url( 'admin.php?page=query-wrangler&action=save_settings&noheader=true' ); ?>"
     
    1326                <select name="qw-theme">
    1427                    <?php
    15                     foreach ( $edit_themes as $key => $edit_theme ) { ?>
     28                    foreach ( $edit_themes as $key => $theme ) { ?>
    1629                        <option
    17                             value="<?php print $key; ?>" <?php selected( $key,
    18                             $theme ); ?>>
    19                             <?php print $edit_theme['title']; ?>
     30                            value="<?php print $key; ?>" <?php selected( $key, $edit_theme ); ?>>
     31                            <?php print $theme['title']; ?>
    2032                        </option>
    2133                    <?php
     
    7991                    <?php
    8092                    foreach ( $meta_value_field_options as $value => $text ) { ?>
    81                         <option
    82                             value="<?php print $value; ?>" <?php selected( $value,
    83                             $meta_value_field_handler ); ?>>
     93                        <option value="<?php print $value; ?>" <?php selected( $value, $meta_value_field_handler ); ?>>
    8494                            <?php print $text; ?>
    8595                        </option>
    86                     <?php
     96                        <?php
    8797                    }
    8898                    ?>
     
    95105                        the UI, and you must provide it the meta key.
    96106                    </li>
     107                </ul>
     108            </td>
     109        </tr>
     110        <tr>
     111            <th>
     112                <label>Meta Keys Cache Life</label>
     113            </th>
     114            <td>
     115                <p class="description">
     116                    Discovering meta keys can be very expensive and time-consuming query for large sites.
     117                    It's recommended to enable <em>some</em> amount of caching on this.
     118                </p>
     119                <?php
     120                $meta_key_cache_options = [
     121                    'none' => '- ' . __('No Caching') . ' -',
     122                    3600 => __('1 Hour'),
     123                    DAY_IN_SECONDS => __('1 Day'),
     124                    WEEK_IN_SECONDS => __('1 Week'),
     125                    0 => __('Forever'),
     126                ];
     127                ?>
     128                <select name="qw-meta-keys-cache-life">
     129                    <?php foreach ( $meta_key_cache_options as $value => $label ) { ?>
     130                        <option value="<?= esc_attr($value) ?>" <?php selected($value, $meta_key_cache_life) ?>>
     131                            <?= esc_html( $label ) ?>
     132                        </option>
     133                    <?php } ?>
     134                </select>
     135                <ul>
     136                    <li><b>No Caching</b> - Never cache meta keys. This could cause performance issues.</li>
     137                    <li><b>Forever</b> - Cache meta keys until a Query Wrangler Query is edited and saved.</li>
    97138                </ul>
    98139            </td>
  • query-wrangler/tags/1.5.51/admin/templates/page-query-list.php

    r1571900 r2900239  
    146146     **************************************************************************/
    147147    function column_name( $item ) {
     148        $edit_url = esc_url( strtr( '?page=%page&edit=%id', [
     149            '%page' => $_REQUEST['page'],
     150            '%id' => $item['ID'],
     151        ] ) );
     152        $export_url = esc_url( strtr( '?page=%page&export=%id', [
     153            '%page' => $_REQUEST['page'],
     154            '%id' => $item['ID'],
     155        ] ) );
     156        $delete_url = esc_url( strtr( '?page=%page&noheader=true&action=delete&edit=%id', [
     157            '%page' => $_REQUEST['page'],
     158            '%id' => $item['ID'],
     159        ] ) );
    148160
    149161        //Build row actions
    150162        $actions = array(
    151             'edit'   => sprintf( '<a href="?page=%s&edit=%s">Edit</a>',
    152                 $_REQUEST['page'],
    153                 $item['ID'] ),
    154             'export' => sprintf( '<a href="?page=%s&export=%s">Export</a>',
    155                 $_REQUEST['page'],
    156                 $item['ID'] ),
    157             'delete' => sprintf( '<a class="qw-delete-query" href="?page=%s&noheader=true&action=delete&edit=%s">Delete</a>',
    158                 $_REQUEST['page'],
    159                 $item['ID'] ),
     163            'edit'   => '<a href="' . $edit_url. '">Edit</a>',
     164            'export' => '<a href="' . $export_url . '">Export</a>',
     165            'delete' => '<a class="qw-delete-query" href="' . $delete_url . '">Delete</a>',
    160166        );
    161167        // pages
    162168        if ( $item['type'] == 'page' ) {
    163             $actions['view'] = '<a href="' . get_bloginfo( 'wpurl' ) . '/' . $item['path'] . '">View</a>';
     169            $view_url =  esc_url(get_bloginfo( 'wpurl' ) . '/' . $item['path']);
     170            $actions['view'] = '<a href="' . $view_url . '">View</a>';
    164171        }
    165172
    166173        //Return the title contents
    167         return sprintf( '%1$s <span style="color:silver">(ID: %2$s)</span> %3$s',
    168             /*$1%s*/
    169             '<a href="?page=query-wrangler&edit=' . $item['ID'] . '">' . $item['name'] . '</a>',
    170             /*$2%s*/
    171             $item['ID'],
    172             /*$3%s*/
    173             $this->row_actions( $actions )
    174         );
     174        return '<a href="' . $edit_url . '">' . $item['name'] . '</a>
     175            <span style="color:silver">(ID: ' . $item['ID'] . ')</span> ' .
     176            $this->row_actions( $actions );
    175177    }
    176178
     
    189191     **************************************************************************/
    190192    function column_cb( $item ) {
    191         return sprintf(
    192             '<input type="checkbox" name="%1$s[]" value="%2$s" />',
    193             /*$1%s*/
    194             $this->_args['singular'],
    195             //Let's simply repurpose the table's singular label ("movie")
    196             /*$2%s*/
    197             $item['ID']                //The value of the checkbox should be the record's id
    198         );
     193        return '<input type="checkbox" name="' . esc_attr( $this->_args['singular'] . '[]' ) . '" value="' . esc_attr( $item['ID'] ) . '" />';
    199194    }
    200195
     
    294289            if ( is_array( $_REQUEST['query'] ) ) {
    295290                foreach ( $_REQUEST['query'] as $query_id ) {
    296                     qw_delete_query( $query_id );
     291                    if ( is_numeric( $query_id ) ) {
     292                        qw_delete_query( $query_id );
     293                    }
    297294                }
    298295            }
     
    375372         * sorting technique would be unnecessary.
    376373         */
    377         /*/ NOT IN USE
    378         function usort_reorder($a,$b){
    379             $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'name'; //If no sort, default to title
    380             $order = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc'; //If no order, default to asc
    381             $result = strcmp($a[$orderby], $b[$orderby]); //Determine sort order
    382             return ($order==='asc') ? $result : -$result; //Send final sort direction to usort
    383         }
    384         //usort($data, 'usort_reorder');
    385         // */
    386374
    387375        /***********************************************************************
     
    495483            <div id="icon-tools" class="icon32"><br/></div>
    496484            <h2>Query Wrangler <a class="add-new-h2"
    497                                   href="admin.php?page=qw-create">Add New</a>
     485                                  href="<?= esc_url('admin.php?page=qw-create' ) ?>">Add New</a>
    498486            </h2>
    499487
    500488            <form id="search-queries-filter" method="get">
    501                 <input type="hidden" name="page" value="<?php echo esc_attr($_REQUEST['page']); ?>"/>
     489                <input type="hidden" name="page" value="<?= esc_attr($_REQUEST['page']) ?>"/>
    502490                <?php $ListTable->search_box( 'Search', 'post' ); ?>
    503491            </form>
     
    507495                <!-- For plugins, we also need to ensure that the form posts back to our current page -->
    508496                <input type="hidden" name="page"
    509                        value="<?php echo $_REQUEST['page'] ?>"/>
     497                       value="<?php echo esc_attr($_REQUEST['page']) ?>"/>
    510498                <input type="hidden" name="noheader" value="true"/>
    511499                <!-- Now we can render the completed list table -->
  • query-wrangler/tags/1.5.51/includes/class-qw-settings.php

    r1329785 r2900239  
    1212        'meta_value_field_handler' => 0,
    1313        'shortcode_compat'         => 0,
     14        'meta_key_cache_life'      => 0, // Forever.
    1415    );
    1516
     
    4950     * @param bool|FALSE $default
    5051     *
    51      * @return bool
     52     * @return mixed
    5253     */
    5354    function get( $key, $default = false ){
  • query-wrangler/tags/1.5.51/includes/fields/taxonomy_terms.php

    r1544833 r2900239  
    3636    $terms = get_the_terms( $post->ID, $field['taxonomy_name'] );
    3737
    38     foreach( $terms as $term ){
    39         if ( isset( $field['link_to_term'] ) ) {
    40             $output[] = '<a href="' . get_term_link( $term->term_id ) . '">' . $term->name . '</a>';
    41         }
    42         else {
    43             $output[] = $term->name;
     38    if ( $terms ) {
     39        foreach( $terms as $term ){
     40            if ( isset( $field['link_to_term'] ) ) {
     41                $output[] = '<a href="' . get_term_link( $term->term_id ) . '">' . $term->name . '</a>';
     42            }
     43            else {
     44                $output[] = $term->name;
     45            }
    4446        }
    4547    }
  • query-wrangler/tags/1.5.51/includes/query.php

    r2480680 r2900239  
    314314    }
    315315
    316     return $page;
     316    return (int) $page;
    317317}
    318318
     
    470470 */
    471471function qw_get_meta_keys() {
    472     global $wpdb;
    473 
    474     $keys = $wpdb->get_col( "
    475             SELECT meta_key
     472    $settings = QW_Settings::get_instance();
     473    $cache_life = $settings->get('meta_key_cache_life');
     474
     475    $keys = get_transient('query_wrangler_meta_keys_cache');
     476    if (!$keys || $cache_life === 'none') {
     477        global $wpdb;
     478
     479        $keys = $wpdb->get_col( "
     480            SELECT DISTINCT(meta_key)
    476481            FROM $wpdb->postmeta
    477             GROUP BY meta_key
    478482            ORDER BY meta_key" );
     483
     484        set_transient('query_wrangler_meta_keys_cache', $keys, (int) $cache_life);
     485    }
     486
    479487
    480488    return $keys;
  • query-wrangler/trunk/admin/admin.php

    r2245280 r2900239  
    156156    } // update for widgets
    157157    else {
    158         $wpdb->query( $wpdb->prepare( "UPDATE {$table_name} SET data = %s WHERE id = %d LIMIT 1", 
    159             $new_data, 
     158        $wpdb->query( $wpdb->prepare( "UPDATE {$table_name} SET data = %s WHERE id = %d LIMIT 1",
     159            $new_data,
    160160            $query_id ) );
     161    }
     162
     163    // Refresh meta_keys_cache.
     164    $settings = QW_Settings::get_instance();
     165    if ($settings->get('meta_key_cache_life') !== 'none') {
     166        delete_transient('query_wrangler_meta_keys_cache');
     167        qw_get_meta_keys();
    161168    }
    162169}
     
    408415        $results = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT(`meta_key`) FROM {$wpdb->postmeta} WHERE `meta_key` LIKE '%s' LIMIT 15",
    409416            '%' . $meta_key . '%' ) );
    410        
     417
    411418        //foreach ($query)
    412419        wp_send_json( array(
  • query-wrangler/trunk/admin/query-admin-pages.php

    r1822973 r2900239  
    223223    $meta_value_field_handler = ( isset( $post['qw-meta-value-field-handler'] ) ) ? $post['qw-meta-value-field-handler'] : '';
    224224    $shortcode_compat = isset( $post['qw-shortcode-compat'] ) ? $post['qw-shortcode-compat'] : '';
     225    $meta_key_cache_life = $post['qw-meta-keys-cache-life'] ?? 'forever';
    225226
    226227    $settings = QW_Settings::get_instance();
     
    231232    $settings->set( 'meta_value_field_handler', $meta_value_field_handler );
    232233    $settings->set( 'shortcode_compat', $shortcode_compat );
     234    $settings->set('meta_key_cache_life', $meta_key_cache_life);
    233235    $settings->save();
    234236}
  • query-wrangler/trunk/admin/templates/form-settings.php

    r1571900 r2900239  
     1<?php
     2/**
     3 * @var string $edit_theme
     4 * @var bool $widget_theme_compat
     5 * @var bool $live_preview
     6 * @var bool $show_silent_meta
     7 * @var bool $shortcode_compat
     8 * @var string $meta_value_field_handler
     9 * @var string $meta_key_cache_life
     10 * @var array[] $edit_themes
     11 * @var array $meta_value_field_options
     12 */
     13?>
    114<form id="qw-edit-settings"
    215      action="<?php print admin_url( 'admin.php?page=query-wrangler&action=save_settings&noheader=true' ); ?>"
     
    1326                <select name="qw-theme">
    1427                    <?php
    15                     foreach ( $edit_themes as $key => $edit_theme ) { ?>
     28                    foreach ( $edit_themes as $key => $theme ) { ?>
    1629                        <option
    17                             value="<?php print $key; ?>" <?php selected( $key,
    18                             $theme ); ?>>
    19                             <?php print $edit_theme['title']; ?>
     30                            value="<?php print $key; ?>" <?php selected( $key, $edit_theme ); ?>>
     31                            <?php print $theme['title']; ?>
    2032                        </option>
    2133                    <?php
     
    7991                    <?php
    8092                    foreach ( $meta_value_field_options as $value => $text ) { ?>
    81                         <option
    82                             value="<?php print $value; ?>" <?php selected( $value,
    83                             $meta_value_field_handler ); ?>>
     93                        <option value="<?php print $value; ?>" <?php selected( $value, $meta_value_field_handler ); ?>>
    8494                            <?php print $text; ?>
    8595                        </option>
    86                     <?php
     96                        <?php
    8797                    }
    8898                    ?>
     
    95105                        the UI, and you must provide it the meta key.
    96106                    </li>
     107                </ul>
     108            </td>
     109        </tr>
     110        <tr>
     111            <th>
     112                <label>Meta Keys Cache Life</label>
     113            </th>
     114            <td>
     115                <p class="description">
     116                    Discovering meta keys can be very expensive and time-consuming query for large sites.
     117                    It's recommended to enable <em>some</em> amount of caching on this.
     118                </p>
     119                <?php
     120                $meta_key_cache_options = [
     121                    'none' => '- ' . __('No Caching') . ' -',
     122                    3600 => __('1 Hour'),
     123                    DAY_IN_SECONDS => __('1 Day'),
     124                    WEEK_IN_SECONDS => __('1 Week'),
     125                    0 => __('Forever'),
     126                ];
     127                ?>
     128                <select name="qw-meta-keys-cache-life">
     129                    <?php foreach ( $meta_key_cache_options as $value => $label ) { ?>
     130                        <option value="<?= esc_attr($value) ?>" <?php selected($value, $meta_key_cache_life) ?>>
     131                            <?= esc_html( $label ) ?>
     132                        </option>
     133                    <?php } ?>
     134                </select>
     135                <ul>
     136                    <li><b>No Caching</b> - Never cache meta keys. This could cause performance issues.</li>
     137                    <li><b>Forever</b> - Cache meta keys until a Query Wrangler Query is edited and saved.</li>
    97138                </ul>
    98139            </td>
  • query-wrangler/trunk/admin/templates/page-query-list.php

    r1571900 r2900239  
    146146     **************************************************************************/
    147147    function column_name( $item ) {
     148        $edit_url = esc_url( strtr( '?page=%page&edit=%id', [
     149            '%page' => $_REQUEST['page'],
     150            '%id' => $item['ID'],
     151        ] ) );
     152        $export_url = esc_url( strtr( '?page=%page&export=%id', [
     153            '%page' => $_REQUEST['page'],
     154            '%id' => $item['ID'],
     155        ] ) );
     156        $delete_url = esc_url( strtr( '?page=%page&noheader=true&action=delete&edit=%id', [
     157            '%page' => $_REQUEST['page'],
     158            '%id' => $item['ID'],
     159        ] ) );
    148160
    149161        //Build row actions
    150162        $actions = array(
    151             'edit'   => sprintf( '<a href="?page=%s&edit=%s">Edit</a>',
    152                 $_REQUEST['page'],
    153                 $item['ID'] ),
    154             'export' => sprintf( '<a href="?page=%s&export=%s">Export</a>',
    155                 $_REQUEST['page'],
    156                 $item['ID'] ),
    157             'delete' => sprintf( '<a class="qw-delete-query" href="?page=%s&noheader=true&action=delete&edit=%s">Delete</a>',
    158                 $_REQUEST['page'],
    159                 $item['ID'] ),
     163            'edit'   => '<a href="' . $edit_url. '">Edit</a>',
     164            'export' => '<a href="' . $export_url . '">Export</a>',
     165            'delete' => '<a class="qw-delete-query" href="' . $delete_url . '">Delete</a>',
    160166        );
    161167        // pages
    162168        if ( $item['type'] == 'page' ) {
    163             $actions['view'] = '<a href="' . get_bloginfo( 'wpurl' ) . '/' . $item['path'] . '">View</a>';
     169            $view_url =  esc_url(get_bloginfo( 'wpurl' ) . '/' . $item['path']);
     170            $actions['view'] = '<a href="' . $view_url . '">View</a>';
    164171        }
    165172
    166173        //Return the title contents
    167         return sprintf( '%1$s <span style="color:silver">(ID: %2$s)</span> %3$s',
    168             /*$1%s*/
    169             '<a href="?page=query-wrangler&edit=' . $item['ID'] . '">' . $item['name'] . '</a>',
    170             /*$2%s*/
    171             $item['ID'],
    172             /*$3%s*/
    173             $this->row_actions( $actions )
    174         );
     174        return '<a href="' . $edit_url . '">' . $item['name'] . '</a>
     175            <span style="color:silver">(ID: ' . $item['ID'] . ')</span> ' .
     176            $this->row_actions( $actions );
    175177    }
    176178
     
    189191     **************************************************************************/
    190192    function column_cb( $item ) {
    191         return sprintf(
    192             '<input type="checkbox" name="%1$s[]" value="%2$s" />',
    193             /*$1%s*/
    194             $this->_args['singular'],
    195             //Let's simply repurpose the table's singular label ("movie")
    196             /*$2%s*/
    197             $item['ID']                //The value of the checkbox should be the record's id
    198         );
     193        return '<input type="checkbox" name="' . esc_attr( $this->_args['singular'] . '[]' ) . '" value="' . esc_attr( $item['ID'] ) . '" />';
    199194    }
    200195
     
    294289            if ( is_array( $_REQUEST['query'] ) ) {
    295290                foreach ( $_REQUEST['query'] as $query_id ) {
    296                     qw_delete_query( $query_id );
     291                    if ( is_numeric( $query_id ) ) {
     292                        qw_delete_query( $query_id );
     293                    }
    297294                }
    298295            }
     
    375372         * sorting technique would be unnecessary.
    376373         */
    377         /*/ NOT IN USE
    378         function usort_reorder($a,$b){
    379             $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'name'; //If no sort, default to title
    380             $order = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc'; //If no order, default to asc
    381             $result = strcmp($a[$orderby], $b[$orderby]); //Determine sort order
    382             return ($order==='asc') ? $result : -$result; //Send final sort direction to usort
    383         }
    384         //usort($data, 'usort_reorder');
    385         // */
    386374
    387375        /***********************************************************************
     
    495483            <div id="icon-tools" class="icon32"><br/></div>
    496484            <h2>Query Wrangler <a class="add-new-h2"
    497                                   href="admin.php?page=qw-create">Add New</a>
     485                                  href="<?= esc_url('admin.php?page=qw-create' ) ?>">Add New</a>
    498486            </h2>
    499487
    500488            <form id="search-queries-filter" method="get">
    501                 <input type="hidden" name="page" value="<?php echo esc_attr($_REQUEST['page']); ?>"/>
     489                <input type="hidden" name="page" value="<?= esc_attr($_REQUEST['page']) ?>"/>
    502490                <?php $ListTable->search_box( 'Search', 'post' ); ?>
    503491            </form>
     
    507495                <!-- For plugins, we also need to ensure that the form posts back to our current page -->
    508496                <input type="hidden" name="page"
    509                        value="<?php echo $_REQUEST['page'] ?>"/>
     497                       value="<?php echo esc_attr($_REQUEST['page']) ?>"/>
    510498                <input type="hidden" name="noheader" value="true"/>
    511499                <!-- Now we can render the completed list table -->
  • query-wrangler/trunk/includes/class-qw-settings.php

    r1329785 r2900239  
    1212        'meta_value_field_handler' => 0,
    1313        'shortcode_compat'         => 0,
     14        'meta_key_cache_life'      => 0, // Forever.
    1415    );
    1516
     
    4950     * @param bool|FALSE $default
    5051     *
    51      * @return bool
     52     * @return mixed
    5253     */
    5354    function get( $key, $default = false ){
  • query-wrangler/trunk/includes/fields/taxonomy_terms.php

    r1544833 r2900239  
    3636    $terms = get_the_terms( $post->ID, $field['taxonomy_name'] );
    3737
    38     foreach( $terms as $term ){
    39         if ( isset( $field['link_to_term'] ) ) {
    40             $output[] = '<a href="' . get_term_link( $term->term_id ) . '">' . $term->name . '</a>';
    41         }
    42         else {
    43             $output[] = $term->name;
     38    if ( $terms ) {
     39        foreach( $terms as $term ){
     40            if ( isset( $field['link_to_term'] ) ) {
     41                $output[] = '<a href="' . get_term_link( $term->term_id ) . '">' . $term->name . '</a>';
     42            }
     43            else {
     44                $output[] = $term->name;
     45            }
    4446        }
    4547    }
  • query-wrangler/trunk/includes/query.php

    r2480680 r2900239  
    314314    }
    315315
    316     return $page;
     316    return (int) $page;
    317317}
    318318
     
    470470 */
    471471function qw_get_meta_keys() {
    472     global $wpdb;
    473 
    474     $keys = $wpdb->get_col( "
    475             SELECT meta_key
     472    $settings = QW_Settings::get_instance();
     473    $cache_life = $settings->get('meta_key_cache_life');
     474
     475    $keys = get_transient('query_wrangler_meta_keys_cache');
     476    if (!$keys || $cache_life === 'none') {
     477        global $wpdb;
     478
     479        $keys = $wpdb->get_col( "
     480            SELECT DISTINCT(meta_key)
    476481            FROM $wpdb->postmeta
    477             GROUP BY meta_key
    478482            ORDER BY meta_key" );
     483
     484        set_transient('query_wrangler_meta_keys_cache', $keys, (int) $cache_life);
     485    }
     486
    479487
    480488    return $keys;
Note: See TracChangeset for help on using the changeset viewer.