| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Author Avatars List/Block |
| 4 |
Plugin URI: http://authoravatars.wordpress.com/ |
| 5 |
Description: Display lists of user avatars using <a href="widgets.php">widgets</a> ,<a href="https://authoravatars.wordpress.com/documentation/">shortcodes</a> and Gutenberg blocks. |
| 6 |
Version: 2.2.0 |
| 7 |
Author: Paul Bearne |
| 8 |
Text Domain: author-avatars |
| 9 |
License: GPLv2 or later |
| 10 |
Domain Path: /translations |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
// The current version of the author avatars plugin. Needs to be updated every time we do a version step. |
| 18 |
define( 'AUTHOR_AVATARS_VERSION', '2.2.0' ); |
| 19 |
|
| 20 |
// List of all version that need an upgrade, used during update check. (Append new version to the end and write an update__10_11 method on AuthorAvatars class if needed) |
| 21 |
define( 'AUTHOR_AVATARS_VERSION_HISTORY', serialize( array( |
| 22 |
'0.1', |
| 23 |
'0.2', |
| 24 |
'0.6.2', |
| 25 |
'0.7', |
| 26 |
) ) ); |
| 27 |
|
| 28 |
require_once( 'lib/AuthorAvatars.class.php' ); |
| 29 |
$aa = new AuthorAvatars(); |
| 30 |
|
| 31 |
// can't add this in the class as it not found |
| 32 |
add_action( 'wp_ajax_AA_shortcode_paging', 'AA_shortcode_paging' ); |
| 33 |
add_action( 'wp_ajax_nopriv_AA_shortcode_paging', 'AA_shortcode_paging' ); |
| 34 |
|
| 35 |
function AA_shortcode_paging() { |
| 36 |
$params = wp_unslash( $_POST ); |
| 37 |
$nonce = isset( $params['postCommentNonce'] ) ? $params['postCommentNonce'] : ''; |
| 38 |
|
| 39 |
// check to see if the submitted nonce matches with the |
| 40 |
// generated nonce we created earlier |
| 41 |
if ( ! wp_verify_nonce( $nonce, 'author-avatars-shortcode-paging-nonce-' . AA_get_shortcode_hash( $params ) ) ) { |
| 42 |
die( 'Busted!' ); |
| 43 |
} |
| 44 |
// need to create class in the function scope |
| 45 |
$aaa = new AuthorAvatars(); |
| 46 |
$aaa->init_shortcodes(); |
| 47 |
echo $aaa->author_avatars_shortcode->shortcode_handler( $_POST, null, true ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 48 |
die(); |
| 49 |
} |
| 50 |
|
| 51 |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'AA_add_action_links' ); |
| 52 |
function AA_add_action_links( $links ) { |
| 53 |
$mylinks = array( |
| 54 |
sprintf( '<a href="%s" target="_blank">%s</a>', |
| 55 |
esc_url( 'https://translate.wordpress.org/projects/wp-plugins/author-avatars' ), |
| 56 |
__( 'Help translate.', 'author-avatars' ) |
| 57 |
) |
| 58 |
); |
| 59 |
|
| 60 |
return array_merge( $links, $mylinks ); |
| 61 |
} |
| 62 |
/** |
| 63 |
* Block Initializer. |
| 64 |
*/ |
| 65 |
require_once plugin_dir_path( __FILE__ ) . 'blocks/src/init.php'; |
| 66 |
|
| 67 |
//function edit_contactmethods( $contactmethods ) { |
| 68 |
// $contactmethods['facebook'] = 'Facebook'; |
| 69 |
// $contactmethods['twitter'] = 'Twitter'; |
| 70 |
//// unset($contactmethods['yim']); |
| 71 |
//// unset($contactmethods['aim']); |
| 72 |
//// unset($contactmethods['jabber']); |
| 73 |
// return $contactmethods; } |
| 74 |
// |
| 75 |
//add_filter( 'user_contactmethods','edit_contactmethods', 10, 1 ); |
| 76 |
|
| 77 |
|
| 78 |
//function aa_user_raw_list( $users ){ |
| 79 |
// $filtered_users = array(); |
| 80 |
// foreach ( $users as $user ) { |
| 81 |
// $user_status = get_user_meta( $user->user_id, 'pw_user_status', true ); |
| 82 |
// if ( 'denied' !== $user_status ) { |
| 83 |
// $filtered_users[] = $user; |
| 84 |
// } |
| 85 |
// } |
| 86 |
// |
| 87 |
// return $filtered_users; |
| 88 |
//} |
| 89 |
// |
| 90 |
// |
| 91 |
//add_filter( 'aa_user_raw_list','aa_user_raw_list' ); |
| 92 |
|