Changeset 3444728
- Timestamp:
- 01/22/2026 11:03:54 AM (4 weeks ago)
- Location:
- pubsubhubbub
- Files:
-
- 16 added
- 10 deleted
- 8 edited
- 1 copied
-
tags/4.0.0 (copied) (copied from pubsubhubbub/trunk)
-
tags/4.0.0/includes/class-autoloader.php (added)
-
tags/4.0.0/includes/class-discovery.php (added)
-
tags/4.0.0/includes/class-publisher.php (added)
-
tags/4.0.0/includes/class-pubsubhubbub-admin.php (deleted)
-
tags/4.0.0/includes/class-pubsubhubbub-publisher.php (deleted)
-
tags/4.0.0/includes/class-pubsubhubbub-topics.php (deleted)
-
tags/4.0.0/includes/class-pubsubhubbub.php (modified) (2 diffs)
-
tags/4.0.0/includes/class-subscriber.php (added)
-
tags/4.0.0/includes/deprecated.php (modified) (1 diff)
-
tags/4.0.0/includes/functions.php (modified) (1 diff)
-
tags/4.0.0/includes/rest (added)
-
tags/4.0.0/includes/rest/class-subscriber-controller.php (added)
-
tags/4.0.0/includes/wp-admin (added)
-
tags/4.0.0/includes/wp-admin/class-admin.php (added)
-
tags/4.0.0/languages (deleted)
-
tags/4.0.0/pubsubhubbub.php (modified) (2 diffs)
-
tags/4.0.0/templates (deleted)
-
trunk/includes/class-autoloader.php (added)
-
trunk/includes/class-discovery.php (added)
-
trunk/includes/class-publisher.php (added)
-
trunk/includes/class-pubsubhubbub-admin.php (deleted)
-
trunk/includes/class-pubsubhubbub-publisher.php (deleted)
-
trunk/includes/class-pubsubhubbub-topics.php (deleted)
-
trunk/includes/class-pubsubhubbub.php (modified) (2 diffs)
-
trunk/includes/class-subscriber.php (added)
-
trunk/includes/deprecated.php (modified) (1 diff)
-
trunk/includes/functions.php (modified) (1 diff)
-
trunk/includes/rest (added)
-
trunk/includes/rest/class-subscriber-controller.php (added)
-
trunk/includes/wp-admin (added)
-
trunk/includes/wp-admin/class-admin.php (added)
-
trunk/languages (deleted)
-
trunk/pubsubhubbub.php (modified) (2 diffs)
-
trunk/templates (deleted)
Legend:
- Unmodified
- Added
- Removed
-
pubsubhubbub/tags/4.0.0/includes/class-pubsubhubbub.php
r3065416 r3444728 1 1 <?php 2 2 /** 3 * The WebSub/PubSubHubbub class 3 * Pubsubhubbub Class 4 * 5 * @package Pubsubhubbub 6 */ 7 8 namespace Pubsubhubbub; 9 10 use Pubsubhubbub\WP_Admin\Admin; 11 use Pubsubhubbub\Rest\Subscriber_Controller; 12 13 /** 14 * Pubsubhubbub Class 15 * 16 * @package Pubsubhubbub 4 17 */ 5 18 class Pubsubhubbub { 19 20 /** 21 * Instance of the class. 22 * 23 * @var Pubsubhubbub 24 */ 25 private static $instance; 26 27 /** 28 * Default hub URLs. 29 * 30 * @var array 31 */ 6 32 const DEFAULT_HUBS = array( 7 33 'https://pubsubhubbub.appspot.com', … … 11 37 12 38 /** 13 * Load the plugin textdomain. 39 * Whether the class has been initialized. 40 * 41 * @var boolean 14 42 */ 15 public static function load_textdomain() { 16 load_plugin_textdomain( 'pubsubhubbub', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 43 private $initialized = false; 44 45 /** 46 * Get the instance of the class. 47 * 48 * @return Pubsubhubbub 49 */ 50 public static function get_instance() { 51 if ( null === self::$instance ) { 52 self::$instance = new self(); 53 } 54 55 return self::$instance; 56 } 57 58 /** 59 * Do not allow multiple instances of the class. 60 */ 61 private function __construct() { 62 // Do nothing. 63 } 64 65 /** 66 * Initialize the plugin. 67 */ 68 public function init() { 69 if ( $this->initialized ) { 70 return; 71 } 72 73 $this->register_hooks(); 74 $this->register_admin_hooks(); 75 $this->register_rest_hooks(); 76 $this->register_subscriber_hooks(); 77 78 $this->initialized = true; 79 } 80 81 /** 82 * Get the plugin version. 83 * 84 * @return string 85 */ 86 public function get_version() { 87 return PUBSUBHUBBUB_VERSION; 88 } 89 90 /** 91 * Register hooks. 92 */ 93 public function register_hooks() { 94 // Publisher integration. 95 \add_action( 'publish_post', array( Publisher::class, 'publish_post' ) ); 96 // phpcs:ignore Squiz.Commenting.InlineComment.InvalidEndChar 97 // Uncomment to enable comment publishing: \add_action( 'comment_post', array( Publisher::class, 'publish_comment' ) ); 98 99 // Feed integrations. 100 \add_action( 'atom_head', array( Discovery::class, 'add_atom_link_tag' ) ); 101 \add_action( 'rdf_header', array( Discovery::class, 'add_rss_link_tag' ) ); 102 \add_action( 'rss2_head', array( Discovery::class, 'add_rss_link_tag' ) ); 103 104 \add_action( 'comments_atom_head', array( Discovery::class, 'add_atom_link_tag' ) ); 105 \add_action( 'commentsrss2_head', array( Discovery::class, 'add_rss_link_tag' ) ); 106 107 \add_action( 'rdf_ns', array( Discovery::class, 'add_rss_ns_link' ) ); 108 109 \add_action( 'template_redirect', array( Discovery::class, 'template_redirect' ) ); 110 } 111 112 /** 113 * Register admin hooks. 114 */ 115 public function register_admin_hooks() { 116 \add_action( 'admin_init', array( Admin::class, 'register_settings' ) ); 117 \add_action( 'admin_menu', array( Admin::class, 'add_plugin_menu' ) ); 118 } 119 120 /** 121 * Register REST API hooks. 122 */ 123 public function register_rest_hooks() { 124 \add_action( 'rest_api_init', array( Subscriber_Controller::class, 'register_routes' ) ); 125 } 126 127 /** 128 * Register subscriber action hooks. 129 * 130 * These hooks allow other plugins to trigger subscriptions via do_action(). 131 */ 132 public function register_subscriber_hooks() { 133 \add_action( 'websub_subscribe', array( Subscriber::class, 'subscribe' ), 10, 3 ); 134 \add_action( 'websub_unsubscribe', array( Subscriber::class, 'unsubscribe' ), 10, 3 ); 17 135 } 18 136 } -
pubsubhubbub/tags/4.0.0/includes/deprecated.php
r2666072 r3444728 1 1 <?php 2 2 /** 3 * Beeing backwards compatible 4 * based on a fix by Stephen Paul Weber (http://singpolyma.net) 3 * Deprecated functions for backward compatibility. 5 4 * 6 * @deprecated 5 * @package Pubsubhubbub 6 */ 7 8 use Pubsubhubbub\Publisher; 9 10 /** 11 * Being backwards compatible. 12 * Based on a fix by Stephen Paul Weber (http://singpolyma.net) 13 * 14 * @deprecated 3.0.0 Use pubsubhubbub_publish_to_hub() instead. 15 * 16 * @param mixed $deprecated Deprecated parameter. 17 * @param array $feed_urls A list of feed urls you want to publish. 18 * 19 * @return void 7 20 */ 8 21 function publish_to_hub( $deprecated, $feed_urls ) { 9 22 _deprecated_function( __FUNCTION__, '3.0.0', 'pubsubhubbub_publish_to_hub()' ); 10 23 11 Pub SubHubbub_Publisher::publish_to_hub( $feed_urls );24 Publisher::publish_to_hub( $feed_urls ); 12 25 } 13 26 14 27 /** 15 * The ability for other plugins to hook into the PuSH code 28 * The ability for other plugins to hook into the PuSH code. 16 29 * 17 * @ param array $feed_urls a list of feed urls you want to publish30 * @deprecated 3.0.0 Use pubsubhubbub_publish_to_hub() instead. 18 31 * 19 * @deprecated 32 * @param array $feed_urls A list of feed urls you want to publish. 33 * 34 * @return void 20 35 */ 21 36 function pshb_publish_to_hub( $feed_urls ) { 22 37 _deprecated_function( __FUNCTION__, '3.0.0', 'pubsubhubbub_publish_to_hub()' ); 23 38 24 Pub SubHubbub_Publisher::publish_to_hub( $feed_urls );39 Publisher::publish_to_hub( $feed_urls ); 25 40 } 26 41 27 42 /** 28 * Map old filter to new filter43 * The ability for other plugins to hook into the PuSH code. 29 44 * 30 * @param array $feed_urls the list of feed urls45 * This function maintains backward compatibility with the old naming convention. 31 46 * 32 * @ return array filtered list47 * @param array $feed_urls A list of feed urls you want to publish. 33 48 * 34 * @deprecated 49 * @return void 50 */ 51 function pubsubhubbub_publish_to_hub( $feed_urls ) { 52 Publisher::publish_to_hub( $feed_urls ); 53 } 54 55 /** 56 * Get the endpoints from the WordPress options table. 57 * 58 * This function maintains backward compatibility with the old naming convention. 59 * 60 * @uses apply_filters() Calls 'websub_hub_urls' filter. 61 * 62 * @return array The hub URLs. 63 */ 64 function pubsubhubbub_get_hubs() { 65 return Publisher::get_hubs(); 66 } 67 68 /** 69 * Check if link supports PubSubHubbub or WebSub. 70 * 71 * This function maintains backward compatibility with the old naming convention. 72 * 73 * @return boolean 74 */ 75 function pubsubhubbub_show_discovery() { 76 return \Pubsubhubbub\show_discovery(); 77 } 78 79 /** 80 * Get the correct self URL. 81 * 82 * This function maintains backward compatibility with the old naming convention. 83 * 84 * @return string The self link URL. 85 */ 86 function pubsubhubbub_get_self_link() { 87 return \Pubsubhubbub\get_self_link(); 88 } 89 90 /** 91 * Return the list of feed types that are supported by PubSubHubbub. 92 * 93 * This function maintains backward compatibility with the old naming convention. 94 * 95 * @return array List of supported feed types. 96 */ 97 function pubsubhubbub_get_supported_feed_types() { 98 return \Pubsubhubbub\get_supported_feed_types(); 99 } 100 101 /** 102 * Return the list of comment feed types that are supported by PubSubHubbub. 103 * 104 * This function maintains backward compatibility with the old naming convention. 105 * 106 * @return array List of supported comment feed types. 107 */ 108 function pubsubhubbub_get_supported_comment_feed_types() { 109 return \Pubsubhubbub\get_supported_comment_feed_types(); 110 } 111 112 /** 113 * Map old filter to new filter. 114 * 115 * @deprecated 3.0.0 116 * 117 * @param array $feed_urls The list of feed urls. 118 * 119 * @return array Filtered list. 35 120 */ 36 121 function pshb_feed_urls( $feed_urls ) { 37 //_deprecated_function( __FUNCTION__, '3.0.0', 'get_feed_urls_by_post_id()' );38 39 122 return apply_filters( 'pshb_feed_urls', $feed_urls ); 40 123 } 41 add_filter( ' pubsubhubbub_feed_urls', 'pshb_feed_urls' );124 add_filter( 'websub_feed_urls', 'pshb_feed_urls' ); -
pubsubhubbub/tags/4.0.0/includes/functions.php
r2618981 r3444728 1 1 <?php 2 2 /** 3 * The ability for other plugins to hook into the PuSH code3 * Helper functions for Pubsubhubbub. 4 4 * 5 * @pa ram array $feed_urls a list of feed urls you want to publish5 * @package Pubsubhubbub 6 6 */ 7 function pubsubhubbub_publish_to_hub( $feed_urls ) { 8 PubSubHubbub_Publisher::publish_to_hub( $feed_urls ); 7 8 namespace Pubsubhubbub; 9 10 /** 11 * The ability for other plugins to hook into the PuSH code. 12 * 13 * @param array $feed_urls A list of feed urls you want to publish. 14 * 15 * @return void 16 */ 17 function publish_to_hub( $feed_urls ) { 18 Publisher::publish_to_hub( $feed_urls ); 9 19 } 10 20 11 21 /** 12 * Get the endpoints from the WordPress options table 13 * valid parameters are "publish" or "subscribe" 22 * Get the endpoints from the WordPress options table. 14 23 * 15 * @uses apply_filters() Calls 'pubsubhubbub_hub_urls' filter 24 * @uses apply_filters() Calls 'websub_hub_urls' filter. 25 * 26 * @return array The hub URLs. 16 27 */ 17 function pubsubhubbub_get_hubs() {18 return Pub SubHubbub_Publisher::get_hubs();28 function get_hubs() { 29 return Publisher::get_hubs(); 19 30 } 20 31 21 32 /** 22 * Check if link supports PubSubHubbub or WebSub33 * Check if link supports WebSub. 23 34 * 24 35 * @return boolean 25 36 */ 26 function pubsubhubbub_show_discovery() {37 function show_discovery() { 27 38 $show_discovery = false; 28 39 29 $supported_feed_types = apply_filters( 'pubsubhubbub_show_discovery_for_feed_types', pubsubhubbub_get_supported_feed_types() ); 30 $supported_comment_feed_types = apply_filters( 'pubsubhubbub_show_discovery_for_comment_feed_types', pubsubhubbub_get_supported_comment_feed_types() ); 40 /** 41 * Filter the list of feed types that show WebSub discovery. 42 * 43 * @since 4.0.0 44 * 45 * @param array $feed_types List of feed types (e.g., 'atom', 'rss2'). 46 */ 47 $supported_feed_types = \apply_filters_deprecated( 'pubsubhubbub_show_discovery_for_feed_types', array( get_supported_feed_types() ), '4.0.0', 'websub_show_discovery_for_feed_types' ); 48 $supported_feed_types = \apply_filters( 'websub_show_discovery_for_feed_types', $supported_feed_types ); 49 50 /** 51 * Filter the list of comment feed types that show WebSub discovery. 52 * 53 * @since 4.0.0 54 * 55 * @param array $feed_types List of comment feed types (e.g., 'atom', 'rss2'). 56 */ 57 $supported_comment_feed_types = \apply_filters_deprecated( 'pubsubhubbub_show_discovery_for_comment_feed_types', array( get_supported_comment_feed_types() ), '4.0.0', 'websub_show_discovery_for_comment_feed_types' ); 58 $supported_comment_feed_types = \apply_filters( 'websub_show_discovery_for_comment_feed_types', $supported_comment_feed_types ); 31 59 32 60 if ( 33 ( is_feed( $supported_feed_types ) && ! is_date() && ! is_post_type_archive() && !is_singular() ) ||34 ( is_feed( $supported_comment_feed_types ) &&is_singular() ) ||35 ( is_home() &¤t_theme_supports( 'microformats2' ) )61 ( \is_feed( $supported_feed_types ) && ! \is_date() && ! \is_post_type_archive() && ! \is_singular() ) || 62 ( \is_feed( $supported_comment_feed_types ) && \is_singular() ) || 63 ( \is_home() && \current_theme_supports( 'microformats2' ) ) 36 64 ) { 37 65 $show_discovery = true; 38 66 } 39 67 40 return apply_filters( 'pubsubhubbub_show_discovery', $show_discovery ); 68 /** 69 * Filter whether to show WebSub discovery links. 70 * 71 * @since 4.0.0 72 * 73 * @param bool $show_discovery Whether to show discovery links. 74 */ 75 $show_discovery = \apply_filters_deprecated( 'pubsubhubbub_show_discovery', array( $show_discovery ), '4.0.0', 'websub_show_discovery' ); 76 $show_discovery = \apply_filters( 'websub_show_discovery', $show_discovery ); 77 78 return $show_discovery; 41 79 } 42 80 43 81 /** 44 * Get the correct self URL 82 * Get the correct self URL. 45 83 * 46 * @return boolean84 * @return string The self link URL. 47 85 */ 48 function pubsubhubbub_get_self_link() { 49 $host = wp_parse_url( home_url() ); 86 function get_self_link() { 87 $host = \wp_parse_url( \home_url() ); 88 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized 89 $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? \wp_unslash( $_SERVER['REQUEST_URI'] ) : ''; 50 90 51 return esc_url( apply_filters( 'self_link', set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] )) ) );91 return \esc_url( \apply_filters( 'self_link', \set_url_scheme( 'http://' . $host['host'] . $request_uri ) ) ); 52 92 } 53 93 54 94 /** 55 * Return the list of feed types that are supported by PubSubHubbub 95 * Return the list of feed types that are supported by PubSubHubbub. 56 96 * 57 * @return array List of supported feed types 97 * @return array List of supported feed types. 58 98 */ 59 function pubsubhubbub_get_supported_feed_types() { 60 return apply_filters( 'pubsubhubbub_supported_feed_types', array( 'atom', 'rss2' ) ); 99 function get_supported_feed_types() { 100 /** 101 * Filter the list of supported feed types for WebSub. 102 * 103 * @since 4.0.0 104 * 105 * @param array $feed_types List of supported feed types. Default: array( 'atom', 'rss2' ). 106 */ 107 $feed_types = \apply_filters_deprecated( 'pubsubhubbub_supported_feed_types', array( array( 'atom', 'rss2' ) ), '4.0.0', 'websub_supported_feed_types' ); 108 $feed_types = \apply_filters( 'websub_supported_feed_types', $feed_types ); 109 110 return $feed_types; 61 111 } 62 112 63 113 /** 64 * Return the list of comment feed types that are supported by PubSubHubbub 114 * Return the list of comment feed types that are supported by PubSubHubbub. 65 115 * 66 * @return array List of supported comment feed types 116 * @return array List of supported comment feed types. 67 117 */ 68 function pubsubhubbub_get_supported_comment_feed_types() { 69 return apply_filters( 'pubsubhubbub_supported_comment_feed_types', array( 'atom', 'rss2' ) ); 118 function get_supported_comment_feed_types() { 119 /** 120 * Filter the list of supported comment feed types for WebSub. 121 * 122 * @since 4.0.0 123 * 124 * @param array $feed_types List of supported comment feed types. Default: array( 'atom', 'rss2' ). 125 */ 126 $feed_types = \apply_filters_deprecated( 'pubsubhubbub_supported_comment_feed_types', array( array( 'atom', 'rss2' ) ), '4.0.0', 'websub_supported_comment_feed_types' ); 127 $feed_types = \apply_filters( 'websub_supported_comment_feed_types', $feed_types ); 128 129 return $feed_types; 70 130 } -
pubsubhubbub/tags/4.0.0/pubsubhubbub.php
r3065416 r3444728 4 4 * Plugin URI: https://github.com/pubsubhubbub/wordpress-pubsubhubbub/ 5 5 * Description: A better way to tell the world when your blog is updated. 6 * Version: 3.2.16 * Version: 4.0.0 7 7 * Author: PubSubHubbub Team 8 8 * Author URI: https://github.com/pubsubhubbub/wordpress-pubsubhubbub … … 10 10 * License URI: http://opensource.org/licenses/MIT 11 11 * Text Domain: pubsubhubbub 12 * Domain Path: /languages 12 * Requires PHP: 7.2 13 * 14 * @package Pubsubhubbub 13 15 */ 14 16 15 /** 16 * Initialize plugin 17 */ 18 function pubsubhubbub_init() { 19 require_once( dirname( __FILE__ ) . '/includes/functions.php' ); 17 namespace Pubsubhubbub; 20 18 21 /** 22 * Publisher integration 23 */ 24 require_once( dirname( __FILE__ ) . '/includes/class-pubsubhubbub-publisher.php' ); 19 \defined( 'ABSPATH' ) || exit; 25 20 26 add_action( 'publish_post', array( 'PubSubHubbub_Publisher', 'publish_post' ) ); 27 //add_action( 'comment_post', array( 'PubSubHubbub_Publisher', 'publish_comment' ) ); 21 \define( 'PUBSUBHUBBUB_VERSION', '4.0.0' ); 22 \define( 'PUBSUBHUBBUB_PLUGIN_DIR', \plugin_dir_path( __FILE__ ) ); 23 \define( 'PUBSUBHUBBUB_PLUGIN_BASENAME', \plugin_basename( __FILE__ ) ); 24 \define( 'PUBSUBHUBBUB_PLUGIN_FILE', __FILE__ ); 25 \define( 'PUBSUBHUBBUB_PLUGIN_URL', \plugin_dir_url( __FILE__ ) ); 28 26 29 /** 30 * Admin panel 31 */ 32 require_once( dirname( __FILE__ ) . '/includes/class-pubsubhubbub-admin.php' ); 27 // Load the autoloader. 28 require_once PUBSUBHUBBUB_PLUGIN_DIR . 'includes/class-autoloader.php'; 33 29 34 add_action( 'init', array( 'PubSubHubbub_Admin', 'register_settings' ) ); 35 add_action( 'admin_menu', array( 'Pubsubhubbub_Admin', 'add_plugin_menu' ) );30 // Load helper functions. 31 require_once PUBSUBHUBBUB_PLUGIN_DIR . 'includes/functions.php'; 36 32 37 /** 38 * Feed integrations 39 */ 40 require_once( dirname( __FILE__ ) . '/includes/class-pubsubhubbub-topics.php' ); 33 // Load deprecated functions for backward compatibility. 34 require_once PUBSUBHUBBUB_PLUGIN_DIR . 'includes/deprecated.php'; 41 35 42 add_action( 'atom_head', array( 'Pubsubhubbub_Topics', 'add_atom_link_tag' ) ); 43 add_action( 'rdf_header', array( 'Pubsubhubbub_Topics', 'add_rss_link_tag' ) ); 44 add_action( 'rss2_head', array( 'Pubsubhubbub_Topics', 'add_rss_link_tag' ) ); 36 // Register the autoloader. 37 Autoloader::register_path( __NAMESPACE__, PUBSUBHUBBUB_PLUGIN_DIR . 'includes' ); 45 38 46 add_action( 'comments_atom_head', array( 'Pubsubhubbub_Topics', 'add_atom_link_tag' ) ); 47 add_action( 'commentsrss2_head', array( 'Pubsubhubbub_Topics', 'add_rss_link_tag' ) ); 48 49 add_action( 'rdf_ns', array( 'Pubsubhubbub_Topics', 'add_rss_ns_link' ) ); 50 51 add_action( 'template_redirect', array( 'Pubsubhubbub_Topics', 'template_redirect' ) ); 52 53 /** 54 * Main class 55 */ 56 require_once( dirname( __FILE__ ) . '/includes/class-pubsubhubbub.php' ); 57 58 add_action( 'init', array( 'PubSubHubbub', 'load_textdomain' ) ); 59 60 /** 61 * Deprecated functions 62 */ 63 require_once( dirname( __FILE__ ) . '/includes/deprecated.php' ); 64 } 65 66 add_action( 'plugins_loaded', 'pubsubhubbub_init' ); 39 // Initialize the plugin. 40 $pubsubhubbub = Pubsubhubbub::get_instance(); 41 $pubsubhubbub->init(); -
pubsubhubbub/trunk/includes/class-pubsubhubbub.php
r3065416 r3444728 1 1 <?php 2 2 /** 3 * The WebSub/PubSubHubbub class 3 * Pubsubhubbub Class 4 * 5 * @package Pubsubhubbub 6 */ 7 8 namespace Pubsubhubbub; 9 10 use Pubsubhubbub\WP_Admin\Admin; 11 use Pubsubhubbub\Rest\Subscriber_Controller; 12 13 /** 14 * Pubsubhubbub Class 15 * 16 * @package Pubsubhubbub 4 17 */ 5 18 class Pubsubhubbub { 19 20 /** 21 * Instance of the class. 22 * 23 * @var Pubsubhubbub 24 */ 25 private static $instance; 26 27 /** 28 * Default hub URLs. 29 * 30 * @var array 31 */ 6 32 const DEFAULT_HUBS = array( 7 33 'https://pubsubhubbub.appspot.com', … … 11 37 12 38 /** 13 * Load the plugin textdomain. 39 * Whether the class has been initialized. 40 * 41 * @var boolean 14 42 */ 15 public static function load_textdomain() { 16 load_plugin_textdomain( 'pubsubhubbub', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 43 private $initialized = false; 44 45 /** 46 * Get the instance of the class. 47 * 48 * @return Pubsubhubbub 49 */ 50 public static function get_instance() { 51 if ( null === self::$instance ) { 52 self::$instance = new self(); 53 } 54 55 return self::$instance; 56 } 57 58 /** 59 * Do not allow multiple instances of the class. 60 */ 61 private function __construct() { 62 // Do nothing. 63 } 64 65 /** 66 * Initialize the plugin. 67 */ 68 public function init() { 69 if ( $this->initialized ) { 70 return; 71 } 72 73 $this->register_hooks(); 74 $this->register_admin_hooks(); 75 $this->register_rest_hooks(); 76 $this->register_subscriber_hooks(); 77 78 $this->initialized = true; 79 } 80 81 /** 82 * Get the plugin version. 83 * 84 * @return string 85 */ 86 public function get_version() { 87 return PUBSUBHUBBUB_VERSION; 88 } 89 90 /** 91 * Register hooks. 92 */ 93 public function register_hooks() { 94 // Publisher integration. 95 \add_action( 'publish_post', array( Publisher::class, 'publish_post' ) ); 96 // phpcs:ignore Squiz.Commenting.InlineComment.InvalidEndChar 97 // Uncomment to enable comment publishing: \add_action( 'comment_post', array( Publisher::class, 'publish_comment' ) ); 98 99 // Feed integrations. 100 \add_action( 'atom_head', array( Discovery::class, 'add_atom_link_tag' ) ); 101 \add_action( 'rdf_header', array( Discovery::class, 'add_rss_link_tag' ) ); 102 \add_action( 'rss2_head', array( Discovery::class, 'add_rss_link_tag' ) ); 103 104 \add_action( 'comments_atom_head', array( Discovery::class, 'add_atom_link_tag' ) ); 105 \add_action( 'commentsrss2_head', array( Discovery::class, 'add_rss_link_tag' ) ); 106 107 \add_action( 'rdf_ns', array( Discovery::class, 'add_rss_ns_link' ) ); 108 109 \add_action( 'template_redirect', array( Discovery::class, 'template_redirect' ) ); 110 } 111 112 /** 113 * Register admin hooks. 114 */ 115 public function register_admin_hooks() { 116 \add_action( 'admin_init', array( Admin::class, 'register_settings' ) ); 117 \add_action( 'admin_menu', array( Admin::class, 'add_plugin_menu' ) ); 118 } 119 120 /** 121 * Register REST API hooks. 122 */ 123 public function register_rest_hooks() { 124 \add_action( 'rest_api_init', array( Subscriber_Controller::class, 'register_routes' ) ); 125 } 126 127 /** 128 * Register subscriber action hooks. 129 * 130 * These hooks allow other plugins to trigger subscriptions via do_action(). 131 */ 132 public function register_subscriber_hooks() { 133 \add_action( 'websub_subscribe', array( Subscriber::class, 'subscribe' ), 10, 3 ); 134 \add_action( 'websub_unsubscribe', array( Subscriber::class, 'unsubscribe' ), 10, 3 ); 17 135 } 18 136 } -
pubsubhubbub/trunk/includes/deprecated.php
r2666072 r3444728 1 1 <?php 2 2 /** 3 * Beeing backwards compatible 4 * based on a fix by Stephen Paul Weber (http://singpolyma.net) 3 * Deprecated functions for backward compatibility. 5 4 * 6 * @deprecated 5 * @package Pubsubhubbub 6 */ 7 8 use Pubsubhubbub\Publisher; 9 10 /** 11 * Being backwards compatible. 12 * Based on a fix by Stephen Paul Weber (http://singpolyma.net) 13 * 14 * @deprecated 3.0.0 Use pubsubhubbub_publish_to_hub() instead. 15 * 16 * @param mixed $deprecated Deprecated parameter. 17 * @param array $feed_urls A list of feed urls you want to publish. 18 * 19 * @return void 7 20 */ 8 21 function publish_to_hub( $deprecated, $feed_urls ) { 9 22 _deprecated_function( __FUNCTION__, '3.0.0', 'pubsubhubbub_publish_to_hub()' ); 10 23 11 Pub SubHubbub_Publisher::publish_to_hub( $feed_urls );24 Publisher::publish_to_hub( $feed_urls ); 12 25 } 13 26 14 27 /** 15 * The ability for other plugins to hook into the PuSH code 28 * The ability for other plugins to hook into the PuSH code. 16 29 * 17 * @ param array $feed_urls a list of feed urls you want to publish30 * @deprecated 3.0.0 Use pubsubhubbub_publish_to_hub() instead. 18 31 * 19 * @deprecated 32 * @param array $feed_urls A list of feed urls you want to publish. 33 * 34 * @return void 20 35 */ 21 36 function pshb_publish_to_hub( $feed_urls ) { 22 37 _deprecated_function( __FUNCTION__, '3.0.0', 'pubsubhubbub_publish_to_hub()' ); 23 38 24 Pub SubHubbub_Publisher::publish_to_hub( $feed_urls );39 Publisher::publish_to_hub( $feed_urls ); 25 40 } 26 41 27 42 /** 28 * Map old filter to new filter43 * The ability for other plugins to hook into the PuSH code. 29 44 * 30 * @param array $feed_urls the list of feed urls45 * This function maintains backward compatibility with the old naming convention. 31 46 * 32 * @ return array filtered list47 * @param array $feed_urls A list of feed urls you want to publish. 33 48 * 34 * @deprecated 49 * @return void 50 */ 51 function pubsubhubbub_publish_to_hub( $feed_urls ) { 52 Publisher::publish_to_hub( $feed_urls ); 53 } 54 55 /** 56 * Get the endpoints from the WordPress options table. 57 * 58 * This function maintains backward compatibility with the old naming convention. 59 * 60 * @uses apply_filters() Calls 'websub_hub_urls' filter. 61 * 62 * @return array The hub URLs. 63 */ 64 function pubsubhubbub_get_hubs() { 65 return Publisher::get_hubs(); 66 } 67 68 /** 69 * Check if link supports PubSubHubbub or WebSub. 70 * 71 * This function maintains backward compatibility with the old naming convention. 72 * 73 * @return boolean 74 */ 75 function pubsubhubbub_show_discovery() { 76 return \Pubsubhubbub\show_discovery(); 77 } 78 79 /** 80 * Get the correct self URL. 81 * 82 * This function maintains backward compatibility with the old naming convention. 83 * 84 * @return string The self link URL. 85 */ 86 function pubsubhubbub_get_self_link() { 87 return \Pubsubhubbub\get_self_link(); 88 } 89 90 /** 91 * Return the list of feed types that are supported by PubSubHubbub. 92 * 93 * This function maintains backward compatibility with the old naming convention. 94 * 95 * @return array List of supported feed types. 96 */ 97 function pubsubhubbub_get_supported_feed_types() { 98 return \Pubsubhubbub\get_supported_feed_types(); 99 } 100 101 /** 102 * Return the list of comment feed types that are supported by PubSubHubbub. 103 * 104 * This function maintains backward compatibility with the old naming convention. 105 * 106 * @return array List of supported comment feed types. 107 */ 108 function pubsubhubbub_get_supported_comment_feed_types() { 109 return \Pubsubhubbub\get_supported_comment_feed_types(); 110 } 111 112 /** 113 * Map old filter to new filter. 114 * 115 * @deprecated 3.0.0 116 * 117 * @param array $feed_urls The list of feed urls. 118 * 119 * @return array Filtered list. 35 120 */ 36 121 function pshb_feed_urls( $feed_urls ) { 37 //_deprecated_function( __FUNCTION__, '3.0.0', 'get_feed_urls_by_post_id()' );38 39 122 return apply_filters( 'pshb_feed_urls', $feed_urls ); 40 123 } 41 add_filter( ' pubsubhubbub_feed_urls', 'pshb_feed_urls' );124 add_filter( 'websub_feed_urls', 'pshb_feed_urls' ); -
pubsubhubbub/trunk/includes/functions.php
r2618981 r3444728 1 1 <?php 2 2 /** 3 * The ability for other plugins to hook into the PuSH code3 * Helper functions for Pubsubhubbub. 4 4 * 5 * @pa ram array $feed_urls a list of feed urls you want to publish5 * @package Pubsubhubbub 6 6 */ 7 function pubsubhubbub_publish_to_hub( $feed_urls ) { 8 PubSubHubbub_Publisher::publish_to_hub( $feed_urls ); 7 8 namespace Pubsubhubbub; 9 10 /** 11 * The ability for other plugins to hook into the PuSH code. 12 * 13 * @param array $feed_urls A list of feed urls you want to publish. 14 * 15 * @return void 16 */ 17 function publish_to_hub( $feed_urls ) { 18 Publisher::publish_to_hub( $feed_urls ); 9 19 } 10 20 11 21 /** 12 * Get the endpoints from the WordPress options table 13 * valid parameters are "publish" or "subscribe" 22 * Get the endpoints from the WordPress options table. 14 23 * 15 * @uses apply_filters() Calls 'pubsubhubbub_hub_urls' filter 24 * @uses apply_filters() Calls 'websub_hub_urls' filter. 25 * 26 * @return array The hub URLs. 16 27 */ 17 function pubsubhubbub_get_hubs() {18 return Pub SubHubbub_Publisher::get_hubs();28 function get_hubs() { 29 return Publisher::get_hubs(); 19 30 } 20 31 21 32 /** 22 * Check if link supports PubSubHubbub or WebSub33 * Check if link supports WebSub. 23 34 * 24 35 * @return boolean 25 36 */ 26 function pubsubhubbub_show_discovery() {37 function show_discovery() { 27 38 $show_discovery = false; 28 39 29 $supported_feed_types = apply_filters( 'pubsubhubbub_show_discovery_for_feed_types', pubsubhubbub_get_supported_feed_types() ); 30 $supported_comment_feed_types = apply_filters( 'pubsubhubbub_show_discovery_for_comment_feed_types', pubsubhubbub_get_supported_comment_feed_types() ); 40 /** 41 * Filter the list of feed types that show WebSub discovery. 42 * 43 * @since 4.0.0 44 * 45 * @param array $feed_types List of feed types (e.g., 'atom', 'rss2'). 46 */ 47 $supported_feed_types = \apply_filters_deprecated( 'pubsubhubbub_show_discovery_for_feed_types', array( get_supported_feed_types() ), '4.0.0', 'websub_show_discovery_for_feed_types' ); 48 $supported_feed_types = \apply_filters( 'websub_show_discovery_for_feed_types', $supported_feed_types ); 49 50 /** 51 * Filter the list of comment feed types that show WebSub discovery. 52 * 53 * @since 4.0.0 54 * 55 * @param array $feed_types List of comment feed types (e.g., 'atom', 'rss2'). 56 */ 57 $supported_comment_feed_types = \apply_filters_deprecated( 'pubsubhubbub_show_discovery_for_comment_feed_types', array( get_supported_comment_feed_types() ), '4.0.0', 'websub_show_discovery_for_comment_feed_types' ); 58 $supported_comment_feed_types = \apply_filters( 'websub_show_discovery_for_comment_feed_types', $supported_comment_feed_types ); 31 59 32 60 if ( 33 ( is_feed( $supported_feed_types ) && ! is_date() && ! is_post_type_archive() && !is_singular() ) ||34 ( is_feed( $supported_comment_feed_types ) &&is_singular() ) ||35 ( is_home() &¤t_theme_supports( 'microformats2' ) )61 ( \is_feed( $supported_feed_types ) && ! \is_date() && ! \is_post_type_archive() && ! \is_singular() ) || 62 ( \is_feed( $supported_comment_feed_types ) && \is_singular() ) || 63 ( \is_home() && \current_theme_supports( 'microformats2' ) ) 36 64 ) { 37 65 $show_discovery = true; 38 66 } 39 67 40 return apply_filters( 'pubsubhubbub_show_discovery', $show_discovery ); 68 /** 69 * Filter whether to show WebSub discovery links. 70 * 71 * @since 4.0.0 72 * 73 * @param bool $show_discovery Whether to show discovery links. 74 */ 75 $show_discovery = \apply_filters_deprecated( 'pubsubhubbub_show_discovery', array( $show_discovery ), '4.0.0', 'websub_show_discovery' ); 76 $show_discovery = \apply_filters( 'websub_show_discovery', $show_discovery ); 77 78 return $show_discovery; 41 79 } 42 80 43 81 /** 44 * Get the correct self URL 82 * Get the correct self URL. 45 83 * 46 * @return boolean84 * @return string The self link URL. 47 85 */ 48 function pubsubhubbub_get_self_link() { 49 $host = wp_parse_url( home_url() ); 86 function get_self_link() { 87 $host = \wp_parse_url( \home_url() ); 88 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized 89 $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? \wp_unslash( $_SERVER['REQUEST_URI'] ) : ''; 50 90 51 return esc_url( apply_filters( 'self_link', set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] )) ) );91 return \esc_url( \apply_filters( 'self_link', \set_url_scheme( 'http://' . $host['host'] . $request_uri ) ) ); 52 92 } 53 93 54 94 /** 55 * Return the list of feed types that are supported by PubSubHubbub 95 * Return the list of feed types that are supported by PubSubHubbub. 56 96 * 57 * @return array List of supported feed types 97 * @return array List of supported feed types. 58 98 */ 59 function pubsubhubbub_get_supported_feed_types() { 60 return apply_filters( 'pubsubhubbub_supported_feed_types', array( 'atom', 'rss2' ) ); 99 function get_supported_feed_types() { 100 /** 101 * Filter the list of supported feed types for WebSub. 102 * 103 * @since 4.0.0 104 * 105 * @param array $feed_types List of supported feed types. Default: array( 'atom', 'rss2' ). 106 */ 107 $feed_types = \apply_filters_deprecated( 'pubsubhubbub_supported_feed_types', array( array( 'atom', 'rss2' ) ), '4.0.0', 'websub_supported_feed_types' ); 108 $feed_types = \apply_filters( 'websub_supported_feed_types', $feed_types ); 109 110 return $feed_types; 61 111 } 62 112 63 113 /** 64 * Return the list of comment feed types that are supported by PubSubHubbub 114 * Return the list of comment feed types that are supported by PubSubHubbub. 65 115 * 66 * @return array List of supported comment feed types 116 * @return array List of supported comment feed types. 67 117 */ 68 function pubsubhubbub_get_supported_comment_feed_types() { 69 return apply_filters( 'pubsubhubbub_supported_comment_feed_types', array( 'atom', 'rss2' ) ); 118 function get_supported_comment_feed_types() { 119 /** 120 * Filter the list of supported comment feed types for WebSub. 121 * 122 * @since 4.0.0 123 * 124 * @param array $feed_types List of supported comment feed types. Default: array( 'atom', 'rss2' ). 125 */ 126 $feed_types = \apply_filters_deprecated( 'pubsubhubbub_supported_comment_feed_types', array( array( 'atom', 'rss2' ) ), '4.0.0', 'websub_supported_comment_feed_types' ); 127 $feed_types = \apply_filters( 'websub_supported_comment_feed_types', $feed_types ); 128 129 return $feed_types; 70 130 } -
pubsubhubbub/trunk/pubsubhubbub.php
r3065416 r3444728 4 4 * Plugin URI: https://github.com/pubsubhubbub/wordpress-pubsubhubbub/ 5 5 * Description: A better way to tell the world when your blog is updated. 6 * Version: 3.2.16 * Version: 4.0.0 7 7 * Author: PubSubHubbub Team 8 8 * Author URI: https://github.com/pubsubhubbub/wordpress-pubsubhubbub … … 10 10 * License URI: http://opensource.org/licenses/MIT 11 11 * Text Domain: pubsubhubbub 12 * Domain Path: /languages 12 * Requires PHP: 7.2 13 * 14 * @package Pubsubhubbub 13 15 */ 14 16 15 /** 16 * Initialize plugin 17 */ 18 function pubsubhubbub_init() { 19 require_once( dirname( __FILE__ ) . '/includes/functions.php' ); 17 namespace Pubsubhubbub; 20 18 21 /** 22 * Publisher integration 23 */ 24 require_once( dirname( __FILE__ ) . '/includes/class-pubsubhubbub-publisher.php' ); 19 \defined( 'ABSPATH' ) || exit; 25 20 26 add_action( 'publish_post', array( 'PubSubHubbub_Publisher', 'publish_post' ) ); 27 //add_action( 'comment_post', array( 'PubSubHubbub_Publisher', 'publish_comment' ) ); 21 \define( 'PUBSUBHUBBUB_VERSION', '4.0.0' ); 22 \define( 'PUBSUBHUBBUB_PLUGIN_DIR', \plugin_dir_path( __FILE__ ) ); 23 \define( 'PUBSUBHUBBUB_PLUGIN_BASENAME', \plugin_basename( __FILE__ ) ); 24 \define( 'PUBSUBHUBBUB_PLUGIN_FILE', __FILE__ ); 25 \define( 'PUBSUBHUBBUB_PLUGIN_URL', \plugin_dir_url( __FILE__ ) ); 28 26 29 /** 30 * Admin panel 31 */ 32 require_once( dirname( __FILE__ ) . '/includes/class-pubsubhubbub-admin.php' ); 27 // Load the autoloader. 28 require_once PUBSUBHUBBUB_PLUGIN_DIR . 'includes/class-autoloader.php'; 33 29 34 add_action( 'init', array( 'PubSubHubbub_Admin', 'register_settings' ) ); 35 add_action( 'admin_menu', array( 'Pubsubhubbub_Admin', 'add_plugin_menu' ) );30 // Load helper functions. 31 require_once PUBSUBHUBBUB_PLUGIN_DIR . 'includes/functions.php'; 36 32 37 /** 38 * Feed integrations 39 */ 40 require_once( dirname( __FILE__ ) . '/includes/class-pubsubhubbub-topics.php' ); 33 // Load deprecated functions for backward compatibility. 34 require_once PUBSUBHUBBUB_PLUGIN_DIR . 'includes/deprecated.php'; 41 35 42 add_action( 'atom_head', array( 'Pubsubhubbub_Topics', 'add_atom_link_tag' ) ); 43 add_action( 'rdf_header', array( 'Pubsubhubbub_Topics', 'add_rss_link_tag' ) ); 44 add_action( 'rss2_head', array( 'Pubsubhubbub_Topics', 'add_rss_link_tag' ) ); 36 // Register the autoloader. 37 Autoloader::register_path( __NAMESPACE__, PUBSUBHUBBUB_PLUGIN_DIR . 'includes' ); 45 38 46 add_action( 'comments_atom_head', array( 'Pubsubhubbub_Topics', 'add_atom_link_tag' ) ); 47 add_action( 'commentsrss2_head', array( 'Pubsubhubbub_Topics', 'add_rss_link_tag' ) ); 48 49 add_action( 'rdf_ns', array( 'Pubsubhubbub_Topics', 'add_rss_ns_link' ) ); 50 51 add_action( 'template_redirect', array( 'Pubsubhubbub_Topics', 'template_redirect' ) ); 52 53 /** 54 * Main class 55 */ 56 require_once( dirname( __FILE__ ) . '/includes/class-pubsubhubbub.php' ); 57 58 add_action( 'init', array( 'PubSubHubbub', 'load_textdomain' ) ); 59 60 /** 61 * Deprecated functions 62 */ 63 require_once( dirname( __FILE__ ) . '/includes/deprecated.php' ); 64 } 65 66 add_action( 'plugins_loaded', 'pubsubhubbub_init' ); 39 // Initialize the plugin. 40 $pubsubhubbub = Pubsubhubbub::get_instance(); 41 $pubsubhubbub->init();
Note: See TracChangeset
for help on using the changeset viewer.