fix phpcs errors
This commit is contained in:
parent
0bd6eccfed
commit
804cb0af1a
7 changed files with 39 additions and 28 deletions
|
@ -25,9 +25,13 @@ class Admin {
|
|||
}
|
||||
|
||||
add_filter(
|
||||
'activitypub/transformers/is_transformer_enabled', function( $should_register, Transformer_Base $widget_instance ) {
|
||||
'activitypub/transformers/is_transformer_enabled',
|
||||
function( $should_register, Transformer_Base $transformer_instance ) {
|
||||
return ! Options::is_transformer_disabled( $transformer_instance->get_name() );
|
||||
}, 10, 2 );
|
||||
},
|
||||
10,
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,7 +191,7 @@ class Admin {
|
|||
),
|
||||
'sanitize_callback' => function ( $value ) {
|
||||
// Check if $value is an array
|
||||
if (!is_array($value)) {
|
||||
if ( ! is_array( $value ) ) {
|
||||
return array();
|
||||
}
|
||||
$value_keys = array_keys( $value );
|
||||
|
@ -196,12 +200,11 @@ class Admin {
|
|||
|
||||
// Unset the keys that are missing in $keysToCheck
|
||||
foreach ( array_diff( $value_keys, $all_public_post_types ) as $missing_key ) {
|
||||
unset($value[$missing_key]);
|
||||
unset( $value[ $missing_key ] );
|
||||
}
|
||||
// var_dump($value);
|
||||
return $value;
|
||||
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
\register_setting(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
namespace Activitypub\Model;
|
||||
|
||||
use Activitypub\Transformer\Post;
|
||||
use Activitypub\Transformer\Post as Transformer_Post;
|
||||
|
||||
/**
|
||||
* ActivityPub Post Class
|
||||
|
@ -34,7 +34,7 @@ class Post {
|
|||
_deprecated_function( __CLASS__, '1.0.0', '\Activitypub\Transformer\Post' );
|
||||
|
||||
$this->post = $post;
|
||||
$this->object = Post_Transformer->set_wp_post( $post )->to_object();
|
||||
$this->object = Transformer_Post->set_wp_post( $post )->to_object();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,7 +59,7 @@ class Outbox {
|
|||
return $user;
|
||||
}
|
||||
|
||||
$post_types = array_keys( \get_option( 'activitypub_transformer_mapping', array( 'post' => 'activitypub/default', 'page' => 'activitypub/default') ) );
|
||||
$post_types = array_keys( \get_option( 'activitypub_transformer_mapping', array( 'post' => 'activitypub/default', 'page' => 'activitypub/default' ) ) );
|
||||
|
||||
$page = $request->get_param( 'page', 1 );
|
||||
|
||||
|
|
|
@ -37,15 +37,20 @@ abstract class Base {
|
|||
* @return void
|
||||
*/
|
||||
public function set_wp_post( WP_Post $wp_post ) {
|
||||
if ( $this->supports_post_type( get_post_type( $wp_post ) ) ) {
|
||||
$this->wp_post = $wp_post;
|
||||
} else {
|
||||
// TODO Error, this should not happen.
|
||||
$post_type = get_post_type( $wp_post );
|
||||
if ( ! $this->supports_post_type( $post_type ) ) {
|
||||
_doing_it_wrong(
|
||||
__METHOD__,
|
||||
/* translators: %s: Block name. */
|
||||
sprintf( 'The Transformer "%s" does not support the post type "%s".', esc_html( $this->get_label() ), esc_html( $post_type ) ),
|
||||
'version_number_transformer_management_placeholder'
|
||||
);
|
||||
}
|
||||
$this->wp_post = $wp_post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the supported WP post_types that the transformer can use as an input.
|
||||
* Get the supported WP post types that the transformer can use as an input.
|
||||
*
|
||||
* By default all post types are supported.
|
||||
* You may very likely wish to override this function.
|
||||
|
@ -74,7 +79,11 @@ abstract class Base {
|
|||
$plugins_data = get_plugins( '/' . $plugin_directory );
|
||||
$plugin_data = array_shift( $plugins_data );
|
||||
|
||||
return $plugin_data['Name'] ?? esc_html__( 'Unknown', 'activitypub' );
|
||||
if ( isset( $plugin_data['Name'] ) ) {
|
||||
return $plugin_data['Name'];
|
||||
} else {
|
||||
return esc_html__( 'Unknown', 'activitypub' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -137,12 +137,12 @@ class Transformers_Manager {
|
|||
*
|
||||
* @return bool True if the ActivityPub transformer was registered.
|
||||
*/
|
||||
public function register( \ActivityPub\Transformer\Base $transformer_instance) {
|
||||
public function register( \ActivityPub\Transformer\Base $transformer_instance ) {
|
||||
|
||||
if ( ! $transformer_instance instanceof \ActivityPub\Transformer\Base ) {
|
||||
_doing_it_wrong(
|
||||
__METHOD__,
|
||||
__( 'ActivityPub transformer instance must be a of \ActivityPub\Transformer_Base class.' ),
|
||||
\esc_html__( 'ActivityPub transformer instance must be a of \ActivityPub\Transformer_Base class.' ),
|
||||
'version_number_transformer_management_placeholder'
|
||||
);
|
||||
return false;
|
||||
|
@ -152,7 +152,7 @@ class Transformers_Manager {
|
|||
if ( preg_match( '/[A-Z]+/', $transformer_name ) ) {
|
||||
_doing_it_wrong(
|
||||
__METHOD__,
|
||||
__( 'ActivityPub transformer names must not contain uppercase characters.' ),
|
||||
\esc_html__( 'ActivityPub transformer names must not contain uppercase characters.' ),
|
||||
'version_number_transformer_management_placeholder'
|
||||
);
|
||||
return false;
|
||||
|
@ -162,7 +162,7 @@ class Transformers_Manager {
|
|||
if ( ! preg_match( $name_matcher, $transformer_name ) ) {
|
||||
_doing_it_wrong(
|
||||
__METHOD__,
|
||||
__( 'ActivityPub transformer names must contain a namespace prefix. Example: my-plugin/my-custom-transformer' ),
|
||||
\esc_html__( 'ActivityPub transformer names must contain a namespace prefix. Example: my-plugin/my-custom-transformer' ),
|
||||
'version_number_transformer_management_placeholder'
|
||||
);
|
||||
return false;
|
||||
|
@ -172,7 +172,7 @@ class Transformers_Manager {
|
|||
_doing_it_wrong(
|
||||
__METHOD__,
|
||||
/* translators: %s: Block name. */
|
||||
sprintf( __( 'ActivityPub transformer with name "%s" is already registered.' ), $transformer_name ),
|
||||
sprintf( 'ActivityPub transformer with name "%s" is already registered.', esc_html( $transformer_name ) ),
|
||||
'version_number_transformer_management_placeholder'
|
||||
);
|
||||
return false;
|
||||
|
@ -209,7 +209,7 @@ class Transformers_Manager {
|
|||
*/
|
||||
private function init_transformers() {
|
||||
$builtin_transformers = [
|
||||
'post'
|
||||
'post',
|
||||
];
|
||||
|
||||
$this->transformers = [];
|
||||
|
@ -290,4 +290,3 @@ class Transformers_Manager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue