Completed
Pull Request — master (#1641)
by Naveen
01:35
created
src/wordlift/no-editor-analysis/class-meta-box.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -10,38 +10,38 @@
 block discarded – undo
10 10
 
11 11
 class Meta_Box {
12 12
 
13
-	const META_BOX_ID = 'wl-no-editor-analysis-meta-box';
14
-
15
-	public function init() {
16
-		add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
17
-	}
18
-
19
-	public function add_meta_box( $post_type ) {
20
-
21
-		// We enable it for only the post types which doesn't support the editor and
22
-		// enabled on the filter.
23
-		if ( ! No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( get_the_ID() ) ) {
24
-			return;
25
-		}
26
-
27
-		add_meta_box(
28
-			self::META_BOX_ID,
29
-			__( 'WordLift', 'wordlift' ),
30
-			array( $this, 'render_meta_box' ),
31
-			$post_type,
32
-			'side',
33
-			'high'
34
-		);
35
-
36
-	}
37
-
38
-	public function render_meta_box() {
39
-		echo sprintf(
40
-			"<div id='%s'></div><div id='%s'></div>",
41
-			esc_attr( 'wl-no-editor-analysis-meta-box-content' ),
42
-			// Div to store the entities.
43
-			esc_attr( 'wl-no-editor-analysis-meta-box-storage' )
44
-		);
45
-	}
13
+    const META_BOX_ID = 'wl-no-editor-analysis-meta-box';
14
+
15
+    public function init() {
16
+        add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
17
+    }
18
+
19
+    public function add_meta_box( $post_type ) {
20
+
21
+        // We enable it for only the post types which doesn't support the editor and
22
+        // enabled on the filter.
23
+        if ( ! No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( get_the_ID() ) ) {
24
+            return;
25
+        }
26
+
27
+        add_meta_box(
28
+            self::META_BOX_ID,
29
+            __( 'WordLift', 'wordlift' ),
30
+            array( $this, 'render_meta_box' ),
31
+            $post_type,
32
+            'side',
33
+            'high'
34
+        );
35
+
36
+    }
37
+
38
+    public function render_meta_box() {
39
+        echo sprintf(
40
+            "<div id='%s'></div><div id='%s'></div>",
41
+            esc_attr( 'wl-no-editor-analysis-meta-box-content' ),
42
+            // Div to store the entities.
43
+            esc_attr( 'wl-no-editor-analysis-meta-box-storage' )
44
+        );
45
+    }
46 46
 
47 47
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,21 +13,21 @@  discard block
 block discarded – undo
13 13
 	const META_BOX_ID = 'wl-no-editor-analysis-meta-box';
14 14
 
15 15
 	public function init() {
16
-		add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
16
+		add_action('add_meta_boxes', array($this, 'add_meta_box'));
17 17
 	}
18 18
 
19
-	public function add_meta_box( $post_type ) {
19
+	public function add_meta_box($post_type) {
20 20
 
21 21
 		// We enable it for only the post types which doesn't support the editor and
22 22
 		// enabled on the filter.
23
-		if ( ! No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( get_the_ID() ) ) {
23
+		if ( ! No_Editor_Analysis_Feature::can_no_editor_analysis_be_used(get_the_ID())) {
24 24
 			return;
25 25
 		}
26 26
 
27 27
 		add_meta_box(
28 28
 			self::META_BOX_ID,
29
-			__( 'WordLift', 'wordlift' ),
30
-			array( $this, 'render_meta_box' ),
29
+			__('WordLift', 'wordlift'),
30
+			array($this, 'render_meta_box'),
31 31
 			$post_type,
32 32
 			'side',
33 33
 			'high'
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	public function render_meta_box() {
39 39
 		echo sprintf(
40 40
 			"<div id='%s'></div><div id='%s'></div>",
41
-			esc_attr( 'wl-no-editor-analysis-meta-box-content' ),
41
+			esc_attr('wl-no-editor-analysis-meta-box-content'),
42 42
 			// Div to store the entities.
43
-			esc_attr( 'wl-no-editor-analysis-meta-box-storage' )
43
+			esc_attr('wl-no-editor-analysis-meta-box-storage')
44 44
 		);
45 45
 	}
46 46
 
Please login to merge, or discard this patch.
src/wordlift/no-editor-analysis/class-post-type.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -3,19 +3,19 @@
 block discarded – undo
3 3
 
4 4
 class Post_Type {
5 5
 
6
-	public static function is_no_editor_analysis_enabled_for_post_type( $post_type ) {
6
+    public static function is_no_editor_analysis_enabled_for_post_type( $post_type ) {
7 7
 
8
-		if ( ! $post_type ) {
9
-			return false;
10
-		}
8
+        if ( ! $post_type ) {
9
+            return false;
10
+        }
11 11
 
12
-		if ( ! post_type_exists( $post_type ) ) {
13
-			return false;
14
-		}
12
+        if ( ! post_type_exists( $post_type ) ) {
13
+            return false;
14
+        }
15 15
 
16
-		// Enable it on post types which doesn't have editor by default.
17
-		return ! post_type_supports( $post_type, 'editor' );
16
+        // Enable it on post types which doesn't have editor by default.
17
+        return ! post_type_supports( $post_type, 'editor' );
18 18
 
19
-	}
19
+    }
20 20
 
21 21
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,18 +3,18 @@
 block discarded – undo
3 3
 
4 4
 class Post_Type {
5 5
 
6
-	public static function is_no_editor_analysis_enabled_for_post_type( $post_type ) {
6
+	public static function is_no_editor_analysis_enabled_for_post_type($post_type) {
7 7
 
8
-		if ( ! $post_type ) {
8
+		if ( ! $post_type) {
9 9
 			return false;
10 10
 		}
11 11
 
12
-		if ( ! post_type_exists( $post_type ) ) {
12
+		if ( ! post_type_exists($post_type)) {
13 13
 			return false;
14 14
 		}
15 15
 
16 16
 		// Enable it on post types which doesn't have editor by default.
17
-		return ! post_type_supports( $post_type, 'editor' );
17
+		return ! post_type_supports($post_type, 'editor');
18 18
 
19 19
 	}
20 20
 
Please login to merge, or discard this patch.
src/wordlift/no-editor-analysis/class-edit-post-scripts.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
 
8 8
 class Edit_Post_Scripts extends Edit_Post_Loader {
9 9
 
10
-	const HANDLE = 'wl-no-editor-analysis-deps';
11
-
12
-	public function run_on_edit_post_screen() {
13
-
14
-		// Dont load this script if the post doesnt support it.
15
-		if ( ! No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( get_the_ID() ) ) {
16
-			return;
17
-		}
18
-
19
-		Scripts_Helper::enqueue_based_on_wordpress_version(
20
-			self::HANDLE,
21
-			plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/no-editor-analysis',
22
-			array(
23
-				'react',
24
-				'react-dom',
25
-				'wp-api-fetch',
26
-				'wp-blocks',
27
-				'wp-components',
28
-				'wp-data',
29
-				'wp-element',
30
-				'wp-hooks',
31
-				'wp-polyfill',
32
-				'wp-rich-text',
33
-			),
34
-			true
35
-		);
36
-
37
-		wp_enqueue_style(
38
-			self::HANDLE,
39
-			plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/no-editor-analysis.full.css',
40
-			array(),
41
-			WORDLIFT_VERSION
42
-		);
43
-
44
-	}
10
+    const HANDLE = 'wl-no-editor-analysis-deps';
11
+
12
+    public function run_on_edit_post_screen() {
13
+
14
+        // Dont load this script if the post doesnt support it.
15
+        if ( ! No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( get_the_ID() ) ) {
16
+            return;
17
+        }
18
+
19
+        Scripts_Helper::enqueue_based_on_wordpress_version(
20
+            self::HANDLE,
21
+            plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/no-editor-analysis',
22
+            array(
23
+                'react',
24
+                'react-dom',
25
+                'wp-api-fetch',
26
+                'wp-blocks',
27
+                'wp-components',
28
+                'wp-data',
29
+                'wp-element',
30
+                'wp-hooks',
31
+                'wp-polyfill',
32
+                'wp-rich-text',
33
+            ),
34
+            true
35
+        );
36
+
37
+        wp_enqueue_style(
38
+            self::HANDLE,
39
+            plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/no-editor-analysis.full.css',
40
+            array(),
41
+            WORDLIFT_VERSION
42
+        );
43
+
44
+    }
45 45
 
46 46
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
 	public function run_on_edit_post_screen() {
13 13
 
14 14
 		// Dont load this script if the post doesnt support it.
15
-		if ( ! No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( get_the_ID() ) ) {
15
+		if ( ! No_Editor_Analysis_Feature::can_no_editor_analysis_be_used(get_the_ID())) {
16 16
 			return;
17 17
 		}
18 18
 
19 19
 		Scripts_Helper::enqueue_based_on_wordpress_version(
20 20
 			self::HANDLE,
21
-			plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/no-editor-analysis',
21
+			plugin_dir_url(dirname(__DIR__)).'js/dist/no-editor-analysis',
22 22
 			array(
23 23
 				'react',
24 24
 				'react-dom',
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
 		wp_enqueue_style(
38 38
 			self::HANDLE,
39
-			plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/no-editor-analysis.full.css',
39
+			plugin_dir_url(dirname(__DIR__)).'js/dist/no-editor-analysis.full.css',
40 40
 			array(),
41 41
 			WORDLIFT_VERSION
42 42
 		);
Please login to merge, or discard this patch.
src/wordlift/no-editor-analysis/class-edit-screen-setting.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@
 block discarded – undo
10 10
  */
11 11
 class Edit_Screen_Setting {
12 12
 
13
-	public function add_setting() {
14
-		add_filter( 'wl_admin_settings', array( $this, 'wl_admin_settings' ) );
15
-	}
13
+    public function add_setting() {
14
+        add_filter( 'wl_admin_settings', array( $this, 'wl_admin_settings' ) );
15
+    }
16 16
 
17
-	public function wl_admin_settings( $settings ) {
18
-		$settings['analysis']['isNoEditorAnalysisActive'] = No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( get_the_ID() );
19
-		return $settings;
20
-	}
17
+    public function wl_admin_settings( $settings ) {
18
+        $settings['analysis']['isNoEditorAnalysisActive'] = No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( get_the_ID() );
19
+        return $settings;
20
+    }
21 21
 
22 22
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@
 block discarded – undo
11 11
 class Edit_Screen_Setting {
12 12
 
13 13
 	public function add_setting() {
14
-		add_filter( 'wl_admin_settings', array( $this, 'wl_admin_settings' ) );
14
+		add_filter('wl_admin_settings', array($this, 'wl_admin_settings'));
15 15
 	}
16 16
 
17
-	public function wl_admin_settings( $settings ) {
18
-		$settings['analysis']['isNoEditorAnalysisActive'] = No_Editor_Analysis_Feature::can_no_editor_analysis_be_used( get_the_ID() );
17
+	public function wl_admin_settings($settings) {
18
+		$settings['analysis']['isNoEditorAnalysisActive'] = No_Editor_Analysis_Feature::can_no_editor_analysis_be_used(get_the_ID());
19 19
 		return $settings;
20 20
 	}
21 21
 
Please login to merge, or discard this patch.
src/wordlift/lod-import/index.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,6 +4,6 @@
 block discarded – undo
4 4
 
5 5
 // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
6 6
 if ( apply_filters( 'wl_feature__enable__lod-import', false ) ) {
7
-	$lod_import = new Lod_Import();
8
-	$lod_import->register_hooks();
7
+    $lod_import = new Lod_Import();
8
+    $lod_import->register_hooks();
9 9
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 use Wordlift\Lod_Import\Lod_Import;
4 4
 
5 5
 // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
6
-if ( apply_filters( 'wl_feature__enable__lod-import', false ) ) {
6
+if (apply_filters('wl_feature__enable__lod-import', false)) {
7 7
 	$lod_import = new Lod_Import();
8 8
 	$lod_import->register_hooks();
9 9
 }
Please login to merge, or discard this patch.
src/wordlift/lod-import/class-lod-import.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -10,30 +10,30 @@  discard block
 block discarded – undo
10 10
 
11 11
 class Lod_Import {
12 12
 
13
-	public function __construct() {
13
+    public function __construct() {
14 14
 
15
-	}
15
+    }
16 16
 
17
-	public function register_hooks() {
18
-		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
19
-	}
17
+    public function register_hooks() {
18
+        add_action( 'admin_menu', array( $this, 'admin_menu' ) );
19
+    }
20 20
 
21
-	public function admin_menu() {
21
+    public function admin_menu() {
22 22
 
23
-		$callback = isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) ? 'handle' : 'render';
23
+        $callback = isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) ? 'handle' : 'render';
24 24
 
25
-		add_submenu_page(
26
-			'wl_admin_menu',
27
-			__( 'LOD Import', 'wordlift' ),
28
-			__( 'LOD Import', 'wordlift' ),
29
-			'manage_options',
30
-			'wl_lod_import',
31
-			array( $this, $callback )
32
-		);
33
-	}
25
+        add_submenu_page(
26
+            'wl_admin_menu',
27
+            __( 'LOD Import', 'wordlift' ),
28
+            __( 'LOD Import', 'wordlift' ),
29
+            'manage_options',
30
+            'wl_lod_import',
31
+            array( $this, $callback )
32
+        );
33
+    }
34 34
 
35
-	public function render() {
36
-		?>
35
+    public function render() {
36
+        ?>
37 37
 		<div class="wrap">
38 38
 			<h1><?php esc_html_e( 'LOD Import', 'wordlift' ); ?></h1>
39 39
 			<p><?php esc_html_e( 'Helpful stuff here', 'wordlift' ); ?></p>
@@ -48,38 +48,38 @@  discard block
 block discarded – undo
48 48
 		</div>
49 49
 		<?php
50 50
 
51
-	}
51
+    }
52 52
 
53
-	public function handle() {
54
-		$item_ids = filter_input( INPUT_POST, 'item-ids' );
55
-		if ( ! $item_ids ) {
56
-			?>
53
+    public function handle() {
54
+        $item_ids = filter_input( INPUT_POST, 'item-ids' );
55
+        if ( ! $item_ids ) {
56
+            ?>
57 57
 			<p class="notice notice-error">Please type stgh</p>
58 58
 			<?php
59
-			return;
60
-		}
59
+            return;
60
+        }
61 61
 
62
-		foreach ( preg_split( '(\r\n|\r|\n)', $item_ids ) as $item_id ) {
63
-			$this->import_single( $item_id );
64
-		}
65
-	}
62
+        foreach ( preg_split( '(\r\n|\r|\n)', $item_ids ) as $item_id ) {
63
+            $this->import_single( $item_id );
64
+        }
65
+    }
66 66
 
67
-	private function import_single( $item_id ) {
67
+    private function import_single( $item_id ) {
68 68
 
69
-		$content_service = Wordpress_Content_Service::get_instance();
69
+        $content_service = Wordpress_Content_Service::get_instance();
70 70
 
71
-		// Do not create/update an existing entity.
72
-		if ( $content_service->get_by_entity_id_or_same_as( $item_id ) ) {
73
-			return;
74
-		}
71
+        // Do not create/update an existing entity.
72
+        if ( $content_service->get_by_entity_id_or_same_as( $item_id ) ) {
73
+            return;
74
+        }
75 75
 
76
-		$remote_entity = Url_To_Remote_Entity_Converter::convert( $item_id );
77
-		$importer      = Remote_Entity_Importer_Factory::from_entity( $remote_entity );
78
-		$content_id    = $importer->import();
79
-		if ( $content_id instanceof Content_Id && $content_id->get_type() === Object_Type_Enum::POST ) {
80
-			edit_post_link( null, null, null, $content_id->get_id() );
81
-		}
76
+        $remote_entity = Url_To_Remote_Entity_Converter::convert( $item_id );
77
+        $importer      = Remote_Entity_Importer_Factory::from_entity( $remote_entity );
78
+        $content_id    = $importer->import();
79
+        if ( $content_id instanceof Content_Id && $content_id->get_type() === Object_Type_Enum::POST ) {
80
+            edit_post_link( null, null, null, $content_id->get_id() );
81
+        }
82 82
 
83
-	}
83
+    }
84 84
 
85 85
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -15,35 +15,35 @@  discard block
 block discarded – undo
15 15
 	}
16 16
 
17 17
 	public function register_hooks() {
18
-		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
18
+		add_action('admin_menu', array($this, 'admin_menu'));
19 19
 	}
20 20
 
21 21
 	public function admin_menu() {
22 22
 
23
-		$callback = isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) ? 'handle' : 'render';
23
+		$callback = isset($_SERVER['REQUEST_METHOD']) && 'POST' === sanitize_text_field(wp_unslash($_SERVER['REQUEST_METHOD'])) ? 'handle' : 'render';
24 24
 
25 25
 		add_submenu_page(
26 26
 			'wl_admin_menu',
27
-			__( 'LOD Import', 'wordlift' ),
28
-			__( 'LOD Import', 'wordlift' ),
27
+			__('LOD Import', 'wordlift'),
28
+			__('LOD Import', 'wordlift'),
29 29
 			'manage_options',
30 30
 			'wl_lod_import',
31
-			array( $this, $callback )
31
+			array($this, $callback)
32 32
 		);
33 33
 	}
34 34
 
35 35
 	public function render() {
36 36
 		?>
37 37
 		<div class="wrap">
38
-			<h1><?php esc_html_e( 'LOD Import', 'wordlift' ); ?></h1>
39
-			<p><?php esc_html_e( 'Helpful stuff here', 'wordlift' ); ?></p>
38
+			<h1><?php esc_html_e('LOD Import', 'wordlift'); ?></h1>
39
+			<p><?php esc_html_e('Helpful stuff here', 'wordlift'); ?></p>
40 40
 			<form method="post" novalidate="novalidate">
41 41
 				<div class="form-field">
42
-					<label for="item-ids"><?php esc_html_e( 'Linked Data IDs', 'wordlift' ); ?></label>
42
+					<label for="item-ids"><?php esc_html_e('Linked Data IDs', 'wordlift'); ?></label>
43 43
 					<textarea name="item-ids" id="item-ids" rows="5" cols="40"></textarea>
44
-					<p><?php esc_html_e( 'The description is not prominent by default; however, some themes may show it.', 'wordlift' ); ?></p>
44
+					<p><?php esc_html_e('The description is not prominent by default; however, some themes may show it.', 'wordlift'); ?></p>
45 45
 				</div>
46
-				<?php submit_button( 'Import' ); ?>
46
+				<?php submit_button('Import'); ?>
47 47
 			</form>
48 48
 		</div>
49 49
 		<?php
@@ -51,33 +51,33 @@  discard block
 block discarded – undo
51 51
 	}
52 52
 
53 53
 	public function handle() {
54
-		$item_ids = filter_input( INPUT_POST, 'item-ids' );
55
-		if ( ! $item_ids ) {
54
+		$item_ids = filter_input(INPUT_POST, 'item-ids');
55
+		if ( ! $item_ids) {
56 56
 			?>
57 57
 			<p class="notice notice-error">Please type stgh</p>
58 58
 			<?php
59 59
 			return;
60 60
 		}
61 61
 
62
-		foreach ( preg_split( '(\r\n|\r|\n)', $item_ids ) as $item_id ) {
63
-			$this->import_single( $item_id );
62
+		foreach (preg_split('(\r\n|\r|\n)', $item_ids) as $item_id) {
63
+			$this->import_single($item_id);
64 64
 		}
65 65
 	}
66 66
 
67
-	private function import_single( $item_id ) {
67
+	private function import_single($item_id) {
68 68
 
69 69
 		$content_service = Wordpress_Content_Service::get_instance();
70 70
 
71 71
 		// Do not create/update an existing entity.
72
-		if ( $content_service->get_by_entity_id_or_same_as( $item_id ) ) {
72
+		if ($content_service->get_by_entity_id_or_same_as($item_id)) {
73 73
 			return;
74 74
 		}
75 75
 
76
-		$remote_entity = Url_To_Remote_Entity_Converter::convert( $item_id );
77
-		$importer      = Remote_Entity_Importer_Factory::from_entity( $remote_entity );
76
+		$remote_entity = Url_To_Remote_Entity_Converter::convert($item_id);
77
+		$importer      = Remote_Entity_Importer_Factory::from_entity($remote_entity);
78 78
 		$content_id    = $importer->import();
79
-		if ( $content_id instanceof Content_Id && $content_id->get_type() === Object_Type_Enum::POST ) {
80
-			edit_post_link( null, null, null, $content_id->get_id() );
79
+		if ($content_id instanceof Content_Id && $content_id->get_type() === Object_Type_Enum::POST) {
80
+			edit_post_link(null, null, null, $content_id->get_id());
81 81
 		}
82 82
 
83 83
 	}
Please login to merge, or discard this patch.
src/wordlift/duplicate-markup-remover/class-duplicate-markup-remover.php 2 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -4,111 +4,111 @@
 block discarded – undo
4 4
 
5 5
 class Duplicate_Markup_Remover {
6 6
 
7
-	private $types_to_properties_map = array(
8
-		'HowTo'   => array(
9
-			'estimatedCost',
10
-			'totalTime',
11
-			'supply',
12
-			'tool',
13
-			'step',
14
-		),
15
-		'FAQPage' => array( 'mainEntity' ),
16
-		'Recipe'  => array(
17
-			'cookTime',
18
-			'cookingMethod',
19
-			'nutrition',
20
-			'recipeCategory',
21
-			'recipeCuisine',
22
-			'recipeIngredient',
23
-			'recipeInstructions',
24
-			'recipeYield',
25
-			'suitableForDiet',
26
-		),
27
-	);
28
-
29
-	public function __construct() {
30
-		add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10 );
31
-	}
32
-
33
-	/**
34
-	 * @param $jsonld array The final jsonld.
35
-	 *
36
-	 * @return array Filtered jsonld.
37
-	 */
38
-	public function wl_after_get_jsonld( $jsonld ) {
39
-
40
-		foreach ( $this->types_to_properties_map as $type_to_remove => $properties_to_remove ) {
41
-			$jsonld = $this->remove_type( $jsonld, $type_to_remove, $properties_to_remove );
42
-		}
43
-
44
-		return $jsonld;
45
-	}
46
-
47
-	/**
48
-	 * @param array $jsonld
49
-	 *
50
-	 * @return bool
51
-	 */
52
-	protected function should_alter_jsonld( $jsonld ) {
53
-		return ! is_array( $jsonld )
54
-			   || ! count( $jsonld ) > 1
55
-			   || ! array_key_exists( 0, $jsonld );
56
-	}
57
-
58
-	/**
59
-	 * @param array $jsonld
60
-	 *
61
-	 * @return array
62
-	 */
63
-	private function remove_type( $jsonld, $type_to_remove, $properties_to_remove ) {
64
-
65
-		if ( $this->should_alter_jsonld( $jsonld ) ) {
66
-			// Return early if there are no referenced entities.
67
-			return $jsonld;
68
-		}
69
-
70
-		$post_jsonld = array_shift( $jsonld );
71
-
72
-		// we need to loop through all the items and remove the faq markup.
73
-		foreach ( $jsonld as $key => &$value ) {
74
-			if ( ! array_key_exists( '@type', $value ) ) {
75
-				continue;
76
-			}
77
-			$type = $value['@type'];
78
-
79
-			/**
80
-			 * Two possibilities:
81
-			 * 1. The referenced entity has only supplied SchemaType markup, in that case remove the complete entity.
82
-			 * 2. The referenced entity has multiple types, in that case completely remove the supplied SchemaType markup, but
83
-			 * retain the other entity data.
84
-			 */
85
-			// If the referenced entity is purely supplied SchemaType markup, then remove it.
86
-
87
-			if ( is_string( $type ) && $type === $type_to_remove ) {
88
-				// Remove the entity completely.
89
-				unset( $jsonld[ $key ] );
90
-			}
91
-
92
-			if ( is_array( $type ) && in_array( $type_to_remove, $type, true ) ) {
93
-				// Remove the supplied SchemaType markup.
94
-				$position = array_search( $type_to_remove, $type, true );
95
-				// Also update the type.
96
-				if ( false !== $position ) {
97
-					unset( $type[ $position ] );
98
-					$value['@type'] = array_values( $type );
99
-				}
100
-
101
-				foreach ( $properties_to_remove as $property ) {
102
-					// Remove keys of supplied SchemaType.
103
-					unset( $value[ $property ] );
104
-				}
105
-			}
106
-		}
107
-
108
-		// Add the post jsonld to front of jsonld array.
109
-		array_unshift( $jsonld, $post_jsonld );
110
-
111
-		return $jsonld;
112
-	}
7
+    private $types_to_properties_map = array(
8
+        'HowTo'   => array(
9
+            'estimatedCost',
10
+            'totalTime',
11
+            'supply',
12
+            'tool',
13
+            'step',
14
+        ),
15
+        'FAQPage' => array( 'mainEntity' ),
16
+        'Recipe'  => array(
17
+            'cookTime',
18
+            'cookingMethod',
19
+            'nutrition',
20
+            'recipeCategory',
21
+            'recipeCuisine',
22
+            'recipeIngredient',
23
+            'recipeInstructions',
24
+            'recipeYield',
25
+            'suitableForDiet',
26
+        ),
27
+    );
28
+
29
+    public function __construct() {
30
+        add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10 );
31
+    }
32
+
33
+    /**
34
+     * @param $jsonld array The final jsonld.
35
+     *
36
+     * @return array Filtered jsonld.
37
+     */
38
+    public function wl_after_get_jsonld( $jsonld ) {
39
+
40
+        foreach ( $this->types_to_properties_map as $type_to_remove => $properties_to_remove ) {
41
+            $jsonld = $this->remove_type( $jsonld, $type_to_remove, $properties_to_remove );
42
+        }
43
+
44
+        return $jsonld;
45
+    }
46
+
47
+    /**
48
+     * @param array $jsonld
49
+     *
50
+     * @return bool
51
+     */
52
+    protected function should_alter_jsonld( $jsonld ) {
53
+        return ! is_array( $jsonld )
54
+               || ! count( $jsonld ) > 1
55
+               || ! array_key_exists( 0, $jsonld );
56
+    }
57
+
58
+    /**
59
+     * @param array $jsonld
60
+     *
61
+     * @return array
62
+     */
63
+    private function remove_type( $jsonld, $type_to_remove, $properties_to_remove ) {
64
+
65
+        if ( $this->should_alter_jsonld( $jsonld ) ) {
66
+            // Return early if there are no referenced entities.
67
+            return $jsonld;
68
+        }
69
+
70
+        $post_jsonld = array_shift( $jsonld );
71
+
72
+        // we need to loop through all the items and remove the faq markup.
73
+        foreach ( $jsonld as $key => &$value ) {
74
+            if ( ! array_key_exists( '@type', $value ) ) {
75
+                continue;
76
+            }
77
+            $type = $value['@type'];
78
+
79
+            /**
80
+             * Two possibilities:
81
+             * 1. The referenced entity has only supplied SchemaType markup, in that case remove the complete entity.
82
+             * 2. The referenced entity has multiple types, in that case completely remove the supplied SchemaType markup, but
83
+             * retain the other entity data.
84
+             */
85
+            // If the referenced entity is purely supplied SchemaType markup, then remove it.
86
+
87
+            if ( is_string( $type ) && $type === $type_to_remove ) {
88
+                // Remove the entity completely.
89
+                unset( $jsonld[ $key ] );
90
+            }
91
+
92
+            if ( is_array( $type ) && in_array( $type_to_remove, $type, true ) ) {
93
+                // Remove the supplied SchemaType markup.
94
+                $position = array_search( $type_to_remove, $type, true );
95
+                // Also update the type.
96
+                if ( false !== $position ) {
97
+                    unset( $type[ $position ] );
98
+                    $value['@type'] = array_values( $type );
99
+                }
100
+
101
+                foreach ( $properties_to_remove as $property ) {
102
+                    // Remove keys of supplied SchemaType.
103
+                    unset( $value[ $property ] );
104
+                }
105
+            }
106
+        }
107
+
108
+        // Add the post jsonld to front of jsonld array.
109
+        array_unshift( $jsonld, $post_jsonld );
110
+
111
+        return $jsonld;
112
+    }
113 113
 
114 114
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 			'tool',
13 13
 			'step',
14 14
 		),
15
-		'FAQPage' => array( 'mainEntity' ),
15
+		'FAQPage' => array('mainEntity'),
16 16
 		'Recipe'  => array(
17 17
 			'cookTime',
18 18
 			'cookingMethod',
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	);
28 28
 
29 29
 	public function __construct() {
30
-		add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10 );
30
+		add_filter('wl_after_get_jsonld', array($this, 'wl_after_get_jsonld'), 10);
31 31
 	}
32 32
 
33 33
 	/**
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return array Filtered jsonld.
37 37
 	 */
38
-	public function wl_after_get_jsonld( $jsonld ) {
38
+	public function wl_after_get_jsonld($jsonld) {
39 39
 
40
-		foreach ( $this->types_to_properties_map as $type_to_remove => $properties_to_remove ) {
41
-			$jsonld = $this->remove_type( $jsonld, $type_to_remove, $properties_to_remove );
40
+		foreach ($this->types_to_properties_map as $type_to_remove => $properties_to_remove) {
41
+			$jsonld = $this->remove_type($jsonld, $type_to_remove, $properties_to_remove);
42 42
 		}
43 43
 
44 44
 		return $jsonld;
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @return bool
51 51
 	 */
52
-	protected function should_alter_jsonld( $jsonld ) {
53
-		return ! is_array( $jsonld )
54
-			   || ! count( $jsonld ) > 1
55
-			   || ! array_key_exists( 0, $jsonld );
52
+	protected function should_alter_jsonld($jsonld) {
53
+		return ! is_array($jsonld)
54
+			   || ! count($jsonld) > 1
55
+			   || ! array_key_exists(0, $jsonld);
56 56
 	}
57 57
 
58 58
 	/**
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @return array
62 62
 	 */
63
-	private function remove_type( $jsonld, $type_to_remove, $properties_to_remove ) {
63
+	private function remove_type($jsonld, $type_to_remove, $properties_to_remove) {
64 64
 
65
-		if ( $this->should_alter_jsonld( $jsonld ) ) {
65
+		if ($this->should_alter_jsonld($jsonld)) {
66 66
 			// Return early if there are no referenced entities.
67 67
 			return $jsonld;
68 68
 		}
69 69
 
70
-		$post_jsonld = array_shift( $jsonld );
70
+		$post_jsonld = array_shift($jsonld);
71 71
 
72 72
 		// we need to loop through all the items and remove the faq markup.
73
-		foreach ( $jsonld as $key => &$value ) {
74
-			if ( ! array_key_exists( '@type', $value ) ) {
73
+		foreach ($jsonld as $key => &$value) {
74
+			if ( ! array_key_exists('@type', $value)) {
75 75
 				continue;
76 76
 			}
77 77
 			$type = $value['@type'];
@@ -84,29 +84,29 @@  discard block
 block discarded – undo
84 84
 			 */
85 85
 			// If the referenced entity is purely supplied SchemaType markup, then remove it.
86 86
 
87
-			if ( is_string( $type ) && $type === $type_to_remove ) {
87
+			if (is_string($type) && $type === $type_to_remove) {
88 88
 				// Remove the entity completely.
89
-				unset( $jsonld[ $key ] );
89
+				unset($jsonld[$key]);
90 90
 			}
91 91
 
92
-			if ( is_array( $type ) && in_array( $type_to_remove, $type, true ) ) {
92
+			if (is_array($type) && in_array($type_to_remove, $type, true)) {
93 93
 				// Remove the supplied SchemaType markup.
94
-				$position = array_search( $type_to_remove, $type, true );
94
+				$position = array_search($type_to_remove, $type, true);
95 95
 				// Also update the type.
96
-				if ( false !== $position ) {
97
-					unset( $type[ $position ] );
98
-					$value['@type'] = array_values( $type );
96
+				if (false !== $position) {
97
+					unset($type[$position]);
98
+					$value['@type'] = array_values($type);
99 99
 				}
100 100
 
101
-				foreach ( $properties_to_remove as $property ) {
101
+				foreach ($properties_to_remove as $property) {
102 102
 					// Remove keys of supplied SchemaType.
103
-					unset( $value[ $property ] );
103
+					unset($value[$property]);
104 104
 				}
105 105
 			}
106 106
 		}
107 107
 
108 108
 		// Add the post jsonld to front of jsonld array.
109
-		array_unshift( $jsonld, $post_jsonld );
109
+		array_unshift($jsonld, $post_jsonld);
110 110
 
111 111
 		return $jsonld;
112 112
 	}
Please login to merge, or discard this patch.
wordlift/duplicate-markup-remover/class-videoobject-duplicate-remover.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -10,47 +10,47 @@
 block discarded – undo
10 10
  */
11 11
 class Videoobject_Duplicate_Remover {
12 12
 
13
-	public function __construct() {
14
-		add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10 );
15
-	}
16
-
17
-	/**
18
-	 * @param $jsonld array The final jsonld.
19
-	 * @return array Filtered jsonld.
20
-	 */
21
-	public function wl_after_get_jsonld( $jsonld ) {
22
-
23
-		if ( ! is_array( $jsonld )
24
-			 || ! count( $jsonld ) > 1
25
-			 || ! array_key_exists( 0, $jsonld ) ) {
26
-			// Return early if there are no referenced entities.
27
-			return $jsonld;
28
-		}
29
-
30
-		$post_jsonld = array_shift( $jsonld );
31
-
32
-		// we need to loop through all the items and remove the faq markup.
33
-		foreach ( $jsonld as $key => &$value ) {
34
-			if ( ! array_key_exists( '@type', $value ) ) {
35
-				continue;
36
-			}
37
-			$type = $value['@type'];
38
-
39
-			if ( ( is_string( $type ) && 'Article' !== $type )
40
-				 || ( is_array( $type ) && ! in_array( 'Article', $type, true ) ) ) {
41
-				continue;
42
-			}
43
-			// Video doesnt exist, dont try to remove it.
44
-			if ( ! array_key_exists( 'video', $value ) ) {
45
-				continue;
46
-			}
47
-			unset( $jsonld[ $key ]['video'] );
48
-		}
49
-
50
-		// Add the post jsonld to front of jsonld array.
51
-		array_unshift( $jsonld, $post_jsonld );
52
-
53
-		return $jsonld;
54
-	}
13
+    public function __construct() {
14
+        add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10 );
15
+    }
16
+
17
+    /**
18
+     * @param $jsonld array The final jsonld.
19
+     * @return array Filtered jsonld.
20
+     */
21
+    public function wl_after_get_jsonld( $jsonld ) {
22
+
23
+        if ( ! is_array( $jsonld )
24
+             || ! count( $jsonld ) > 1
25
+             || ! array_key_exists( 0, $jsonld ) ) {
26
+            // Return early if there are no referenced entities.
27
+            return $jsonld;
28
+        }
29
+
30
+        $post_jsonld = array_shift( $jsonld );
31
+
32
+        // we need to loop through all the items and remove the faq markup.
33
+        foreach ( $jsonld as $key => &$value ) {
34
+            if ( ! array_key_exists( '@type', $value ) ) {
35
+                continue;
36
+            }
37
+            $type = $value['@type'];
38
+
39
+            if ( ( is_string( $type ) && 'Article' !== $type )
40
+                 || ( is_array( $type ) && ! in_array( 'Article', $type, true ) ) ) {
41
+                continue;
42
+            }
43
+            // Video doesnt exist, dont try to remove it.
44
+            if ( ! array_key_exists( 'video', $value ) ) {
45
+                continue;
46
+            }
47
+            unset( $jsonld[ $key ]['video'] );
48
+        }
49
+
50
+        // Add the post jsonld to front of jsonld array.
51
+        array_unshift( $jsonld, $post_jsonld );
52
+
53
+        return $jsonld;
54
+    }
55 55
 
56 56
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -11,44 +11,44 @@
 block discarded – undo
11 11
 class Videoobject_Duplicate_Remover {
12 12
 
13 13
 	public function __construct() {
14
-		add_filter( 'wl_after_get_jsonld', array( $this, 'wl_after_get_jsonld' ), 10 );
14
+		add_filter('wl_after_get_jsonld', array($this, 'wl_after_get_jsonld'), 10);
15 15
 	}
16 16
 
17 17
 	/**
18 18
 	 * @param $jsonld array The final jsonld.
19 19
 	 * @return array Filtered jsonld.
20 20
 	 */
21
-	public function wl_after_get_jsonld( $jsonld ) {
21
+	public function wl_after_get_jsonld($jsonld) {
22 22
 
23
-		if ( ! is_array( $jsonld )
24
-			 || ! count( $jsonld ) > 1
25
-			 || ! array_key_exists( 0, $jsonld ) ) {
23
+		if ( ! is_array($jsonld)
24
+			 || ! count($jsonld) > 1
25
+			 || ! array_key_exists(0, $jsonld)) {
26 26
 			// Return early if there are no referenced entities.
27 27
 			return $jsonld;
28 28
 		}
29 29
 
30
-		$post_jsonld = array_shift( $jsonld );
30
+		$post_jsonld = array_shift($jsonld);
31 31
 
32 32
 		// we need to loop through all the items and remove the faq markup.
33
-		foreach ( $jsonld as $key => &$value ) {
34
-			if ( ! array_key_exists( '@type', $value ) ) {
33
+		foreach ($jsonld as $key => &$value) {
34
+			if ( ! array_key_exists('@type', $value)) {
35 35
 				continue;
36 36
 			}
37 37
 			$type = $value['@type'];
38 38
 
39
-			if ( ( is_string( $type ) && 'Article' !== $type )
40
-				 || ( is_array( $type ) && ! in_array( 'Article', $type, true ) ) ) {
39
+			if ((is_string($type) && 'Article' !== $type)
40
+				 || (is_array($type) && ! in_array('Article', $type, true))) {
41 41
 				continue;
42 42
 			}
43 43
 			// Video doesnt exist, dont try to remove it.
44
-			if ( ! array_key_exists( 'video', $value ) ) {
44
+			if ( ! array_key_exists('video', $value)) {
45 45
 				continue;
46 46
 			}
47
-			unset( $jsonld[ $key ]['video'] );
47
+			unset($jsonld[$key]['video']);
48 48
 		}
49 49
 
50 50
 		// Add the post jsonld to front of jsonld array.
51
-		array_unshift( $jsonld, $post_jsonld );
51
+		array_unshift($jsonld, $post_jsonld);
52 52
 
53 53
 		return $jsonld;
54 54
 	}
Please login to merge, or discard this patch.
wordlift/content/wordpress/class-wordpress-permalink-content-service.php 2 patches
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -9,65 +9,65 @@  discard block
 block discarded – undo
9 9
 // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledClassName
10 10
 class Wordpress_Permalink_Content_Service implements Content_Service {
11 11
 
12
-	private static $instance = null;
13
-
14
-	protected function __construct() {
15
-	}
16
-
17
-	/**
18
-	 * The singleton instance.
19
-	 *
20
-	 * @return Content_Service
21
-	 */
22
-	public static function get_instance() {
23
-		if ( ! isset( self::$instance ) ) {
24
-			self::$instance = new self();
25
-		}
26
-
27
-		return self::$instance;
28
-	}
29
-
30
-	/**
31
-	 * @param $uri string In the form https://example.org/path/post#post/1
32
-	 *
33
-	 * @return Wordpress_Content|null
34
-	 */
35
-	public function get_by_entity_id( $uri ) {
36
-		if ( ! preg_match( '@.*#(\w+)/(\d+)@', $uri, $matches ) ) {
37
-			return null;
38
-		}
39
-
40
-		$type_name = $matches[1];
41
-		$id        = $matches[2];
42
-		switch ( Object_Type_Enum::from_string( $type_name ) ) {
43
-			case Object_Type_Enum::POST:
44
-				return new Wordpress_Content( get_post( $id ) );
45
-			case Object_Type_Enum::TERM:
46
-				return new Wordpress_Content( get_term( $id ) );
47
-			case Object_Type_Enum::USER:
48
-				return new Wordpress_Content( get_user_by( 'ID', $id ) );
49
-		}
50
-
51
-		return null;
52
-	}
53
-
54
-	/**
55
-	 * Get a
56
-	 *
57
-	 * @throws Exception in case of error.
58
-	 */
59
-	public function get_by_entity_id_or_same_as( $uri ) {
60
-		// If the URL is in the local site URL, then try to find a corresponding post.
61
-		if ( 0 === strpos( $uri, site_url() ) ) {
62
-			return $this->get_by_entity_id( $uri );
63
-		}
64
-
65
-		// Otherwise look in sameAs.
66
-		global $wpdb;
67
-
68
-		$row = $wpdb->get_row(
69
-			$wpdb->prepare(
70
-				"
12
+    private static $instance = null;
13
+
14
+    protected function __construct() {
15
+    }
16
+
17
+    /**
18
+     * The singleton instance.
19
+     *
20
+     * @return Content_Service
21
+     */
22
+    public static function get_instance() {
23
+        if ( ! isset( self::$instance ) ) {
24
+            self::$instance = new self();
25
+        }
26
+
27
+        return self::$instance;
28
+    }
29
+
30
+    /**
31
+     * @param $uri string In the form https://example.org/path/post#post/1
32
+     *
33
+     * @return Wordpress_Content|null
34
+     */
35
+    public function get_by_entity_id( $uri ) {
36
+        if ( ! preg_match( '@.*#(\w+)/(\d+)@', $uri, $matches ) ) {
37
+            return null;
38
+        }
39
+
40
+        $type_name = $matches[1];
41
+        $id        = $matches[2];
42
+        switch ( Object_Type_Enum::from_string( $type_name ) ) {
43
+            case Object_Type_Enum::POST:
44
+                return new Wordpress_Content( get_post( $id ) );
45
+            case Object_Type_Enum::TERM:
46
+                return new Wordpress_Content( get_term( $id ) );
47
+            case Object_Type_Enum::USER:
48
+                return new Wordpress_Content( get_user_by( 'ID', $id ) );
49
+        }
50
+
51
+        return null;
52
+    }
53
+
54
+    /**
55
+     * Get a
56
+     *
57
+     * @throws Exception in case of error.
58
+     */
59
+    public function get_by_entity_id_or_same_as( $uri ) {
60
+        // If the URL is in the local site URL, then try to find a corresponding post.
61
+        if ( 0 === strpos( $uri, site_url() ) ) {
62
+            return $this->get_by_entity_id( $uri );
63
+        }
64
+
65
+        // Otherwise look in sameAs.
66
+        global $wpdb;
67
+
68
+        $row = $wpdb->get_row(
69
+            $wpdb->prepare(
70
+                "
71 71
 			SELECT content_type, content_id
72 72
 			FROM (
73 73
 			    SELECT %d AS content_type, post_id AS content_id
@@ -84,84 +84,84 @@  discard block
 block discarded – undo
84 84
 			) _tmp_same_as 
85 85
 			LIMIT 1
86 86
 		",
87
-				Object_Type_Enum::POST,
88
-				$uri,
89
-				Object_Type_Enum::TERM,
90
-				$uri,
91
-				Object_Type_Enum::USER,
92
-				$uri
93
-			)
94
-		);
95
-
96
-		if ( ! isset( $row ) ) {
97
-			return null;
98
-		}
99
-
100
-		switch ( (int) $row->content_type ) {
101
-			case Object_Type_Enum::POST:
102
-				return new Wordpress_Content( get_post( $row->content_id ) );
103
-			case Object_Type_Enum::TERM:
104
-				return new Wordpress_Content( get_term( $row->content_id ) );
105
-			case Object_Type_Enum::USER:
106
-				return new Wordpress_Content( get_user_by( 'ID', $row->content_id ) );
107
-			default:
108
-				return null;
109
-		}
110
-
111
-	}
112
-
113
-	/**
114
-	 * @param Wordpress_Content_Id $content_id
115
-	 *
116
-	 * @return string|void|null
117
-	 */
118
-	public function get_entity_id( $content_id ) {
119
-		$type = $content_id->get_type();
120
-		$id   = $content_id->get_id();
121
-
122
-		switch ( $type ) {
123
-			case Object_Type_Enum::POST:
124
-				$base_uri = get_permalink( $id );
125
-				break;
126
-			case Object_Type_Enum::TERM:
127
-				$base_uri = get_term_link( $id );
128
-				break;
129
-			case Object_Type_Enum::USER:
130
-				$base_uri = get_author_posts_url( $id );
131
-				break;
132
-			default:
133
-				return null;
134
-		}
135
-
136
-		$type_name = Object_Type_Enum::to_string( $type );
137
-
138
-		return "$base_uri#$type_name/$id";
139
-	}
140
-
141
-	// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
142
-	public function set_entity_id( $content_id, $uri ) {
143
-		// do nothing.
144
-	}
145
-
146
-	/**
147
-	 * @param Wordpress_Content_Id $content_id
148
-	 *
149
-	 * @return bool|void
150
-	 */
151
-	public function supports( $content_id ) {
152
-		return in_array(
153
-			$content_id->get_type(),
154
-			array(
155
-				Object_Type_Enum::POST,
156
-				Object_Type_Enum::TERM,
157
-				Object_Type_Enum::USER,
158
-			),
159
-			true
160
-		);
161
-	}
162
-
163
-	// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
164
-	public function delete( $content_id ) {
165
-		// Ignore, we don't store any data.
166
-	}
87
+                Object_Type_Enum::POST,
88
+                $uri,
89
+                Object_Type_Enum::TERM,
90
+                $uri,
91
+                Object_Type_Enum::USER,
92
+                $uri
93
+            )
94
+        );
95
+
96
+        if ( ! isset( $row ) ) {
97
+            return null;
98
+        }
99
+
100
+        switch ( (int) $row->content_type ) {
101
+            case Object_Type_Enum::POST:
102
+                return new Wordpress_Content( get_post( $row->content_id ) );
103
+            case Object_Type_Enum::TERM:
104
+                return new Wordpress_Content( get_term( $row->content_id ) );
105
+            case Object_Type_Enum::USER:
106
+                return new Wordpress_Content( get_user_by( 'ID', $row->content_id ) );
107
+            default:
108
+                return null;
109
+        }
110
+
111
+    }
112
+
113
+    /**
114
+     * @param Wordpress_Content_Id $content_id
115
+     *
116
+     * @return string|void|null
117
+     */
118
+    public function get_entity_id( $content_id ) {
119
+        $type = $content_id->get_type();
120
+        $id   = $content_id->get_id();
121
+
122
+        switch ( $type ) {
123
+            case Object_Type_Enum::POST:
124
+                $base_uri = get_permalink( $id );
125
+                break;
126
+            case Object_Type_Enum::TERM:
127
+                $base_uri = get_term_link( $id );
128
+                break;
129
+            case Object_Type_Enum::USER:
130
+                $base_uri = get_author_posts_url( $id );
131
+                break;
132
+            default:
133
+                return null;
134
+        }
135
+
136
+        $type_name = Object_Type_Enum::to_string( $type );
137
+
138
+        return "$base_uri#$type_name/$id";
139
+    }
140
+
141
+    // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
142
+    public function set_entity_id( $content_id, $uri ) {
143
+        // do nothing.
144
+    }
145
+
146
+    /**
147
+     * @param Wordpress_Content_Id $content_id
148
+     *
149
+     * @return bool|void
150
+     */
151
+    public function supports( $content_id ) {
152
+        return in_array(
153
+            $content_id->get_type(),
154
+            array(
155
+                Object_Type_Enum::POST,
156
+                Object_Type_Enum::TERM,
157
+                Object_Type_Enum::USER,
158
+            ),
159
+            true
160
+        );
161
+    }
162
+
163
+    // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
164
+    public function delete( $content_id ) {
165
+        // Ignore, we don't store any data.
166
+    }
167 167
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @return Content_Service
21 21
 	 */
22 22
 	public static function get_instance() {
23
-		if ( ! isset( self::$instance ) ) {
23
+		if ( ! isset(self::$instance)) {
24 24
 			self::$instance = new self();
25 25
 		}
26 26
 
@@ -32,20 +32,20 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @return Wordpress_Content|null
34 34
 	 */
35
-	public function get_by_entity_id( $uri ) {
36
-		if ( ! preg_match( '@.*#(\w+)/(\d+)@', $uri, $matches ) ) {
35
+	public function get_by_entity_id($uri) {
36
+		if ( ! preg_match('@.*#(\w+)/(\d+)@', $uri, $matches)) {
37 37
 			return null;
38 38
 		}
39 39
 
40 40
 		$type_name = $matches[1];
41 41
 		$id        = $matches[2];
42
-		switch ( Object_Type_Enum::from_string( $type_name ) ) {
42
+		switch (Object_Type_Enum::from_string($type_name)) {
43 43
 			case Object_Type_Enum::POST:
44
-				return new Wordpress_Content( get_post( $id ) );
44
+				return new Wordpress_Content(get_post($id));
45 45
 			case Object_Type_Enum::TERM:
46
-				return new Wordpress_Content( get_term( $id ) );
46
+				return new Wordpress_Content(get_term($id));
47 47
 			case Object_Type_Enum::USER:
48
-				return new Wordpress_Content( get_user_by( 'ID', $id ) );
48
+				return new Wordpress_Content(get_user_by('ID', $id));
49 49
 		}
50 50
 
51 51
 		return null;
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 	 *
57 57
 	 * @throws Exception in case of error.
58 58
 	 */
59
-	public function get_by_entity_id_or_same_as( $uri ) {
59
+	public function get_by_entity_id_or_same_as($uri) {
60 60
 		// If the URL is in the local site URL, then try to find a corresponding post.
61
-		if ( 0 === strpos( $uri, site_url() ) ) {
62
-			return $this->get_by_entity_id( $uri );
61
+		if (0 === strpos($uri, site_url())) {
62
+			return $this->get_by_entity_id($uri);
63 63
 		}
64 64
 
65 65
 		// Otherwise look in sameAs.
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 			)
94 94
 		);
95 95
 
96
-		if ( ! isset( $row ) ) {
96
+		if ( ! isset($row)) {
97 97
 			return null;
98 98
 		}
99 99
 
100
-		switch ( (int) $row->content_type ) {
100
+		switch ((int) $row->content_type) {
101 101
 			case Object_Type_Enum::POST:
102
-				return new Wordpress_Content( get_post( $row->content_id ) );
102
+				return new Wordpress_Content(get_post($row->content_id));
103 103
 			case Object_Type_Enum::TERM:
104
-				return new Wordpress_Content( get_term( $row->content_id ) );
104
+				return new Wordpress_Content(get_term($row->content_id));
105 105
 			case Object_Type_Enum::USER:
106
-				return new Wordpress_Content( get_user_by( 'ID', $row->content_id ) );
106
+				return new Wordpress_Content(get_user_by('ID', $row->content_id));
107 107
 			default:
108 108
 				return null;
109 109
 		}
@@ -115,31 +115,31 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @return string|void|null
117 117
 	 */
118
-	public function get_entity_id( $content_id ) {
118
+	public function get_entity_id($content_id) {
119 119
 		$type = $content_id->get_type();
120 120
 		$id   = $content_id->get_id();
121 121
 
122
-		switch ( $type ) {
122
+		switch ($type) {
123 123
 			case Object_Type_Enum::POST:
124
-				$base_uri = get_permalink( $id );
124
+				$base_uri = get_permalink($id);
125 125
 				break;
126 126
 			case Object_Type_Enum::TERM:
127
-				$base_uri = get_term_link( $id );
127
+				$base_uri = get_term_link($id);
128 128
 				break;
129 129
 			case Object_Type_Enum::USER:
130
-				$base_uri = get_author_posts_url( $id );
130
+				$base_uri = get_author_posts_url($id);
131 131
 				break;
132 132
 			default:
133 133
 				return null;
134 134
 		}
135 135
 
136
-		$type_name = Object_Type_Enum::to_string( $type );
136
+		$type_name = Object_Type_Enum::to_string($type);
137 137
 
138 138
 		return "$base_uri#$type_name/$id";
139 139
 	}
140 140
 
141 141
 	// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
142
-	public function set_entity_id( $content_id, $uri ) {
142
+	public function set_entity_id($content_id, $uri) {
143 143
 		// do nothing.
144 144
 	}
145 145
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return bool|void
150 150
 	 */
151
-	public function supports( $content_id ) {
151
+	public function supports($content_id) {
152 152
 		return in_array(
153 153
 			$content_id->get_type(),
154 154
 			array(
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	}
162 162
 
163 163
 	// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
164
-	public function delete( $content_id ) {
164
+	public function delete($content_id) {
165 165
 		// Ignore, we don't store any data.
166 166
 	}
167 167
 }
Please login to merge, or discard this patch.