--- a/indieweb/includes/class-general-settings.php
+++ b/indieweb/includes/class-general-settings.php
@@ -1,24 +1,38 @@
<?php
+/**
+ * IndieWeb General Settings.
+ *
+ * @package IndieWeb
+ */
add_action( 'admin_menu', array( 'IndieWeb_General_Settings', 'admin_menu' ) );
add_action( 'init', array( 'IndieWeb_General_Settings', 'register_settings' ) );
add_action( 'admin_menu', array( 'IndieWeb_General_Settings', 'admin_settings' ), 11 );
+/**
+ * General Settings class for IndieWeb plugin.
+ */
class IndieWeb_General_Settings {
+ /**
+ * Add admin menu item.
+ */
public static function admin_menu() {
$page = 'iw_general_options';
// Add General Options Page.
add_submenu_page(
'indieweb',
- __( 'Options', 'indieweb' ), // page title
- __( 'Options', 'indieweb' ), // menu title
- 'manage_options', // access capability
+ __( 'Options', 'indieweb' ), // Page title.
+ __( 'Options', 'indieweb' ), // Menu title.
+ 'manage_options', // Access capability.
$page,
array( 'IndieWeb_General_Settings', 'general_options_page' )
);
}
+ /**
+ * Register plugin settings.
+ */
public static function register_settings() {
$section = 'iw_identity_settings';
register_setting(
@@ -32,7 +46,7 @@
)
);
- // Set Default Author
+ // Set Default Author.
register_setting(
$section,
'iw_default_author',
@@ -67,24 +81,27 @@
);
}
+ /**
+ * Add settings sections and fields.
+ */
public static function admin_settings() {
$page = 'iw_general_options';
- // Settings Section
+ // Settings Section.
$section = 'iw_identity_settings';
add_settings_section(
- $section, // ID used to identify this section and with which to register options
- __( 'Identity Settings', 'indieweb' ), // Title to be displayed on the administration page
- array( 'IndieWeb_General_Settings', 'identity_options_callback' ), // Callback used to render the description of the section
- $page // Page on which to add this section of options
+ $section, // ID used to identify this section and with which to register options.
+ __( 'Identity Settings', 'indieweb' ), // Title to be displayed on the administration page.
+ array( 'IndieWeb_General_Settings', 'identity_options_callback' ), // Callback used to render the description of the section.
+ $page // Page on which to add this section of options.
);
add_settings_field(
- 'iw_single_author', // ID used to identify the field throughout the theme
- 'Single Author Site', // The label to the left of the option interface element
- array( 'IndieWeb_General_Settings', 'checkbox_callback' ), // The name of the function responsible for rendering the option interface
- $page, // The page on which this option will be displayed
- $section, // The name of the section to which this field belongs
+ 'iw_single_author', // ID used to identify the field throughout the theme.
+ 'Single Author Site', // The label to the left of the option interface element.
+ array( 'IndieWeb_General_Settings', 'checkbox_callback' ), // The name of the function responsible for rendering the option interface.
+ $page, // The page on which this option will be displayed.
+ $section, // The name of the section to which this field belongs.
array( // The array of arguments to pass to the callback. In this case, just a description.
'name' => 'iw_single_author',
'description' => __( 'If this website represents a single individual or entity, check this. This setting is disabled if you only have one user who has made a post.', 'indieweb' ),
@@ -93,19 +110,19 @@
);
add_settings_field(
- 'iw_default_author', // ID used to identify the field throughout the theme
- 'Default Author', // The label to the left of the option interface element
- array( 'IndieWeb_General_Settings', 'default_author_callback' ), // The name of the function responsible for rendering the option interface
- $page, // The page on which this option will be displayed
- $section // The name of the section to which this field belongs
+ 'iw_default_author', // ID used to identify the field throughout the theme.
+ 'Default Author', // The label to the left of the option interface element.
+ array( 'IndieWeb_General_Settings', 'default_author_callback' ), // The name of the function responsible for rendering the option interface.
+ $page, // The page on which this option will be displayed.
+ $section // The name of the section to which this field belongs.
);
add_settings_field(
- 'iw_author_url', // ID used to identify the field throughout the theme
- __( 'Use User Website URL for Author', 'indieweb' ), // The label to the left of the option interface element
- array( 'IndieWeb_General_Settings', 'checkbox_callback' ), // The name of the function responsible for rendering the option interface
- $page, // The page on which this option will be displayed
- $section, // The name of the section to which this field belongs
+ 'iw_author_url', // ID used to identify the field throughout the theme.
+ __( 'Use User Website URL for Author', 'indieweb' ), // The label to the left of the option interface element.
+ array( 'IndieWeb_General_Settings', 'checkbox_callback' ), // The name of the function responsible for rendering the option interface.
+ $page, // The page on which this option will be displayed.
+ $section, // The name of the section to which this field belongs.
array( // The array of arguments to pass to the callback. In this case, just a description.
'name' => 'iw_author_url',
'description' => __( 'If checked, this will replace the author page URL with the website URL from your user profile.', 'indieweb' ),
@@ -114,11 +131,11 @@
);
add_settings_field(
- 'iw_relme_bw', // ID used to identify the field throughout the theme
- __( 'Black and White Icons', 'indieweb' ), // The label to the left of the option interface element
- array( 'IndieWeb_General_Settings', 'checkbox_callback' ), // The name of the function responsible for rendering the option interface
- $page, // The page on which this option will be displayed
- $section, // The name of the section to which this field belongs
+ 'iw_relme_bw', // ID used to identify the field throughout the theme.
+ __( 'Black and White Icons', 'indieweb' ), // The label to the left of the option interface element.
+ array( 'IndieWeb_General_Settings', 'checkbox_callback' ), // The name of the function responsible for rendering the option interface.
+ $page, // The page on which this option will be displayed.
+ $section, // The name of the section to which this field belongs.
array( // The array of arguments to pass to the callback. In this case, just a description.
'name' => 'iw_relme_bw',
'description' => __( 'If checked, the icon colors will not be loaded', 'indieweb' ),
@@ -128,6 +145,9 @@
}
+ /**
+ * Callback for identity options section.
+ */
public static function identity_options_callback() {
echo '<p>';
esc_html_e(
@@ -147,8 +167,11 @@
echo '</p>';
}
+ /**
+ * Render the general options page.
+ */
public static function general_options_page() {
- // If this is not a multi-author site, remove the single author setting
+ // If this is not a multi-author site, remove the single author setting.
if ( ! is_multi_author() ) {
delete_option( 'iw_single_author' );
}
@@ -165,6 +188,11 @@
echo '</div>';
}
+ /**
+ * Render a checkbox field.
+ *
+ * @param array $args Field arguments.
+ */
public static function checkbox_callback( array $args ) {
$option = get_option( $args['name'] );
$disabled = isset( $args['disabled'] ) ? $args['disabled'] : false;
@@ -179,6 +207,9 @@
}
}
+ /**
+ * Render the default author dropdown.
+ */
public static function default_author_callback() {
$users = get_users(
array(
--- a/indieweb/includes/class-hcard-author-widget.php
+++ b/indieweb/includes/class-hcard-author-widget.php
@@ -1,27 +1,39 @@
<?php
+/**
+ * H-Card Author Widget.
+ *
+ * @package IndieWeb
+ *
+ * phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed
+ */
add_action( 'widgets_init', 'indieweb_register_hcard' );
+/**
+ * Register the H-Card widget.
+ */
function indieweb_register_hcard() {
register_widget( 'HCard_Author_Widget' );
}
-// phpcs:ignore Universal.Files.SeparateFunctionsFromOO.Mixed
+/**
+ * Widget to display author profile as an h-card.
+ */
class HCard_Author_Widget extends WP_Widget {
/**
* Register widget with WordPress.
*/
public function __construct() {
parent::__construct(
- 'HCard_Widget', // Base ID
- 'Author Profile H-Card Widget', // Name
+ 'HCard_Widget', // Base ID.
+ 'Author Profile H-Card Widget', // Name.
array(
'classname' => 'hcard_widget',
'description' => __( 'A widget that allows you to display author profile marked up as an h-card', 'indieweb' ),
'show_instance_in_rest' => true,
)
);
- } // end constructor
+ }
/**
* Front-end display of widget.
@@ -74,7 +86,7 @@
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
- // Strip tags to remove HTML (important for text inputs)
+ // Strip tags to remove HTML (important for text inputs).
foreach ( $new_instance as $k => $v ) {
if ( in_array( $k, array( 'notes', 'location', 'avatar' ), true ) ) {
$v = (int) $v;
@@ -82,7 +94,7 @@
$instance[ $k ] = wp_strip_all_tags( $v );
}
- // Apply changes to checkboxes which are unchecked when absent from the POST
+ // Apply changes to checkboxes which are unchecked when absent from the POST.
$instance['reveal_email'] = isset( $new_instance['reveal_email'] ) ? 'on' : '';
return $instance;
@@ -90,7 +102,7 @@
/**
- * Create the form for the Widget admin
+ * Create the form for the Widget admin.
*
* @see WP_Widget::form()
*
@@ -98,7 +110,7 @@
*/
public function form( $instance ) {
- // Set up some default widget settings
+ // Set up some default widget settings.
$defaults = array(
'avatar' => 1,
'location' => 1,
--- a/indieweb/includes/class-hcard-user.php
+++ b/indieweb/includes/class-hcard-user.php
@@ -1,21 +1,31 @@
<?php
+/**
+ * H-Card User Profile Extensions.
+ *
+ * @package IndieWeb
+ */
add_action( 'init', array( 'HCard_User', 'init' ) );
add_action( 'widgets_init', array( 'HCard_User', 'init_widgets' ) );
-// Extended Profile for Rel-Me and H-Card
+/**
+ * Extended Profile for Rel-Me and H-Card.
+ */
class HCard_User {
+ /**
+ * Initialize the H-Card user functionality.
+ */
public static function init() {
include_once 'simple-icons.php';
if ( 1 === (int) get_option( 'iw_author_url' ) ) {
- add_filter( 'author_link', array( 'HCard_User', 'author_link' ), 10, 3 );
+ add_filter( 'author_link', array( 'HCard_User', 'author_link' ), 10, 2 );
}
add_filter( 'user_contactmethods', array( 'HCard_User', 'user_contactmethods' ) );
add_action( 'show_user_profile', array( 'HCard_User', 'extended_user_profile' ) );
add_action( 'edit_user_profile', array( 'HCard_User', 'extended_user_profile' ) );
- // Save Extra User Data
+ // Save Extra User Data.
add_action( 'personal_options_update', array( 'HCard_User', 'save_profile' ), 11 );
add_action( 'edit_user_profile_update', array( 'HCard_User', 'save_profile' ), 11 );
add_filter( 'wp_head', array( 'HCard_User', 'pgp' ), 11 );
@@ -23,16 +33,20 @@
}
/**
- * register WordPress widgets
+ * Register WordPress widgets.
*/
public static function init_widgets() {
register_widget( 'RelMe_Widget' );
}
/**
- * If there is a URL set in the user profile, set author link to that
+ * If there is a URL set in the user profile, set author link to that.
+ *
+ * @param string $link The author link.
+ * @param int $author_id The author ID.
+ * @return string The modified author link.
*/
- public static function author_link( $link, $author_id, $nicename ) {
+ public static function author_link( $link, $author_id ) {
if ( in_the_loop() && ( is_home() || is_archive() || is_singular() ) ) {
$user_info = get_userdata( $author_id );
if ( ! empty( $user_info->user_url ) ) {
@@ -43,9 +57,12 @@
}
/**
- * list of popular silos and profile url patterns
- * Focusing on those which are supported by indieauth
- * https://indieweb.org/indieauth.com
+ * List of popular silos and profile URL patterns.
+ *
+ * Focusing on those which are supported by IndieAuth.
+ *
+ * @see https://indieweb.org/indieauth.com
+ * @return array Array of silo configurations.
*/
public static function silos() {
$silos = array(
@@ -92,11 +109,10 @@
/**
- * additional user fields
- *
- * @param array $profile_fields Current profile fields
+ * Additional user fields.
*
- * @return array $profile_fields extended
+ * @param array $profile_fields Current profile fields.
+ * @return array Extended profile fields.
*/
public static function user_contactmethods( $profile_fields ) {
foreach ( self::silos() as $silo => $details ) {
@@ -105,12 +121,17 @@
}
}
- // Telephone Number and PGP Key are not silos
+ // Telephone Number and PGP Key are not silos.
$profile_fields['tel'] = __( 'Telephone', 'indieweb' );
$profile_fields['pgp'] = __( 'PGP Key (URL)', 'indieweb' );
return $profile_fields;
}
+ /**
+ * Get address fields configuration.
+ *
+ * @return array Address fields.
+ */
public static function address_fields() {
$address = array(
'street_address' => array(
@@ -141,6 +162,11 @@
return apply_filters( 'wp_user_address', $address );
}
+ /**
+ * Get extra profile fields configuration.
+ *
+ * @return array Extra fields.
+ */
public static function extra_fields() {
$extras = array(
'job_title' => array(
@@ -159,6 +185,11 @@
return apply_filters( 'wp_user_extrafields', $extras );
}
+ /**
+ * Render extended user profile fields.
+ *
+ * @param WP_User $user The user object.
+ */
public static function extended_user_profile( $user ) {
echo '<h3>' . esc_html__( 'Address', 'indieweb' ) . '</h3>';
echo '<p>' . esc_html__( 'Fill in all fields you wish displayed.', 'indieweb' ) . '</p>';
@@ -178,6 +209,14 @@
echo '</table>';
}
+ /**
+ * Render a text field for the extended profile.
+ *
+ * @param WP_User $user The user object.
+ * @param string $key The field key.
+ * @param string $title The field title.
+ * @param string $description The field description.
+ */
public static function extended_profile_text_field( $user, $key, $title, $description ) {
?>
<tr>
@@ -190,6 +229,14 @@
<?php
}
+ /**
+ * Render a textarea field for the extended profile.
+ *
+ * @param WP_User $user The user object.
+ * @param string $key The field key.
+ * @param string $title The field title.
+ * @param string $description The field description.
+ */
public static function extended_profile_textarea_field( $user, $key, $title, $description ) {
$value = get_the_author_meta( $key, $user->ID );
if ( is_array( $value ) ) {
@@ -206,12 +253,15 @@
<?php
}
+ /**
+ * Register REST API fields.
+ */
public static function rest_fields() {
register_rest_field(
'user',
'me',
array(
- 'get_callback' => function ( $user, $attr, $request, $object_type ) {
+ 'get_callback' => function ( $user ) {
return array_values( self::get_rel_me( $user['id'] ) );
},
)
@@ -220,13 +270,19 @@
'user',
'first_name',
array(
- 'get_callback' => function ( $user, $attr, $request, $object_type ) {
- return get_user_meta( $user['id'], 'first_name' );
+ 'get_callback' => function ( $user ) {
+ return get_user_meta( $user['id'], 'first_name', true );
},
)
);
}
+ /**
+ * Save profile data.
+ *
+ * @param int $user_id The user ID.
+ * @return bool|void False if permission denied.
+ */
public static function save_profile( $user_id ) {
if ( ! current_user_can( 'edit_user', $user_id ) ) {
return false;
@@ -254,12 +310,11 @@
/**
* Filters a single silo URL.
*
- * @param string $string A string that is expected to be a silo URL.
- * @return string|bool The filtered and escaped URL string, or FALSE if invalid.
- * @used-by clean_urls
+ * @param string $url_string A string that is expected to be a silo URL.
+ * @return string|bool The filtered and escaped URL string, or FALSE if invalid.
*/
- public static function clean_url( $string ) {
- $url = trim( $string );
+ public static function clean_url( $url_string ) {
+ $url = trim( $url_string );
if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
return false;
}
@@ -267,7 +322,7 @@
if ( ! $host ) {
return false;
}
- // Rewrite these to https as needed
+ // Rewrite these to https as needed.
$secure = apply_filters( 'iwc_rewrite_secure', array( 'facebook.com', 'twitter.com', 'github.com' ) );
if ( in_array( preg_replace( '/^www./', '', $host ), $secure, true ) ) {
$url = preg_replace( '/^http:/i', 'https:', $url );
@@ -291,7 +346,10 @@
}
/**
- * returns an array of links from the user profile to be used as rel-me
+ * Returns an array of links from the user profile to be used as rel-me.
+ *
+ * @param int|null $author_id The author ID.
+ * @return array|false Array of rel-me links or false.
*/
public static function get_rel_me( $author_id = null ) {
if ( empty( $author_id ) ) {
@@ -308,14 +366,14 @@
$socialmeta = get_the_author_meta( $silo, $author_id );
if ( ! empty( $socialmeta ) ) {
- // If it is not a URL
+ // If it is not a URL.
if ( ! filter_var( $socialmeta, FILTER_VALIDATE_URL ) ) {
- // If the username has the @ symbol strip it
+ // If the username has the @ symbol strip it.
if ( ( 'twitter' === $silo ) && ( preg_match( '/^@?(w+)$/i', $socialmeta, $matches ) ) ) {
$socialmeta = trim( $socialmeta, '@' );
}
$list[ $silo ] = sprintf( $details['baseurl'], $socialmeta );
- // Pass the URL itself
+ // Pass the URL itself.
} else {
$list[ $silo ] = self::clean_url( $socialmeta );
}
@@ -337,14 +395,21 @@
}
/**
- * returns a formatted <ul> list of rel=me to supported silos
+ * Prints a formatted list of rel=me to supported silos.
+ *
+ * @param int|null $author_id The author ID.
+ * @param bool $include_rel Whether to include rel attribute.
*/
public static function rel_me_list( $author_id = null, $include_rel = false ) {
echo self::get_rel_me_list( $author_id, $include_rel ); // phpcs:ignore
}
/**
- * returns a formatted <ul> list of rel=me to supported silos
+ * Returns a formatted list of rel=me to supported silos.
+ *
+ * @param int|null $author_id The author ID.
+ * @param bool $include_rel Whether to include rel attribute.
+ * @return string|false The HTML list or false.
*/
public static function get_rel_me_list( $author_id = null, $include_rel = false ) {
$list = self::get_rel_me( $author_id );
@@ -367,25 +432,32 @@
}
/**
- * prints a formatted list of rel=me for the head to supported silos
+ * Returns a formatted list of rel=me for the head to supported silos.
+ *
+ * @param int|null $author_id The author ID.
+ * @return string|false The HTML links or false.
*/
public static function relme_head_list( $author_id = null ) {
$list = self::get_rel_me( $author_id );
if ( ! $list ) {
return false;
}
- $author_name = get_the_author_meta( 'display_name', $author_id );
- $r = array();
+ $r = array();
foreach ( $list as $silo => $profile_url ) {
$r[ $silo ] = '<link rel="me" href="' . esc_url( $profile_url ) . '" />' . PHP_EOL;
}
return join( '', $r );
}
+ /**
+ * Get the current author ID based on context.
+ *
+ * @return int|null The author ID or null.
+ */
public static function get_author() {
$single_author = get_option( 'iw_single_author' );
if ( is_front_page() && 1 === (int) $single_author ) {
- return get_option( 'iw_default_author' ); // Set the author ID to default
+ return get_option( 'iw_default_author' ); // Set the author ID to default.
} elseif ( is_author() ) {
$author = get_user_by( 'slug', get_query_var( 'author_name' ) );
if ( $author instanceof WP_User ) {
@@ -398,6 +470,9 @@
}
}
+ /**
+ * Output PGP key link in head.
+ */
public static function pgp() {
$author_id = self::get_author();
if ( ! $author_id ) {
@@ -405,12 +480,12 @@
}
$pgp = get_user_option( 'pgp', $author_id );
if ( ! empty( $pgp ) ) {
- printf( '<link rel="pgpkey" href="%1$s" />', $pgp ); // phpcs:ignore
+ printf( '<link rel="pgpkey" href="%1$s" />', esc_url( $pgp ) );
}
}
/**
- *
+ * Output rel-me links in head.
*/
public static function relme_head() {
$author_id = self::get_author();
@@ -420,17 +495,22 @@
echo self::relme_head_list( $author_id ); // phpcs:ignore
}
+ /**
+ * Get default display options for h-card.
+ *
+ * @return array Default display options.
+ */
public static function get_hcard_display_defaults() {
$defaults = array(
'style' => 'div',
'container-css' => '',
'single-css' => '',
'avatar_size' => 96,
- 'avatar' => true, // Display Avatar
- 'location' => true, // Display location elements
- 'notes' => true, // Display Bio/Notes
- 'email' => false, // Display email
- 'me' => true, // Display rel-me links inside h-card
+ 'avatar' => true, // Display Avatar.
+ 'location' => true, // Display location elements.
+ 'notes' => true, // Display Bio/Notes.
+ 'email' => false, // Display email.
+ 'me' => true, // Display rel-me links inside h-card.
);
return apply_filters( 'hcard_display_defaults', $defaults );
}
@@ -440,14 +520,21 @@
* /templates subdirectory of the active theme (child, parent).
* Defaults to the /templates subdirectory in this plugin.
*
- * @param string $file_name File name, example: h-card.php
- * @return string Full path to file
+ * @param string $file_name File name, example: h-card.php.
+ * @return string Full path to file.
*/
public static function get_template_file( $file_name ) {
$theme_template_file = locate_template( 'templates/' . $file_name );
return $theme_template_file ? $theme_template_file : __DIR__ . '/../templates/' . $file_name;
}
+ /**
+ * Render the h-card for a user.
+ *
+ * @param int|WP_User $user The user ID or object.
+ * @param array $args Display arguments.
+ * @return string|false The h-card HTML or false.
+ */
public static function hcard( $user, $args = array() ) {
if ( ! $user ) {
return false;
@@ -458,6 +545,8 @@
}
$args = wp_parse_args( $args, self::get_hcard_display_defaults() );
+ // Variables are used in the included template file (h-card.php).
+ // phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
if ( $args['avatar'] ) {
$avatar = get_avatar(
$user,
@@ -474,6 +563,7 @@
$url = $user->has_prop( 'user_url' ) ? $user->get( 'user_url' ) : $url = get_author_posts_url( $user->ID );
$name = $user->get( 'display_name' );
$email = $user->get( 'user_email' );
+ // phpcs:enable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
ob_start();
include self::get_template_file( 'h-card.php' );
$return = ob_get_contents();
--- a/indieweb/includes/class-integrations.php
+++ b/indieweb/includes/class-integrations.php
@@ -1,22 +1,29 @@
<?php
+/**
+ * Third party integrations for IndieWeb.
+ *
+ * @package IndieWeb
+ */
add_action( 'init', array( 'IndieWeb_Integrations', 'init' ) );
/**
- * Third party integrations
- *
+ * Third party integrations.
*/
class IndieWeb_Integrations {
+ /**
+ * Initialize integrations.
+ */
public static function init() {
add_filter( 'pubsubhubbub_feed_urls', array( 'IndieWeb_Integrations', 'add_pubsubhubbub_feeds' ) );
}
/**
- * adds the Microformats (2) feed to PubsubHubBub
+ * Adds the Microformats (2) feed to PubsubHubBub.
*
- * @param array $feeds
- * @return array
+ * @param array $feeds Array of feed URLs.
+ * @return array Modified array of feed URLs.
*/
public static function add_pubsubhubbub_feeds( $feeds ) {
$feeds[] = get_post_type_archive_link( 'post' );
--- a/indieweb/includes/class-plugin-installer.php
+++ b/indieweb/includes/class-plugin-installer.php
@@ -1,46 +1,43 @@
<?php
/**
- * IndieWeb_Plugin_Installer
+ * IndieWeb Plugin Installer.
*
* @author Darren Cooney
* @link https://github.com/dcooney/wordpress-plugin-installer
* @link https://connekthq.com
* @version 1.0
+ * @package IndieWeb
*/
-
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
-
-
if ( ! class_exists( 'IndieWeb_Plugin_Installer' ) ) {
+ /**
+ * Plugin Installer class for IndieWeb.
+ */
class IndieWeb_Plugin_Installer {
+ /**
+ * Start the installer.
+ */
public function start() {
if ( ! defined( 'CNKT_INSTALLER_PATH' ) ) {
- // Update this constant to use outside the plugins directory
+ // Update this constant to use outside the plugins directory.
define( 'CNKT_INSTALLER_PATH', plugins_url( '/', __FILE__ ) );
}
- add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); // Enqueue scripts and Localize
- add_action( 'wp_ajax_cnkt_plugin_installer', array( &$this, 'cnkt_plugin_installer' ) ); // Install plugin
- add_action( 'wp_ajax_cnkt_plugin_activation', array( &$this, 'cnkt_plugin_activation' ) ); // Activate plugin
+ add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); // Enqueue scripts and Localize.
+ add_action( 'wp_ajax_cnkt_plugin_installer', array( &$this, 'cnkt_plugin_installer' ) ); // Install plugin.
+ add_action( 'wp_ajax_cnkt_plugin_activation', array( &$this, 'cnkt_plugin_activation' ) ); // Activate plugin.
}
-
-
-
- /*
- * init
- * Initialize the display of the plugins.
- *
- *
- * @param $plugin Array - plugin data
- *
- * @since 1.0
- */
+ /**
+ * Initialize the display of the plugins.
+ *
+ * @param array $plugins Array of plugin data.
+ */
public static function init( $plugins ) {
?>
@@ -74,23 +71,22 @@
)
);
- if ( ! is_wp_error( $api ) ) { // confirm error free
+ if ( ! is_wp_error( $api ) ) { // Confirm error free.
- $main_plugin_file = self::get_plugin_file( $plugin['slug'] ); // Get main plugin file
- //echo $main_plugin_file;
- if ( self::check_file_extension( $main_plugin_file ) ) { // check file extension
+ $main_plugin_file = self::get_plugin_file( $plugin['slug'] ); // Get main plugin file.
+ if ( self::check_file_extension( $main_plugin_file ) ) { // Check file extension.
if ( is_plugin_active( $main_plugin_file ) ) {
- // plugin activation, confirmed!
+ // Plugin activation, confirmed!
$button_classes = 'button disabled';
$button_text = __( 'Activated', 'indieweb' );
} else {
- // It's installed, let's activate it
+ // It's installed, let's activate it.
$button_classes = 'activate button button-primary';
$button_text = __( 'Activate', 'indieweb' );
}
}
- // Send plugin data to template
+ // Send plugin data to template.
self::render_template( $plugin, $api, $button_text, $button_classes );
}
@@ -101,21 +97,14 @@
<?php
}
-
-
-
- /*
- * render_template
- * Render display template for each plugin.
- *
- *
- * @param $plugin Array - Original data passed to init()
- * @param $api Array - Results from plugins_api
- * @param $button_text String - text for the button
- * @param $button_classes String - classnames for the button
- *
- * @since 1.0
- */
+ /**
+ * Render display template for each plugin.
+ *
+ * @param array $plugin Original data passed to init().
+ * @param object $api Results from plugins_api.
+ * @param string $button_text Text for the button.
+ * @param string $button_classes Classnames for the button.
+ */
public static function render_template( $plugin, $api, $button_text, $button_classes ) {
if ( isset( $api->icons['1x'] ) ) {
$icon = $api->icons['1x'];
@@ -138,7 +127,7 @@
<h2><?php echo esc_html( $api->name ); ?></h2>
<p><?php echo esc_html( $api->short_description ); ?></p>
- <p class="plugin-author"><?php esc_html_e( 'By', 'indieweb' ); ?> <?php echo $api->author; // phpcs:ignore ?></p>
+ <p class="plugin-author"><?php esc_html_e( 'By', 'indieweb' ); ?> <?php echo wp_kses( $api->author, array( 'a' => array( 'href' => array() ) ) ); ?></p>
</div>
<ul class="activation-row">
<li>
@@ -162,35 +151,30 @@
- /*
- * cnkt_plugin_installer
- * An Ajax method for installing plugin.
- *
- * @return $json
- *
- * @since 1.0
- */
+ /**
+ * An Ajax method for installing plugin.
+ */
public function cnkt_plugin_installer() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( esc_html( __( 'Sorry, you are not allowed to install plugins on this site.', 'indieweb' ) ) );
}
- $nonce = $_POST['nonce']; // phpcs:ignore
- $plugin = $_POST['plugin']; // phpcs:ignore
+ $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
+ $plugin = isset( $_POST['plugin'] ) ? sanitize_key( wp_unslash( $_POST['plugin'] ) ) : '';
// Check our nonce, if they don't match then bounce!
if ( ! wp_verify_nonce( $nonce, 'cnkt_installer_nonce' ) ) {
wp_die( esc_html( __( 'Error - unable to verify nonce, please try again.', 'indieweb' ) ) );
}
- // Include required libs for installation
+ // Include required libs for installation.
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php';
require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php';
- // Get Plugin Info
+ // Get Plugin Info.
$api = plugins_api(
'plugin_information',
array(
@@ -235,33 +219,28 @@
- /*
- * cnkt_plugin_activation
- * Activate plugin via Ajax.
- *
- * @return $json
- *
- * @since 1.0
- */
+ /**
+ * Activate plugin via Ajax.
+ */
public function cnkt_plugin_activation() {
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( esc_html( __( 'Sorry, you are not allowed to activate plugins on this site.', 'indieweb' ) ) );
}
- $nonce = $_POST['nonce']; // phpcs:ignore
- $plugin = $_POST['plugin']; // phpcs:ignore
+ $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
+ $plugin = isset( $_POST['plugin'] ) ? sanitize_key( wp_unslash( $_POST['plugin'] ) ) : '';
// Check our nonce, if they don't match then bounce!
if ( ! wp_verify_nonce( $nonce, 'cnkt_installer_nonce' ) ) {
- die( esc_html( __( 'Error - unable to verify nonce, please try again.', 'indieweb' ) ) );
+ wp_die( esc_html( __( 'Error - unable to verify nonce, please try again.', 'indieweb' ) ) );
}
- // Include required libs for activation
+ // Include required libs for activation.
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php';
- // Get Plugin Info
+ // Get Plugin Info.
$api = plugins_api(
'plugin_information',
array(
@@ -306,68 +285,46 @@
- /*
- * get_plugin_file
- * A method to get the main plugin file.
- *
- *
- * @param $plugin_slug String - The slug of the plugin
- * @return $plugin_file
- *
- * @since 1.0
- */
-
+ /**
+ * A method to get the main plugin file.
+ *
+ * @param string $plugin_slug The slug of the plugin.
+ * @return string|null The plugin file path or null.
+ */
public static function get_plugin_file( $plugin_slug ) {
- require_once ABSPATH . '/wp-admin/includes/plugin.php'; // Load plugin lib
+ require_once ABSPATH . '/wp-admin/includes/plugin.php'; // Load plugin lib.
$plugins = get_plugins();
foreach ( $plugins as $plugin_file => $plugin_info ) {
- // Get the basename of the plugin e.g. [askismet]/askismet.php
+ // Get the basename of the plugin e.g. [askismet]/askismet.php.
$slug = dirname( plugin_basename( $plugin_file ) );
- if ( $slug ) {
- if ( $slug === $plugin_slug ) {
- return $plugin_file; // If $slug = $plugin_name
- }
+ if ( $slug && $slug === $plugin_slug ) {
+ return $plugin_file;
}
}
return null;
}
-
-
-
- /*
- * check_file_extension
- * A helper to check file extension
- *
- *
- * @param $filename String - The filename of the plugin
- * @return boolean
- *
- * @since 1.0
- */
+ /**
+ * A helper to check file extension.
+ *
+ * @param string $filename The filename of the plugin.
+ * @return bool True if PHP file, false otherwise.
+ */
public static function check_file_extension( $filename ) {
if ( substr( strrchr( $filename, '.' ), 1 ) === 'php' ) {
- // has .php exension
+ // Has .php extension.
return true;
} else {
- // ./wp-content/plugins
return false;
}
}
-
-
-
- /*
- * enqueue_scripts
- * Enqueue admin scripts and scripts localization
- *
- *
- * @since 1.0
- */
+ /**
+ * Enqueue admin scripts and scripts localization.
+ */
public function enqueue_scripts() {
wp_enqueue_script( 'plugin-installer', CNKT_INSTALLER_PATH . 'static/js/installer.js', array( 'jquery' ), IndieWeb_Plugin::$version, true );
wp_localize_script(
@@ -388,7 +345,7 @@
}
- // initialize
+ // Initialize.
$connekt_plugin_installer = new IndieWeb_Plugin_Installer();
$connekt_plugin_installer->start();
} // End if( class_exists )
--- a/indieweb/includes/class-relme-domain-icon-map.php
+++ b/indieweb/includes/class-relme-domain-icon-map.php
@@ -1,9 +1,20 @@
<?php
-/* Maps domain names to icons from the provided SVG fontset
+/**
+ * Maps domain names to icons from the provided SVG fontset.
+ *
+ * @package IndieWeb
+ */
+
+/**
+ * Rel-Me Domain Icon Map class.
*/
class Rel_Me_Domain_Icon_Map {
- // Common mappings and custom mappings
+ /**
+ * Common and custom domain to icon mappings.
+ *
+ * @var array
+ */
private static $map = array(
'twitter.com' => 'twitter',
'blogspot.com' => 'blogger',
@@ -35,19 +46,29 @@
);
- // Try to get the correct icon for the majority of sites
- public static function split_domain( $string ) {
- $explode = explode( '.', $string );
+ /**
+ * Try to get the correct icon for the majority of sites.
+ *
+ * @param string $domain_string The domain string to split.
+ * @return string The extracted domain part.
+ */
+ public static function split_domain( $domain_string ) {
+ $explode = explode( '.', $domain_string );
if ( 2 === count( $explode ) ) {
return $explode[0];
}
if ( 3 === count( $explode ) ) {
return $explode[1];
}
- return $string;
+ return $domain_string;
}
- // Return the filename of an icon based on name if the file exists
+ /**
+ * Return the filename of an icon based on name if the file exists.
+ *
+ * @param string $name The icon name.
+ * @return string|null The icon file path or null if not found.
+ */
public static function get_icon_filename( $name ) {
$svg = sprintf( '%1$s/static/svg/%2$s.svg', plugin_dir_path( __DIR__ ), $name );
if ( file_exists( $svg ) ) {
@@ -56,7 +77,12 @@
return null;
}
- // Return the retrieved svg based on name
+ /**
+ * Return the retrieved SVG based on name.
+ *
+ * @param string $name The icon name.
+ * @return string|null The SVG content or null if not found.
+ */
public static function get_icon_svg( $name ) {
$file = self::get_icon_filename( $name );
if ( $file ) {
@@ -68,6 +94,12 @@
return null;
}
+ /**
+ * Get the icon HTML markup.
+ *
+ * @param string $name The icon name.
+ * @return string The icon HTML or the name if not found.
+ */
public static function get_icon( $name ) {
$icon = self::get_icon_svg( $name );
$title = self::get_title( $name );
@@ -77,6 +109,12 @@
return $name;
}
+ /**
+ * Get the title for an icon.
+ *
+ * @param string $name The icon name.
+ * @return string The icon title.
+ */
public static function get_title( $name ) {
$strings = simpleicons_iw_get_names();
if ( isset( $strings[ $name ] ) ) {
@@ -85,6 +123,11 @@
return $name;
}
+ /**
+ * Get the Mastodon URL from user meta.
+ *
+ * @return string|false The Mastodon domain or false.
+ */
public static function mastodon_url() {
$mastodon = get_transient( 'indieweb_mastodon' );
if ( false !== $mastodon ) {
@@ -93,6 +136,7 @@
$args = array(
'number' => 1,
'count_total' => false,
+ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Required to find users with Mastodon URL.
'meta_query' => array(
array(
'key' => 'mastodon',
@@ -114,24 +158,30 @@
set_transient( 'indieweb_mastodon', $value );
}
+ /**
+ * Convert a URL to an icon name.
+ *
+ * @param string $url The URL to convert.
+ * @return string The icon name.
+ */
public static function url_to_name( $url ) {
$scheme = wp_parse_url( $url, PHP_URL_SCHEME );
- // The default if not an http link is to return notice
+ // The default if not an http link is to return notice.
$return = 'notice';
if ( ( 'http' === $scheme ) || ( 'https' === $scheme ) ) {
- $return = 'website'; // default for web links
+ $return = 'website'; // Default for web links.
$url = strtolower( $url );
$domain = wp_parse_url( $url, PHP_URL_HOST );
- $domain = str_replace( 'www.', '', $domain ); // Always remove www
+ $domain = str_replace( 'www.', '', $domain ); // Always remove www.
- // If the domain is already on the pre-loaded list then use that
+ // If the domain is already on the pre-loaded list then use that.
if ( array_key_exists( $domain, self::$map ) ) {
$return = self::$map[ $domain ];
} elseif ( self::mastodon_url() === $domain ) {
$return = 'mastodon';
} else {
- // Remove extra info and try to map it to an icon
+ // Remove extra info and try to map it to an icon.
$strip = self::split_domain( $domain );
if ( self::get_icon_filename( $strip ) ) {
$return = $strip;
@@ -139,17 +189,17 @@
$return = str_replace( '.', '-dot-', $domain );
} elseif ( self::get_icon_filename( str_replace( '.', '', $domain ) ) ) {
$return = str_replace( '.', '', $domain );
- } else if ( false !== stripos( $domain, 'wordpress' ) ) { // phpcs:ignore
- // Anything with WordPress in the name that is not matched return WordPress
- $return = 'wordpress'; // phpcs:ignore
- } else if ( false !== stripos( $domain, 'read' ) ) { // phpcs:ignore
- // Anything with read in the name that is not matched return a book
- $return = 'book'; // phpcs:ignore
- } else if ( false !== stripos( $domain, 'news' ) ) { // phpcs:ignore
- // Anything with news in the name that is not matched return the summary icon
- $return = 'summary'; // phpcs:ignore
+ } elseif ( false !== stripos( $domain, 'wordpress' ) ) { // phpcs:ignore WordPress.WP.CapitalPDangit
+ // Anything with WordPress in the name that is not matched return WordPress icon.
+ $return = 'wordpress'; // phpcs:ignore WordPress.WP.CapitalPDangit
+ } elseif ( false !== stripos( $domain, 'read' ) ) {
+ // Anything with read in the name that is not matched return a book.
+ $return = 'book';
+ } elseif ( false !== stripos( $domain, 'news' ) ) {
+ // Anything with news in the name that is not matched return the summary icon.
+ $return = 'summary';
} else {
- // Some domains have the word app in them check for matches with that
+ // Some domains have the word app in them check for matches with that.
$strip = str_replace( 'app', '', $strip );
if ( self::get_icon_filename( $strip ) ) {
$return = $strip;
@@ -166,7 +216,7 @@
if ( 'gtalk' === $scheme ) {
return 'googlehangouts';
}
- // Save the determined mapping into the map so that it will not have to look again on the same page load
+ // Save the determined mapping into the map so that it will not have to look again on the same page load.
self::$map[ $domain ] = $return;
$return = apply_filters( 'indieweb_links_url_to_name', $return, $url );
return $return;
--- a/indieweb/includes/class-relme-widget.php
+++ b/indieweb/includes/class-relme-widget.php
@@ -1,12 +1,17 @@
<?php
+/**
+ * Rel-Me Widget.
+ *
+ * @package IndieWeb
+ */
/**
- * adds widget to display rel-me links for indieauth with per-user profile support
+ * Adds widget to display rel-me links for IndieAuth with per-user profile support.
*/
class RelMe_Widget extends WP_Widget {
/**
- * widget constructor
+ * Widget constructor.
*/
public function __construct() {
parent::__construct(
@@ -23,59 +28,53 @@
}
/**
- * widget worker
+ * Widget worker.
*
- * @param mixed $args widget parameters
- * @param mixed $instance saved widget data
- *
- * @output echoes the list of rel-me links for the author
+ * @param mixed $args Widget parameters (unused, required by WP_Widget).
+ * @param mixed $instance Saved widget data (unused, required by WP_Widget).
*/
- public function widget( $args, $instance ) {
- global $authordata;
+ public function widget( $args, $instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
+ global $authordata, $post;
$default_admin_user = $this->get_default_admin_author_id();
$single_author = get_option( 'iw_single_author', is_multi_author() ? '0' : '1' );
- $author_id = get_option( 'iw_default_author', $default_admin_user ); // Set the author ID to default.
+ $author_id = get_option( 'iw_default_author', $default_admin_user );
$include_rel = false;
if ( is_front_page() && '1' === $single_author ) {
$include_rel = true;
}
if ( is_author() ) {
- global $authordata;
$author_id = ( $authordata instanceof WP_User ) ? $authordata->ID : $author_id;
if ( 0 === (int) $single_author ) {
$include_rel = true;
}
}
if ( is_singular() && '0' === $single_author ) {
- global $post;
$author_id = $post->post_author;
}
- echo hcard_user::rel_me_list( $author_id, $include_rel ); // phpcs:ignore
+ echo HCard_User::rel_me_list( $author_id, $include_rel ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
- * widget data updater
+ * Widget data updater.
*
- * @param mixed $new_instance new widget data
- * @param mixed $old_instance current widget data
+ * @param mixed $new_instance New widget data.
+ * @param mixed $old_instance Current widget data (unused, required by WP_Widget).
*
- * @return mixed widget data
+ * @return mixed Widget data.
*/
- public function update( $new_instance, $old_instance ) {
+ public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
return $new_instance;
}
/**
- * widget form
- *
- * @param mixed $instance
+ * Widget form.
*
- * @output displays the widget form
+ * @param mixed $instance Widget instance (unused, required by WP_Widget).
*/
- public function form( $instance ) {
+ public function form( $instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
echo '<p>';
esc_html_e( 'Displays rel=me links which appear as icons with the logo of the site linked to when possible', 'indieweb' );
echo '</p>';
--- a/indieweb/includes/getting-started.php
+++ b/indieweb/includes/getting-started.php
@@ -1,3 +1,19 @@
+<?php
+/**
+ * Getting Started page template.
+ *
+ * @package IndieWeb
+ */
+
+$allowed_html = array(
+ 'strong' => array(),
+ 'em' => array(),
+ 'a' => array(
+ 'href' => array(),
+ 'target' => array(),
+ ),
+);
+?>
<div class="wrap indieweb-getting-started">
<h1><?php esc_html_e( 'IndieWebify your WordPress-Blog', 'indieweb' ); ?></h1>
@@ -9,67 +25,99 @@
<p>
<?php
esc_html_e(
- 'The IndieWeb Plugin can help you establish your identity online, as well as recommend other plugins to support additional IndieWeb features.', 'indieweb'
+ 'The IndieWeb Plugin can help you establish your identity online, as well as recommend other plugins to support additional IndieWeb features.',
+ 'indieweb'
);
?>
</p>
<ol>
- <li><?php _e( 'Complete your user profile, adding in connections to other websites. This allows you to connect your identity on those sites to your website.', 'indieweb' ); ?></li>
- <li><?php _e( 'Under Options on the IndieWeb menu, in the sidebar, set whether this is a single author or multi-author site', 'indieweb' ); ?></li>
- <li><?php _e( 'Links to your various sites will now appear on your site. If you want them visible to site visitors, you can add the Author Profile H-Card widget or the standalone Show My Profile on Other Sites widget to your site.', 'indieweb' ); ?></li>
+ <li><?php esc_html_e( 'Complete your user profile, adding in connections to other websites. This allows you to connect your identity on those sites to your website.', 'indieweb' ); ?></li>
+ <li><?php esc_html_e( 'Under Options on the IndieWeb menu, in the sidebar, set whether this is a single author or multi-author site', 'indieweb' ); ?></li>
+ <li><?php esc_html_e( 'Links to your various sites will now appear on your site. If you want them visible to site visitors, you can add the Author Profile H-Card widget or the standalone Show My Profile on Other Sites widget to your site.', 'indieweb' ); ?></li>
</ol>
</div>
<div class="indieweb-flex what-is">
<h2><?php esc_html_e( 'What is the IndieWeb?', 'indieweb' ); ?></h2>
- <p><?php _e( '<strong>Own your data.</strong> Create and publish content on your own site, and only optionally syndicate to third-party silos.', 'indieweb' ); ?></p>
+ <p>
+ <?php
+ echo wp_kses(
+ __( '<strong>Own your data.</strong> Create and publish content on your own site, and only optionally syndicate to third-party silos.', 'indieweb' ),
+ $allowed_html
+ );
+ ?>
+ </p>
<p>
<?php
- _e(
- 'This is the basis of the <strong>IndieWeb</strong>. For more, see <a
- href="https://indieweb.org/principles" target="_blank">principles</a> and <a
- href="https://indieweb.org/why" target="_blank">why</a>.', 'indieweb'
+ echo wp_kses(
+ __( 'This is the basis of the <strong>IndieWeb</strong>. For more, see <a href="https://indieweb.org/principles" target="_blank">principles</a> and <a href="https://indieweb.org/why" target="_blank">why</a>.', 'indieweb' ),
+ $allowed_html
);
?>
</p>
- <p><?php _e( 'For even more information, please visit the <a href="https://indieweb.org/" target="_blank"><em>IndieWeb</em> wiki</a>.', 'indieweb' ); ?></p>
- <p><?php _e( 'For assistance and to chat with community members, please visit <a href="https://indieweb.org/discuss" target="_blank">the discuss</a> page for more details.', 'indieweb' ); ?></p>
+ <p>
+ <?php
+ echo wp_kses(
+ __( 'For even more information, please visit the <a href="https://indieweb.org/" target="_blank"><em>IndieWeb</em> wiki</a>.', 'indieweb' ),
+ $allowed_html
+ );
+ ?>
+ </p>
+ <p>
+ <?php
+ echo wp_kses(
+ __( 'For assistance and to chat with community members, please visit <a href="https://indieweb.org/discuss" target="_blank">the discuss</a> page for more details.', 'indieweb' ),
+ $allowed_html
+ );
+ ?>
+ </p>
</div>
<div class="indieweb-flex indieweb-plugins">
<h2><?php esc_html_e( 'Plugins', 'indieweb' ); ?></h2>
- <p><?php _e( 'After you have established your identity, you can now optionally log into the <a href="https://indieweb.org">IndieWeb wiki</a> and create a user page as a way of introducing yourself to the community. The wiki is also a great source of IndieWeb information', 'indieweb' ); ?></p>
+ <p>
+ <?php
+ echo wp_kses(
+ __( 'After you have established your identity, you can now optionally log into the <a href="https://indieweb.org">IndieWeb wiki</a> and create a user page as a way of introducing yourself to the community. The wiki is also a great source of IndieWeb information', 'indieweb' ),
+ $allowed_html
+ );
+ ?>
+ </p>
<p><?php esc_html_e( 'To continue setting up and configuring your WordPress install to support IndieWeb features, you can start exploring the following optional plugins.', 'indieweb' ); ?></p>
<ol>
- <li><?php _e( 'Install and activate the Webmentions and Semantic Linkbacks plugins. These will allow you to receive responses such as replies, likes, etc from other IndieWeb sites. You can configure it in the Webmention Settings', 'indieweb' ); ?></li>
- <li><?php _e( 'Install and activate the Micropub and IndieAuth plugins. The Micropub plugin will allow you to publish to your website using Micropub clients and the IndieAuth plugin adds an IndieAuth endpoint to allow authentication through your site, which Micropub requires.', 'indieweb' ); ?></li>
- <li><?php _e( 'Install and activate the Syndication Links plugin. This will allow you to display the external permalinks that your content published to, on site such as Twitter, Facebook, Flickr, LinkedIn, and others.', 'indieweb' ); ?></li>
- <li><?php _e( 'Browse the Extensions page for a list of other recommended IndieWeb plugins that can expand your functionality.', 'indieweb' ); ?></li>
+ <li><?php esc_html_e( 'Install and activate the Webmentions and Semantic Linkbacks plugins. These will allow you to receive responses such as replies, likes, etc from other IndieWeb sites. You can configure it in the Webmention Settings', 'indieweb' ); ?></li>
+ <li><?php esc_html_e( 'Install and activate the Micropub and IndieAuth plugins. The Micropub plugin will allow you to publish to your website using Micropub clients and the IndieAuth plugin adds an IndieAuth endpoint to allow authentication through your site, which Micropub requires.', 'indieweb' ); ?></li>
+ <li><?php esc_html_e( 'Install and activate the Syndication Links plugin. This will allow you to display the external permalinks that your content published to, on site such as Twitter, Facebook, Flickr, LinkedIn, and others.', 'indieweb' ); ?></li>
+ <li><?php esc_html_e( 'Browse the Extensions page for a list of other recommended IndieWeb plugins that can expand your functionality.', 'indieweb' ); ?></li>
</ol>
- <p><a href="<?php echo admin_url( 'admin.php?page=indieweb-installer' ); ?>" class="button button-primary"><?php esc_html_e( 'Install plugins on the Extensions page.', 'indieweb' ); ?></a></p>
+ <p><a href="<?php echo esc_url( admin_url( 'admin.php?page=indieweb-installer' ) ); ?>" class="button button-primary"><?php esc_html_e( 'Install plugins on the Extensions page.', 'indieweb' ); ?></a></p>
</div>
<div class="indieweb-flex indieweb-themes">
<h2><?php esc_html_e( 'Themes', 'indieweb' ); ?></h2>
- <p><?php _e( 'The IndieWeb uses <a href="https://indieweb.org/microformats">microformats2</a> to mark up sites so that they can be interpreted by other sites when retrieved.', 'indieweb' ); ?></p>
- <p><?php _e( 'The Microformats2 Plugin attempts to add microformats to a theme that does not support them. This is not a replacement for a correctly configured theme and does not work with all themes.', 'indieweb' ); ?></p>
- <p><?php _e( 'Formatting your site so other sites can consume the information allows for the communications IndieWeb sites support. Most tools will attempt to use means other than Microformats2 if they are not available, but will lack detail.', 'indieweb' ); ?></p>
+ <p>
+ <?php
+ echo wp_kses(
+ __( 'The IndieWeb uses <a href="https://indieweb.org/microformats">microformats2</a> to mark up sites so that they can be interpreted by other sites when retrieved.', 'indieweb' ),
+ $allowed_html
+ );
+ ?>
+ </p>
+ <p><?php esc_html_e( 'The Microformats2 Plugin attempts to add microformats to a theme that does not support them. This is not a replacement for a correctly configured theme and does not work with all themes.', 'indieweb' ); ?></p>
+ <p><?php esc_html_e( 'Formatting your site so other sites can consume the information allows for the communications IndieWeb sites support. Most tools will attempt to use means other than Microformats2 if they are not available, but will lack detail.', 'indieweb' ); ?></p>
<p>
<?php
- _e(
- 'Currently, <a href="https://wordpress.org/themes/sempress/"
- target="_blank">SemPress</a> is the only theme in the WordPress repository that is fully
- microformats2 compliant. <a href="http://wordpress.org/themes/independent-publisher/"
- target="_blank">Independent Publisher</a> has been updated to include basic microformats2 and
- webmention display support. In practice, most themes will work relatively well out of the box, though there can be some minor display issues. If you are interested in receiving help in converting your theme to support Microformats2, the community will be <a href="https://indieweb.org/discuss">happy to assist</a>.', 'indieweb'
+ echo wp_kses(
+ __( 'Currently, <a href="https://wordpress.org/themes/sempress/" target="_blank">SemPress</a> is the only theme in the WordPress repository that is fully microformats2 compliant. <a href="http://wordpress.org/themes/independent-publisher/" target="_blank">Independent Publisher</a> has been updated to include basic microformats2 and webmention display support. In practice, most themes will work relatively well out of the box, though there can be some minor display issues. If you are interested in receiving help in converting your theme to support Microformats2, the community will be <a href="https://indieweb.org/discuss">happy to assist</a>.', 'indieweb' ),
+ $allowed_html
);
?>
</p>
--- a/indieweb/includes/simple-icons.php
+++ b/indieweb/includes/simple-icons.php
@@ -1,5 +1,15 @@
<?php
+/**
+ * Simple Icons name mappings.
+ *
+ * @package IndieWeb
+ */
+/**
+ * Returns an array of Simple Icons name mappings.
+ *
+ * @return array Associative array of icon slug to display name.
+ */
function simpleicons_iw_get_names() {
return array(
'dotenv' => '.ENV',
--- a/indieweb/indieweb.php
+++ b/indieweb/indieweb.php
@@ -1,18 +1,20 @@
<?php
-/*
+/**
* Plugin Name: IndieWeb
* Plugin URI: https://github.com/indieweb/wordpress-indieweb
* Description: Interested in connecting your WordPress site to the IndieWeb?
* Author: IndieWebCamp WordPress Outreach Club
* Author URI: https://indieweb.org/WordPress_Outreach_Club
- * Version: 4.0.5
+ * Version: 5.0.0
* License: MIT
* License URI: http://opensource.org/licenses/MIT
* Text Domain: indieweb
* Domain Path: /languages
+ *
+ * @package IndieWeb
*/
-// initialize plugin
+// Initialize plugin.
add_action( 'plugins_loaded', array( 'IndieWeb_Plugin', 'init' ) );
defined( 'INDIEWEB_ADD_HCARD_SUPPORT' ) || define( 'INDIEWEB_ADD_HCARD_SUPPORT', true );
@@ -26,6 +28,11 @@
*/
class IndieWeb_Plugin {
+ /**
+ * Plugin version.
+ *
+ * @var string
+ */
public static $version;
/**
@@ -33,14 +40,13 @@
*/
public static function init() {
self::$version = get_file_data( __FILE__, array( 'Version' => 'Version' ) )['Version'];
- // enable translation
+ // Enable translation.
self::enable_translation();
require_once __DIR__ . '/includes/class-plugin-installer.php';
if ( INDIEWEB_ADD_HCARD_SUPPORT ) {
- // Require H-Card Enhancements to User Profile
-
+ // Require H-Card Enhancements to User Profile.
require_once __DIR__ . '/includes/class-relme-domain-icon-map.php';
require_once __DIR__ . '/includes/class-hcard-user.php';
require_once __DIR__ . '/includes/class-hcard-author-widget.php';
@@ -48,7 +54,7 @@
}
if ( INDIEWEB_ADD_RELME_SUPPORT ) {
- // Require Rel Me Widget Class
+ // Require Rel Me Widget Class.
require_once __DIR__ . '/includes/class-relme-widget.php';
}
@@ -56,19 +62,19 @@
add_action( 'admin_enqueue_scripts', array( 'IndieWeb_Plugin', 'enqueue_admin_style' ) );
- // Add General Settings Page
+ // Add General Settings Page.
require_once __DIR__ . '/includes/class-general-settings.php';
- // Add third party integrations
+ // Add third party integrations.
require_once __DIR__ . '/includes/class-integrations.php';
- // add menu
+ // Add menu.
add_action( 'admin_menu', array( 'IndieWeb_Plugin', 'add_menu_item' ), 9 );
- // Privacy Declaration
+ // Privacy Declaration.
add_action( 'admin_init', array( 'Indieweb_Plugin', 'privacy_declaration' ) );
- // we're up and running
+ // We're up and running.
do_action( 'indieweb_loaded' );
}
@@ -79,14 +85,17 @@
* http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/
*/
public static function enable_translation() {
- // for plugins
+ // For plugins.
load_plugin_textdomain(
'indieweb',
false,
- dirname( plugin_basename( __FILE__ ) ) . '/languages/' // path
+ dirname( plugin_basename( __FILE__ ) ) . '/languages/'
);
}
+ /**
+ * Enqueue frontend styles.
+ */
public static function enqueue_style() {
if ( '1' === get_option( 'iw_relme_bw' ) ) {
wp_enqueue_style( 'indieweb', plugins_url( 'static/css/indieweb-bw.css', __FILE__ ), array(), self::$version );
@@ -95,15 +104,18 @@
}
}
+ /**
+ * Enqueue admin styles.
+ */
public static function enqueue_admin_style() {
wp_enqueue_style( 'indieweb-admin', plugins_url( 'static/css/indieweb-admin.css', __FILE__ ), array(), self::$version );
}
/**
- * Add Top Level Menu Item
+ * Add Top Level Menu Item.
*/
public static function add_menu_item() {
- $options_page = add_menu_page(
+ add_menu_page(
'IndieWeb',
'IndieWeb',
'manage_options',
@@ -113,9 +125,9 @@
);
add_submenu_page(
'indieweb',
- __( 'Extensions', 'indieweb' ), // page title
- __( 'Extensions', 'indieweb' ), // menu title
- 'manage_options', // access capability
+ __( 'Extensions', 'indieweb' ), // Page title.
+ __( 'Extensions', 'indieweb' ), // Menu title.
+ 'manage_options', // Access capability.
'indieweb-installer',
array( 'IndieWeb_Plugin', 'plugin_installer' )
);
@@ -140,6 +152,9 @@
require_once __DIR__ . '/includes/getting-started.php';
}
+ /**
+ * Render the plugin installer page.
+ */
public static function plugin_installer() {
echo '<h1>' . esc_html__( 'IndieWeb Plugin Installer', 'indieweb' ) . '</h1>';
echo '<p>' . esc_html__( 'The below plugins are recommended to enable additional IndieWeb functionality.', 'indieweb' ) . '</p>';
@@ -150,8 +165,6 @@
/**
* Register the required plugins.
- *
- *
*/
public static function register_plugins() {
$plugin_array = array(
@@ -183,6 +196,9 @@
return $plugin_array;
}
+ /**
+ * Add privacy policy content.
+ */
public static function privacy_declaration() {
if ( function_exists( 'wp_add_privacy_policy_content' ) ) {
$content = __(
--- a/indieweb/templates/h-card.php
+++ b/indieweb/templates/h-card.php
@@ -1,16 +1,36 @@
+<?php
+/**
+