Changeset 2616974
- Timestamp:
- 10/20/2021 07:32:45 AM (4 years ago)
- Location:
- snip-structured-data
- Files:
-
- 3 edited
- 43 copied
-
tags/2.28.1 (copied) (copied from snip-structured-data/trunk)
-
tags/2.28.1/classes/controller/admin-post.php (copied) (copied from snip-structured-data/trunk/classes/controller/admin-post.php) (4 diffs)
-
tags/2.28.1/classes/controller/admin-scripts.php (copied) (copied from snip-structured-data/trunk/classes/controller/admin-scripts.php)
-
tags/2.28.1/classes/controller/admin-settings.php (copied) (copied from snip-structured-data/trunk/classes/controller/admin-settings.php)
-
tags/2.28.1/classes/controller/admin-setup-wizard.php (copied) (copied from snip-structured-data/trunk/classes/controller/admin-setup-wizard.php)
-
tags/2.28.1/classes/controller/admin-snippets.php (copied) (copied from snip-structured-data/trunk/classes/controller/admin-snippets.php)
-
tags/2.28.1/classes/controller/admin-uninstall.php (copied) (copied from snip-structured-data/trunk/classes/controller/admin-uninstall.php)
-
tags/2.28.1/classes/controller/admin.php (copied) (copied from snip-structured-data/trunk/classes/controller/admin.php)
-
tags/2.28.1/classes/controller/frontend.php (copied) (copied from snip-structured-data/trunk/classes/controller/frontend.php)
-
tags/2.28.1/classes/controller/rest.php (copied) (copied from snip-structured-data/trunk/classes/controller/rest.php)
-
tags/2.28.1/classes/model/fields.php (copied) (copied from snip-structured-data/trunk/classes/model/fields.php)
-
tags/2.28.1/classes/model/helper.php (copied) (copied from snip-structured-data/trunk/classes/model/helper.php)
-
tags/2.28.1/classes/model/posttypes.php (copied) (copied from snip-structured-data/trunk/classes/model/posttypes.php)
-
tags/2.28.1/classes/model/schemas.php (copied) (copied from snip-structured-data/trunk/classes/model/schemas.php)
-
tags/2.28.1/classes/model/snippets.php (copied) (copied from snip-structured-data/trunk/classes/model/snippets.php)
-
tags/2.28.1/classes/objects/position-rule.php (copied) (copied from snip-structured-data/trunk/classes/objects/position-rule.php)
-
tags/2.28.1/classes/objects/rich-snippet.php (copied) (copied from snip-structured-data/trunk/classes/objects/rich-snippet.php)
-
tags/2.28.1/classes/objects/settings-setting.php (copied) (copied from snip-structured-data/trunk/classes/objects/settings-setting.php)
-
tags/2.28.1/classes/rich-snippets-plugin.php (copied) (copied from snip-structured-data/trunk/classes/rich-snippets-plugin.php)
-
tags/2.28.1/classes/view/admin/intro.php (copied) (copied from snip-structured-data/trunk/classes/view/admin/intro.php)
-
tags/2.28.1/classes/view/admin/posts/metabox/options.php (copied) (copied from snip-structured-data/trunk/classes/view/admin/posts/metabox/options.php)
-
tags/2.28.1/classes/view/admin/setupwizard.php (copied) (copied from snip-structured-data/trunk/classes/view/admin/setupwizard.php)
-
tags/2.28.1/classes/view/admin/snippets/metabox/news.php (copied) (copied from snip-structured-data/trunk/classes/view/admin/snippets/metabox/news.php)
-
tags/2.28.1/img/examples (copied) (copied from snip-structured-data/trunk/img/examples)
-
tags/2.28.1/img/people.svg (copied) (copied from snip-structured-data/trunk/img/people.svg)
-
tags/2.28.1/js/admin-posts.js (copied) (copied from snip-structured-data/trunk/js/admin-posts.js)
-
tags/2.28.1/js/admin-snippets-free.js (copied) (copied from snip-structured-data/trunk/js/admin-snippets-free.js)
-
tags/2.28.1/js/admin-snippets.js (copied) (copied from snip-structured-data/trunk/js/admin-snippets.js)
-
tags/2.28.1/js/build (copied) (copied from snip-structured-data/trunk/js/build)
-
tags/2.28.1/js/build/admin-setupwizard.js (copied) (copied from snip-structured-data/trunk/js/build/admin-setupwizard.js)
-
tags/2.28.1/js/build/admin-setupwizard.js.map (copied) (copied from snip-structured-data/trunk/js/build/admin-setupwizard.js.map)
-
tags/2.28.1/js/build/admin-snippets.js (copied) (copied from snip-structured-data/trunk/js/build/admin-snippets.js)
-
tags/2.28.1/js/build/admin-snippets.js.map (copied) (copied from snip-structured-data/trunk/js/build/admin-snippets.js.map)
-
tags/2.28.1/js/build/schema-property.js (copied) (copied from snip-structured-data/trunk/js/build/schema-property.js)
-
tags/2.28.1/js/build/schema-property.js.map (copied) (copied from snip-structured-data/trunk/js/build/schema-property.js.map)
-
tags/2.28.1/languages/rich-snippets-schema-de_DE.mo (copied) (copied from snip-structured-data/trunk/languages/rich-snippets-schema-de_DE.mo)
-
tags/2.28.1/languages/rich-snippets-schema-de_DE.po (copied) (copied from snip-structured-data/trunk/languages/rich-snippets-schema-de_DE.po)
-
tags/2.28.1/languages/rich-snippets-schema-en_US.mo (copied) (copied from snip-structured-data/trunk/languages/rich-snippets-schema-en_US.mo)
-
tags/2.28.1/languages/rich-snippets-schema-en_US.po (copied) (copied from snip-structured-data/trunk/languages/rich-snippets-schema-en_US.po)
-
tags/2.28.1/languages/rich-snippets-schema-fa_IR.mo (copied) (copied from snip-structured-data/trunk/languages/rich-snippets-schema-fa_IR.mo)
-
tags/2.28.1/languages/rich-snippets-schema-fa_IR.po (copied) (copied from snip-structured-data/trunk/languages/rich-snippets-schema-fa_IR.po)
-
tags/2.28.1/readme.txt (copied) (copied from snip-structured-data/trunk/readme.txt) (1 diff)
-
tags/2.28.1/rich-snippets-wordpress-plugin.php (copied) (copied from snip-structured-data/trunk/rich-snippets-wordpress-plugin.php) (1 diff)
-
trunk/classes/controller/admin-post.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/rich-snippets-wordpress-plugin.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
snip-structured-data/tags/2.28.1/classes/controller/admin-post.php
r2616285 r2616974 11 11 * Class Admin_Post_Controller. 12 12 * 13 * Helps to manage things on the dit screen.13 * Helps to manage things on the edit screen. 14 14 * 15 15 * @package wpbuddy\rich_snippets … … 29 29 $post_types = (array) get_option( 'wpb_rs/setting/post_types', array( 'post', 'page' ) ); 30 30 31 32 31 foreach ( $post_types as $post_type ) { 33 32 $p = get_post_types( [ 'name' => $post_type ], 'objects' ); … … 46 45 ], 10, 2 ); 47 46 } 47 48 add_action( 'pre_get_posts', [ $this, 'filter_query_orderby' ], 100 ); 49 50 add_filter( 'posts_clauses_request', [ $this, 'filter_query_number' ], 100, 2 ); 48 51 49 52 } … … 90 93 } 91 94 } 95 96 97 /** 98 * Correctly adds the orderBy statement. 99 * 100 * @param \WP_Query $query 101 * 102 * @since 2.28.1 103 */ 104 public function filter_query_orderby( $query ) { 105 106 if ( ! isset( $query->query_vars['orderby'] ) ) { 107 return; 108 } 109 110 if ( 'schema_count' !== $query->query_vars['orderby'] ) { 111 return; 112 } 113 114 if ( ! isset( $query->query_vars['meta_query'] ) ) { 115 $query->query_vars['meta_query'] = []; 116 } 117 118 $query->query_vars['meta_query'][] = [ 119 'relation' => 'OR', 120 [ 121 'key' => '_wpb_rs_schema', 122 'compare' => 'EXISTS' 123 ], 124 [ 125 'key' => '_wpb_rs_schema', 126 'compare' => 'NOT EXISTS' 127 ] 128 ]; 129 130 $this->meta_query_counter( count( $query->query_vars['meta_query'] ) ); 131 } 132 133 /** 134 * An internal value for the meta query counter. 135 * 136 * @param null|int $ctn 137 * 138 * @return int 139 * 140 * @since 2.28.1 141 */ 142 private function meta_query_counter( $ctn = null ) { 143 static $counter; 144 145 if ( ! isset( $counter ) && ! is_null( $ctn ) ) { 146 $counter = $ctn; 147 } 148 149 return $counter; 150 } 151 152 /** 153 * Correctly adds the orderBy statement. 154 * 155 * @param string[] $clauses 156 * @param \WP_Query $query 157 * 158 * @return string[] 159 * 160 * @since 2.28.1 161 */ 162 public function filter_query_number( $clauses, $query ) { 163 164 if ( ! isset( $query->query_vars['orderby'] ) ) { 165 return $clauses; 166 } 167 168 if ( 'schema_count' !== $query->query_vars['orderby'] ) { 169 return $clauses; 170 } 171 172 $counter = $this->meta_query_counter(); 173 174 $clauses['fields'] .= ', CAST(SUBSTR(REGEXP_SUBSTR (mt' . $counter . '.meta_value, \'^a:([0-9]+)\'), 3) AS UNSIGNED INTEGER) as schema_count'; 175 $clauses['orderby'] = 'schema_count ' . $query->query_vars['order']; 176 177 return $clauses; 178 } 92 179 } -
snip-structured-data/tags/2.28.1/readme.txt
r2616285 r2616974 1 1 === snip - Structured Data & Schema === 2 Stable tag: 2.28. 02 Stable tag: 2.28.1 3 3 Contributors: floriansimeth 4 4 Donate link: https://rich-snippets.io -
snip-structured-data/tags/2.28.1/rich-snippets-wordpress-plugin.php
r2616285 r2616974 4 4 Plugin URI: https://rich-snippets.io?pk_campaign=snip-plugin-uri 5 5 Description: Allows to create Rich Snippets and general structured data readable by search engines. 6 Version: 2.28. 06 Version: 2.28.1 7 7 Author: floriansimeth 8 8 Author URI: https://florian-simeth.de?pk_campaign=snip-author-uri -
snip-structured-data/trunk/classes/controller/admin-post.php
r2616285 r2616974 11 11 * Class Admin_Post_Controller. 12 12 * 13 * Helps to manage things on the dit screen.13 * Helps to manage things on the edit screen. 14 14 * 15 15 * @package wpbuddy\rich_snippets … … 29 29 $post_types = (array) get_option( 'wpb_rs/setting/post_types', array( 'post', 'page' ) ); 30 30 31 32 31 foreach ( $post_types as $post_type ) { 33 32 $p = get_post_types( [ 'name' => $post_type ], 'objects' ); … … 46 45 ], 10, 2 ); 47 46 } 47 48 add_action( 'pre_get_posts', [ $this, 'filter_query_orderby' ], 100 ); 49 50 add_filter( 'posts_clauses_request', [ $this, 'filter_query_number' ], 100, 2 ); 48 51 49 52 } … … 90 93 } 91 94 } 95 96 97 /** 98 * Correctly adds the orderBy statement. 99 * 100 * @param \WP_Query $query 101 * 102 * @since 2.28.1 103 */ 104 public function filter_query_orderby( $query ) { 105 106 if ( ! isset( $query->query_vars['orderby'] ) ) { 107 return; 108 } 109 110 if ( 'schema_count' !== $query->query_vars['orderby'] ) { 111 return; 112 } 113 114 if ( ! isset( $query->query_vars['meta_query'] ) ) { 115 $query->query_vars['meta_query'] = []; 116 } 117 118 $query->query_vars['meta_query'][] = [ 119 'relation' => 'OR', 120 [ 121 'key' => '_wpb_rs_schema', 122 'compare' => 'EXISTS' 123 ], 124 [ 125 'key' => '_wpb_rs_schema', 126 'compare' => 'NOT EXISTS' 127 ] 128 ]; 129 130 $this->meta_query_counter( count( $query->query_vars['meta_query'] ) ); 131 } 132 133 /** 134 * An internal value for the meta query counter. 135 * 136 * @param null|int $ctn 137 * 138 * @return int 139 * 140 * @since 2.28.1 141 */ 142 private function meta_query_counter( $ctn = null ) { 143 static $counter; 144 145 if ( ! isset( $counter ) && ! is_null( $ctn ) ) { 146 $counter = $ctn; 147 } 148 149 return $counter; 150 } 151 152 /** 153 * Correctly adds the orderBy statement. 154 * 155 * @param string[] $clauses 156 * @param \WP_Query $query 157 * 158 * @return string[] 159 * 160 * @since 2.28.1 161 */ 162 public function filter_query_number( $clauses, $query ) { 163 164 if ( ! isset( $query->query_vars['orderby'] ) ) { 165 return $clauses; 166 } 167 168 if ( 'schema_count' !== $query->query_vars['orderby'] ) { 169 return $clauses; 170 } 171 172 $counter = $this->meta_query_counter(); 173 174 $clauses['fields'] .= ', CAST(SUBSTR(REGEXP_SUBSTR (mt' . $counter . '.meta_value, \'^a:([0-9]+)\'), 3) AS UNSIGNED INTEGER) as schema_count'; 175 $clauses['orderby'] = 'schema_count ' . $query->query_vars['order']; 176 177 return $clauses; 178 } 92 179 } -
snip-structured-data/trunk/readme.txt
r2616285 r2616974 1 1 === snip - Structured Data & Schema === 2 Stable tag: 2.28. 02 Stable tag: 2.28.1 3 3 Contributors: floriansimeth 4 4 Donate link: https://rich-snippets.io -
snip-structured-data/trunk/rich-snippets-wordpress-plugin.php
r2616285 r2616974 4 4 Plugin URI: https://rich-snippets.io?pk_campaign=snip-plugin-uri 5 5 Description: Allows to create Rich Snippets and general structured data readable by search engines. 6 Version: 2.28. 06 Version: 2.28.1 7 7 Author: floriansimeth 8 8 Author URI: https://florian-simeth.de?pk_campaign=snip-author-uri
Note: See TracChangeset
for help on using the changeset viewer.