Changeset 3545 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
- Timestamp:
- 06/22/2016 01:33:53 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r3511 r3545 462 462 return ent2ncr( htmlspecialchars_decode( htmlentities( $string, ENT_NOQUOTES, 'UTF-8' ), ENT_NOQUOTES ) ); 463 463 } 464 465 /** 466 * Generates a link to toggle a plugin favorites state. 467 * 468 * @param string $plugin_slug The plugin slug. 469 * @param mixed $user The user to alter the favorite status for. 470 * @return string URL to toggle status. 471 */ 472 public static function get_favourite_link( $plugin_slug, $user = 0 ) { 473 $post = Plugin_Directory::get_plugin_post( $plugin_slug ); 474 if ( ! $post ) { 475 return false; 476 } 477 478 $favorited = Tools::favorited_plugin( $post, $user ); 479 480 return add_query_arg( 481 array( 482 '_wpnonce' => wp_create_nonce( 'wp_rest' ), 483 ( $favorited ? 'unfavorite' : 'favorite' ) => '1' 484 ), 485 home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/favorite' ) 486 ); 487 } 464 488 }
Note: See TracChangeset
for help on using the changeset viewer.