Skip to content

Commit

Permalink
Remove deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
gmjuhasz committed Jan 17, 2025
1 parent 12e58ec commit 4931093
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 119 deletions.
45 changes: 0 additions & 45 deletions projects/plugins/social/src/class-note.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,51 +189,6 @@ public function maybe_flush_rewrite_rules( $force = false ) {
}
}

/**
* Set whether or not the Notes feature is enabled.
*
* @param boolean $enabled Whether or not the Notes feature is enabled.
*/
public function set_enabled( $enabled ) {
if ( $enabled === self::enabled() ) {
return;
}

if ( $enabled ) {
update_option( self::JETPACK_SOCIAL_NOTE_CPT, true );
} else {
delete_option( self::JETPACK_SOCIAL_NOTE_CPT );
}
// Delete this option, so the rules get flushe in maybe_flush_rewrite_rules when the CPT is registered.
delete_option( self::FLUSH_REWRITE_RULES_FLUSHED );
}

/**
* Get the social notes config.
*
* @return array The social notes config.
*/
public function get_config() {
return get_option(
self::JETPACK_SOCIAL_NOTES_CONFIG,
// Append link by default.
array(
'append_link' => true,
)
);
}

/**
* Update social notes config
*
* @param array $config The config to update.
*/
public function update_config( $config ) {
$old_config = get_option( self::JETPACK_SOCIAL_NOTES_CONFIG, array() );
$new_config = array_merge( $old_config, $config );
update_option( self::JETPACK_SOCIAL_NOTES_CONFIG, $new_config );
}

/**
* Use the_title hook so we show the social note's exceprt in the post list view.
*
Expand Down
55 changes: 1 addition & 54 deletions projects/plugins/social/src/class-rest-settings-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,6 @@ public function get_item( $request ) {
$data['publicize_active'] = Jetpack_Social::is_publicize_active();
}

if ( rest_is_field_included( 'show_pricing_page', $fields ) ) {
$data['show_pricing_page'] = Jetpack_Social::should_show_pricing_page();
}

$note = new Note();

if ( rest_is_field_included( 'social_notes_enabled', $fields ) ) {
$data['social_notes_enabled'] = $note->enabled();
}

if ( rest_is_field_included( 'social_notes_config', $fields ) ) {
$data['social_notes_config'] = $note->get_config();
}

return $this->prepare_item_for_response( $data, $request );
}

Expand All @@ -132,8 +118,6 @@ public function update_item( $request ) {
$params = $request->get_params();
$settings = $this->get_endpoint_args_for_item_schema( $request->get_method() );

$note = new Note();

foreach ( array_keys( $settings ) as $name ) {
if ( ! array_key_exists( $name, $params ) ) {
continue;
Expand All @@ -146,15 +130,6 @@ public function update_item( $request ) {
return $updated;
}
break;
case 'show_pricing_page':
update_option( Jetpack_Social::JETPACK_SOCIAL_SHOW_PRICING_PAGE_OPTION, (int) $params[ $name ] );
break;
case 'social_notes_enabled':
$note->set_enabled( (bool) $params[ $name ] );
break;
case 'social_notes_config':
$note->update_config( $params[ $name ] );
break;
}
}

Expand Down Expand Up @@ -222,39 +197,11 @@ public function get_item_schema() {
'title' => 'system_status',
'type' => 'object',
'properties' => array(
'publicize_active' => array(
'publicize_active' => array(
'description' => __( 'Is the publicize module enabled?', 'jetpack-social' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'show_pricing_page' => array(
'description' => __( 'Should we show the pricing page?', 'jetpack-social' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'social_notes_enabled' => array(
'description' => __( 'Is the social notes feature enabled?', 'jetpack-social' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'social_notes_config' => array(
'description' => __( 'The social notes configuration', 'jetpack-social' ),
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'append_link' => array(
'description' => __( 'Whether to append the post link when sharing the note.', 'jetpack-social' ),
'type' => 'boolean',
'context' => array( 'view', 'edit' ),
),
'link_format' => array(
'description' => __( 'Link format', 'jetpack-social' ),
'type' => 'string',
'enum' => array( 'full_url', 'shortlink', 'permashortcitation' ),
'context' => array( 'view', 'edit' ),
),
),
),
),
);
return $this->add_additional_fields_schema( $schema );
Expand Down
20 changes: 0 additions & 20 deletions projects/plugins/social/tests/php/test-class-jetpack-social.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

use Automattic\Jetpack\Connection\Manager as Connection_Manager;
use Automattic\Jetpack\Social\Note;
use WorDBless\BaseTestCase;

/**
Expand Down Expand Up @@ -72,23 +71,4 @@ public function test_publicize_not_configured() {

$this->assertSame( 0, did_action( 'jetpack_feature_publicize_enabled' ) );
}

/**
* Test the social notes feature.
*/
public function test_social_notes() {
$note = new Note();
$note->init();
$this->assertEmpty( get_option( Note::FLUSH_REWRITE_RULES_FLUSHED ) );
update_option( Note::JETPACK_SOCIAL_NOTE_CPT, true );
$note->init();
$this->assertTrue( get_option( Note::FLUSH_REWRITE_RULES_FLUSHED ) );
$note->set_enabled( false );
$this->assertFalse( $note->enabled() );
$note->init();
$this->assertEmpty( get_option( Note::FLUSH_REWRITE_RULES_FLUSHED ) );
$note->set_enabled( true );
$note->init();
$this->assertTrue( get_option( Note::FLUSH_REWRITE_RULES_FLUSHED ) );
}
}

0 comments on commit 4931093

Please sign in to comment.