Skip to content

Commit

Permalink
🔀 Merge branch 'main' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
MatzeKitt committed Oct 4, 2024
2 parents f97f1f6 + 21cb3a3 commit e422f87
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 73 deletions.
8 changes: 8 additions & 0 deletions .github/exclude_list
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules/
src/
package.json
package-lock.json
ruleset.xml
webpack.config.js
*scss/
.git*
14 changes: 13 additions & 1 deletion .github/workflows/wordpress-plugin-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@ jobs:
- name: npm build
run: npm run build
- name: WordPress Plugin Deploy
uses: 10up/action-wordpress-plugin-deploy@master
uses: 10up/action-wordpress-plugin-deploy@stable
with:
generate-zip: true
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
# Create artifacts
- uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}.zip
path: ${{ github.event.repository.name }}.zip
# Create release
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
files: ${{ github.event.repository.name }}.zip
name: Release ${{ github.ref_name }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.10.6
* Fixed: Detection for unknown embeds
* Fixed: Detection for Maps Marker Pro

## 1.10.5
* Improved: Renamed Twitter to X
* Fixed: Check for matching provider
Expand Down
8 changes: 4 additions & 4 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

We usually only support the latest major version.

| Version | Supported |
| ------- | ------------------ |
| 1.9.x | :white_check_mark: |
| < 1.9 | :x: |
| Version | Supported |
| -------- | ------------------ |
| 1.10.x | :white_check_mark: |
| < 1.10 | :x: |

## How can I report security bugs?

Expand Down
4 changes: 2 additions & 2 deletions embed-privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Plugin Name: Embed Privacy
Plugin URL: https://epiph.yt/en/embed-privacy/
Description: Embed Privacy prevents from loading external embeds directly and lets the user control which one should be loaded.
Version: 1.10.5
Version: 1.10.6
Author: Epiphyt
Author URI: https://epiph.yt/en/
License: GPL2
Expand All @@ -30,7 +30,7 @@
*/
\defined( 'ABSPATH' ) || exit;

\define( 'EMBED_PRIVACY_VERSION', '1.10.5' );
\define( 'EMBED_PRIVACY_VERSION', '1.10.6' );

if ( ! \defined( 'EPI_EMBED_PRIVACY_BASE' ) ) {
\define( 'EPI_EMBED_PRIVACY_BASE', \WP_PLUGIN_DIR . '/embed-privacy/' );
Expand Down
19 changes: 19 additions & 0 deletions inc/class-embed-privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,25 @@ public function is_theme( $name ) {
return Theme::is( $name );
}

/**
* Get the WP_Filesystem object
*
* @return \WP_Filesystem_Direct WP_Filesystem object
*/
public static function get_wp_filesystem() {
/** @var \WP_Filesystem_Direct $wp_filesystem */
global $wp_filesystem;

// initialize the WP filesystem if not exists
if ( empty( $wp_filesystem ) ) {
require_once \ABSPATH . 'wp-admin/includes/file.php';

\WP_Filesystem();
}

return $wp_filesystem;
}

/**
* Load the translation files.
*/
Expand Down
73 changes: 59 additions & 14 deletions inc/class-migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Migration {
* @var string Current migration version
* @since 1.2.2
*/
private $version = '1.10.5';
private $version = '1.10.6';

/**
* Migration constructor.
Expand Down Expand Up @@ -80,7 +80,7 @@ private function add_embed( array $embed ) {
* @since 1.5.0
*/
private function create_thumbnails_dir() {
$directory = Thumbnails::get_instance()->get_directory();
$directory = Thumbnail::get_directory();

if ( empty( $directory['base_dir'] ) ) {
return;
Expand Down Expand Up @@ -189,46 +189,56 @@ public function migrate( $deprecated = null, $deprecated2 = null ) {
$this->update_option( 'migration_count', (int) $this->get_option( 'migration_count' ) + 1 );
// load textdomain early for migrations
\load_plugin_textdomain( 'embed-privacy', false, \dirname( \plugin_basename( Embed_Privacy::get_instance()->plugin_file ) ) . '/languages' );
// make sure all default embed providers are avalable and translated
// make sure all default embed providers are available and translated
$this->register_default_embed_providers();

switch ( $version ) {
case $this->version:
// most recent version, do nothing
break;
case '1.10.5':
$this->migrate_1_10_6();
break;
case '1.8.0':
$this->migrate_1_10_6();
$this->migrate_1_10_5();
break;
case '1.7.3':
$this->migrate_1_10_6();
$this->migrate_1_10_5();
$this->migrate_1_8_0();
break;
case '1.7.0':
$this->migrate_1_10_6();
$this->migrate_1_10_5();
$this->migrate_1_8_0();
$this->migrate_1_7_3();
break;
case '1.6.0':
$this->migrate_1_10_6();
$this->migrate_1_10_5();
$this->migrate_1_8_0();
$this->migrate_1_7_3();
$this->migrate_1_7_0();
break;
case '1.5.0':
$this->migrate_1_10_6();
$this->migrate_1_10_5();
$this->migrate_1_8_0();
$this->migrate_1_7_3();
$this->migrate_1_7_0();
$this->migrate_1_6_0();
break;
case '1.4.7':
$this->migrate_1_10_6();
$this->migrate_1_10_5();
$this->migrate_1_8_0();
$this->migrate_1_7_0();
$this->migrate_1_6_0();
$this->migrate_1_5_0();
break;
case '1.4.0':
$this->migrate_1_10_6();
$this->migrate_1_10_5();
$this->migrate_1_8_0();
$this->migrate_1_7_0();
Expand All @@ -237,6 +247,7 @@ public function migrate( $deprecated = null, $deprecated2 = null ) {
$this->migrate_1_4_7();
break;
case '1.3.0':
$this->migrate_1_10_6();
$this->migrate_1_10_5();
$this->migrate_1_8_0();
$this->migrate_1_7_0();
Expand All @@ -245,6 +256,7 @@ public function migrate( $deprecated = null, $deprecated2 = null ) {
$this->migrate_1_4_0();
break;
case '1.2.2':
$this->migrate_1_10_6();
$this->migrate_1_10_5();
$this->migrate_1_8_0();
$this->migrate_1_7_0();
Expand All @@ -254,6 +266,7 @@ public function migrate( $deprecated = null, $deprecated2 = null ) {
$this->migrate_1_3_0();
break;
case '1.2.1':
$this->migrate_1_10_6();
$this->migrate_1_10_5();
$this->migrate_1_8_0();
$this->migrate_1_7_0();
Expand All @@ -264,6 +277,7 @@ public function migrate( $deprecated = null, $deprecated2 = null ) {
$this->migrate_1_2_2();
break;
case '1.2.0':
$this->migrate_1_10_6();
$this->migrate_1_10_5();
$this->migrate_1_8_0();
$this->migrate_1_7_0();
Expand Down Expand Up @@ -521,9 +535,9 @@ private function migrate_1_5_0() {
'regex_default' => '',
],
/* translators: embed provider */
'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Maps Marker', 'embed provider', 'embed-privacy' ) ),
'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ) ),
'post_status' => 'publish',
'post_title' => \_x( 'Maps Marker', 'embed provider', 'embed-privacy' ),
'post_title' => \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ),
'post_type' => 'epi_embed',
] );
$this->create_thumbnails_dir();
Expand Down Expand Up @@ -645,7 +659,7 @@ private function migrate_1_7_3() {

// move thumbnail
if ( \file_exists( $old_dir . '/' . $filename ) ) {
\rename( $old_dir . '/' . $filename, $new_dir . '/' . $filename );
Embed_Privacy::get_wp_filesystem()->move( $old_dir . '/' . $filename, $new_dir . '/' . $filename );
}
}
}
Expand All @@ -654,13 +668,9 @@ private function migrate_1_7_3() {
$posts = \get_posts( $post_args );
}

// remove old directory if it's empty
// remove old directory
if ( ! ( new FilesystemIterator( $old_dir ) )->valid() ) {
\rmdir( $old_dir );

if ( ! ( new FilesystemIterator( \dirname( $old_dir ) ) )->valid() ) {
\rmdir( \dirname( $old_dir ) );
}
Embed_Privacy::get_wp_filesystem()->rmdir( $old_dir, true );
}
}
}
Expand Down Expand Up @@ -726,6 +736,41 @@ private function migrate_1_10_5() {
}
}

/**
* Migrations for version 1.10.6.
*
* @since 1.10.6
*
* - Rename Maps Marker to Maps Marker Pro
*/
private function migrate_1_10_6() {
$maps_marker_provider = \get_posts( [
'meta_key' => 'is_system',
'meta_value' => 'yes',
'name' => 'maps-marker',
'no_found_rows' => true,
'post_type' => 'epi_embed',
'update_post_term_cache' => false,
] );
$maps_marker_provider = \reset( $maps_marker_provider );

if ( $maps_marker_provider instanceof WP_Post ) {
$maps_marker_pro_provider = [
'ID' => $maps_marker_provider->ID,
'post_name' => \sanitize_title( \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ) ),
'post_title' => \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ),
];

/* translators: embed provider */
if ( $maps_marker_provider->post_content === \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Maps Marker', 'embed provider', 'embed-privacy' ) ) ) {
/* translators: embed provider */
$maps_marker_pro_provider['post_content'] = \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ) );
}

\wp_update_post( $maps_marker_pro_provider );
}
}

/**
* Register default embed providers.
*/
Expand Down Expand Up @@ -906,9 +951,9 @@ public function register_default_embed_providers() {
'regex_default' => '',
],
/* translators: embed provider */
'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Maps Marker', 'embed provider', 'embed-privacy' ) ),
'post_content' => \sprintf( \__( 'Click here to display content from %s.', 'embed-privacy' ), \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ) ),
'post_status' => 'publish',
'post_title' => \_x( 'Maps Marker', 'embed provider', 'embed-privacy' ),
'post_title' => \_x( 'Maps Marker Pro', 'embed provider', 'embed-privacy' ),
'post_type' => 'epi_embed',
],
[
Expand Down
2 changes: 1 addition & 1 deletion inc/data/class-replacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static function replace_oembed( $output, $url, array $attributes ) {
return X::get_local_tweet( $output );
}

$output = $replacement->get( $attributes );
$output = $replacement->get( $attributes, $provider );

if ( $provider->is( 'youtube' ) ) {
// replace youtube.com with youtube-nocookie.com
Expand Down
Loading

0 comments on commit e422f87

Please sign in to comment.