Changeset 3443140
- Timestamp:
- 01/20/2026 10:36:16 AM (2 months ago)
- Location:
- molongui-authorship/trunk
- Files:
-
- 12 edited
-
README.txt (modified) (1 diff)
-
changelog.txt (modified) (1 diff)
-
common/utils/post.php (modified) (1 diff)
-
includes/admin/admin-post.php (modified) (1 diff)
-
includes/admin/post-count-updater.php (modified) (5 diffs)
-
includes/author.php (modified) (12 diffs)
-
includes/authors.php (modified) (3 diffs)
-
includes/post.php (modified) (2 diffs)
-
includes/settings.php (modified) (2 diffs)
-
molongui-authorship.php (modified) (2 diffs)
-
views/author-box/related/html-layout-1.php (modified) (1 diff)
-
views/author-box/related/html-layout-2.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
molongui-authorship/trunk/README.txt
r3439873 r3443140 254 254 <strong>Important</strong>: If you use a caching plugin, please clear your cache after updating any plugins. 255 255 256 = 5.2.7 (2026-01-20) = 257 258 * **Fixed**: Related posts in the author box now respect the configured ordering settings. 259 * **Fixed**: Related posts in the author box no longer include drafts or future posts. 260 * **Fixed**: Post count updates now work correctly in edge cases. 261 * **Fixed**: Post count filtering now ignores empty or invalid author IDs to prevent unexpected behavior. 262 * **Fixed**: Compatibility issue with BetterDocs where enabling Guest Author or Co-Authors could cause single doc posts to render as an archive list. 263 256 264 = 5.2.6 (2026-01-14) = 257 265 258 * **Fixed**: Missing author descriptionin author boxes.266 * **Fixed**: Author description now correctly appears in author boxes. 259 267 260 268 = 5.2.5 (2026-01-14) = -
molongui-authorship/trunk/changelog.txt
r3439873 r3443140 3 3 == Changelog == 4 4 5 = 5.2.7 (2026-01-20) = 6 7 * **Fixed**: Related posts in the author box now respect the configured ordering settings. 8 * **Fixed**: Related posts in the author box no longer include drafts or future posts. 9 * **Fixed**: Post count updates now work correctly in edge cases. 10 * **Fixed**: Post count filtering now ignores empty or invalid author IDs to prevent unexpected behavior. 11 * **Fixed**: Compatibility issue with BetterDocs where enabling Guest Author or Co-Authors could cause single doc posts to render as an archive list. 12 5 13 = 5.2.6 (2026-01-14) = 6 14 7 * **Fixed**: Missing author descriptionin author boxes.15 * **Fixed**: Author description now correctly appears in author boxes. 8 16 9 17 = 5.2.5 (2026-01-14) = -
molongui-authorship/trunk/common/utils/post.php
r3222089 r3443140 282 282 } 283 283 } 284 public static function sanitize_post_status_arg( $post_status, $fallback = 'publish' ) 285 { 286 $valid_statuses = array_keys( get_post_stati() ); 287 288 /*! 289 * FILTER HOOK 290 * Filters the default fallback value used when sanitizing a "post_status" query argument. 291 * 292 * The fallback is used only when the incoming post_status value is empty/invalid and a safe default must be 293 * applied. The default fallback is an empty string, which causes WP_Query to apply its own context-aware 294 * defaults: 295 * 296 * - On the front end, the default status is "publish". 297 * - When the user is logged in, "private" may also be included (subject to capabilities and post type). 298 * - Public custom post statuses may be included by default. 299 * - In admin/AJAX contexts, protected statuses may be added as well (by default: "future", "draft", "pending"). 300 * 301 * Return a string status (e.g. "publish"), "any", an array of statuses, or an empty string to defer 302 * to WordPress defaults. 303 * 304 * @param string|array $fallback Default fallback value. Empty string defers to WordPress defaults. 305 * @return string|array Filtered fallback value. 306 */ 307 $fallback = apply_filters( 'authorship/post_status_fallback', '' ); 308 if ( is_string( $post_status ) ) 309 { 310 $raw = trim( $post_status ); 311 312 if ( $raw === '' ) 313 { 314 return $fallback; 315 } 316 317 if ( strtolower( $raw ) === 'any' ) 318 { 319 return 'any'; 320 } 321 322 if ( is_numeric( $raw ) ) 323 { 324 return $fallback; 325 } 326 327 $key = sanitize_key( $raw ); 328 return ( $key !== '' && in_array( $key, $valid_statuses, true ) ) 329 ? array( $key ) 330 : $fallback; 331 } 332 if ( is_array( $post_status ) ) 333 { 334 $out = array(); 335 336 foreach ( $post_status as $st ) 337 { 338 if ( ! is_string( $st ) ) 339 { 340 continue; 341 } 342 343 $raw = trim( $st ); 344 if ( $raw === '' || is_numeric( $raw ) ) 345 { 346 continue; 347 } 348 349 $key = sanitize_key( $raw ); 350 if ( $key !== '' && in_array( $key, $valid_statuses, true ) ) 351 { 352 $out[] = $key; 353 } 354 } 355 356 $out = array_values( array_unique( $out ) ); 357 return ! empty( $out ) ? $out : $fallback; 358 } 359 return $fallback; 360 } 284 361 285 362 } // class -
molongui-authorship/trunk/includes/admin/admin-post.php
r3439281 r3443140 1231 1231 * @since 4.9.0 1232 1232 */ 1233 returnapply_filters( 'molongui_authorship/countable_post_statuses', array1233 $countable_post_status = apply_filters( 'molongui_authorship/countable_post_statuses', array 1234 1234 ( 1235 1235 'publish', 1236 1236 'private', 1237 1237 )); 1238 1239 return Post::sanitize_post_status_arg( $countable_post_status ); 1238 1240 } 1239 1241 public static function update_authors( $post_authors, $post_id, $post_type, $post_author ) -
molongui-authorship/trunk/includes/admin/post-count-updater.php
r3439281 r3443140 16 16 use Molongui\Authorship\Author; 17 17 use Molongui\Authorship\Authors; 18 use Molongui\Authorship\Common\Utils\Debug; 18 19 use Molongui\Authorship\Common\Utils\Singleton; 19 20 use Molongui\Authorship\Guest_Author; … … 282 283 foreach( $ids as $id ) 283 284 { 284 $authors[] = array( 'id' => $id, 'type' => $type, 'ref' => $type.'-'.$id, 'name' => '');285 $authors[] = new Author( $id, $type ); 285 286 } 286 287 } … … 331 332 if ( !isset( $count ) ) 332 333 { 333 $count = $_author->get_post_count( $post_type, false);334 $count = $_author->get_post_count( $post_type, 'live' ); 334 335 } 335 336 $_author->persist_post_count( $count, $post_type ); … … 341 342 return; 342 343 } 343 if ( is_string( $post_authors ) ) 344 { 345 $parts = explode( '-', $post_authors ); 346 347 if ( isset( $parts[0] ) and $parts[0] === $post_authors ) 348 { 349 return; 350 } 351 352 $post_authors = array(); 353 $post_authors[0] = new \stdClass(); 354 $post_authors[0]->id = $parts[1]; 355 $post_authors[0]->type = $parts[0]; 356 } 357 358 foreach ( $post_authors as $post_author ) 359 { 360 $author = new Author( $post_author->id, $post_author->type ); 361 $count = $author->get_post_count( $post_type ); 362 self::update_author_post_counter( array( 'id' => $post_author->id, 'type' => $post_author->type ), $post_type, $count + 1 ); 344 345 foreach ( (array) $post_authors as $post_author ) 346 { 347 $author_id = null; 348 $author_type = null; 349 350 if ( is_object( $post_author ) && isset( $post_author->id, $post_author->type ) ) 351 { 352 $author_id = (int) $post_author->id; 353 $author_type = (string) $post_author->type; 354 355 } 356 elseif ( is_string( $post_author ) ) 357 { 358 $parts = explode( '-', $post_author, 2 ); 359 if ( count( $parts ) !== 2 ) 360 { 361 continue; 362 } 363 $author_type = $parts[0]; 364 $author_id = (int) $parts[1]; 365 366 } 367 else 368 { 369 continue; 370 } 371 372 if ( ! in_array( $author_type, array( 'user', 'guest' ), true ) || $author_id <= 0 ) 373 { 374 continue; 375 } 376 377 $author = new Author( $author_id, $author_type ); 378 $count = (int) $author->get_post_count( $post_type ); 379 380 self::update_author_post_counter( 381 array( 'id' => $author_id, 'type' => $author_type ), 382 $post_type, 383 max( 0, $count + 1 ) 384 ); 363 385 } 364 386 } … … 369 391 return; 370 392 } 371 if ( is_string( $post_authors ) ) 372 { 373 $parts = explode( '-', $post_authors ); 374 375 if ( isset( $parts[0] ) and $parts[0] === $post_authors ) 376 { 377 return; 378 } 379 380 $post_authors = array(); 381 $post_authors[0] = new \stdClass(); 382 $post_authors[0]->id = $parts[1]; 383 $post_authors[0]->type = $parts[0]; 384 } 385 386 foreach ( $post_authors as $post_author ) 387 { 388 $author = new Author( $post_author->id, $post_author->type ); 389 $count = $author->get_post_count( $post_type ); 390 self::update_author_post_counter( array( 'id' => $post_author->id, 'type' => $post_author->type ), $post_type, $count - 1 ); 393 394 foreach ( (array) $post_authors as $post_author ) 395 { 396 $author_id = null; 397 $author_type = null; 398 399 if ( is_object( $post_author ) && isset( $post_author->id, $post_author->type ) ) 400 { 401 $author_id = (int) $post_author->id; 402 $author_type = (string) $post_author->type; 403 404 } 405 elseif ( is_string( $post_author ) ) 406 { 407 $parts = explode( '-', $post_author, 2 ); 408 if ( count( $parts ) !== 2 ) 409 { 410 continue; 411 } 412 $author_type = $parts[0]; 413 $author_id = (int) $parts[1]; 414 415 } 416 else 417 { 418 continue; 419 } 420 421 if ( ! in_array( $author_type, array( 'user', 'guest' ), true ) || $author_id <= 0 ) 422 { 423 continue; 424 } 425 426 $author = new Author( $author_id, $author_type ); 427 $count = (int) $author->get_post_count( $post_type ); 428 429 self::update_author_post_counter( 430 array( 'id' => $author_id, 'type' => $author_type ), 431 $post_type, 432 max( 0, $count - 1 ) 433 ); 391 434 } 392 435 } -
molongui-authorship/trunk/includes/author.php
r3439873 r3443140 304 304 return self::GUEST_META_PREFIX . $short_key; 305 305 } 306 private function get_all_plugin_meta() 307 { 308 $prefix = $this->is_user ? self::USER_META_PREFIX : self::GUEST_META_PREFIX; 309 310 return $this->cache_remember( 'meta:all_plugin', function () use ( $prefix ) 311 { 312 $all_meta = $this->is_user ? get_user_meta( $this->id ) : get_post_meta( $this->id ); 313 314 if ( ! is_array( $all_meta ) || empty( $all_meta ) ) 315 { 316 return array(); 317 } 318 319 $plugin_meta = array(); 320 321 foreach ( $all_meta as $meta_key => $values ) 322 { 323 if ( ! is_string( $meta_key ) || strpos( $meta_key, $prefix ) !== 0 ) 324 { 325 continue; 326 } 327 if ( ! is_array( $values ) ) 328 { 329 $values = array( $values ); 330 } 331 332 $plugin_meta[ $meta_key ] = $values; 333 if ( ! array_key_exists( $meta_key, $this->prefetched_meta ) ) 334 { 335 $first = isset( $values[0] ) ? $values[0] : ''; 336 $this->prefetched_meta[ $meta_key ] = ( $first === null ) ? '' : $first; 337 } 338 } 339 340 return $plugin_meta; 341 } ); 342 } 306 343 final public function get_id() 307 344 { … … 731 768 732 769 $key = (string) $key; 770 if ( $key === 'all' ) 771 { 772 return $this->get_all_plugin_meta(); 773 } 733 774 $label = 'meta:' . $key; 734 775 if ( $this->type === 'user' ) … … 753 794 * @deprecated 5.2.0 Use "molongui_authorship/author/{$key}" instead 754 795 */ 755 if ( has_filter( "molongui_authorship/get_author_meta_{$key}" ) && apply_filters( 'molongui_authorship/apply_filters_deprecated', true ) )796 if ( has_filter( "molongui_authorship/get_author_meta_{$key}" ) && apply_filters( 'molongui_authorship/apply_filters_deprecated', true, __FUNCTION__ ) ) 756 797 { 757 798 $value = apply_filters_deprecated( … … 863 904 * @deprecated 5.2.0 Use 'molongui_authorship/author/user_roles' instead 864 905 */ 865 if ( has_filter( 'molongui_authorship/get_author_user_roles' ) and apply_filters( 'molongui_authorship/apply_filters_deprecated', false ) )906 if ( has_filter( 'molongui_authorship/get_author_user_roles' ) and apply_filters( 'molongui_authorship/apply_filters_deprecated', false, __FUNCTION__ ) ) 866 907 { 867 908 $user_roles = apply_filters_deprecated( 'molongui_authorship/get_author_user_roles', array( $user_roles, $this->id, $this->type, $this ), '5.2.0', 'molongui_authorship/author/user_roles' ); … … 1188 1229 public function get_posts( $args = null ) 1189 1230 { 1231 1190 1232 $defaults = array 1191 1233 ( 1192 'cat' => '',1234 'cat' => 0, 1193 1235 'fields' => 'all', 1194 1236 'ignore_sticky_posts' => true, … … 1201 1243 'post__not_in' => array(), 1202 1244 'post_type' => 'post', 1203 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ), // all WP default post_status //Admin_Post::get_countable_post_statuses(),1245 'post_status' => '', 1204 1246 'posts_per_page' => -1, 1205 'author_id' => $this->id,1206 'author_type' => $this->type,1207 'site_id' => apply_filters( 'authorship/get_posts/blog_id', get_current_blog_id() ),1208 'language' => apply_filters( 'authorship/get_posts/language', Helpers::get_language() ),1247 'author_id' => $this->id, 1248 'author_type' => $this->type, 1249 'site_id' => apply_filters( 'authorship/get_posts/blog_id', get_current_blog_id() ), 1250 'language' => apply_filters( 'authorship/get_posts/language', Helpers::get_language() ), 1209 1251 1210 1252 ); … … 1212 1254 1213 1255 $fields = is_string( $a['fields'] ) ? strtolower( $a['fields'] ) : 'all'; 1214 if ( ! in_array( $fields, array( ' ', 'all', 'ids', 'id=>parent' ), true ) )1256 if ( ! in_array( $fields, array( 'all', 'ids', 'id=>parent' ), true ) ) 1215 1257 { 1216 1258 $fields = 'all'; … … 1222 1264 $order = 'DESC'; 1223 1265 } 1266 1267 $orderby = is_string( $a['orderby'] ) ? strtolower( trim( $a['orderby'] ) ) : 'date'; 1268 $allowed_orderby = array 1269 ( 1270 'none', 1271 'id', 1272 'author', 1273 'title', 1274 'name', 1275 'date', 1276 'modified', 1277 'parent', 1278 'rand', 1279 'comment_count', 1280 'menu_order', 1281 'meta_value', 1282 'meta_value_num', 1283 'post__in', 1284 ); 1285 if ( ! in_array( $orderby, $allowed_orderby, true ) ) 1286 { 1287 $orderby = 'date'; 1288 } 1289 1290 $posts_per_page = (int) $a['posts_per_page']; 1291 if ( $posts_per_page < -1 ) 1292 { 1293 $posts_per_page = -1; 1294 } 1295 1296 $offset = (int) $a['offset']; 1297 if ( $offset < 0 ) 1298 { 1299 $offset = 0; 1300 } 1301 1302 $cat = $a['cat']; 1303 if ( $cat === '' || $cat === null ) 1304 { 1305 $cat = 0; 1306 } 1307 else 1308 { 1309 $cat = absint( $cat ); 1310 } 1311 1312 $post__in = $a['post__in']; // accept array|string|int. 1313 if ( is_string( $post__in ) ) 1314 { 1315 $post__in = array_filter( array_map( 'absint', explode( ',', $post__in ) ) ); 1316 } 1317 elseif ( is_numeric( $post__in ) ) 1318 { 1319 $post__in = array( absint( $post__in ) ); 1320 } 1321 else 1322 { 1323 $post__in = array_filter( array_map( 'absint', (array) $post__in ) ); 1324 } 1325 $post__in = array_values( array_unique( $post__in ) ); 1326 1327 $post__not_in = $a['post__not_in']; // accept array|string|int. 1328 if ( is_string( $post__not_in ) ) 1329 { 1330 $post__not_in = array_filter( array_map( 'absint', explode( ',', $post__not_in ) ) ); 1331 } 1332 elseif ( is_numeric( $post__not_in ) ) 1333 { 1334 $post__not_in = array( absint( $post__not_in ) ); 1335 } 1336 else 1337 { 1338 $post__not_in = array_filter( array_map( 'absint', (array) $post__not_in ) ); 1339 } 1340 $post__not_in = array_values( array_unique( $post__not_in ) ); 1341 1342 $meta_query = is_array( $a['meta_query'] ) ? $a['meta_query'] : array(); 1343 1344 $ignore_sticky_posts = (bool) $a['ignore_sticky_posts']; 1345 $no_found_rows_raw = (bool) $a['no_found_rows']; 1346 1224 1347 if ( is_string( $a['post_type'] ) && $a['post_type'] !== '' ) 1225 1348 { … … 1235 1358 1236 1359 case 'related': 1237 $post_types = explode( ",", Settings::get( 'author_box_related_posts_post_types' ) );1238 $a['posts_per_page'] = Settings::get( 'author_box_related_posts_count' );1239 $a['orderby'] = Settings::get( 'author_box_related_orderby' );1240 $order = Settings::get( 'author_box_related_order' );1241 1360 break; 1242 1361 1243 1362 default: 1244 1363 $post_types = array( sanitize_key( $a['post_type'] ) ); 1364 break; 1245 1365 } 1246 1366 } … … 1256 1376 } 1257 1377 } 1258 if ( empty( $post_types ) ) 1259 { 1260 $post_types = array( 'post' ); 1261 } 1378 $post_types = array_values( array_unique( $post_types ) ); 1262 1379 } 1263 1380 else … … 1265 1382 $post_types = array( 'post' ); 1266 1383 } 1267 if ( is_string( $a['post_status'] ) && $a['post_status'] !== '' ) 1268 { 1269 $post_status = ( $a['post_status'] === 'any' ) ? 'any' : array( sanitize_key( $a['post_status'] ) ); 1270 } 1271 elseif ( is_array( $a['post_status'] ) ) 1272 { 1273 $post_status = array(); 1274 foreach ( $a['post_status'] as $st ) 1275 { 1276 $st = sanitize_key( $st ); 1277 if ( $st !== '' ) 1278 { 1279 $post_status[] = $st; 1280 } 1281 } 1282 if ( empty( $post_status ) ) 1283 { 1284 $post_status = Admin_Post::get_countable_post_statuses(); 1285 } 1286 } 1287 else 1288 { 1289 $post_status = Admin_Post::get_countable_post_statuses(); 1290 } 1291 $no_found_rows = ( $a['posts_per_page'] > 0 ) ? false : (bool) $a['no_found_rows']; 1292 1293 /*! 1294 * FILTER HOOK 1295 * Allows filtering returned posts list before it is generated. 1296 * 1297 * Passing a non-null value will effectively short-circuit the generation, returning that value instead. 1298 * 1299 * @param array $posts The posts list. Default null. 1300 * @param array $args Array of function arguments. 1301 * @param Author $author The current author instance. 1302 * @since 5.2.0 1303 */ 1304 $posts = apply_filters( 'molongui_authorship/author/pre_get_posts', null, $args, $this ); 1305 if ( null !== $posts ) 1306 { 1307 return $posts; 1308 } 1384 1385 $post_status = Post::sanitize_post_status_arg( $a['post_status'] ); 1386 $no_found_rows = ( $posts_per_page > 0 ) ? false : $no_found_rows_raw; 1387 $raw_args = wp_parse_args( $args, array() ); 1388 1389 $caller_set_order = array_key_exists( 'order', $raw_args ); 1390 $caller_set_orderby = array_key_exists( 'orderby', $raw_args ); 1391 $caller_set_posts_per_page = array_key_exists( 'posts_per_page', $raw_args ); 1392 if ( is_string( $a['post_type'] ) && $a['post_type'] === 'related' ) 1393 { 1394 $related_post_types = array_filter( 1395 array_map( 1396 'sanitize_key', 1397 array_map( 'trim', explode( ',', (string) Settings::get( 'author_box_related_posts_post_types' ) ) ) 1398 ) 1399 ); 1400 if ( ! empty( $related_post_types ) ) 1401 { 1402 $post_types = array_values( array_unique( $related_post_types ) ); 1403 } 1404 if ( ! $caller_set_posts_per_page ) 1405 { 1406 $related_count = (int) Settings::get( 'author_box_related_posts_count' ); 1407 $posts_per_page = ( $related_count > 0 ) ? $related_count : -1; 1408 } 1409 if ( ! $caller_set_orderby ) 1410 { 1411 $settings_orderby = is_string( Settings::get( 'author_box_related_posts_orderby' ) ) 1412 ? strtolower( trim( (string) Settings::get( 'author_box_related_posts_orderby' ) ) ) 1413 : 'date'; 1414 if ( ! in_array( $settings_orderby, $allowed_orderby, true ) ) 1415 { 1416 $settings_orderby = 'date'; 1417 } 1418 1419 $orderby = $settings_orderby; 1420 } 1421 if ( ! $caller_set_order ) 1422 { 1423 $settings_order = strtoupper( (string) Settings::get( 'author_box_related_posts_order' ) ); 1424 if ( $settings_order !== 'ASC' && $settings_order !== 'DESC' ) 1425 { 1426 $settings_order = 'DESC'; 1427 } 1428 1429 $order = $settings_order; 1430 } 1431 } 1432 $no_found_rows = ( $posts_per_page > 0 ) ? false : $no_found_rows_raw; 1309 1433 $ref = ( $this->type === 'user' ) ? ( 'user-' . $this->id ) : ( 'guest-' . $this->id ); 1310 1311 $meta_query = is_array( $a['meta_query'] ) ? $a['meta_query'] : array();1312 1434 $meta_query[] = array 1313 1435 ( … … 1316 1438 'compare' => '==', 1317 1439 ); 1440 if ( is_string( $a['post_type'] ) && $a['post_type'] === 'related' ) 1441 { 1442 $current_post_id = (int) get_queried_object_id(); 1443 if ( $current_post_id > 0 ) 1444 { 1445 $post__not_in[] = $current_post_id; 1446 $post__not_in = array_values( array_unique( array_filter( array_map( 'absint', $post__not_in ) ) ) ); 1447 } 1448 } 1449 if ( $orderby === 'post__in' && empty( $post__in ) ) 1450 { 1451 $orderby = 'date'; 1452 } 1318 1453 $q_args = array 1319 1454 ( 1320 1455 'post_type' => $post_types, 1321 1456 'post_status' => $post_status, 1322 'fields' => $fields, // 'all' | 'ids' | 'id=>parent'1323 'orderby' => $ a['orderby'],1457 'fields' => $fields, // 'all' | 'ids' | 'id=>parent' 1458 'orderby' => $orderby, 1324 1459 'order' => $order, 1325 'posts_per_page' => (int) $a['posts_per_page'],1326 'offset' => (int) $a['offset'],1327 'ignore_sticky_posts' => (bool) $ a['ignore_sticky_posts'],1460 'posts_per_page' => $posts_per_page, 1461 'offset' => $offset, 1462 'ignore_sticky_posts' => (bool) $ignore_sticky_posts, 1328 1463 'no_found_rows' => (bool) $no_found_rows, 1329 1464 'meta_query' => $meta_query, 1330 'post__in' => (array) $a['post__in'],1331 'post__not_in' => (array) $a['post__not_in'],1332 'cat' => $ a['cat'], // pass-through1333 'suppress_filters' => false, // let multilingual/plugins scope by language if needed1465 'post__in' => $post__in, 1466 'post__not_in' => $post__not_in, 1467 'cat' => $cat, 1468 'suppress_filters' => false, 1334 1469 'update_post_term_cache' => ( $fields === 'all' ), // if only IDs, don't waste time filling term cache 1335 1470 'update_post_meta_cache' => ( $fields === 'all' ), // if only IDs, skip meta cache 1336 1471 ); 1472 1473 /*! 1474 * FILTER HOOK 1475 * Allow last-second customization of the query args. 1476 * 1477 * @param array $q_args WP_Query args that will be used to fetch authored posts. 1478 * @param Author $this The current author instance. 1479 * @since 5.2.0 1480 */ 1337 1481 $q_args = apply_filters( 'molongui_authorship/author/get_posts/query_args', $q_args, $this ); 1482 1483 $resolved = array 1484 ( 1485 'cat' => $cat, 1486 'fields' => $fields, 1487 'ignore_sticky_posts' => $ignore_sticky_posts, 1488 'meta_query' => $meta_query, 1489 'no_found_rows' => $no_found_rows, 1490 'offset' => $offset, 1491 'order' => $order, 1492 'orderby' => $orderby, 1493 'post__in' => $post__in, 1494 'post__not_in' => $post__not_in, 1495 'post_type' => $a['post_type'], 1496 'post_types' => $post_types, 1497 1498 'post_status' => $post_status, 1499 'posts_per_page' => $posts_per_page, 1500 'author_id' => $a['author_id'], 1501 'author_type' => $a['author_type'], 1502 'site_id' => $a['site_id'], 1503 'language' => $a['language'], 1504 ); 1505 1506 /*! 1507 * FILTER HOOK 1508 * Allows filtering returned posts list before it is generated. 1509 * 1510 * Returning a non-null value will effectively short-circuit WP_Query execution, returning that value instead. 1511 * 1512 * @param mixed $posts The posts list. Default null. 1513 * @param mixed $args Raw method input (array|string|null). 1514 * @param Author $author The current author instance. 1515 * @param array $parsed Parsed args after defaults are applied (wp_parse_args()). 1516 * @param array $resolved Sanitized/normalized args as they will be used. 1517 * @param array $q_args Prepared WP_Query args that would be executed. 1518 * @since 5.2.0 1519 */ 1520 $posts = apply_filters( 'molongui_authorship/author/pre_get_posts', null, $args, $this, $a, $resolved, $q_args ); 1521 if ( null !== $posts ) 1522 { 1523 return $posts; 1524 } 1338 1525 $q = new \WP_Query( $q_args ); 1339 1526 $posts = $q->posts; -
molongui-authorship/trunk/includes/authors.php
r3439281 r3443140 70 70 $authors = Post::get_authors( $post_id ); 71 71 } 72 if ( empty( $authors ) or $authors[0]->id == 0)72 if ( empty( $authors ) || !is_array( $authors ) || !isset( $authors[0] ) || empty( $authors[0]->id ) ) 73 73 { 74 74 return false; … … 297 297 $core_wishlist = array( 'display_name','user_nicename','user_email','user_url','post_title','post_name','post_content' ); 298 298 $meta_wishlist_users = array( 299 'first_name','last_name','description', // native usermeta299 'first_name','last_name','description', 300 300 'molongui_author_phone','molongui_author_custom_link', 301 301 'molongui_author_position','molongui_author_company','molongui_author_company_link', 302 'molongui_author_archived', // archived flag302 'molongui_author_archived', 303 303 ); 304 304 $meta_wishlist_guests = array( … … 307 307 '_molongui_guest_author_web','_molongui_guest_author_custom_link', 308 308 '_molongui_guest_author_job','_molongui_guest_author_company','_molongui_guest_author_company_link', 309 '_molongui_guest_author_archived', // archived flag309 '_molongui_guest_author_archived', 310 310 ); 311 311 $need_post_counts = in_array( 'post_count', $fields, true ) || (int) $args['min_post_count'] > 0; -
molongui-authorship/trunk/includes/post.php
r3439281 r3443140 75 75 { 76 76 $author_type = 'guest'; 77 $author_id = $the_query->guest_author_id;77 $author_id = absint( $the_query->guest_author_id ); 78 78 } 79 79 else 80 80 { 81 81 $author_type = 'user'; 82 $author_id = $userid;82 $author_id = absint( $userid ); 83 83 } 84 84 … … 89 89 */ 90 90 list( $author_id, $author_type ) = apply_filters( '_authorship/post_count/author', array( $author_id, $author_type ), $count, $userid, $post_type, $public_only ); 91 if ( empty( $author_id ) || absint( $author_id ) === 0 ) 92 { 93 return apply_filters( 'molongui_authorship/post_count', $count, $count, $userid, $post_type, $public_only ); 94 } 91 95 $author = new Author( $author_id, $author_type ); 92 96 $post_count = $author->get_post_count( $post_type, true ); 93 return apply_filters( 'authorship/post_count', $post_count, $count, $userid, $post_type, $public_only ); 97 98 /*! 99 * DEPRECATED 100 * This filter hook is scheduled for removal in version 5.4.0. Update any dependencies accordingly. 101 * 102 * @since 4.6.18 103 * @deprecated 5.2.7 Use 'molongui_authorship/post_count' instead 104 */ 105 if ( has_filter( 'authorship/post_count' ) and apply_filters( 'molongui_authorship/apply_filters_deprecated', true, __FUNCTION__ ) ) 106 { 107 $post_count = apply_filters_deprecated( 'authorship/post_count', array( $post_count, $count, $userid, $post_type, $public_only ), '5.2.7', 'molongui_authorship/post_count' ); 108 } 109 110 /*! 111 * FILTER HOOK 112 * Allows filtering the post count before it is returned. 113 * 114 * @param int $post_count The filtered user's post count. 115 * @param int $count The original user's post count. 116 * @param int $userid User ID. 117 * @param string|array $post_type Single post type or array of post types to count the number of posts for. 118 * @param bool $public_only Whether to limit counted posts to public posts. 119 * @since 5.2.7 120 */ 121 return apply_filters( 'molongui_authorship/post_count', $post_count, $count, $userid, $post_type, $public_only ); 94 122 } 95 123 public function filter_user_posts( $wp_query ) -
molongui-authorship/trunk/includes/settings.php
r3421622 r3443140 4111 4111 $wpdb->query( "DELETE FROM {$wpdb->prefix}options WHERE option_name LIKE '{$like}';" ); 4112 4112 } 4113 4114 do_action( 'molongui_authorship/delete_job_flags' ); 4113 4115 } 4114 4116 public function stylesheet( $file ) … … 4445 4447 * @deprecated 5.0.8 4446 4448 */ 4447 if ( has_filter( 'authorship/user/roles' ) and apply_filters( 'molongui_authorship/apply_filters_deprecated', true ) )4449 if ( has_filter( 'authorship/user/roles' ) and apply_filters( 'molongui_authorship/apply_filters_deprecated', true, __FUNCTION__ ) ) 4448 4450 { 4449 4451 $user_roles = apply_filters_deprecated( 'authorship/user/roles', array( $user_roles ), '5.0.8' ); -
molongui-authorship/trunk/molongui-authorship.php
r3439873 r3443140 13 13 * Plugin URI: https://www.molongui.com/wordpress-plugin-post-authors 14 14 * Description: All-in-One Authorship Solution: Seamless Author Box, Guest Authors, and Co-Authors to enhance your site's authority, credibility, engagement, and SEO. 15 * Version: 5.2. 615 * Version: 5.2.7 16 16 * Requires at least: 5.2 17 17 * Tested up to: 6.9 … … 44 44 final class MolonguiAuthorship 45 45 { 46 const VERSION = '5.2. 6';46 const VERSION = '5.2.7'; 47 47 use Singleton; 48 48 function __construct() -
molongui-authorship/trunk/views/author-box/related/html-layout-1.php
r3415065 r3443140 3 3 defined( 'ABSPATH' ) or exit; // Exit if accessed directly 4 4 5 foreach( $profile->get_posts_ids( array( 'post_type' => 'related' ) ) as $related_id ) 5 $related_posts_ids = $profile->get_posts_ids( array 6 ( 7 'post_type' => 'related', 8 'post__not_in' => get_the_ID(), 9 ) ); 10 11 if ( empty( $related_posts_ids ) ) 12 { 13 return; 14 } 15 16 foreach( $related_posts_ids as $related_id ) 6 17 { 7 18 ?> -
molongui-authorship/trunk/views/author-box/related/html-layout-2.php
r3415065 r3443140 3 3 defined( 'ABSPATH' ) or exit; // Exit if accessed directly 4 4 5 foreach( $profile->get_posts_ids( array( 'post_type' => 'related' ) ) as $related_id ) 5 $related_posts_ids = $profile->get_posts_ids( array 6 ( 7 'post_type' => 'related', 8 'post__not_in' => get_the_ID(), 9 ) ); 10 11 if ( empty( $related_posts_ids ) ) 12 { 13 return; 14 } 15 16 foreach( $related_posts_ids as $related_id ) 6 17 { 7 18 ?>
Note: See TracChangeset
for help on using the changeset viewer.