Skip to content

Commit

Permalink
Merge branch 'trunk' into add/global-styles-on-personal-experiment-ca…
Browse files Browse the repository at this point in the history
…che-if-running
  • Loading branch information
rcrdortiz committed Jan 29, 2025
2 parents 0fe7108 + 7008f93 commit 22f6d70
Show file tree
Hide file tree
Showing 18 changed files with 66 additions and 71 deletions.
12 changes: 11 additions & 1 deletion .phan/stubs/wpcom-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* `bin/teamcity-builds/jetpack-stubs/stub-defs.php` and regenerate the stubs
* by triggering the Jetpack Staging → Update WPCOM Stubs job in TeamCity.
*
* Stubs automatically generated from WordPress.com commit 25fe8874f126229252809211e216317f571c666f.
* Stubs automatically generated from WordPress.com commit 58daa278d1c6807cf18400dee1d9f45815e24fae.
*/

namespace {
Expand Down Expand Up @@ -1524,6 +1524,16 @@ function get_blog_subscriptions_aggregate_count(int $blog_id = null, $post_term_
{
}
}
namespace WPCOM\Experiments\Internal {
/**
* @param string $name
* @return \WPCOM\Experiments\Models\Experiment|null
* @throws File_Cache_Failure
*/
function get_cached_experiment_by_name(string $name): ?\WPCOM\Experiments\Models\Experiment
{
}
}
namespace WPCOM\Jetpack_AI {
class Feature_Control
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Move initial state from Social plugin to publicize package
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@ export const shouldShowPricingPage = createRegistrySelector( select => () => {
const settings = getSite( undefined, { _fields: SHOW_PRICING_PAGE_KEY } );

// If the settings are not available in the store yet, use the default settings.
return (
settings?.[ SHOW_PRICING_PAGE_KEY ] ??
getSocialScriptData().settings?.socialPlugin?.show_pricing_page
);
return settings?.[ SHOW_PRICING_PAGE_KEY ] ?? getSocialScriptData().settings?.showPricingPage;
} );
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ import { PostShareStatus, SocialStoreState } from '../types';

/**
* Get the post share status.
*
* @param {SocialStoreState} state - State object.
* @param {number} postId - The post ID.
*
* @return {PostShareStatus} - The post share status.
*/
export const getPostShareStatus = createRegistrySelector(
select =>
Expand All @@ -18,7 +13,7 @@ export const getPostShareStatus = createRegistrySelector(

return state.shareStatus?.[ id ] ?? { shares: [] };
}
) as ( state: SocialStoreState, postId?: number ) => PostShareStatus;
);

/**
* Whether the share status modal is open.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { store as coreStore } from '@wordpress/core-data';
import { createRegistrySelector } from '@wordpress/data';
import { getSocialScriptData } from '../../utils';
import { SIG_SETTINGS_KEY } from '../constants';
import { SocialImageGeneratorConfig, SocialSettingsFields } from '../types';
import { SocialSettingsFields } from '../types';

/**
* Returns the Social Image Generator settings for the current site.
Expand All @@ -14,4 +14,4 @@ export const getSocialImageGeneratorConfig = createRegistrySelector( select => (

// If the settings are not available in the store yet, use the default settings.
return settings?.[ SIG_SETTINGS_KEY ] ?? getSocialScriptData().settings.socialImageGenerator;
} ) as ( state: object ) => SocialImageGeneratorConfig;
} );
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export const isSocialNotesEnabled = createRegistrySelector( select => () => {
} );
// If the settings are not available in the store yet, use the default settings.
return (
settings?.[ SOCIAL_NOTES_ENABLED_KEY ] ??
getSocialScriptData().settings?.socialPlugin?.social_notes_enabled
settings?.[ SOCIAL_NOTES_ENABLED_KEY ] ?? getSocialScriptData().settings?.socialNotes?.enabled
);
} );

Expand All @@ -31,7 +30,6 @@ export const getSocialNotesConfig = createRegistrySelector( select => () => {

// If the settings are not available in the store yet, use the default settings.
return (
settings?.[ SOCIAL_NOTES_CONFIG_KEY ] ??
getSocialScriptData().settings?.socialPlugin?.social_notes_config
settings?.[ SOCIAL_NOTES_CONFIG_KEY ] ?? getSocialScriptData().settings?.socialNotes?.config
);
} );
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import { SocialPluginSettings } from '../types';
export const getSocialPluginSettings = createRegistrySelector( select => () => {
const data = select( coreStore ).getEntityRecord( 'jetpack/v4', 'social/settings', undefined );

return data ?? getSocialScriptData().settings.socialPlugin;
return data ?? { publicize_active: getSocialScriptData().is_publicize_enabled };
} ) as ( state: object ) => SocialPluginSettings;

/**
* Returns whether the Social plugin settings are being saved
*
* @type {() => boolean} Whether the Social plugin settings are being saved
*/
export const isSavingSocialPluginSettings = createRegistrySelector( select => () => {
return select( coreStore ).isSavingEntityRecord( 'jetpack/v4', 'social/settings', undefined );
} ) as () => boolean;
} );
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ import { store as coreStore } from '@wordpress/core-data';
import { createRegistrySelector } from '@wordpress/data';
import { getSocialScriptData } from '../../utils';
import { UTM_ENABLED_KEY } from '../constants';
import { SocialSettingsFields, UtmSettingsConfig } from '../types';

/**
* Returns the UTM state.
*/
export const getUtmSettings = createRegistrySelector( select => () => {
const { getSite } = select( coreStore );

const settings = getSite( undefined, { _fields: UTM_ENABLED_KEY } ) as SocialSettingsFields;
const settings = getSite( undefined, { _fields: UTM_ENABLED_KEY } );

// If the settings are not available in the store yet, use the default settings.
return settings?.[ UTM_ENABLED_KEY ] ?? getSocialScriptData().settings.utmSettings;
} ) as ( state: object ) => UtmSettingsConfig;
} );
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,13 @@ export type SocialNotesConfig = {
link_format: 'full_url' | 'shortlink' | 'permashortcitation';
};

export type SocialNotesSettings = {
enabled: boolean;
config: SocialNotesConfig;
};

export type SocialPluginSettings = {
publicize_active: boolean;
show_pricing_page: boolean;
social_notes_enabled: boolean;
social_notes_config: {
append_link: boolean;
link_format: 'full_url' | 'shortlink' | 'permashortcitation';
};
};

export type SocialSettingsFields = {
Expand Down
5 changes: 3 additions & 2 deletions projects/js-packages/publicize-components/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
SocialImageGeneratorConfig,
SocialPluginSettings,
UtmSettingsConfig,
SocialStoreState,
SocialNotesSettings,
} from './social-store/types';

export interface SocialUrls {
Expand Down Expand Up @@ -39,7 +39,8 @@ export interface ApiPaths {
export type SocialSettings = {
socialImageGenerator: SocialImageGeneratorConfig;
utmSettings: UtmSettingsConfig;
socialPlugin: SocialPluginSettings;
socialNotes: SocialNotesSettings;
showPricingPage: boolean;
};

export type PluginInfo = Record< 'social' | 'jetpack', { version: string } >;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Forms: Fix the block placeholder throwing an error when the Forms module is disabled.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const ContactFormPlaceholder = ( { changeStatus, isLoading, isModuleActiv

return (
<Placeholder
icon={ settings.icon }
icon={ settings.icon.src }
instructions={ __(
'You’ll need to activate the Contact Form feature to use this block.',
'jetpack-forms'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Move initial state from Social plugin to publicize package
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ public static function get_social_settings() {
return array(
'socialImageGenerator' => $settings->get_image_generator_settings(),
'utmSettings' => $settings->get_utm_settings(),
'socialNotes' => array(
'enabled' => $settings->is_social_notes_enabled(),
'config' => $settings->get_social_notes_config(),
),
'showPricingPage' => $settings->should_show_pricing_page(),
);
}

Expand Down Expand Up @@ -272,7 +277,7 @@ public static function has_feature_flag( $feature ): bool {
* @return ?array
*/
public static function get_shares_data() {
return self::publicize()->get_publicize_shares_info( Jetpack_Options::get_option( 'id' ) );
return self::publicize()->get_publicize_shares_info( Jetpack_Options::get_option( 'id' ) ) ?? array();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,22 @@ public function get_social_notes_config() {
return get_option( self::OPTION_PREFIX . self::NOTES_CONFIG, self::DEFAULT_NOTES_CONFIG );
}

/**
* Check if the pricing page should be displayed.
*
* @return bool
*/
public static function should_show_pricing_page() {
return (bool) get_option( self::JETPACK_SOCIAL_SHOW_PRICING_PAGE, true );
}

/**
* Get if the social notes feature is enabled.
*
* @return bool
*/
public function is_social_notes_enabled() {
return get_option( self::JETPACK_SOCIAL_NOTE_CPT_ENABLED, false );
return (bool) get_option( self::JETPACK_SOCIAL_NOTE_CPT_ENABLED, false );
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix

Forms: Fix the block placeholder throwing an error when the Forms module is disabled.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Move initial state from Social plugin to publicize package
36 changes: 0 additions & 36 deletions projects/plugins/social/src/class-jetpack-social.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ function () {
add_filter( 'plugin_action_links_' . JETPACK_SOCIAL_PLUGIN_FOLDER . '/jetpack-social.php', array( $this, 'add_settings_link' ) );

add_shortcode( 'jp_shares_shortcode', array( $this, 'add_shares_shortcode' ) );

add_filter( 'jetpack_social_admin_script_data', array( $this, 'set_social_admin_script_data' ) );
}

/**
Expand Down Expand Up @@ -176,40 +174,6 @@ public function get_shares_info() {
return ! is_wp_error( $shares_info ) ? $shares_info : null;
}

/**
* Set the social admin script data.
*
* @param array $data The initial state data.
* @return array
*/
public function set_social_admin_script_data( $data ) {

$data['plugin_info']['social'] = array(
'version' => $this->get_plugin_version(),
);

$data['settings']['socialPlugin'] = array(
'publicize_active' => self::is_publicize_active(),

);

if ( $this->is_connected() ) {

$jetpack_social_settings = new Automattic\Jetpack\Publicize\Jetpack_Social_Settings\Settings();

$data['settings']['socialPlugin'] = array_merge(
$data['settings']['socialPlugin'],
array(
'show_pricing_page' => self::should_show_pricing_page(),
'social_notes_enabled' => $jetpack_social_settings->is_social_notes_enabled(),
'social_notes_config' => $jetpack_social_settings->get_social_notes_config(),
)
);
}

return $data;
}

/**
* Returns a boolean as to whether we have a plan that supports
* sharing beyond the free limit.
Expand Down

0 comments on commit 22f6d70

Please sign in to comment.