kollapsminoriteten/wp-content/plugins/jetpack/modules/theme-tools/social-links.php

133 lines
4.6 KiB
PHP
Raw Normal View History

2022-06-16 14:01:47 +02:00
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2019-11-15 23:26:29 +01:00
/**
2022-06-16 14:01:47 +02:00
* Theme Tools: Social Links.
2019-11-15 23:26:29 +01:00
*
* This feature will only be activated for themes that declare their support.
* This can be done by adding code similar to the following during the
* 'after_setup_theme' action:
*
* add_theme_support( 'social-links', array(
2020-05-06 17:20:49 +02:00
* 'facebook', 'twitter', 'linkedin', 'tumblr',
2019-11-15 23:26:29 +01:00
* ) );
2022-06-16 14:01:47 +02:00
*
* @package automattic/jetpack
2019-11-15 23:26:29 +01:00
*/
2025-02-28 08:42:11 +01:00
use Automattic\Jetpack\Status\Host;
2023-04-26 17:39:43 +02:00
// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
2025-02-28 08:42:11 +01:00
if ( ! function_exists( 'jetpack_theme_supports_social_links' ) ) {
/**
* Init Social_Links if the theme declares support.
*/
function jetpack_theme_supports_social_links() {
new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links();
}
if ( ! ( new Host() )->is_wpcom_platform() ) {
add_action( 'init', 'jetpack_theme_supports_social_links', 30 );
2019-11-15 23:26:29 +01:00
}
}
if ( ! class_exists( 'Social_Links' ) ) {
2022-06-16 14:01:47 +02:00
/**
* Social_Links main class.
2025-02-28 08:42:11 +01:00
*
* @deprecated 13.8 Moved to Classic Theme Helper package.
2022-06-16 14:01:47 +02:00
*/
2019-11-15 23:26:29 +01:00
class Social_Links {
/**
* Constructor.
2025-02-28 08:42:11 +01:00
*
* @deprecated 13.8 Moved to Classic Theme Helper package.
2019-11-15 23:26:29 +01:00
*/
public function __construct() {
2025-02-28 08:42:11 +01:00
_deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->__construct' );
new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links();
2019-11-15 23:26:29 +01:00
}
2022-06-16 14:01:47 +02:00
/**
* Init the admin setup.
2025-02-28 08:42:11 +01:00
*
* @deprecated 13.8 Moved to Classic Theme Helper package.
2022-06-16 14:01:47 +02:00
*/
2019-11-15 23:26:29 +01:00
public function admin_setup() {
2025-02-28 08:42:11 +01:00
_deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->admin_setup' );
$social_links_instance = new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links();
$social_links_instance->admin_setup();
2019-11-15 23:26:29 +01:00
}
/**
* Compares the currently saved links with the connected services and removes
* links from services that are no longer connected.
*
2025-02-28 08:42:11 +01:00
* @deprecated 13.8 Moved to Classic Theme Helper package.
2019-11-15 23:26:29 +01:00
* @return void
*/
public function check_links() {
2025-02-28 08:42:11 +01:00
_deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->check_links' );
$social_links_instance = new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links();
$social_links_instance->check_links();
2019-11-15 23:26:29 +01:00
}
/**
* Add social link dropdown to the Customizer.
*
2025-02-28 08:42:11 +01:00
* @deprecated 13.8 Moved to Classic Theme Helper package.
2019-11-15 23:26:29 +01:00
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
public function customize_register( $wp_customize ) {
2025-02-28 08:42:11 +01:00
_deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->customize_register' );
$social_links_instance = new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links();
$social_links_instance->customize_register( $wp_customize );
2019-11-15 23:26:29 +01:00
}
/**
* Sanitizes social links.
*
2025-02-28 08:42:11 +01:00
* @deprecated 13.8 Moved to Classic Theme Helper package.
2019-11-15 23:26:29 +01:00
* @param array $option The incoming values to be sanitized.
2025-02-28 08:42:11 +01:00
* @return array
2019-11-15 23:26:29 +01:00
*/
public function sanitize_link( $option ) {
2025-02-28 08:42:11 +01:00
_deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->sanitize_link' );
return ( new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links() )->sanitize_link( $option );
2019-11-15 23:26:29 +01:00
}
/**
* Returns whether there are any social links set.
*
2025-02-28 08:42:11 +01:00
* @deprecated 13.8 Moved to Classic Theme Helper package.
* @return bool
2019-11-15 23:26:29 +01:00
*/
public function has_social_links() {
2025-02-28 08:42:11 +01:00
_deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->has_social_links' );
return ( new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links() )->has_social_links(); }
2019-11-15 23:26:29 +01:00
/**
* Return available social links.
*
2025-02-28 08:42:11 +01:00
* @return array
2019-11-15 23:26:29 +01:00
*/
public function get_social_links() {
2025-02-28 08:42:11 +01:00
_deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->get_social_links' );
return ( new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links() )->get_social_links();
2019-11-15 23:26:29 +01:00
}
/**
* Short-circuits get_option and get_theme_mod calls.
*
2025-02-28 08:42:11 +01:00
* @deprecated 13.8 Moved to Classic Theme Helper package.
2019-11-15 23:26:29 +01:00
* @param string $link The incoming value to be replaced.
2025-02-28 08:42:11 +01:00
* @return string $link The social link that we've got.
2019-11-15 23:26:29 +01:00
*/
public function get_social_link_filter( $link ) {
2025-02-28 08:42:11 +01:00
_deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->get_social_link_filter' );
return ( new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links() )->get_social_link_filter( $link );
2019-11-15 23:26:29 +01:00
}
}
2022-06-16 14:01:47 +02:00
} // - end if ( ! class_exists( 'Social_Links' )