diff --git a/projects/packages/classic-theme-helper/.phan/baseline.php b/projects/packages/classic-theme-helper/.phan/baseline.php
index 889311320576f..89047ffe08480 100644
--- a/projects/packages/classic-theme-helper/.phan/baseline.php
+++ b/projects/packages/classic-theme-helper/.phan/baseline.php
@@ -19,11 +19,13 @@
// PhanTypeMismatchProperty : 1 occurrence
// PhanTypeMismatchPropertyProbablyReal : 1 occurrence
// PhanTypePossiblyInvalidDimOffset : 1 occurrence
+ // PhanUndeclaredFunction : 1 occurrence
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
'_inc/lib/tonesque.php' => ['PhanNonClassMethodCall', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchPropertyProbablyReal', 'PhanUndeclaredClassMethod'],
'src/class-featured-content.php' => ['PhanTypeComparisonToArray', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgument', 'PhanTypeMismatchProperty', 'PhanTypePossiblyInvalidDimOffset'],
+ 'src/social-menu/icon-functions.php' => ['PhanUndeclaredFunction'],
],
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.
// (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases)
diff --git a/projects/packages/classic-theme-helper/changelog/add-social-menu-to-classic-theme-helper-package b/projects/packages/classic-theme-helper/changelog/add-social-menu-to-classic-theme-helper-package
new file mode 100644
index 0000000000000..9c018ceec030b
--- /dev/null
+++ b/projects/packages/classic-theme-helper/changelog/add-social-menu-to-classic-theme-helper-package
@@ -0,0 +1,4 @@
+Significance: patch
+Type: added
+
+Theme Tools: Adding Social Menu to Classic Theme Helper package
diff --git a/projects/packages/classic-theme-helper/package.json b/projects/packages/classic-theme-helper/package.json
index c57a08d135d77..e0d78bd18d0f2 100644
--- a/projects/packages/classic-theme-helper/package.json
+++ b/projects/packages/classic-theme-helper/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-classic-theme-helper",
- "version": "0.4.0",
+ "version": "0.4.1-alpha",
"description": "Features used with classic themes",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/classic-theme-helper/#readme",
"bugs": {
diff --git a/projects/packages/classic-theme-helper/src/class-main.php b/projects/packages/classic-theme-helper/src/class-main.php
index a495cf2e9cd05..c03dea06b286c 100644
--- a/projects/packages/classic-theme-helper/src/class-main.php
+++ b/projects/packages/classic-theme-helper/src/class-main.php
@@ -14,7 +14,7 @@
*/
class Main {
- const PACKAGE_VERSION = '0.4.0';
+ const PACKAGE_VERSION = '0.4.1-alpha';
/**
* Modules to include.
diff --git a/projects/packages/classic-theme-helper/src/social-menu.php b/projects/packages/classic-theme-helper/src/social-menu.php
new file mode 100644
index 0000000000000..be89a1c68c36a
--- /dev/null
+++ b/projects/packages/classic-theme-helper/src/social-menu.php
@@ -0,0 +1,127 @@
+ esc_html( $social_menu_description ),
+ )
+ );
+
+ // Enqueue CSS
+ add_action( 'wp_enqueue_scripts', 'jetpack_social_menu_style' );
+
+ // Load SVG icons related functions and filters
+ if ( 'svg' === jetpack_social_menu_get_type() ) {
+ require __DIR__ . '/social-menu/icon-functions.php';
+ }
+ }
+ add_action( 'after_setup_theme', 'jetpack_social_menu_init', 99 );
+ add_action( 'restapi_theme_init', 'jetpack_social_menu_init' );
+}
+
+if ( ! function_exists( 'jetpack_social_menu_get_type' ) ) {
+ /**
+ * Return the type of menu the theme is using.
+ *
+ * @uses get_theme_support()
+ * @return null|string $menu_type
+ */
+ function jetpack_social_menu_get_type() {
+ $options = get_theme_support( 'jetpack-social-menu' );
+
+ if ( ! $options ) {
+ $menu_type = null;
+ } else {
+ $menu_type = 'genericons';
+ if ( is_array( $options ) && isset( $options[0] ) ) {
+ $menu_type = ( in_array( $options[0], array( 'genericons', 'svg' ), true ) ) ? $options[0] : 'genericons';
+ }
+ }
+
+ return $menu_type;
+ }
+}
+
+if ( ! function_exists( 'jetpack_social_menu_style' ) ) {
+ /**
+ * Function to enqueue the CSS.
+ */
+ function jetpack_social_menu_style() {
+ $menu_type = jetpack_social_menu_get_type();
+
+ if ( ! $menu_type ) {
+ return;
+ }
+
+ $deps = ( 'genericons' === $menu_type ) ? array( 'genericons' ) : null;
+
+ if ( has_nav_menu( 'jetpack-social-menu' ) ) {
+ wp_enqueue_style( 'jetpack-social-menu', plugins_url( 'social-menu/social-menu.css', __FILE__ ), $deps, '1.0' );
+ }
+ }
+}
+
+if ( ! function_exists( 'jetpack_social_menu' ) ) {
+ /**
+ * Create the function for the menu.
+ */
+ function jetpack_social_menu() {
+ if ( has_nav_menu( 'jetpack-social-menu' ) ) :
+ $menu_type = (string) jetpack_social_menu_get_type();
+ $link_after = '';
+
+ if ( 'svg' === $menu_type ) {
+ $link_after .= jetpack_social_menu_get_svg( array( 'icon' => 'chain' ) );
+ } ?>
+
+ '',
+ 'fallback' => false,
+ );
+
+ // Parse args.
+ $args = wp_parse_args( $args, $defaults );
+
+ // Set aria hidden.
+ $aria_hidden = ' aria-hidden="true"';
+
+ // Begin SVG markup.
+ $svg = '';
+
+ return $svg;
+ }
+}
+
+if ( ! function_exists( 'jetpack_social_menu_nav_menu_social_icons' ) ) {
+ /**
+ * Display SVG icons in social links menu.
+ *
+ * @param string $item_output The menu item output.
+ * @param WP_Post $item Menu item object.
+ * @param int $depth Depth of the menu.
+ * @param object $args wp_nav_menu() arguments.
+ * @return string $item_output The menu item output with social icon.
+ */
+ function jetpack_social_menu_nav_menu_social_icons( $item_output, $item, $depth, $args ) {
+ // Get supported social icons.
+ $social_icons = jetpack_social_menu_social_links_icons();
+
+ // Change SVG icon inside social links menu if there is supported URL.
+ if ( 'jetpack-social-menu' === $args->theme_location ) {
+ foreach ( $social_icons as $attr => $value ) {
+ /*
+ * attr can be a URL host, or a regex, starting with #.
+ * Let's check for both scenarios.
+ */
+ if (
+ // First Regex.
+ (
+ str_starts_with( $attr, '#' ) && str_ends_with( $attr, '#' )
+ && preg_match( $attr, $item_output )
+ )
+ // Then, regular host name.
+ || str_contains( $item_output, $attr )
+ ) {
+ $item_output = str_replace(
+ $args->link_after,
+ '' . jetpack_social_menu_get_svg( array( 'icon' => esc_attr( $value ) ) ),
+ $item_output
+ );
+ }
+ }
+ }
+
+ return $item_output;
+ }
+ add_filter( 'walker_nav_menu_start_el', 'jetpack_social_menu_nav_menu_social_icons', 10, 4 );
+}
+
+if ( ! function_exists( 'jetpack_social_menu_social_links_icons' ) ) {
+ /**
+ * Returns an array of supported social links (URL / regex and icon name).
+ * For regex, use the # delimiter.
+ *
+ * @return array $social_links_icons
+ */
+ function jetpack_social_menu_social_links_icons() {
+ // Supported social links icons.
+ $social_links_icons = array(
+ '#https?:\/\/(www\.)?amazon\.(com|cn|in|fr|de|it|nl|es|co|ca)\/#' => 'amazon',
+ '500px.com' => '500px',
+ 'apple.com' => 'apple',
+ 'itunes.com' => 'apple',
+ 'bandcamp.com' => 'bandcamp',
+ 'behance.net' => 'behance',
+ 'blogger.com' => 'blogger',
+ 'blogspot.com' => 'blogger',
+ 'bsky.app' => 'bluesky',
+ 'codepen.io' => 'codepen',
+ 'deviantart.com' => 'deviantart',
+ 'discord.gg' => 'discord',
+ 'discordapp.com' => 'discord',
+ 'digg.com' => 'digg',
+ 'dribbble.com' => 'dribbble',
+ 'dropbox.com' => 'dropbox',
+ 'etsy.com' => 'etsy',
+ 'eventbrite.com' => 'eventbrite',
+ 'facebook.com' => 'facebook',
+ '/feed/' => 'feed',
+ 'flickr.com' => 'flickr',
+ 'foursquare.com' => 'foursquare',
+ 'ghost.org' => 'ghost',
+ 'goodreads.com' => 'goodreads',
+ 'google.com' => 'google',
+ 'github.com' => 'github',
+ 'instagram.com' => 'instagram',
+ 'linkedin.com' => 'linkedin',
+ 'mailto:' => 'mail',
+ 'meetup.com' => 'meetup',
+ 'medium.com' => 'medium',
+ 'nextdoor.com' => 'nextdoor',
+ 'patreon.com' => 'patreon',
+ 'pinterest.' => 'pinterest',
+ 'getpocket.com' => 'pocket',
+ 'ravelry.com' => 'ravelry',
+ 'reddit.com' => 'reddit',
+ 'skype.com' => 'skype',
+ 'skype:' => 'skype',
+ 'slideshare.net' => 'slideshare',
+ 'sms:' => 'sms',
+ 'snapchat.com' => 'snapchat',
+ 'soundcloud.com' => 'soundcloud',
+ 'spotify.com' => 'spotify',
+ 'stackoverflow.com' => 'stackoverflow',
+ 'strava.com' => 'strava',
+ 'stumbleupon.com' => 'stumbleupon',
+ 'telegram.me' => 'telegram',
+ 'threads.net' => 'threads',
+ 'tiktok.com' => 'tiktok',
+ 'tumblr.com' => 'tumblr',
+ 'twitch.tv' => 'twitch',
+ 'twitter.com' => 'twitter',
+ 'vimeo.com' => 'vimeo',
+ 'vk.com' => 'vk',
+ 'whatsapp.com' => 'whatsapp',
+ 'woocommerce.com' => 'woocommerce',
+ 'wordpress.org' => 'wordpress',
+ 'wordpress.com' => 'wordpress',
+ 'yelp.com' => 'yelp',
+ 'x.com' => 'x',
+ 'xanga.com' => 'xanga',
+ 'youtube.com' => 'youtube',
+ );
+
+ /*
+ * Add Mastodon instances to this array.
+ */
+ $mastodon_instance_list = jetpack_mastodon_get_instance_list();
+ foreach ( $mastodon_instance_list as $instance ) {
+ $social_links_icons[ $instance ] = 'mastodon';
+ }
+
+ return $social_links_icons;
+ }
+}
diff --git a/projects/packages/classic-theme-helper/src/social-menu/social-menu.css b/projects/packages/classic-theme-helper/src/social-menu/social-menu.css
new file mode 100644
index 0000000000000..aad2f077364d3
--- /dev/null
+++ b/projects/packages/classic-theme-helper/src/social-menu/social-menu.css
@@ -0,0 +1,222 @@
+/*--------------------------------------------------------------
+Global
+--------------------------------------------------------------*/
+.jetpack-social-navigation ul {
+ display: block;
+ margin: 0 0 1.5em;
+ padding: 0;
+}
+
+.jetpack-social-navigation li {
+ display: inline-block;
+ margin: 0;
+ line-height: 1;
+}
+
+.jetpack-social-navigation a {
+ border: 0;
+ height: 1em;
+ text-decoration: none;
+ width: 1em;
+}
+
+/*--------------------------------------------------------------
+SVG
+--------------------------------------------------------------*/
+.jetpack-social-navigation-svg .icon {
+ color: inherit;
+ fill: currentColor;
+ height: 1em;
+ vertical-align: middle;
+ width: 1em;
+}
+
+/*--------------------------------------------------------------
+Genericons
+--------------------------------------------------------------*/
+.jetpack-social-navigation-genericons a:before {
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ display: inline-block;
+ font-family: Genericons;
+ font-size: 1em;
+ font-style: normal;
+ font-weight: normal;
+ height: 1em;
+ line-height: 1;
+ speak: none;
+ text-decoration: inherit;
+ vertical-align: top;
+ width: 1em;
+}
+
+/* Default */
+.jetpack-social-navigation-genericons a:before {
+ content: "\f415";
+}
+
+/* Bluesky */
+.jetpack-social-navigation-genericons a[href*="bsky.app"]:before {
+ content: "\f10f";
+}
+
+/* CodePen */
+.jetpack-social-navigation-genericons a[href*="codepen.io"]:before {
+ content: "\f216";
+}
+
+/* Digg */
+.jetpack-social-navigation-genericons a[href*="digg.com"]:before {
+ content: "\f221";
+}
+
+/* Dribbble */
+.jetpack-social-navigation-genericons a[href*="dribbble.com"]:before {
+ content: "\f201";
+}
+
+/* Dropbox */
+.jetpack-social-navigation-genericons a[href*="dropbox.com"]:before {
+ content: "\f225";
+}
+
+/* Email */
+.jetpack-social-navigation-genericons a[href*="mailto:"]:before {
+ content: "\f410";
+}
+
+/* Facebook */
+.jetpack-social-navigation-genericons a[href*="facebook.com"]:before {
+ content: "\f203";
+}
+
+/* Flickr */
+.jetpack-social-navigation-genericons a[href*="flickr.com"]:before {
+ content: "\f211";
+}
+
+/* Foursquare */
+.jetpack-social-navigation-genericons a[href*="foursquare.com"]:before {
+ content: "\f226";
+}
+
+/* GitHub */
+.jetpack-social-navigation-genericons a[href*="github.com"]:before {
+ content: "\f200";
+}
+
+/* Google Plus */
+.jetpack-social-navigation-genericons a[href*="plus.google.com"]:before {
+ content: "\f206";
+}
+
+/* Instagram */
+.jetpack-social-navigation-genericons a[href*="instagram.com"]:before {
+ content: "\f215";
+}
+
+/* LinkedIn */
+.jetpack-social-navigation-genericons a[href*="linkedin.com"]:before {
+ content: "\f208";
+}
+
+/* Nextdoor */
+.jetpack-social-navigation-genericons a[href*="nextdoor.com"]:before {
+ content: "\f10c";
+}
+
+/* Path */
+.jetpack-social-navigation-genericons a[href*="path.com"]:before {
+ content: "\f219";
+}
+
+/* Pinterest */
+.jetpack-social-navigation-genericons a[href*="pinterest."]:before {
+ content: "\f210";
+}
+
+/* Pocket */
+.jetpack-social-navigation-genericons a[href*="getpocket.com"]:before {
+ content: "\f224";
+}
+
+/* Polldaddy */
+.jetpack-social-navigation-genericons a[href*="polldaddy.com"]:before {
+ content: "\f217";
+}
+
+/* Reddit */
+.jetpack-social-navigation-genericons a[href*="reddit.com"]:before {
+ content: "\f222";
+}
+
+/* RSS Feed */
+.jetpack-social-navigation-genericons a[href$="/feed/"]:before {
+ content: "\f413";
+}
+
+/* Skype */
+.jetpack-social-navigation-genericons a[href*="skype:"]:before {
+ content: "\f220";
+}
+
+/* Skype */
+.jetpack-social-navigation-genericons a[href*="sms:"]:before {
+ content: "\f110";
+}
+
+/* Spotify */
+.jetpack-social-navigation-genericons a[href*="spotify.com"]:before {
+ content: "\f515";
+}
+
+/* StumbleUpon */
+.jetpack-social-navigation-genericons a[href*="stumbleupon.com"]:before {
+ content: "\f223";
+}
+
+/* Threads */
+.jetpack-social-navigation-genericons a[href*="threads.net"]:before {
+ content: "\f10d";
+}
+
+/* Tumblr */
+.jetpack-social-navigation-genericons a[href*="tumblr.com"]:before {
+ content: "\f214";
+}
+
+/* Twitch */
+.jetpack-social-navigation-genericons a[href*="twitch.tv"]:before {
+ content: "\f516";
+}
+
+/* Twitter */
+.jetpack-social-navigation-genericons a[href*="twitter.com"]:before {
+ content: "\f202";
+}
+
+/* Vimeo */
+.jetpack-social-navigation-genericons a[href*="vimeo.com"]:before {
+ content: "\f212";
+}
+
+/* Vine */
+.jetpack-social-navigation-genericons a[href*="vine.co"]:before {
+ content: "\f517";
+}
+
+/* WordPress */
+.jetpack-social-navigation-genericons a[href*="wordpress.com"]:before,
+.jetpack-social-navigation-genericons a[href*="wordpress.org"]:before {
+ content: "\f205";
+}
+
+/* X */
+.jetpack-social-navigation-genericons a[href*="x.com"]:before {
+ content: "\f10e";
+}
+
+/* YouTube */
+.jetpack-social-navigation-genericons a[href*="youtube.com"]:before {
+ content: "\f213";
+}
diff --git a/projects/packages/classic-theme-helper/src/social-menu/social-menu.svg b/projects/packages/classic-theme-helper/src/social-menu/social-menu.svg
new file mode 100644
index 0000000000000..6d68732322fd8
--- /dev/null
+++ b/projects/packages/classic-theme-helper/src/social-menu/social-menu.svg
@@ -0,0 +1,192 @@
+
diff --git a/projects/plugins/jetpack/.phan/baseline.php b/projects/plugins/jetpack/.phan/baseline.php
index 74a6598a9d95a..35e86c79b8916 100644
--- a/projects/plugins/jetpack/.phan/baseline.php
+++ b/projects/plugins/jetpack/.phan/baseline.php
@@ -28,6 +28,7 @@
// PhanUndeclaredProperty : 35+ occurrences
// PhanParamSignatureMismatch : 25+ occurrences
// PhanPluginSimplifyExpressionBool : 25+ occurrences
+ // PhanRedefineFunction : 25+ occurrences
// PhanTypeInvalidDimOffset : 25+ occurrences
// PhanTypeMismatchDefault : 25+ occurrences
// PhanTypeMismatchPropertyProbablyReal : 25+ occurrences
@@ -38,7 +39,6 @@
// PhanTypeMismatchDimFetch : 20+ occurrences
// PhanPluginDuplicateExpressionAssignmentOperation : 15+ occurrences
// PhanPluginMixedKeyNoKey : 15+ occurrences
- // PhanRedefineFunction : 15+ occurrences
// PhanSuspiciousMagicConstant : 15+ occurrences
// PhanTypeExpectedObjectPropAccessButGotNull : 15+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 15+ occurrences
@@ -444,8 +444,8 @@
'modules/theme-tools/site-logo/inc/class-site-logo.php' => ['PhanRedundantCondition', 'PhanTypeComparisonToArray', 'PhanTypeMismatchReturn'],
'modules/theme-tools/site-logo/inc/functions.php' => ['PhanTypeMismatchReturnProbablyReal'],
'modules/theme-tools/social-links.php' => ['PhanNoopNew', 'PhanTypeMismatchArgumentInternal'],
- 'modules/theme-tools/social-menu.php' => ['PhanTypeMismatchArgumentNullable'],
- 'modules/theme-tools/social-menu/icon-functions.php' => ['PhanPluginSimplifyExpressionBool', 'PhanTypeExpectedObjectPropAccess'],
+ 'modules/theme-tools/social-menu.php' => ['PhanRedefineFunction', 'PhanTypeMismatchArgumentNullable'],
+ 'modules/theme-tools/social-menu/icon-functions.php' => ['PhanPluginSimplifyExpressionBool', 'PhanRedefineFunction', 'PhanTypeExpectedObjectPropAccess'],
'modules/tiled-gallery/math/class-constrained-array-rounding.php' => ['PhanTypeMismatchDefault'],
'modules/tiled-gallery/tiled-gallery.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgumentProbablyReal'],
'modules/tiled-gallery/tiled-gallery/templates/carousel-container.php' => ['PhanTypeMismatchArgument'],
diff --git a/projects/plugins/jetpack/changelog/add-social-menu-to-classic-theme-helper-package b/projects/plugins/jetpack/changelog/add-social-menu-to-classic-theme-helper-package
new file mode 100644
index 0000000000000..83b75a9ebbd51
--- /dev/null
+++ b/projects/plugins/jetpack/changelog/add-social-menu-to-classic-theme-helper-package
@@ -0,0 +1,4 @@
+Significance: patch
+Type: other
+
+Theme tools: Add social menu to Classic Theme Helper package
diff --git a/projects/plugins/jetpack/modules/theme-tools/social-menu.php b/projects/plugins/jetpack/modules/theme-tools/social-menu.php
index df241b89844a7..36152af2c8f7e 100644
--- a/projects/plugins/jetpack/modules/theme-tools/social-menu.php
+++ b/projects/plugins/jetpack/modules/theme-tools/social-menu.php
@@ -11,109 +11,117 @@
* @package automattic/jetpack
*/
-/**
- * Activate the Social Menu plugin.
- *
- * @uses current_theme_supports()
- */
-function jetpack_social_menu_init() {
- // Only load our code if our theme declares support
- if ( ! current_theme_supports( 'jetpack-social-menu' ) ) {
- return;
- }
-
- /*
- * Social Menu description.
- *
- * Rename the social menu description.
- *
- * @module theme-tools
+if ( ! function_exists( 'jetpack_social_menu_init' ) ) {
+ /**
+ * Activate the Social Menu plugin.
*
- * @since 3.9.0
- *
- * @param string $social_menu_description Social Menu description
+ * @uses current_theme_supports()
*/
- $social_menu_description = apply_filters( 'jetpack_social_menu_description', __( 'Social Menu', 'jetpack' ) );
+ function jetpack_social_menu_init() {
+ // Only load our code if our theme declares support
+ if ( ! current_theme_supports( 'jetpack-social-menu' ) ) {
+ return;
+ }
- // Register a new menu location
- register_nav_menus(
- array(
- 'jetpack-social-menu' => esc_html( $social_menu_description ),
- )
- );
+ /*
+ * Social Menu description.
+ *
+ * Rename the social menu description.
+ *
+ * @module theme-tools
+ *
+ * @since 3.9.0
+ *
+ * @param string $social_menu_description Social Menu description
+ */
+ $social_menu_description = apply_filters( 'jetpack_social_menu_description', __( 'Social Menu', 'jetpack' ) );
- // Enqueue CSS
- add_action( 'wp_enqueue_scripts', 'jetpack_social_menu_style' );
+ // Register a new menu location
+ register_nav_menus(
+ array(
+ 'jetpack-social-menu' => esc_html( $social_menu_description ),
+ )
+ );
- // Load SVG icons related functions and filters
- if ( 'svg' === jetpack_social_menu_get_type() ) {
- require __DIR__ . '/social-menu/icon-functions.php';
+ // Enqueue CSS
+ add_action( 'wp_enqueue_scripts', 'jetpack_social_menu_style' );
+
+ // Load SVG icons related functions and filters
+ if ( 'svg' === jetpack_social_menu_get_type() ) {
+ require __DIR__ . '/social-menu/icon-functions.php';
+ }
}
+ add_action( 'after_setup_theme', 'jetpack_social_menu_init', 99 );
+ add_action( 'restapi_theme_init', 'jetpack_social_menu_init' );
}
-add_action( 'after_setup_theme', 'jetpack_social_menu_init', 99 );
-add_action( 'restapi_theme_init', 'jetpack_social_menu_init' );
-/**
- * Return the type of menu the theme is using.
- *
- * @uses get_theme_support()
- * @return null|string $menu_type
- */
-function jetpack_social_menu_get_type() {
- $options = get_theme_support( 'jetpack-social-menu' );
+if ( ! function_exists( 'jetpack_social_menu_get_type' ) ) {
+ /**
+ * Return the type of menu the theme is using.
+ *
+ * @uses get_theme_support()
+ * @return null|string $menu_type
+ */
+ function jetpack_social_menu_get_type() {
+ $options = get_theme_support( 'jetpack-social-menu' );
- if ( ! $options ) {
- $menu_type = null;
- } else {
- $menu_type = 'genericons';
- if ( is_array( $options ) && isset( $options[0] ) ) {
- $menu_type = ( in_array( $options[0], array( 'genericons', 'svg' ), true ) ) ? $options[0] : 'genericons';
+ if ( ! $options ) {
+ $menu_type = null;
+ } else {
+ $menu_type = 'genericons';
+ if ( is_array( $options ) && isset( $options[0] ) ) {
+ $menu_type = ( in_array( $options[0], array( 'genericons', 'svg' ), true ) ) ? $options[0] : 'genericons';
+ }
}
- }
- return $menu_type;
+ return $menu_type;
+ }
}
-/**
- * Function to enqueue the CSS.
- */
-function jetpack_social_menu_style() {
- $menu_type = jetpack_social_menu_get_type();
+if ( ! function_exists( 'jetpack_social_menu_style' ) ) {
+ /**
+ * Function to enqueue the CSS.
+ */
+ function jetpack_social_menu_style() {
+ $menu_type = jetpack_social_menu_get_type();
- if ( ! $menu_type ) {
- return;
- }
+ if ( ! $menu_type ) {
+ return;
+ }
- $deps = ( 'genericons' === $menu_type ) ? array( 'genericons' ) : null;
+ $deps = ( 'genericons' === $menu_type ) ? array( 'genericons' ) : null;
- if ( has_nav_menu( 'jetpack-social-menu' ) ) {
- wp_enqueue_style( 'jetpack-social-menu', plugins_url( 'social-menu/social-menu.css', __FILE__ ), $deps, '1.0' );
+ if ( has_nav_menu( 'jetpack-social-menu' ) ) {
+ wp_enqueue_style( 'jetpack-social-menu', plugins_url( 'social-menu/social-menu.css', __FILE__ ), $deps, '1.0' );
+ }
}
}
-/**
- * Create the function for the menu.
- */
-function jetpack_social_menu() {
- if ( has_nav_menu( 'jetpack-social-menu' ) ) :
- $menu_type = jetpack_social_menu_get_type();
- $link_after = '';
+if ( ! function_exists( 'jetpack_social_menu' ) ) {
+ /**
+ * Create the function for the menu.
+ */
+ function jetpack_social_menu() {
+ if ( has_nav_menu( 'jetpack-social-menu' ) ) :
+ $menu_type = jetpack_social_menu_get_type();
+ $link_after = '';
- if ( 'svg' === $menu_type ) {
- $link_after .= jetpack_social_menu_get_svg( array( 'icon' => 'chain' ) );
- } ?>
-
-