compat
1 year ago
content-options
1 year ago
js
6 years ago
responsive-videos
1 year ago
site-logo
2 years ago
social-menu
2 years ago
content-options.php
1 year ago
devicepx.php
2 years ago
featured-content.php
2 years ago
responsive-videos.php
2 years ago
site-breadcrumbs.php
2 years ago
site-logo.php
2 years ago
social-links.php
2 years ago
social-menu.php
2 years ago
social-links.php
135 lines
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | /** |
| 3 | * Theme Tools: Social Links. |
| 4 | * |
| 5 | * This feature will only be activated for themes that declare their support. |
| 6 | * This can be done by adding code similar to the following during the |
| 7 | * 'after_setup_theme' action: |
| 8 | * |
| 9 | * add_theme_support( 'social-links', array( |
| 10 | * 'facebook', 'twitter', 'linkedin', 'tumblr', |
| 11 | * ) ); |
| 12 | * |
| 13 | * @package automattic/jetpack |
| 14 | */ |
| 15 | |
| 16 | use Automattic\Jetpack\Status\Host; |
| 17 | |
| 18 | // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files. |
| 19 | |
| 20 | if ( ! function_exists( 'jetpack_theme_supports_social_links' ) ) { |
| 21 | /** |
| 22 | * Init Social_Links if the theme declares support. |
| 23 | */ |
| 24 | function jetpack_theme_supports_social_links() { |
| 25 | // @phan-suppress-next-line PhanNoopNew |
| 26 | new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links(); |
| 27 | } |
| 28 | if ( ! ( new Host() )->is_wpcom_platform() ) { |
| 29 | add_action( 'init', 'jetpack_theme_supports_social_links', 30 ); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | if ( ! class_exists( 'Social_Links' ) ) { |
| 34 | |
| 35 | /** |
| 36 | * Social_Links main class. |
| 37 | * |
| 38 | * @deprecated 13.8 Moved to Classic Theme Helper package. |
| 39 | */ |
| 40 | class Social_Links { |
| 41 | |
| 42 | /** |
| 43 | * Constructor. |
| 44 | * |
| 45 | * @deprecated 13.8 Moved to Classic Theme Helper package. |
| 46 | */ |
| 47 | public function __construct() { |
| 48 | _deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->__construct' ); |
| 49 | // @phan-suppress-next-line PhanNoopNew |
| 50 | new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links(); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Init the admin setup. |
| 55 | * |
| 56 | * @deprecated 13.8 Moved to Classic Theme Helper package. |
| 57 | */ |
| 58 | public function admin_setup() { |
| 59 | _deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->admin_setup' ); |
| 60 | $social_links_instance = new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links(); |
| 61 | $social_links_instance->admin_setup(); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Compares the currently saved links with the connected services and removes |
| 66 | * links from services that are no longer connected. |
| 67 | * |
| 68 | * @deprecated 13.8 Moved to Classic Theme Helper package. |
| 69 | * @return void |
| 70 | */ |
| 71 | public function check_links() { |
| 72 | _deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->check_links' ); |
| 73 | $social_links_instance = new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links(); |
| 74 | $social_links_instance->check_links(); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Add social link dropdown to the Customizer. |
| 79 | * |
| 80 | * @deprecated 13.8 Moved to Classic Theme Helper package. |
| 81 | * @param WP_Customize_Manager $wp_customize Theme Customizer object. |
| 82 | */ |
| 83 | public function customize_register( $wp_customize ) { |
| 84 | _deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->customize_register' ); |
| 85 | $social_links_instance = new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links(); |
| 86 | $social_links_instance->customize_register( $wp_customize ); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Sanitizes social links. |
| 91 | * |
| 92 | * @deprecated 13.8 Moved to Classic Theme Helper package. |
| 93 | * @param array $option The incoming values to be sanitized. |
| 94 | * @return array |
| 95 | */ |
| 96 | public function sanitize_link( $option ) { |
| 97 | _deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->sanitize_link' ); |
| 98 | return ( new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links() )->sanitize_link( $option ); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Returns whether there are any social links set. |
| 103 | * |
| 104 | * @deprecated 13.8 Moved to Classic Theme Helper package. |
| 105 | * @return bool |
| 106 | */ |
| 107 | public function has_social_links() { |
| 108 | _deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->has_social_links' ); |
| 109 | return ( new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links() )->has_social_links(); } |
| 110 | |
| 111 | /** |
| 112 | * Return available social links. |
| 113 | * |
| 114 | * @return array |
| 115 | */ |
| 116 | public function get_social_links() { |
| 117 | _deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->get_social_links' ); |
| 118 | return ( new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links() )->get_social_links(); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Short-circuits get_option and get_theme_mod calls. |
| 123 | * |
| 124 | * @deprecated 13.8 Moved to Classic Theme Helper package. |
| 125 | * @param string $link The incoming value to be replaced. |
| 126 | * @return string $link The social link that we've got. |
| 127 | */ |
| 128 | public function get_social_link_filter( $link ) { |
| 129 | _deprecated_function( __METHOD__, '13.8', 'Automattic\\Jetpack\\Classic_Theme_Helper\\Social_Links->get_social_link_filter' ); |
| 130 | return ( new \Automattic\Jetpack\Classic_Theme_Helper\Social_Links() )->get_social_link_filter( $link ); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | } // - end if ( ! class_exists( 'Social_Links' ) |
| 135 |