Changeset 3463709
- Timestamp:
- 02/17/2026 05:18:44 PM (3 months ago)
- Location:
- xv-random-quotes/trunk
- Files:
-
- 8 edited
-
changelog.txt (modified) (1 diff)
-
js/quote-refresh.js (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
-
src/Output/QuoteOutput.php (modified) (3 diffs)
-
src/RestAPI/QuoteEndpoint.php (modified) (4 diffs)
-
src/Shortcodes/ShortcodeHandlers.php (modified) (2 diffs)
-
vendor/composer/installed.php (modified) (2 diffs)
-
xv-random-quotes.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
xv-random-quotes/trunk/changelog.txt
r3435421 r3463709 1 1 == XV Random Quotes == 2 3 = 2.6.1 = 4 Fix: Sequential mode now works on shortcodes 5 Fix: LinkPhrase not being required for AJAX shortcodes 6 Improvement: Added `enable_ajax` as an equivalent (in reverse) to `noajax` for shortcodes. 2 7 3 8 = 2.6.0 = -
xv-random-quotes/trunk/js/quote-refresh.js
r3429339 r3463709 56 56 const disableaspect = container.getAttribute('data-disableaspect') === '1'; 57 57 const contributor = container.getAttribute('data-contributor') || ''; 58 const currentId = container.getAttribute('data-current-id') || ''; 58 59 59 60 // Build query string … … 64 65 if (sequence) { 65 66 params.append('sequence', '1'); 67 // For sequential mode, send current ID to get next quote 68 if (currentId) { 69 params.append('current_id', currentId); 70 } 66 71 } 67 72 if (multi > 1) { … … 105 110 // Get the refresh link wrapper to preserve it 106 111 const refreshWrapper = container.querySelector('.xv-quote-refresh-wrapper'); 107 112 108 113 // Update the container content 109 114 // We need to replace everything except the refresh link 110 115 const tempDiv = document.createElement('div'); 111 116 tempDiv.innerHTML = data.html; 112 117 113 118 // Clear container except for refresh wrapper 114 119 while (container.firstChild && container.firstChild !== refreshWrapper) { 115 120 container.removeChild(container.firstChild); 116 121 } 117 122 118 123 // Insert new content before refresh wrapper 119 124 if (refreshWrapper) { … … 125 130 container.innerHTML = data.html; 126 131 } 127 132 133 // Update current ID for sequential tracking 134 if (data.quote_id) { 135 container.setAttribute('data-current-id', data.quote_id); 136 } 137 138 // Handle end of sequence 139 if (data.end_of_sequence && refreshWrapper) { 140 const refreshLink = refreshWrapper.querySelector('.xv-quote-refresh'); 141 if (refreshLink) { 142 refreshLink.style.display = 'none'; 143 } 144 } 145 128 146 // Fade in 129 147 container.style.opacity = '1'; -
xv-random-quotes/trunk/readme.txt
r3435421 r3463709 6 6 Tested up to: 6.9 7 7 Requires PHP: 7.4 8 Stable tag: 2.6. 08 Stable tag: 2.6.1 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
xv-random-quotes/trunk/src/Output/QuoteOutput.php
r3431360 r3463709 118 118 // Wrap with AJAX functionality if enabled 119 119 if ( $args['enable_ajax'] ) { 120 return $this->wrap_with_ajax( $quote_html, $args );120 return $this->wrap_with_ajax( $quote_html, $args, $quotes ); 121 121 } 122 122 … … 129 129 * @param string $quote_html The rendered quote HTML. 130 130 * @param array $args Arguments array with AJAX configuration. 131 * @param array $quotes Array of WP_Post quote objects being displayed. 131 132 * @return string HTML wrapped with AJAX functionality. 132 133 */ 133 private function wrap_with_ajax( $quote_html, $args ) {134 private function wrap_with_ajax( $quote_html, $args, $quotes = array() ) { 134 135 // Generate or use provided container ID 135 136 $container_id = ! empty( $args['container_id'] ) ? $args['container_id'] : 'xv-quote-container-' . uniqid(); … … 144 145 if ( ! empty( $args['contributor'] ) ) { 145 146 $output .= ' data-contributor="' . esc_attr( $args['contributor'] ) . '"'; 147 } 148 149 // Add current quote ID(s) for sequential tracking 150 if ( ! empty( $quotes ) ) { 151 if ( $args['multi'] > 1 ) { 152 // For multiple quotes, store comma-separated IDs 153 $quote_ids = array_map( function( $quote ) { 154 return $quote->ID; 155 }, $quotes ); 156 $output .= ' data-current-id="' . esc_attr( implode( ',', $quote_ids ) ) . '"'; 157 } else { 158 // For single quote, store just the ID 159 $output .= ' data-current-id="' . esc_attr( $quotes[0]->ID ) . '"'; 160 } 146 161 } 147 162 -
xv-random-quotes/trunk/src/RestAPI/QuoteEndpoint.php
r3431360 r3463709 80 80 'sanitize_callback' => 'sanitize_text_field', 81 81 ), 82 'current_id' => array( 83 'description' => 'Current quote ID(s) for sequential progression (comma-separated for multi)', 84 'type' => 'string', 85 'default' => '', 86 'sanitize_callback' => 'sanitize_text_field', 87 ), 82 88 ); 83 89 } … … 96 102 $disableaspect = $request->get_param( 'disableaspect' ); 97 103 $contributor = $request->get_param( 'contributor' ); 104 $current_id = $request->get_param( 'current_id' ); 98 105 99 106 // Get quotes first (before rendering) … … 107 114 'posts_per_page' => $multi, 108 115 ); 109 116 110 117 // Add ordering 111 118 if ( $sequence ) { 112 119 $query_args['orderby'] = 'date'; 113 120 $query_args['order'] = 'ASC'; 121 122 // If current_id is provided, get the next quote(s) after it 123 if ( ! empty( $current_id ) ) { 124 // For multi-quote, get the last ID 125 $current_ids = explode( ',', $current_id ); 126 $last_id = end( $current_ids ); 127 128 // Get the post to find its date 129 $current_post = get_post( absint( $last_id ) ); 130 if ( $current_post ) { 131 // Query for quotes published after this date 132 $query_args['date_query'] = array( 133 array( 134 'after' => $current_post->post_date, 135 'inclusive' => false, 136 ), 137 ); 138 } 139 } 114 140 } else { 115 141 $query_args['orderby'] = 'rand'; 116 142 } 117 143 118 144 // Get quotes 119 145 if ( ! empty( $categories_array ) ) { … … 156 182 ); 157 183 184 // Check if we've reached the end of sequence 185 $end_of_sequence = false; 186 if ( $sequence && ! empty( $current_id ) ) { 187 // If we got quotes, check if there are more after these 188 if ( ! empty( $quotes ) ) { 189 $last_quote = end( $quotes ); 190 $check_query_args = array( 191 'posts_per_page' => 1, 192 'fields' => 'ids', 193 'orderby' => 'date', 194 'order' => 'ASC', 195 'date_query' => array( 196 array( 197 'after' => $last_quote->post_date, 198 'inclusive' => false, 199 ), 200 ), 201 ); 202 203 // Check for more quotes 204 if ( ! empty( $categories_array ) ) { 205 $more_quotes = $quote_queries->get_quotes_by_categories( $categories_array, $check_query_args ); 206 } else { 207 $more_quotes = $quote_queries->get_all_quotes( $check_query_args ); 208 } 209 210 $end_of_sequence = empty( $more_quotes ); 211 } 212 } 213 214 $response_data['end_of_sequence'] = $end_of_sequence; 215 158 216 // Add metadata for single quote 159 217 if ( $multi === 1 && ! empty( $quotes ) && count( $quotes ) > 0 ) { 160 218 $quote = $quotes[0]; 161 219 162 220 $response_data['quote_id'] = $quote->ID; 163 221 $response_data['quote_text'] = wp_strip_all_tags( $quote->post_content ); 164 222 $response_data['quote_content'] = $quote->post_content; 165 223 166 224 // Get author 167 225 $authors = wp_get_post_terms( $quote->ID, 'quote_author' ); 168 $response_data['author'] = ! empty( $authors ) && ! is_wp_error( $authors ) 169 ? $authors[0]->name 226 $response_data['author'] = ! empty( $authors ) && ! is_wp_error( $authors ) 227 ? $authors[0]->name 170 228 : ''; 171 229 172 230 // Get source 173 231 $response_data['source'] = get_post_meta( $quote->ID, '_quote_source', true ); 174 232 175 233 // Get categories 176 234 $categories_terms = wp_get_post_terms( $quote->ID, 'quote_category' ); -
xv-random-quotes/trunk/src/Shortcodes/ShortcodeHandlers.php
r3430809 r3463709 110 110 'widgetid' => '', 111 111 'noajax' => '', 112 'enable_ajax' => '', 112 113 'multi' => 1, 113 114 'timer' => '', … … 118 119 )); 119 120 120 // Determine if AJAX is enabled (noajax="" means enabled) 121 $enable_ajax = empty( $atts['noajax'] ) && ! empty( $atts['linkphrase'] ); 121 // Determine if AJAX is enabled 122 // Priority order: 123 // 1. If enable_ajax is explicitly set, use it (true = enable, false = disable) 124 // 2. Otherwise, use legacy noajax logic (noajax="" or false = enable, noajax="true" = disable) 125 // 3. Check global AJAX setting (if globally disabled, override to false) 126 if ( ! empty( $atts['enable_ajax'] ) ) { 127 // Explicit enable_ajax parameter takes priority 128 $enable_ajax = filter_var( $atts['enable_ajax'], FILTER_VALIDATE_BOOLEAN ); 129 } else { 130 // Legacy noajax logic: empty/false = AJAX enabled 131 $enable_ajax = empty( $atts['noajax'] ); 132 } 133 134 // Check global AJAX setting (if disabled globally, override to false) 135 $global_ajax_disabled = get_option( \XVRandomQuotes\Admin\Settings::OPTION_AJAX, false ); 136 if ( $global_ajax_disabled ) { 137 $enable_ajax = false; 138 } 122 139 123 140 // Use QuoteOutput class for complete rendering (including AJAX if enabled) -
xv-random-quotes/trunk/vendor/composer/installed.php
r3435421 r3463709 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => 'c 5c63fb91808ddbfdfb9ab496437bfe15ad21871',6 'reference' => 'ce36e0cf96881317dd73f3a6f9cdd2878096ee62', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => 'c 5c63fb91808ddbfdfb9ab496437bfe15ad21871',16 'reference' => 'ce36e0cf96881317dd73f3a6f9cdd2878096ee62', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', -
xv-random-quotes/trunk/xv-random-quotes.php
r3435421 r3463709 5 5 Author: Xavi Ivars 6 6 Author URI: https://xavi.ivars.me/ 7 Version: 2.6. 07 Version: 2.6.1 8 8 Requires at least: 6.0 9 9 Requires PHP: 7.4
Note: See TracChangeset
for help on using the changeset viewer.