Skip to content

Commit

Permalink
Classic Theme Helper: Require Social Menus from the package (#38297)
Browse files Browse the repository at this point in the history
  • Loading branch information
coder-karen authored Jul 24, 2024
1 parent 7aa3daf commit 4bbcab7
Show file tree
Hide file tree
Showing 20 changed files with 234 additions and 126 deletions.
1 change: 0 additions & 1 deletion projects/packages/classic-theme-helper/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
'file_suppressions' => [
'_inc/lib/tonesque.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentProbablyReal'],
'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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Social Menus: Requiring the feature from the Classic Theme Helper package.
2 changes: 1 addition & 1 deletion projects/packages/classic-theme-helper/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-classic-theme-helper",
"version": "0.4.2",
"version": "0.4.3-alpha",
"description": "Features used with classic themes",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/classic-theme-helper/#readme",
"bugs": {
Expand Down
3 changes: 2 additions & 1 deletion projects/packages/classic-theme-helper/src/class-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class Main {

const PACKAGE_VERSION = '0.4.2';
const PACKAGE_VERSION = '0.4.3-alpha';

/**
* Modules to include.
Expand All @@ -23,6 +23,7 @@ class Main {
*/
public $modules = array(
'responsive-videos.php',
'social-menu.php',
'jetpack-color.php',
);

Expand Down
44 changes: 44 additions & 0 deletions projects/packages/classic-theme-helper/src/shared-functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Theme Tools: Functions shared between several features.
*
* @package automattic/jetpack-classic-theme-helper
*/

if ( ! function_exists( 'jetpack_mastodon_get_instance_list' ) ) {

/**
* Build a list of Mastodon instance hosts.
* That list can be extended via a filter.
*
* @since $$next-version$$ in Classic Theme Helper (previously in Jetpack since 11.8)
*
* @return array
*/
function jetpack_mastodon_get_instance_list() {
$mastodon_instance_list = array(
// Regex pattern to match any .tld for the mastodon host name.
'#https?:\/\/(www\.)?mastodon\.(\w+)(\.\w+)?#',
// Regex pattern to match any .tld for the mstdn host name.
'#https?:\/\/(www\.)?mstdn\.(\w+)(\.\w+)?#',
'counter.social',
'fosstodon.org',
'gc2.jp',
'hachyderm.io',
'infosec.exchange',
'mas.to',
'pawoo.net',
);

/**
* Filter the list of Mastodon instances.
*
* @since $$next-version$$ in Classic Theme Helper (previously in Jetpack since 11.8)
*
* @module widgets, theme-tools
*
* @param array $mastodon_instance_list Array of Mastodon instances.
*/
return (array) apply_filters( 'jetpack_mastodon_instance_list', $mastodon_instance_list );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ function jetpack_social_menu_social_links_icons() {
/*
* Add Mastodon instances to this array.
*/
require_once __DIR__ . '../../shared-functions.php';
$mastodon_instance_list = jetpack_mastodon_get_instance_list();
foreach ( $mastodon_instance_list as $instance ) {
$social_links_icons[ $instance ] = 'mastodon';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


2 changes: 1 addition & 1 deletion projects/plugins/jetpack/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
'extensions/blocks/wordads/wordads.php' => ['PhanNonClassMethodCall', 'PhanTypeExpectedObjectPropAccessButGotNull', 'PhanTypeMismatchArgument'],
'extensions/plugins/sharing/sharing.php' => ['PhanRedundantCondition'],
'functions.compat.php' => ['PhanRedefineFunction', 'PhanTypeMismatchReturn'],
'functions.global.php' => ['PhanRedundantCondition', 'PhanSuspiciousMagicConstant', 'PhanTypeMismatchArgument'],
'functions.global.php' => ['PhanRedefineFunction', 'PhanRedundantCondition', 'PhanSuspiciousMagicConstant', 'PhanTypeMismatchArgument'],
'functions.opengraph.php' => ['PhanTypeArraySuspicious'],
'json-endpoints/class.wpcom-json-api-add-widget-endpoint.php' => ['PhanNoopNew', 'PhanTypeMismatchReturn'],
'json-endpoints/class.wpcom-json-api-autosave-post-v1-1-endpoint.php' => ['PhanNoopNew', 'PhanTypeMismatchReturn'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Social Menus: Requiring the feature from the Classic Theme Helper package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Updated composer.lock.


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Updated composer.lock.


61 changes: 33 additions & 28 deletions projects/plugins/jetpack/functions.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,37 +513,42 @@ function jetpack_is_frontend() {
return (bool) apply_filters( 'jetpack_is_frontend', $is_frontend );
}

/**
* Build a list of Mastodon instance hosts.
* That list can be extended via a filter.
*
* @since 11.8
*
* @return array
*/
function jetpack_mastodon_get_instance_list() {
$mastodon_instance_list = array(
// Regex pattern to match any .tld for the mastodon host name.
'#https?:\/\/(www\.)?mastodon\.(\w+)(\.\w+)?#',
// Regex pattern to match any .tld for the mstdn host name.
'#https?:\/\/(www\.)?mstdn\.(\w+)(\.\w+)?#',
'counter.social',
'fosstodon.org',
'gc2.jp',
'hachyderm.io',
'infosec.exchange',
'mas.to',
'pawoo.net',
);

if ( ! function_exists( 'jetpack_mastodon_get_instance_list' ) ) {
/**
* Filter the list of Mastodon instances.
* Build a list of Mastodon instance hosts.
* That list can be extended via a filter.
*
* @since 11.8
* @todo This function is now replicated in the Classic Theme Helper package and can be
* removed here once Social Links are moved out of Jetpack.
*
* @module widgets, theme-tools
* @since 11.8
*
* @param array $mastodon_instance_list Array of Mastodon instances.
* @return array
*/
return (array) apply_filters( 'jetpack_mastodon_instance_list', $mastodon_instance_list );
function jetpack_mastodon_get_instance_list() {
$mastodon_instance_list = array(
// Regex pattern to match any .tld for the mastodon host name.
'#https?:\/\/(www\.)?mastodon\.(\w+)(\.\w+)?#',
// Regex pattern to match any .tld for the mstdn host name.
'#https?:\/\/(www\.)?mstdn\.(\w+)(\.\w+)?#',
'counter.social',
'fosstodon.org',
'gc2.jp',
'hachyderm.io',
'infosec.exchange',
'mas.to',
'pawoo.net',
);

/**
* Filter the list of Mastodon instances.
*
* @since 11.8
*
* @module widgets, theme-tools
*
* @param array $mastodon_instance_list Array of Mastodon instances.
*/
return (array) apply_filters( 'jetpack_mastodon_instance_list', $mastodon_instance_list );
}
}
Loading

0 comments on commit 4bbcab7

Please sign in to comment.