Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the missing namespace in the main plugin file #151

Merged
merged 3 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 0.9.3
- Bring back the upgrade code.

### 0.9.2
- Quick fix to disable the upgrade script to avoid errors.

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- Tested up to: 6.5
- Requires PHP: 7.4
- License: [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html)
- Stable tag: 0.9.2
- Stable tag: 0.9.3

Allow accessing your WordPress with Mastodon clients. Just enter your own blog URL as your instance.

Expand Down Expand Up @@ -97,6 +97,9 @@ Endpoints around interacting with non-local users require the [ActivityPub plugi

## Changelog

### 0.9.3
- Bring back the upgrade code.

### 0.9.2
- Quick fix to disable the upgrade script to avoid errors.

Expand Down
17 changes: 12 additions & 5 deletions enable-mastodon-apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin name: Enable Mastodon Apps
* Plugin author: Alex Kirk
* Plugin URI: https://github.com/akirk/enable-mastodon-apps
* Version: 0.9.2
* Version: 0.9.3
*
* Description: Allow accessing your WordPress with Mastodon clients. Just enter your own blog URL as your instance.
*
Expand All @@ -13,9 +13,12 @@
* @package Enable_Mastodon_Apps
*/

namespace Enable_Mastodon_Apps;
use OAuth2;

defined( 'ABSPATH' ) || exit;
define( 'ENABLE_MASTODON_APPS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'ENABLE_MASTODON_APPS_VERSION', '0.9.2' );
define( 'ENABLE_MASTODON_APPS_VERSION', '0.9.3' );

require __DIR__ . '/vendor/bshaffer/oauth2-server-php/src/OAuth2/Autoloader.php';
OAuth2\Autoloader::register();
Expand Down Expand Up @@ -59,8 +62,12 @@ function ( $full_class ) {
add_action(
'init',
function () {
new Enable_Mastodon_Apps\Mastodon_API();
new Enable_Mastodon_Apps\Integration\Pixelfed();
new Enable_Mastodon_Apps\Comment_CPT();
new Mastodon_API();
new Integration\Pixelfed();
new Comment_CPT();
}
);

if ( is_admin() && version_compare( get_option( 'ema_plugin_version', ENABLE_MASTODON_APPS_VERSION ), '<' ) ) {
add_action( 'admin_init', array( __NAMESPACE__ . '\Mastodon_Admin', 'upgrade_plugin' ) );
}
4 changes: 3 additions & 1 deletion includes/class-mastodon-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,9 @@ public static function upgrade_plugin( $override_old_version = false ) {
}
$comment = get_comment( $comment_id );
if ( ! $comment || 1 !== intval( $comment->comment_approved ) ) {
wp_delete_post( $comment_post->ID, true );
if ( Comment_CPT::CPT === get_post_type( $comment_post->ID ) ) {
wp_delete_post( $comment_post->ID, true );
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions tests/test-comments-cpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,17 @@ public function test_upgrade() {
)
);

$post_count = wp_count_posts();
$this->assertEquals( 1, $post_count->publish );
$old_count = wp_count_posts( Comment_CPT::CPT );
$this->assertEquals( 2, $old_count->publish );

Mastodon_Admin::upgrade_plugin( '0.9.0' );

wp_cache_delete( _count_posts_cache_key(), 'counts' );
$post_count = wp_count_posts();
$this->assertEquals( 1, $post_count->publish );

wp_cache_delete( _count_posts_cache_key( Comment_CPT::CPT ), 'counts' );
$new_count = wp_count_posts( Comment_CPT::CPT );
$this->assertEquals( 1, $new_count->publish );
Expand Down
Loading