Skip to content

Commit

Permalink
Merge branch 'main' into fix/clear-post-meta
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedmonkey committed Sep 16, 2022
2 parents a9f8587 + 2c06dea commit 9e34261
Show file tree
Hide file tree
Showing 153 changed files with 2,545 additions and 935 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ jobs:
run: sudo apt-get install libgbm1

- name: Install dependencies
run: npm install puppeteer
run: |
npm install puppeteer
npm install expect-puppeteer --no-save
npx patch-package # Apply patches to expect-puppeteer
env:
PUPPETEER_PRODUCT: ${{ matrix.browser }}

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/tests-unit-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ jobs:
wp: 'trunk'
experimental: true

- php: '8.2'
wp: 'trunk'
experimental: true

steps:
- name: Harden Runner
uses: step-security/harden-runner@dd2c410b088af7c0dc8046f3ac9a8f4148492a95
Expand Down
2 changes: 2 additions & 0 deletions .phpstorm.meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'adsense' => \Google\Web_Stories\AdSense::class,
'ad_manager' => \Google\Web_Stories\Ad_Manager::class,
'admin' => \Google\Web_Stories\Admin\Admin::class,
'admin.revisions' => \Google\Web_Stories\Admin\Revisions::class,
'analytics' => \Google\Web_Stories\Analytics::class,
'coi' => \Google\Web_Stories\Admin\Cross_Origin_Isolation::class,
'customizer' => \Google\Web_Stories\Admin\Customizer::class,
Expand Down Expand Up @@ -52,6 +53,7 @@
'site_health' => \Google\Web_Stories\Admin\Site_Health::class,
'story_archive' => \Google\Web_Stories\Story_Archive::class,
'story_post_type' => \Google\Web_Stories\Story_Post_Type::class,
'story_revisions' => \Google\Web_Stories\Story_Revisions::class,
'story_shortcode' => \Google\Web_Stories\Shortcode\Stories_Shortcode::class,
'svg' => \Google\Web_Stories\Media\SVG::class,
'tracking' => \Google\Web_Stories\Tracking::class,
Expand Down
93 changes: 34 additions & 59 deletions includes/Experiments.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,6 @@ public function get_experiment_groups(): array {
*/
public function get_experiments(): array {
return [
/**
* Author: @littlemilkstudio
* Issue: 6379
* Creation date: 2021-03-09
*/
[
'name' => 'enableExperimentalAnimationEffects',
'label' => __( 'Experimental animations', 'web-stories' ),
'description' => __( 'Enable any animation effects that are currently experimental', 'web-stories' ),
'group' => 'editor',
],
/**
* Author: @brittanyirl
* Issue: 2381
Expand Down Expand Up @@ -277,54 +266,6 @@ public function get_experiments(): array {
'description' => __( 'Allow locked stories to be taken over by another author', 'web-stories' ),
'group' => 'editor',
],
/**
* Author: @barklund
* Issue: #10112
* Creation date: 2022-01-27
*/
[
'name' => 'floatingMenu',
'label' => __( 'Floating Menu', 'web-stories' ),
'description' => __( 'Enable the new floating design menu', 'web-stories' ),
'group' => 'editor',
'default' => true,
],
/**
* Author: @barklund
* Issue: #7332
* Creation date: 2022-04-19
*/
[
'name' => 'layerLocking',
'label' => __( 'Layer locking', 'web-stories' ),
'description' => __( 'Enable layer locking', 'web-stories' ),
'group' => 'editor',
'default' => true,
],
/**
* Author: @merapi
* Issue: #9244
* Creation date: 2022-05-04
*/
[
'name' => 'layerGrouping',
'label' => __( 'Layer grouping', 'web-stories' ),
'description' => __( 'Enable layer grouping', 'web-stories' ),
'group' => 'editor',
'default' => true,
],
/**
* Author: @mariana-k
* Issue: #9248
* Creation date: 2022-05-12
*/
[
'name' => 'layerNaming',
'label' => __( 'Layer naming', 'web-stories' ),
'description' => __( 'Enable layer naming', 'web-stories' ),
'group' => 'editor',
'default' => true,
],
/**
* Author: @barklund
* Issue: #9643
Expand Down Expand Up @@ -371,6 +312,40 @@ public function get_experiments(): array {
'label' => __( 'Improved Autosaves', 'web-stories' ),
'description' => __( 'Enable improved autosaves support', 'web-stories' ),
'group' => 'editor',
'default' => true,
],
/**
* Author: @timarney
* Issue: #12093
* Creation date: 2022-08-18
*/
[
'name' => 'offScreenVideoCropping',
'label' => __( 'Crop off-screen video parts', 'web-stories' ),
'description' => __( 'Enable support for cropping cut off-screen parts of videos', 'web-stories' ),
'group' => 'editor',
],
/**
* Author: @spacedmonkey
* Issue: #12211
* Creation date: 2022-09-07
*/
[
'name' => 'videoVolume',
'label' => __( 'Video Volume', 'web-stories' ),
'description' => __( 'Enable setting video volume', 'web-stories' ),
'group' => 'editor',
],
/**
* Author: @barklund
* Issue: #12210
* Creation date: 2022-09-14
*/
[
'name' => 'customPageAdvance',
'label' => __( 'Per-Page Page Advance', 'web-stories' ),
'description' => __( 'Enable detailed page advancement settings on a per-page basis', 'web-stories' ),
'group' => 'editor',
],
];
}
Expand Down
4 changes: 3 additions & 1 deletion includes/Model/Story.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,12 @@ public function load_from_post( $_post ): bool {
$this->publisher_name = apply_filters( 'web_stories_publisher_name', get_bloginfo( 'name' ) );

$post = get_post( $_post );
if ( ! $post instanceof WP_Post || Story_Post_Type::POST_TYPE_SLUG !== $post->post_type ) {
if ( ! $post instanceof WP_Post ) {
return false;
}

// At this point we assume being passed a legit web-story post or perhaps a web-story revision.

$this->id = $post->ID;
$this->title = get_the_title( $post );
$this->excerpt = $post->post_excerpt;
Expand Down
1 change: 1 addition & 0 deletions includes/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class Plugin extends ServiceBasedPlugin {
'site_health' => Admin\Site_Health::class,
'story_archive' => Story_Archive::class,
'story_post_type' => Story_Post_Type::class,
'story_revisions' => Story_Revisions::class,
'story_shortcode' => Shortcode\Stories_Shortcode::class,
'svg' => Media\SVG::class,
'tracking' => Tracking::class,
Expand Down
39 changes: 0 additions & 39 deletions includes/Story_Post_Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,9 @@ public function register(): void {
$this->register_post_type();
$this->register_meta();

add_filter( '_wp_post_revision_fields', [ $this, 'filter_revision_fields' ], 10, 2 );
add_filter( 'wp_insert_post_data', [ $this, 'change_default_title' ] );
add_filter( 'bulk_post_updated_messages', [ $this, 'bulk_post_updated_messages' ], 10, 2 );
add_action( 'clean_post_cache', [ $this, 'clear_user_posts_count' ], 10, 2 );

$post_type = $this->get_slug();
add_action( "wp_{$post_type}_revisions_to_keep", [ $this, 'revisions_to_keep' ] );
}

/**
Expand Down Expand Up @@ -266,27 +262,6 @@ protected function get_post_type_icon(): string {
return 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMCAyMGM1LjUyMyAwIDEwLTQuNDc3IDEwLTEwUzE1LjUyMyAwIDEwIDAgMCA0LjQ3NyAwIDEwczQuNDc3IDEwIDEwIDEwek01LjUgNmExIDEgMCAwMTEtMUgxMWExIDEgMCAwMTEgMXY4YTEgMSAwIDAxLTEgMUg2LjVhMSAxIDAgMDEtMS0xVjZ6TTEzIDZhMSAxIDAgMDExIDF2NmExIDEgMCAwMS0xIDFWNnptMi43NSAxLjc1QS43NS43NSAwIDAwMTUgN3Y2YS43NS43NSAwIDAwLjc1LS43NXYtNC41eiIgZmlsbD0iI2EwYTVhYSIvPjwvc3ZnPg==';
}

/**
* Filters the revision fields to ensure that JSON representation gets saved to Story revisions.
*
* @since 1.0.0
*
* @param array|mixed $fields Array of allowed revision fields.
* @param array<string,mixed> $story Story post array.
* @return array|mixed Array of allowed fields.
*/
public function filter_revision_fields( $fields, array $story ) {
if ( ! \is_array( $fields ) ) {
return $fields;
}

if ( $this->get_slug() === $story['post_type'] ) {
$fields['post_content_filtered'] = __( 'Story data', 'web-stories' );
}

return $fields;
}

/**
* Filters the bulk action updated messages.
*
Expand Down Expand Up @@ -364,7 +339,6 @@ public function clear_user_posts_count( $post_id, $post ): void {
* @return bool|string Whether the post type should have an archive, or archive slug.
*/
public function get_has_archive() {

$archive_page_option = $this->settings->get_setting( $this->settings::SETTING_NAME_ARCHIVE );
$custom_archive_page_id = (int) $this->settings->get_setting( $this->settings::SETTING_NAME_ARCHIVE_PAGE_ID );
$has_archive = true;
Expand All @@ -384,17 +358,4 @@ public function get_has_archive() {

return $has_archive;
}

/**
* Force WordPress to only keep 10 revisions for the web stories post type.
*
* @since 1.16.0
*
* @param int $num Number of revisions to store.
* @return int Number of revisions to store.
*/
public function revisions_to_keep( $num ): int {
$num = (int) $num;
return ( $num >= 0 && $num < 10 ) ? $num : 10;
}
}
Loading

0 comments on commit 9e34261

Please sign in to comment.