Changeset 3069819
- Timestamp:
- 04/13/2024 12:42:02 AM (4 months ago)
- Location:
- media-library-assistant/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
media-library-assistant/trunk/examples/plugins/mla-multi-search-example.php
r1926030 r3069819 6 6 * 7 7 * 1. A custom "multi_search" parameter names one or more "search keys", e.g. 8 * multi_search="keyword:,custom:Country,custom:City" 9 * 10 * 2. Each custom field is queried for a LIKE match with the content of the "s" parameter. 8 * multi_search="keyword:,custom:Country,custom:City" 9 * Where "keyword:" performs the usual Keyword(s) search 10 * and "custom:" searches the custom fields names in the list. 11 * You can code "custom:*" to search ALL custom fields without naming them. 12 * 13 * 2. Each custom field is queried for a LIKE match with the content of the "s" parameter.<br /> 14 * Note that this is more limited than the logic provided by the Keyword(s) Search function. 11 15 * 12 16 * 3. Matches from the custom field search(es) are added to any keyword(s) search matches, … … 20 24 * https://wordpress.org/support/topic/gallery-layout-with-thumbnails/ 21 25 * 26 27 28 29 22 30 * @package MLA Multi-search Example 23 * @version 1.0 131 * @version 1.0 24 32 */ 25 33 … … 29 37 Description: Adds custom field search(es) to the [mla_gallery] keyword(s) search results 30 38 Author: David Lingren 31 Version: 1.0 139 Version: 1.0 32 40 Author URI: http://davidlingren.com/ 33 41 34 Copyright 2016 David Lingren42 Copyright 2016 David Lingren 35 43 36 44 This program is free software; you can redistribute it and/or modify … … 59 67 class MLAMultiSearchExample { 60 68 /** 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 61 87 * Initialization function, similar to __construct() 62 88 * … … 91 117 */ 92 118 public static function mla_gallery_attributes( $shortcode_attributes ) { 93 //error_log( 'MLAMultiSearchExample::mla_gallery_attributes $shortcode_attributes = ' . var_export( $shortcode_attributes, true ), 0 ); 119 if ( isset( $shortcode_attributes['multi_search'] ) ) { 120 MLACore::mla_debug_add( __LINE__ . " MLAMultiSearchExample::mla_gallery_attributes \$shortcode_attributes = " . var_export( $shortcode_attributes, true ), self::MLA_DEBUG_CATEGORY ); 121 } 122 94 123 // Save the attributes for use in the later filters 95 124 self::$shortcode_attributes = $shortcode_attributes; … … 98 127 return $shortcode_attributes; 99 128 } // mla_gallery_attributes 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 100 150 101 151 /** … … 119 169 global $post; 120 170 171 172 121 173 $multi_search = self::$shortcode_attributes['multi_search']; 122 174 unset( self::$shortcode_attributes['multi_search'] ); … … 141 193 142 194 $results = array(); 143 $search_value = !empty( self::$shortcode_attributes['s'] ) ? trim( self::$shortcode_attributes['s'] ) : '';195 $search_value = !empty( self::$shortcode_attributes['s'] ) ? trim( self::$shortcode_attributes['s'] ) : ''; 144 196 $search_keys = explode( ',', $multi_search ); 197 198 199 200 201 202 203 204 205 206 207 208 145 209 146 210 foreach( $search_keys as $search_key ) { 147 211 $tokens = array_map( 'trim', explode( ':', $search_key ) ); 212 148 213 switch ( $tokens[0] ) { 149 214 case 'keyword': … … 166 231 167 232 if ( is_string( $attachments ) ) { 233 168 234 $attachments = array(); 235 236 169 237 } 170 238 171 239 unset( $attachments['found_rows'] ); 172 240 unset( $attachments['max_num_pages'] ); … … 179 247 if ( count( $results ) ) { 180 248 $all_query_parameters['include'] = implode( ',', $results ); 249 181 250 } else { 182 251 $all_query_parameters['include'] = '1'; … … 190 259 } // Class MLAMultiSearchExample 191 260 192 /* 193 * Install the filters at an early opportunity 194 */ 261 // Install the filters at an early opportunity 195 262 add_action('init', 'MLAMultiSearchExample::initialize'); 196 263 ?> -
media-library-assistant/trunk/includes/class-mla-core.php
r3060779 r3069819 31 31 * @var string 32 32 */ 33 const MLA_DEVELOPMENT_VERSION = ' ';33 const MLA_DEVELOPMENT_VERSION = ''; 34 34 35 35 /** … … 793 793 if ( ( false !== strpos( $location, 'upload.php?' ) ) || ( false !== strpos( $location, 'post.php?' ) ) ) { 794 794 if ( isset( $_REQUEST['mla_source'] ) ) { 795 $location = add_query_arg( array( 'mla_source' => sanitize_text_field( wp_unslash( $_REQUEST['mla_source']) ) ), $location );795 $location = add_query_arg( array( 'mla_source' => ) ) ), $location ); 796 796 } 797 797 } -
media-library-assistant/trunk/includes/class-mla-edit-media.php
r2988720 r3069819 1078 1078 $view_args = array( 'page' => MLACore::ADMIN_PAGE_SLUG, 'mla_item_ID' => $post->ID ); 1079 1079 if ( isset( $_REQUEST['mla_source'] ) ) { 1080 $view_args['mla_source'] = sanitize_text_field( wp_unslash( $_REQUEST['mla_source']) );1080 $view_args['mla_source'] = ) ); 1081 1081 1082 // apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-post_{$post->ID}" ), $post->ID, $force_delete ) in /wp-includes/link-template.php1083 1082 add_filter( 'get_delete_post_link', 'MLAEdit::get_delete_post_link_filter', 10, 3 ); 1084 1083 } 1085 1084 1086 1085 if ( isset( $_REQUEST['lang'] ) ) { 1087 $view_args['lang'] = sanitize_text_field( wp_unslash( $_REQUEST['lang']) );1086 $view_args['lang'] = ) ); 1088 1087 } 1089 1088 -
media-library-assistant/trunk/includes/class-mla-shortcode-custom-list.php
r3057514 r3069819 1 1 <?php 2 2 /** 3 * Media Library Assistant TermList Shortcode3 * Media Library Assistant List Shortcode 4 4 * 5 5 * @package Media Library Assistant … … 1801 1801 $clause_parameters = array( $arguments['meta_key'] ); 1802 1802 $clause = array ( $wpdb->prepare( 'm.meta_key = \'' . join( ',', $placeholders ) . '\'', $clause_parameters ) ); // phpcs:ignore 1803 // $clause = array( "m.meta_key = '" . $arguments['meta_key'] . "'" );1804 1803 1805 1804 $clause_parameters = array(); … … 1807 1806 1808 1807 /* 1809 * The "ids" parameter can build an item-specific cloud.1810 * Compile a list of all the terms assigned to the items.1808 * The "ids" parameter can build an item-specific . 1809 * Compile a list of all the s assigned to the items. 1811 1810 */ 1812 1811 if ( ! empty( $arguments['ids'] ) ) { 1813 1812 $ids = wp_parse_id_list( $arguments['ids'] ); 1814 $ placeholders= implode( "','", $ids );1815 $clause[] = "AND m.post_id IN ( '{$ placeholders}' )";1813 $ = implode( "','", $ids ); 1814 $clause[] = "AND m.post_id IN ( '{$}' )"; 1816 1815 1817 1816 $includes = array(); … … 1827 1826 // Apply a non-empty argument before we replace it. 1828 1827 if ( ! empty( $arguments['include'] ) ) { 1829 $includes = array_intersect( $includes, wp_parse_id_list( $arguments['include'] ) );1830 } 1831 1832 // If there are no values we want an empty cloud1828 $includes = array_intersect( $includes, ( $arguments['include'] ) ); 1829 } 1830 1831 // If there are no values we want an empty 1833 1832 if ( empty( $includes ) ) { 1834 1833 $arguments['include'] = (string) 0x7FFFFFFF; … … 1839 1838 } 1840 1839 1841 // Add include/exclude and parentconstraints to WHERE cluse1840 // Add include/exclude constraints to WHERE cluse 1842 1841 if ( ! empty( $arguments['include'] ) ) { 1843 $placeholders = implode( "','", str_getcsv( $arguments['include'] ) ); 1844 $clause[] = "AND m.meta_value IN ( '{$placeholders}' )"; 1842 $includes = str_getcsv( $arguments['include'] ); 1843 foreach ( $includes as $include ) { 1844 $placeholders[] = '%s'; 1845 $clause_parameters[] = $include; 1846 } 1847 1848 $clause[] = 'AND m.meta_value IN (' . join( ',', $placeholders ) . ')'; 1845 1849 } elseif ( ! empty( $arguments['exclude'] ) ) { 1846 $placeholders = implode( "','", str_getcsv( $arguments['exclude'] ) ); 1847 $clause[] = "AND m.meta_value NOT IN ( '{$placeholders}' )"; 1850 $excludes = str_getcsv( $arguments['exclude'] ); 1851 foreach ( $excludes as $exclude ) { 1852 $placeholders[] = '%s'; 1853 $clause_parameters[] = $exclude; 1854 } 1855 1856 $clause[] = 'AND m.meta_value NOT IN (' . join( ',', $placeholders ) . ')'; 1848 1857 } 1849 1858 -
media-library-assistant/trunk/index.php
r3060779 r3069819 16 16 Plugin Name: Media Library Assistant 17 17 Plugin URI: http://davidlingren.com/#two 18 Description: Enhances the Media Library; powerful [mla_gallery] [mla_tag_cloud] [mla_term_list], taxonomy support, IPTC/EXIF/XMP/PDF processing, bulk/quick edit.18 Description: Enhances the Media Library; powerful [mla_gallery] [mla_tag_cloud] [mla_term_list], taxonomy support, IPTC/EXIF/XMP/PDF processing, bulk/quick edit. 19 19 Version: 3.15 20 20 Requires at least: 4.1 -
media-library-assistant/trunk/readme.txt
r3060779 r3069819 187 187 188 188 == Changelog == 189 190 191 192 193 194 189 195 190 196 = 3.15 =
Note: See TracChangeset
for help on using the changeset viewer.