kollapsminoriteten/wp-content/plugins/jetpack/modules/enhanced-distribution.php

82 lines
2.4 KiB
PHP
Raw Normal View History

2019-11-15 23:26:29 +01:00
<?php
/**
* Module Name: Enhanced Distribution
* Module Description: Increase reach and traffic.
* Sort Order: 5
* First Introduced: 1.2
* Requires Connection: Yes
* Auto Activate: Public
* Module Tags: Writing
* Feature: Engagement
2023-12-07 09:44:11 +01:00
* Additional Search Queries: google, seo, firehose, search, broadcast, broadcasting, creator
2022-04-02 10:26:41 +02:00
*
* @package automattic/jetpack
2019-11-15 23:26:29 +01:00
*/
2022-04-02 10:26:41 +02:00
/**
* In case it's active prior to upgrading to '1.9'.
*/
2019-11-15 23:26:29 +01:00
function jetpack_enhanced_distribution_before_activate_default_modules() {
2022-04-02 10:26:41 +02:00
$old_version = Jetpack_Options::get_option( 'old_version' );
2019-11-15 23:26:29 +01:00
list( $old_version ) = explode( ':', $old_version );
if ( version_compare( $old_version, '1.9-something', '>=' ) ) {
return;
}
Jetpack::check_privacy( __FILE__ );
}
add_action( 'jetpack_before_activate_default_modules', 'jetpack_enhanced_distribution_before_activate_default_modules' );
2022-04-02 10:26:41 +02:00
if ( isset( $_GET['get_freshly_pressed_data'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
/**
* If a request has ?get_freshly_pressed_data=true appended
* to the end, then let's provide the necessary data back via JSON.
*/
2019-11-15 23:26:29 +01:00
function jetpack_get_freshly_pressed_data() {
if ( is_single() ) {
2022-04-02 10:26:41 +02:00
wp_send_json_success(
array(
'blog_id' => Jetpack_Options::get_option( 'id' ),
'post_id' => get_the_ID(),
)
);
2019-11-15 23:26:29 +01:00
} else {
2022-04-02 10:26:41 +02:00
wp_send_json_error(
array(
'message' => 'Not Singular',
)
);
2019-11-15 23:26:29 +01:00
}
}
2022-04-02 10:26:41 +02:00
add_action( 'template_redirect', 'jetpack_get_freshly_pressed_data' );
2019-11-15 23:26:29 +01:00
}
2022-04-02 10:26:41 +02:00
add_action( 'rss_head', 'jetpack_enhanced_distribution_feed_id' );
add_action( 'rss_item', 'jetpack_enhanced_distribution_post_id' );
2019-11-15 23:26:29 +01:00
add_action( 'rss2_head', 'jetpack_enhanced_distribution_feed_id' );
add_action( 'rss2_item', 'jetpack_enhanced_distribution_post_id' );
2022-04-02 10:26:41 +02:00
/**
* Output feed identifier based on blog ID.
*/
function jetpack_enhanced_distribution_feed_id() {
$id = (int) Jetpack_Options::get_option( 'id' );
2019-11-15 23:26:29 +01:00
if ( $id > 0 ) {
$output = sprintf( '<site xmlns="com-wordpress:feed-additions:1">%d</site>', $id );
2022-04-02 10:26:41 +02:00
echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2019-11-15 23:26:29 +01:00
}
}
2022-04-02 10:26:41 +02:00
/**
* Output feed item identifier based on current post ID.
*/
function jetpack_enhanced_distribution_post_id() {
$id = (int) get_the_ID();
2019-11-15 23:26:29 +01:00
if ( $id ) {
$output = sprintf( '<post-id xmlns="com-wordpress:feed-additions:1">%d</post-id>', $id );
2022-04-02 10:26:41 +02:00
echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2019-11-15 23:26:29 +01:00
}
}