Skip to content

Commit

Permalink
1.2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Stiofan committed Sep 12, 2024
1 parent 077bbe6 commit 3f70ce4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
3 changes: 3 additions & 0 deletions change-log.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
= 1.2.8 - 2024-09-12 =
* Template get_pages call changed to custom query for better memory management - CHANGED

= 1.2.7 - 2024-08-29 =
* Fix conflicts with UpSolution Core plugin - FIXED

Expand Down
32 changes: 23 additions & 9 deletions sd-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3165,18 +3165,12 @@ function sd_visibility_output_options() {
* @return array Template page options.
*/
function sd_template_page_options( $args = array() ) {
global $sd_tmpl_page_options;
global $sd_tmpl_page_options,$wpdb;

if ( ! empty( $sd_tmpl_page_options ) ) {
return $sd_tmpl_page_options;
}

$args = wp_parse_args( $args, array(
'child_of' => 0,
'sort_column' => 'post_title',
'sort_order' => 'ASC'
) );

$exclude_pages = array();
if ( $page_on_front = get_option( 'page_on_front' ) ) {
$exclude_pages[] = $page_on_front;
Expand All @@ -3186,11 +3180,31 @@ function sd_template_page_options( $args = array() ) {
$exclude_pages[] = $page_for_posts;
}

$exclude_pages_placeholders = '';
if ( ! empty( $exclude_pages ) ) {
// Sanitize the array of excluded pages and implode it for the SQL query
$exclude_pages_placeholders = implode(',', array_fill(0, count($exclude_pages), '%d'));
}

// Prepare the base SQL query, including child_of = 0 (only root-level pages)
$sql = "
SELECT ID, post_title
FROM $wpdb->posts
WHERE post_type = 'page'
AND post_status = 'publish'
AND post_parent = 0
";

// Add the exclusion if there are pages to exclude
if ( ! empty( $exclude_pages ) ) {
$args['exclude'] = $exclude_pages;
$sql .= " AND ID NOT IN ($exclude_pages_placeholders)";
}

$pages = get_pages( $args );
// Add sorting
$sql .= " ORDER BY post_title ASC";

// Prepare the SQL query to include the excluded pages
$pages = $wpdb->get_results( $wpdb->prepare( $sql, ...$exclude_pages ) );

$options = array( '' => __( 'Select Page...', 'ayecode-connect' ) );
if ( ! empty( $pages ) ) {
Expand Down
2 changes: 1 addition & 1 deletion sd-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @wordpress-plugin
* Plugin Name: Super Duper - Examples
* Description: This is a Hello World test plugin for WP Super Duper Class.
* Version: 1.2.7
* Version: 1.2.8
* Author: AyeCode
* Author URI: https://ayecode.io
* Text Domain: super-duper
Expand Down
2 changes: 1 addition & 1 deletion wp-super-duper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

if ( ! class_exists( 'WP_Super_Duper' ) ) {

define( 'SUPER_DUPER_VER', '1.2.7' );
define( 'SUPER_DUPER_VER', '1.2.8' );

/**
* A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
Expand Down

0 comments on commit 3f70ce4

Please sign in to comment.