Plugin Directory

Changeset 3281980


Ignore:
Timestamp:
04/25/2025 03:08:01 PM (11 months ago)
Author:
quentn
Message:

Fixed pagination and screen options for list of restricted pages and access overview.

Location:
quentn-wp/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • quentn-wp/trunk/admin/class-quentn-wp-admin.php

    r3073163 r3281980  
    231231        $hook_access_overview = add_submenu_page("NULL", __( 'Quentn User Access', 'quentn-wp'),   __('Access', 'quentn-wp'), "manage_options", "quentn-page-access-overview", array( $this, 'access_restrictions_list' ) );
    232232
    233         add_action( "load-$hook_access_overview", array( $this, 'access_overview_list_screen_option' ) );
     233        add_action( "load-$hook_access_overview", array( $this, 'set_access_overview_screen_option' ) );
    234234    }
    235235
     
    312312        $args   = array(
    313313            'label'   => 'Access',
    314             'default' => 1,
    315             'option'  => 'quentn_restricted_access_records_per_page'
     314            'default' => 20,
     315            'option'  => 'quentn_restricted_records_per_page'
    316316        );
    317317
     
    328328     */
    329329
    330     public function access_overview_list_screen_option() {
     330    public function set_access_overview_screen_option() {
    331331
    332332        $option = 'per_page';
     
    589589    }
    590590
     591
     592    /**
     593     * Display warning message for older version than 1.2.9
     594     *
     595     * @since  1.2.11
     596     * @access public
     597     * @return void
     598     */
     599    public function version_update_warning($plugin_data) {
     600        if ( version_compare( $plugin_data['Version'], '1.2.9', '<' ) ) {
     601            printf(
     602                '<span style="display:block; margin-top: 5px; color: #c00;"><strong>⚠️ %s</strong></span>',
     603                esc_html__( 'This is an important update! Please update immediately to version 1.2.9 or higher!', 'quentn-wp' )
     604            );
     605
     606        }
     607    }
     608
     609
    591610    /**
    592611     * Check if learndash plugin is active
     
    11131132     * @return void
    11141133     */
    1115     public function set_screen_option( $status, $option, $value ) {
    1116         return $value;
     1134    public function set_screen_option($status, $option, $value) {
     1135        $valid_options = [
     1136            'quentn_restricted_records_per_page',
     1137            'quentn_access_overview_records_per_page'
     1138        ];
     1139
     1140        if (in_array($option, $valid_options)) {
     1141            return $value;
     1142        }
     1143        return $status;
    11171144    }
    11181145
  • quentn-wp/trunk/includes/class-quentn-wp-access-overview-list.php

    r3266307 r3281980  
    213213     * @return mixed
    214214     */
    215     public function get_quentn_restrictions( $per_page = 5, $page_number = 1, $page_id ) {
     215    public function get_quentn_restrictions( $per_page = 20, $page_number = 1, $page_id ) {
    216216        global $wpdb;
    217217
     
    229229        }
    230230
    231         $sql .= " LIMIT $per_page";
    232         $sql .= ' OFFSET ' . ( $page_number - 1 ) * $per_page;
    233 
    234         $results = $wpdb->get_results( $sql, 'ARRAY_A' );
     231        $offset = ($page_number - 1) * $per_page;
     232        $sql .= $wpdb->prepare(" LIMIT %d OFFSET %d", $per_page, $offset);
     233
     234        $results = $wpdb->get_results($sql, 'ARRAY_A');
    235235
    236236        $is_countdown = ( isset( $this->quentn_page_restriction_data['countdown'] ) && $this->quentn_page_restriction_data['countdown'] ) ?  true : false ;
     
    471471
    472472    $qntn_list_table = new Quentn_Wp_Access_Overview( sanitize_text_field( $_REQUEST['page_id'] ) );
     473
     474    // Get current screen
     475    $screen = get_current_screen();
     476
     477    // Add screen option if not already added
     478    if (!empty($screen) && !$screen->get_option('per_page')) {
     479        add_screen_option('per_page', [
     480            'default' => 20,
     481            'option' => 'quentn_access_overview_records_per_page',
     482            'label' => __('Records per page', 'quentn-wp')
     483        ]);
     484    }
     485
    473486    $qntn_list_table->prepare_items();
    474487
  • quentn-wp/trunk/includes/class-quentn-wp-page-restrictions-list.php

    r3073163 r3281980  
    4848        $per_page     = $this->get_items_per_page( 'quentn_restricted_records_per_page', 20 );
    4949        $current_page = $this->get_pagenum();
    50         $total_items  = count( $this->get_restricted_pages() );
     50        $total_items = $this->get_total_restricted_pages_count();
    5151
    5252        $this->set_pagination_args( array(
     
    139139     * @return array
    140140     */
    141     public function get_quentn_restrictions( $per_page = 20, $page_number = 1 ) {
    142 
    143         $restricted_pages = $this->get_restricted_pages();
    144         if( count( $restricted_pages ) < 1 ) {
     141    public function get_quentn_restrictions($per_page = 20, $page_number = 1) {
     142        $restricted_pages = $this->get_restricted_pages($per_page, $page_number);
     143
     144        if(empty($restricted_pages)) {
    145145            return array();
    146146        }
    147147
    148148        $result = array();
    149 
    150         //get number of access links for all restricted pages
    151         $restricted_pages_ids = array_column( $restricted_pages, 'ID' );
    152         $number_of_access_links = $this->access_links_count( $restricted_pages_ids );
    153 
    154         foreach( $restricted_pages as $restricted_page )
    155         {
    156             //get meta of page
    157             $quentn_post_restrict_meta = get_post_meta( $restricted_page->ID, '_quentn_post_restrict_meta', true );
    158 
    159             $restriction_type = ( isset( $quentn_post_restrict_meta['countdown'] ) && $quentn_post_restrict_meta['countdown'] ) ? __( 'CountDown', 'quentn-wp' ): __( 'Access', 'quentn-wp' );
     149        $restricted_pages_ids = wp_list_pluck($restricted_pages, 'ID');
     150        $number_of_access_links = $this->access_links_count($restricted_pages_ids);
     151
     152        foreach($restricted_pages as $restricted_page) {
     153            $quentn_post_restrict_meta = get_post_meta($restricted_page->ID, '_quentn_post_restrict_meta', true);
     154
     155            $restriction_type = (isset($quentn_post_restrict_meta['countdown']) && $quentn_post_restrict_meta['countdown'])
     156                ? __('CountDown', 'quentn-wp')
     157                : __('Access', 'quentn-wp');
    160158
    161159            $result[] = array(
     
    163161                "page_title"         => $restricted_page->post_title,
    164162                "restriction_type"   => $restriction_type,
    165                 "total_access_links" => isset( $number_of_access_links[$restricted_page->ID] ) ? $number_of_access_links[$restricted_page->ID] : 0 ,
     163                "total_access_links" => isset($number_of_access_links[$restricted_page->ID])
     164                    ? $number_of_access_links[$restricted_page->ID]
     165                    : 0,
    166166            );
    167167        }
     168
    168169        return $result;
    169170    }
     171
    170172
    171173    /**
     
    225227    }
    226228
    227     /**
    228      * get restricted pages list
    229      *
    230      * @since  1.2.8
    231      * @access public
    232      * @return void
    233      */
    234     public function get_restricted_pages() {
    235 
    236         $restricted_pages_query = new WP_Query( array(
    237             'post_type' => 'page',
    238             'meta_key' => '_quentn_post_restrict_meta',
    239             'orderby' => 'title',
    240             'order' => 'ASC',
    241         ) );
    242         $restricted_pages = [];
    243         if ( $restricted_pages_query->have_posts() ) {
    244             $restricted_pages = $restricted_pages_query->posts;
    245         }
    246         return $restricted_pages;
    247     }
     229    /**
     230     * Get restricted pages list with pagination support
     231     *
     232     * @since  1.2.8
     233     * @access public
     234     * @param int $per_page Number of items per page
     235     * @param int $page_number Current page number
     236     * @return array
     237     */
     238    public function get_restricted_pages($per_page = 20, $page_number = 1) {
     239        $args = array(
     240            'post_type'      => 'page',
     241            'meta_key'       => '_quentn_post_restrict_meta',
     242            'orderby'        => 'title',
     243            'order'          => 'ASC',
     244            'posts_per_page' => $per_page,
     245            'paged'          => $page_number,
     246            'fields'         => 'all', // Get full post objects
     247        );
     248
     249        $restricted_pages_query = new WP_Query($args);
     250        return $restricted_pages_query->posts;
     251    }
     252
     253    /**
     254     * Get total count of restricted pages
     255     *
     256     * @return int
     257     */
     258    public function get_total_restricted_pages_count() {
     259        $args = array(
     260            'post_type'  => 'page',
     261            'meta_key'   => '_quentn_post_restrict_meta',
     262            'fields'     => 'ids',
     263            'posts_per_page' => -1,
     264        );
     265
     266        $query = new WP_Query($args);
     267        return $query->found_posts;
     268    }
    248269}
    249270
     
    255276 */
    256277function quentn_show_data_page_restrictions_list() {
    257     ?>
    258     <h3><?php _e( 'List of Pages With Limited Access', 'quentn-wp' ); ?></h3>
    259     <?php
    260278    $qntn_list_table = new Quentn_Wp_Page_Restrictions_List();
     279
     280    // Get current screen
     281    $screen = get_current_screen();
     282
     283    // Add screen option if not already added
     284    if (!empty($screen) && !$screen->get_option('per_page')) {
     285        add_screen_option('per_page', [
     286            'default' => 20,
     287            'option' => 'quentn_restricted_records_per_page',
     288            'label' => __('Records per page', 'quentn-wp')
     289        ]);
     290    }
     291
     292    echo '<div class="wrap">';
     293    echo '<h1>' . __('List of Pages With Limited Access', 'quentn-wp') . '</h1>';
    261294    $qntn_list_table->prepare_items();
    262295    $qntn_list_table->display();
     296    echo '</div>';
    263297}
    264298
  • quentn-wp/trunk/includes/class-quentn-wp-rest-api-controller.php

    r3266340 r3281980  
    592592        $wp_roles = new WP_Roles();
    593593        $all_roles = $wp_roles->get_names();
     594        unset($all_roles['administrator']); //do not support anymore to add administrator role using api
    594595        //todo remove json_encode function
    595596        return rest_ensure_response( json_encode( $all_roles ) );
     
    863864            return new WP_Error('page_access_call_failed', $wpdb->last_error);
    864865        }
    865 
    866866
    867867        //prepare response data
  • quentn-wp/trunk/includes/class-quentn-wp.php

    r3266340 r3281980  
    7575            $this->version = QUENTN_WP_VERSION;
    7676        } else {
    77             $this->version = '1.2.10';
     77            $this->version = '1.2.11';
    7878        }
    7979        $this->plugin_name = 'quentn-wp';
     
    294294        $this->loader->add_action( 'wp_ajax_quentn_dismiss_member_plugin_notice', $plugin_admin, 'member_plugin_notice_dismiss_ajax_handler' );
    295295
     296        $this->loader->add_action( 'in_plugin_update_message-'.Helper::get_plugin_name(), $plugin_admin, 'version_update_warning' );
     297
    296298        //filter screen options
    297299        $this->loader->add_filter( 'set-screen-option', $plugin_admin, 'set_screen_option', 10, 3 );
  • quentn-wp/trunk/languages/quentn-wp-de_DE.po

    r3073163 r3281980  
    33"Project-Id-Version: Quentn wp\n"
    44"POT-Creation-Date: 2019-08-07 17:34+0200\n"
    5 "PO-Revision-Date: 2024-03-19 14:43+0100\n"
     5"PO-Revision-Date: 2025-04-25 18:13+0500\n"
    66"Last-Translator: \n"
    77"Language-Team: Quentn GmbH\n"
     
    1111"Content-Transfer-Encoding: 8bit\n"
    1212"Plural-Forms: nplurals=2; plural=(n != 1);\n"
    13 "X-Generator: Poedit 3.4.2\n"
     13"X-Generator: Poedit 3.6\n"
    1414"X-Poedit-Basepath: ..\n"
    1515"X-Poedit-KeywordsList: __;_e;_n;esc_html__;esc_html_e\n"
     
    606606msgid "User access could not be deleted."
    607607msgstr "Benutzerzugang konnte nicht gelöscht werden."
     608
     609msgid "This is an important update! Please update immediately to version 1.2.9 or higher!"
     610msgstr "Wichtiges Update! Bitte update umgehend auf die Version 1.2.9 oder höher!"
  • quentn-wp/trunk/languages/quentn-wp.pot

    r3073163 r3281980  
    612612msgid "User access could not be deleted."
    613613msgstr ""
     614
     615msgid "This is an important update! Please update immediately to version 1.2.9 or higher!"
     616msgstr ""
  • quentn-wp/trunk/quentn-wp.php

    r3266340 r3281980  
    1717 * Plugin URI:        https://docs.quentn.com/de/beta-quentn-wordpress-plugin/installieren-und-verbinden
    1818 * Description:       This plugin allows you to restrict access to specific pages, create custom access links and create dynamic page countdowns. Optionally, you can connect your Quentn account to your WordPress installation to share contacts and manage access restrictions through Quentn.
    19  * Version:           1.2.10
     19 * Version:           1.2.11
    2020 * Author:            Quentn.com GmbH
    2121 * Author URI:        https://quentn.com/
     
    3535define( "QUENTN_WP_PLUGIN_DIR", plugin_dir_path( __FILE__ ) );
    3636define( "QUENTN_WP_PLUGIN_URL", plugin_dir_url(  __FILE__ ) );
    37 define( 'QUENTN_WP_VERSION', '1.2.10' );
     37define( 'QUENTN_WP_VERSION', '1.2.11' );
    3838define( 'QUENTN_WP_DB_VERSION', '1.1' );
    3939
  • quentn-wp/trunk/readme.txt

    r3266340 r3281980  
    44Requires at least: 4.6.0
    55Tested up to: 6.7.2
    6 Stable tag: 1.2.10
     6Stable tag: 1.2.11
    77Requires PHP: 5.6.0
    88License: GPLv2 or later
     
    6767== Changelog ==
    6868
     69= 1.2.11 =
     70* Fix: Fixed pagination and screen options for list of restricted pages and access overview.
     71
    6972= 1.2.10 =
    7073* Fix: Update user messages
     
    175178== Upgrade Notice ==
    176179
     180= 1.2.11 - Security Update =
     181Thanks for using Quentn Plugin! Please update the plugin to fix pagination and screen options for list of restricted pages and access overview.
     182
    177183= 1.2.10 - Security Update =
    178184This is a critical security update. It addresses potential SQL injection vulnerabilities found in previous versions. Please update immediately to ensure your site remains secure.
Note: See TracChangeset for help on using the changeset viewer.