Completed
Pull Request — master (#1641)
by Naveen
01:35
created
src/admin/class-wordlift-admin-entity-taxonomy-list-page.php 2 patches
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -28,107 +28,107 @@  discard block
 block discarded – undo
28 28
  */
29 29
 class Wordlift_Admin_Entity_Taxonomy_List_Page {
30 30
 
31
-	/**
32
-	 * Hook to `wl_entity_type_row_actions` to add an "action" link to Thread
33
-	 * SEO related settings for the term.
34
-	 *
35
-	 * @see   https://developer.wordpress.org/reference/hooks/taxonomy_row_actions/
36
-	 *
37
-	 * @since 3.11.0
38
-	 *
39
-	 * @param array  $actions An array of action links to be displayed. Default
40
-	 *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
41
-	 * @param object $term    Term object.
42
-	 *
43
-	 * @return array  $actions An array of action links to be displayed. Default
44
-	 *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
45
-	 */
46
-	public function wl_entity_type_row_actions( $actions, $term ) {
47
-
48
-		$url               = admin_url( "admin.php?page=wl_entity_type_settings&tag_ID=$term->term_id" );
49
-		$actions['wl-seo'] = '<a href="' . esc_url( $url ) . '">' . __( 'SEO Settings', 'wordlift' ) . '</a>';
50
-
51
-		// Hacks for pre 4.7 compatibility:
52
-		// * remove the quick edit.
53
-		unset( $actions['inline hide-if-no-js'] );
54
-		// * remove the edit link.
55
-		unset( $actions['edit'] );
56
-
57
-		return $actions;
58
-	}
59
-
60
-	/**
61
-	 * Override the capabilities related to managing the entity type terms
62
-	 * for multisite super admin to prevent it from manipulating it in any
63
-	 * way.
64
-	 *
65
-	 * @since 3.12.0
66
-	 *
67
-	 * @param array  $caps    The user's current capabilities.
68
-	 * @param string $cap     Capability name.
69
-	 *
70
-	 * @return array    Array containing the do_not_allow capability for super admin
71
-	 *                  when editing and deleting entity type terms capabilities
72
-	 *                    are being "approved"
73
-	 */
74
-	public function restrict_super_admin( $caps, $cap ) {
75
-
76
-		switch ( $cap ) {
77
-			case 'wl_entity_type_edit_term':
78
-			case 'wl_entity_type_delete_term':
79
-				$caps[] = 'do_not_allow';
80
-		}
81
-
82
-		return $caps;
83
-	}
84
-
85
-	/**
86
-	 * Override the capabilities related to managing the entity type terms
87
-	 * required for WordPress < 4.7 to get access to the admin page.
88
-	 *
89
-	 * Before 4.7, WordPress checks whether the user has permission to access
90
-	 * the `edit-tags.php` page. So we need to provide temporary the permission
91
-	 * otherwise the user will get an `access not allowed` when trying to access
92
-	 * the page.
93
-	 *
94
-	 * @see   https://github.com/insideout10/wordlift-plugin/issues/512
95
-	 *
96
-	 * @since 3.12.0
97
-	 *
98
-	 * @param array  $caps    The user's current capabilities.
99
-	 * @param string $cap     Capability name.
100
-	 *
101
-	 * @return array    Array containing the manage_options capability
102
-	 */
103
-	public function enable_admin_access_pre_47( $caps, $cap ) {
104
-
105
-		// Bail out if we're not dealing with the `wl_entity_type_edit_term`
106
-		// capability.
107
-		if ( 'wl_entity_type_edit_term' !== $cap || ! isset( $_SERVER['REQUEST_URI'] ) ) {
108
-			return $caps;
109
-		}
110
-
111
-		$path = wp_parse_url( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) ) );
112
-
113
-		// Bail out if the `path` cannot be determined.
114
-		if ( null === $path ) {
115
-			return $caps;
116
-		}
117
-
118
-		// Bail out if a specific term is being handled.
119
-		if ( isset( $_REQUEST['action'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
120
-			return $caps;
121
-		}
122
-
123
-		// Split the path and check if the page is the `edit-tags.php`. We can't
124
-		// use WP's own function because this is called very early.
125
-		$components = explode( '/', $path );
126
-		if ( 'edit-tags.php' !== $components[ count( $components ) - 1 ] ) {
127
-			return $caps;
128
-		}
129
-
130
-		// Give permission to the user.
131
-		return array( 'manage_options' );
132
-	}
31
+    /**
32
+     * Hook to `wl_entity_type_row_actions` to add an "action" link to Thread
33
+     * SEO related settings for the term.
34
+     *
35
+     * @see   https://developer.wordpress.org/reference/hooks/taxonomy_row_actions/
36
+     *
37
+     * @since 3.11.0
38
+     *
39
+     * @param array  $actions An array of action links to be displayed. Default
40
+     *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
41
+     * @param object $term    Term object.
42
+     *
43
+     * @return array  $actions An array of action links to be displayed. Default
44
+     *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
45
+     */
46
+    public function wl_entity_type_row_actions( $actions, $term ) {
47
+
48
+        $url               = admin_url( "admin.php?page=wl_entity_type_settings&tag_ID=$term->term_id" );
49
+        $actions['wl-seo'] = '<a href="' . esc_url( $url ) . '">' . __( 'SEO Settings', 'wordlift' ) . '</a>';
50
+
51
+        // Hacks for pre 4.7 compatibility:
52
+        // * remove the quick edit.
53
+        unset( $actions['inline hide-if-no-js'] );
54
+        // * remove the edit link.
55
+        unset( $actions['edit'] );
56
+
57
+        return $actions;
58
+    }
59
+
60
+    /**
61
+     * Override the capabilities related to managing the entity type terms
62
+     * for multisite super admin to prevent it from manipulating it in any
63
+     * way.
64
+     *
65
+     * @since 3.12.0
66
+     *
67
+     * @param array  $caps    The user's current capabilities.
68
+     * @param string $cap     Capability name.
69
+     *
70
+     * @return array    Array containing the do_not_allow capability for super admin
71
+     *                  when editing and deleting entity type terms capabilities
72
+     *                    are being "approved"
73
+     */
74
+    public function restrict_super_admin( $caps, $cap ) {
75
+
76
+        switch ( $cap ) {
77
+            case 'wl_entity_type_edit_term':
78
+            case 'wl_entity_type_delete_term':
79
+                $caps[] = 'do_not_allow';
80
+        }
81
+
82
+        return $caps;
83
+    }
84
+
85
+    /**
86
+     * Override the capabilities related to managing the entity type terms
87
+     * required for WordPress < 4.7 to get access to the admin page.
88
+     *
89
+     * Before 4.7, WordPress checks whether the user has permission to access
90
+     * the `edit-tags.php` page. So we need to provide temporary the permission
91
+     * otherwise the user will get an `access not allowed` when trying to access
92
+     * the page.
93
+     *
94
+     * @see   https://github.com/insideout10/wordlift-plugin/issues/512
95
+     *
96
+     * @since 3.12.0
97
+     *
98
+     * @param array  $caps    The user's current capabilities.
99
+     * @param string $cap     Capability name.
100
+     *
101
+     * @return array    Array containing the manage_options capability
102
+     */
103
+    public function enable_admin_access_pre_47( $caps, $cap ) {
104
+
105
+        // Bail out if we're not dealing with the `wl_entity_type_edit_term`
106
+        // capability.
107
+        if ( 'wl_entity_type_edit_term' !== $cap || ! isset( $_SERVER['REQUEST_URI'] ) ) {
108
+            return $caps;
109
+        }
110
+
111
+        $path = wp_parse_url( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) ) );
112
+
113
+        // Bail out if the `path` cannot be determined.
114
+        if ( null === $path ) {
115
+            return $caps;
116
+        }
117
+
118
+        // Bail out if a specific term is being handled.
119
+        if ( isset( $_REQUEST['action'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
120
+            return $caps;
121
+        }
122
+
123
+        // Split the path and check if the page is the `edit-tags.php`. We can't
124
+        // use WP's own function because this is called very early.
125
+        $components = explode( '/', $path );
126
+        if ( 'edit-tags.php' !== $components[ count( $components ) - 1 ] ) {
127
+            return $caps;
128
+        }
129
+
130
+        // Give permission to the user.
131
+        return array( 'manage_options' );
132
+    }
133 133
 
134 134
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @since      3.11.0
13 13
  */
14 14
 
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 	 * @return array  $actions An array of action links to be displayed. Default
44 44
 	 *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
45 45
 	 */
46
-	public function wl_entity_type_row_actions( $actions, $term ) {
46
+	public function wl_entity_type_row_actions($actions, $term) {
47 47
 
48
-		$url               = admin_url( "admin.php?page=wl_entity_type_settings&tag_ID=$term->term_id" );
49
-		$actions['wl-seo'] = '<a href="' . esc_url( $url ) . '">' . __( 'SEO Settings', 'wordlift' ) . '</a>';
48
+		$url               = admin_url("admin.php?page=wl_entity_type_settings&tag_ID=$term->term_id");
49
+		$actions['wl-seo'] = '<a href="'.esc_url($url).'">'.__('SEO Settings', 'wordlift').'</a>';
50 50
 
51 51
 		// Hacks for pre 4.7 compatibility:
52 52
 		// * remove the quick edit.
53
-		unset( $actions['inline hide-if-no-js'] );
53
+		unset($actions['inline hide-if-no-js']);
54 54
 		// * remove the edit link.
55
-		unset( $actions['edit'] );
55
+		unset($actions['edit']);
56 56
 
57 57
 		return $actions;
58 58
 	}
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
 	 *                  when editing and deleting entity type terms capabilities
72 72
 	 *                    are being "approved"
73 73
 	 */
74
-	public function restrict_super_admin( $caps, $cap ) {
74
+	public function restrict_super_admin($caps, $cap) {
75 75
 
76
-		switch ( $cap ) {
76
+		switch ($cap) {
77 77
 			case 'wl_entity_type_edit_term':
78 78
 			case 'wl_entity_type_delete_term':
79 79
 				$caps[] = 'do_not_allow';
@@ -100,35 +100,35 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @return array    Array containing the manage_options capability
102 102
 	 */
103
-	public function enable_admin_access_pre_47( $caps, $cap ) {
103
+	public function enable_admin_access_pre_47($caps, $cap) {
104 104
 
105 105
 		// Bail out if we're not dealing with the `wl_entity_type_edit_term`
106 106
 		// capability.
107
-		if ( 'wl_entity_type_edit_term' !== $cap || ! isset( $_SERVER['REQUEST_URI'] ) ) {
107
+		if ('wl_entity_type_edit_term' !== $cap || ! isset($_SERVER['REQUEST_URI'])) {
108 108
 			return $caps;
109 109
 		}
110 110
 
111
-		$path = wp_parse_url( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) ) );
111
+		$path = wp_parse_url(esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'], PHP_URL_PATH)));
112 112
 
113 113
 		// Bail out if the `path` cannot be determined.
114
-		if ( null === $path ) {
114
+		if (null === $path) {
115 115
 			return $caps;
116 116
 		}
117 117
 
118 118
 		// Bail out if a specific term is being handled.
119
-		if ( isset( $_REQUEST['action'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
119
+		if (isset($_REQUEST['action'])) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
120 120
 			return $caps;
121 121
 		}
122 122
 
123 123
 		// Split the path and check if the page is the `edit-tags.php`. We can't
124 124
 		// use WP's own function because this is called very early.
125
-		$components = explode( '/', $path );
126
-		if ( 'edit-tags.php' !== $components[ count( $components ) - 1 ] ) {
125
+		$components = explode('/', $path);
126
+		if ('edit-tags.php' !== $components[count($components) - 1]) {
127 127
 			return $caps;
128 128
 		}
129 129
 
130 130
 		// Give permission to the user.
131
-		return array( 'manage_options' );
131
+		return array('manage_options');
132 132
 	}
133 133
 
134 134
 }
Please login to merge, or discard this patch.
src/admin/class-wordlift-admin-not-enriched-filter.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -2,60 +2,60 @@
 block discarded – undo
2 2
 
3 3
 class Wordlift_Admin_Not_Enriched_Filter {
4 4
 
5
-	const PARAMETER_NAME = 'wl_enriched';
5
+    const PARAMETER_NAME = 'wl_enriched';
6 6
 
7
-	public function __construct() {
7
+    public function __construct() {
8 8
 
9
-		// Hook to `views_edit-post`.
10
-		add_filter( 'views_edit-post', array( $this, 'view_edit' ) );
9
+        // Hook to `views_edit-post`.
10
+        add_filter( 'views_edit-post', array( $this, 'view_edit' ) );
11 11
 
12
-		// Add the `posts_where` filter if the filter is active.
13
-		if ( $this->is_filter_active() ) {
14
-			add_filter( 'posts_where', array( $this, 'posts_where' ) );
15
-		}
12
+        // Add the `posts_where` filter if the filter is active.
13
+        if ( $this->is_filter_active() ) {
14
+            add_filter( 'posts_where', array( $this, 'posts_where' ) );
15
+        }
16 16
 
17
-	}
17
+    }
18 18
 
19
-	public function posts_where( $where ) {
20
-		global $wpdb;
19
+    public function posts_where( $where ) {
20
+        global $wpdb;
21 21
 
22
-		return $where .
23
-			   " AND {$wpdb->posts}.ID NOT IN ( SELECT DISTINCT subject_id FROM {$wpdb->prefix}wl_relation_instances )";
24
-	}
22
+        return $where .
23
+                " AND {$wpdb->posts}.ID NOT IN ( SELECT DISTINCT subject_id FROM {$wpdb->prefix}wl_relation_instances )";
24
+    }
25 25
 
26
-	public function view_edit( $views ) {
27
-		global $wpdb;
26
+    public function view_edit( $views ) {
27
+        global $wpdb;
28 28
 
29
-		$url = add_query_arg(
30
-			array(
31
-				self::PARAMETER_NAME => 'no',
32
-				'post_type'          => 'post',
33
-			),
34
-			'edit.php'
35
-		);
29
+        $url = add_query_arg(
30
+            array(
31
+                self::PARAMETER_NAME => 'no',
32
+                'post_type'          => 'post',
33
+            ),
34
+            'edit.php'
35
+        );
36 36
 
37
-		$not_enriched_count = $wpdb->get_var(
38
-			"
37
+        $not_enriched_count = $wpdb->get_var(
38
+            "
39 39
 SELECT COUNT( 1 ) FROM $wpdb->posts p
40 40
  WHERE p.post_type = 'post'
41 41
    AND p.post_status <> 'trash' 
42 42
    AND p.post_status <> 'auto-draft'
43 43
    AND p.ID NOT IN ( SELECT DISTINCT subject_id FROM {$wpdb->prefix}wl_relation_instances )
44 44
 "
45
-		);
45
+        );
46 46
 
47
-		$link = '<a href="'
48
-				. esc_url( $url ) . '"'
49
-				. ( $this->is_filter_active() ? ' class="current" aria-current="page"' : '' )
50
-				. '>' . esc_html( __( 'Not enriched', 'wordlift' ) ) . '</a> (' . $not_enriched_count . ')';
47
+        $link = '<a href="'
48
+                . esc_url( $url ) . '"'
49
+                . ( $this->is_filter_active() ? ' class="current" aria-current="page"' : '' )
50
+                . '>' . esc_html( __( 'Not enriched', 'wordlift' ) ) . '</a> (' . $not_enriched_count . ')';
51 51
 
52
-		$views['wl_not_enriched'] = $link;
52
+        $views['wl_not_enriched'] = $link;
53 53
 
54
-		return $views;
55
-	}
54
+        return $views;
55
+    }
56 56
 
57
-	public function is_filter_active() {
58
-		return 'no' === filter_input( INPUT_GET, self::PARAMETER_NAME );
59
-	}
57
+    public function is_filter_active() {
58
+        return 'no' === filter_input( INPUT_GET, self::PARAMETER_NAME );
59
+    }
60 60
 
61 61
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,23 +7,23 @@  discard block
 block discarded – undo
7 7
 	public function __construct() {
8 8
 
9 9
 		// Hook to `views_edit-post`.
10
-		add_filter( 'views_edit-post', array( $this, 'view_edit' ) );
10
+		add_filter('views_edit-post', array($this, 'view_edit'));
11 11
 
12 12
 		// Add the `posts_where` filter if the filter is active.
13
-		if ( $this->is_filter_active() ) {
14
-			add_filter( 'posts_where', array( $this, 'posts_where' ) );
13
+		if ($this->is_filter_active()) {
14
+			add_filter('posts_where', array($this, 'posts_where'));
15 15
 		}
16 16
 
17 17
 	}
18 18
 
19
-	public function posts_where( $where ) {
19
+	public function posts_where($where) {
20 20
 		global $wpdb;
21 21
 
22
-		return $where .
22
+		return $where.
23 23
 			   " AND {$wpdb->posts}.ID NOT IN ( SELECT DISTINCT subject_id FROM {$wpdb->prefix}wl_relation_instances )";
24 24
 	}
25 25
 
26
-	public function view_edit( $views ) {
26
+	public function view_edit($views) {
27 27
 		global $wpdb;
28 28
 
29 29
 		$url = add_query_arg(
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 		);
46 46
 
47 47
 		$link = '<a href="'
48
-				. esc_url( $url ) . '"'
49
-				. ( $this->is_filter_active() ? ' class="current" aria-current="page"' : '' )
50
-				. '>' . esc_html( __( 'Not enriched', 'wordlift' ) ) . '</a> (' . $not_enriched_count . ')';
48
+				. esc_url($url).'"'
49
+				. ($this->is_filter_active() ? ' class="current" aria-current="page"' : '')
50
+				. '>'.esc_html(__('Not enriched', 'wordlift')).'</a> ('.$not_enriched_count.')';
51 51
 
52 52
 		$views['wl_not_enriched'] = $link;
53 53
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	public function is_filter_active() {
58
-		return 'no' === filter_input( INPUT_GET, self::PARAMETER_NAME );
58
+		return 'no' === filter_input(INPUT_GET, self::PARAMETER_NAME);
59 59
 	}
60 60
 
61 61
 }
Please login to merge, or discard this patch.
src/admin/class-wordlift-admin-mappings-page.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -16,36 +16,36 @@
 block discarded – undo
16 16
  */
17 17
 class Wordlift_Admin_Mappings_Page extends Wordlift_Admin_Page {
18 18
 
19
-	/**
20
-	 * {@inheritdoc}
21
-	 */
22
-	public function get_page_title() {
19
+    /**
20
+     * {@inheritdoc}
21
+     */
22
+    public function get_page_title() {
23 23
 
24
-		return __( 'Schema.org Types', 'wordlift' );
25
-	}
24
+        return __( 'Schema.org Types', 'wordlift' );
25
+    }
26 26
 
27
-	/**
28
-	 * {@inheritdoc}
29
-	 */
30
-	public function get_menu_title() {
27
+    /**
28
+     * {@inheritdoc}
29
+     */
30
+    public function get_menu_title() {
31 31
 
32
-		return __( 'Schema.org Types', 'wordlift' );
33
-	}
32
+        return __( 'Schema.org Types', 'wordlift' );
33
+    }
34 34
 
35
-	/**
36
-	 * {@inheritdoc}
37
-	 */
38
-	public function get_menu_slug() {
35
+    /**
36
+     * {@inheritdoc}
37
+     */
38
+    public function get_menu_slug() {
39 39
 
40
-		return 'wl_mappings';
41
-	}
40
+        return 'wl_mappings';
41
+    }
42 42
 
43
-	/**
44
-	 * {@inheritdoc}
45
-	 */
46
-	public function get_partial_name() {
43
+    /**
44
+     * {@inheritdoc}
45
+     */
46
+    public function get_partial_name() {
47 47
 
48
-		return 'wordlift-admin-mappings-page.php';
49
-	}
48
+        return 'wordlift-admin-mappings-page.php';
49
+    }
50 50
 
51 51
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function get_page_title() {
23 23
 
24
-		return __( 'Schema.org Types', 'wordlift' );
24
+		return __('Schema.org Types', 'wordlift');
25 25
 	}
26 26
 
27 27
 	/**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function get_menu_title() {
31 31
 
32
-		return __( 'Schema.org Types', 'wordlift' );
32
+		return __('Schema.org Types', 'wordlift');
33 33
 	}
34 34
 
35 35
 	/**
Please login to merge, or discard this patch.
src/admin/class-wordlift-dashboard-service.php 2 patches
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -18,107 +18,107 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Dashboard_Service {
20 20
 
21
-	/**
22
-	 * Transient Name
23
-	 *
24
-	 * @since  3.4.0
25
-	 */
26
-	const TRANSIENT_NAME = 'wl_dashboard_stats';
27
-
28
-	/**
29
-	 * Transient Expiration (in seconds)
30
-	 *
31
-	 * @since  3.4.0
32
-	 */
33
-	const TRANSIENT_EXPIRATION = 86400;
34
-
35
-	/**
36
-	 * A {@link Wordlift_Rating_Service} instance.
37
-	 *
38
-	 * @since  3.10.0
39
-	 * @access private
40
-	 * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
41
-	 */
42
-	private $rating_service;
43
-
44
-	/**
45
-	 * The {@link Wordlift_Entity_Service} instance.
46
-	 *
47
-	 * @since  3.15.0
48
-	 * @access private
49
-	 * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
50
-	 */
51
-	private $entity_service;
52
-
53
-	/**
54
-	 * Create a Wordlift_Entity_List_Service.
55
-	 *
56
-	 * @since 3.4.0
57
-	 */
58
-	protected function __construct() {
59
-
60
-		$this->rating_service = Wordlift_Rating_Service::get_instance();
61
-		$this->entity_service = Wordlift_Entity_Service::get_instance();
62
-
63
-	}
64
-
65
-	private static $instance;
66
-
67
-	public static function get_instance() {
68
-		if ( ! isset( self::$instance ) ) {
69
-			self::$instance = new self();
70
-		}
71
-
72
-		return self::$instance;
73
-	}
74
-
75
-	/**
76
-	 * Return stats layout
77
-	 *
78
-	 * @since 3.4.0
79
-	 */
21
+    /**
22
+     * Transient Name
23
+     *
24
+     * @since  3.4.0
25
+     */
26
+    const TRANSIENT_NAME = 'wl_dashboard_stats';
27
+
28
+    /**
29
+     * Transient Expiration (in seconds)
30
+     *
31
+     * @since  3.4.0
32
+     */
33
+    const TRANSIENT_EXPIRATION = 86400;
34
+
35
+    /**
36
+     * A {@link Wordlift_Rating_Service} instance.
37
+     *
38
+     * @since  3.10.0
39
+     * @access private
40
+     * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance.
41
+     */
42
+    private $rating_service;
43
+
44
+    /**
45
+     * The {@link Wordlift_Entity_Service} instance.
46
+     *
47
+     * @since  3.15.0
48
+     * @access private
49
+     * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
50
+     */
51
+    private $entity_service;
52
+
53
+    /**
54
+     * Create a Wordlift_Entity_List_Service.
55
+     *
56
+     * @since 3.4.0
57
+     */
58
+    protected function __construct() {
59
+
60
+        $this->rating_service = Wordlift_Rating_Service::get_instance();
61
+        $this->entity_service = Wordlift_Entity_Service::get_instance();
62
+
63
+    }
64
+
65
+    private static $instance;
66
+
67
+    public static function get_instance() {
68
+        if ( ! isset( self::$instance ) ) {
69
+            self::$instance = new self();
70
+        }
71
+
72
+        return self::$instance;
73
+    }
74
+
75
+    /**
76
+     * Return stats layout
77
+     *
78
+     * @since 3.4.0
79
+     */
80 80
     // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
81
-	public function dashboard_widget_callback( $post ) {
82
-		$caption_kses           = array( 'a' => array( 'href' => array() ) );
83
-		$enriched_posts_title   = __( 'enriched posts', 'wordlift' );
84
-		$enriched_posts_caption = sprintf(
85
-			wp_kses(
86
-				/* translators: 1: Percentage of annotated posts, 2: Link to the edit screen, 3: Number of annotated posts, 4: Total posts. */
87
-				__( '%1$s, of your <a href="%2$s">posts</a> are annotated. This means %3$s annotated posts on %4$s.', 'wordlift' ),
88
-				array( 'a' => array( 'href' => array() ) )
89
-			),
90
-			$this->render_stat_param( 'annotatedPostsPercentage' ),
91
-			esc_url( admin_url( 'edit.php' ) ),
92
-			$this->render_stat_param( 'annotated_posts' ),
93
-			$this->render_stat_param( 'posts' )
94
-		);
95
-
96
-		$rating_title   = __( 'average entity rating', 'wordlift' );
97
-		$rating_caption = sprintf(
98
-			wp_kses(
99
-					/* translators: 1: The entities count, 2: The link to the vocabulary, 3: The average rating. */
100
-				__( 'You have %1$s entities in your <a href="%2$s">vocabulary</a> with an average rating of %3$s.', 'wordlift' ),
101
-				array( 'a' => array( 'href' => array() ) )
102
-			),
103
-			$this->render_stat_param( 'entities' ),
104
-			esc_url( admin_url( 'edit.php?post_type=entity' ) ),
105
-			$this->render_stat_param( 'rating' )
106
-		);
107
-
108
-		$graph_title   = __( 'triples in your graph', 'wordlift' );
109
-		$graph_caption = sprintf(
110
-			wp_kses(
111
-					/* translators: 1: The percentage of the graph size compared to Wikidata, 2: The link to Wikidata. */
112
-				__( 'Your graphs size corresponds to %1$s of <a href="%2$s">Wikidata</a>.', 'wordlift' ),
113
-				array( 'a' => array( 'href' => array() ) )
114
-			),
115
-			$this->render_stat_param( 'wikidata' ),
116
-			esc_url( 'https://www.wikidata.org/' )
117
-		);
118
-
119
-		$triples_label = __( 'triples', 'wordlift' );
120
-
121
-		?>
81
+    public function dashboard_widget_callback( $post ) {
82
+        $caption_kses           = array( 'a' => array( 'href' => array() ) );
83
+        $enriched_posts_title   = __( 'enriched posts', 'wordlift' );
84
+        $enriched_posts_caption = sprintf(
85
+            wp_kses(
86
+                /* translators: 1: Percentage of annotated posts, 2: Link to the edit screen, 3: Number of annotated posts, 4: Total posts. */
87
+                __( '%1$s, of your <a href="%2$s">posts</a> are annotated. This means %3$s annotated posts on %4$s.', 'wordlift' ),
88
+                array( 'a' => array( 'href' => array() ) )
89
+            ),
90
+            $this->render_stat_param( 'annotatedPostsPercentage' ),
91
+            esc_url( admin_url( 'edit.php' ) ),
92
+            $this->render_stat_param( 'annotated_posts' ),
93
+            $this->render_stat_param( 'posts' )
94
+        );
95
+
96
+        $rating_title   = __( 'average entity rating', 'wordlift' );
97
+        $rating_caption = sprintf(
98
+            wp_kses(
99
+                    /* translators: 1: The entities count, 2: The link to the vocabulary, 3: The average rating. */
100
+                __( 'You have %1$s entities in your <a href="%2$s">vocabulary</a> with an average rating of %3$s.', 'wordlift' ),
101
+                array( 'a' => array( 'href' => array() ) )
102
+            ),
103
+            $this->render_stat_param( 'entities' ),
104
+            esc_url( admin_url( 'edit.php?post_type=entity' ) ),
105
+            $this->render_stat_param( 'rating' )
106
+        );
107
+
108
+        $graph_title   = __( 'triples in your graph', 'wordlift' );
109
+        $graph_caption = sprintf(
110
+            wp_kses(
111
+                    /* translators: 1: The percentage of the graph size compared to Wikidata, 2: The link to Wikidata. */
112
+                __( 'Your graphs size corresponds to %1$s of <a href="%2$s">Wikidata</a>.', 'wordlift' ),
113
+                array( 'a' => array( 'href' => array() ) )
114
+            ),
115
+            $this->render_stat_param( 'wikidata' ),
116
+            esc_url( 'https://www.wikidata.org/' )
117
+        );
118
+
119
+        $triples_label = __( 'triples', 'wordlift' );
120
+
121
+        ?>
122 122
 		<div id="wl-dashboard-widget-inner-wrapper">
123 123
 			<div class="wl-stat-card">
124 124
 				<div class="wl-stat-graph-wrapper">
@@ -157,114 +157,114 @@  discard block
 block discarded – undo
157 157
 		</div>
158 158
 		<?php
159 159
 
160
-	}
161
-
162
-	/**
163
-	 * Return stats
164
-	 *
165
-	 * @since 3.4.0
166
-	 */
167
-	public function add_dashboard_widgets() {
168
-		wp_add_dashboard_widget(
169
-			'wordlift-dashboard-widget',
170
-			'WordLift Dashboard',
171
-			array(
172
-				$this,
173
-				'dashboard_widget_callback',
174
-			)
175
-		);
176
-	}
177
-
178
-	/**
179
-	 * Return stats
180
-	 *
181
-	 * @uses  https://codex.wordpress.org/Function_Reference/set_transient
182
-	 *
183
-	 * @since 3.4.0
184
-	 */
185
-	public function ajax_get_stats() {
186
-
187
-		// If needed, the transient is force to reloaded.
188
-		if ( isset( $_GET['force_reload'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
189
-			delete_transient( self::TRANSIENT_NAME );
190
-		}
191
-
192
-		// Try to retrieve the transient
193
-		$stats = get_transient( self::TRANSIENT_NAME );
194
-
195
-		if ( ! $stats ) {
196
-			// Calculate stats
197
-			$count_triples = $this->count_triples();
198
-			$stats         = array(
199
-				'entities'        => $this->entity_service->count(),
200
-				'posts'           => $this->count_posts(),
201
-				'annotated_posts' => $this->count_annotated_posts(),
202
-				'triples'         => $count_triples ? $count_triples : '-',
203
-				'rating'          => $this->average_entities_rating(),
204
-			);
205
-			// Cache stats results trough transient
206
-			set_transient( self::TRANSIENT_NAME, $stats, self::TRANSIENT_EXPIRATION );
207
-		}
208
-		// Return stats as json object
209
-		wl_core_send_json( $stats );
210
-	}
211
-
212
-	/**
213
-	 * Calculate total number of published posts
214
-	 *
215
-	 * @uses  https://codex.wordpress.org/it:Riferimento_funzioni/wp_count_posts
216
-	 * @since 3.4.0
217
-	 *
218
-	 * @return int Total number of published posts.
219
-	 */
220
-	public function count_posts() {
221
-
222
-		return (int) wp_count_posts()->publish;
223
-	}
224
-
225
-	/**
226
-	 * Calculate total number of annotated published posts
227
-	 *
228
-	 * @return int Total number of annotated published posts.
229
-	 * @since 3.4.0
230
-	 */
231
-	public function count_annotated_posts() {
232
-
233
-		// Prepare interaction with db
234
-		global $wpdb;
235
-		// Retrieve Wordlift relation instances table name
236
-		// $table_name = wl_core_get_relation_instances_table_name();
237
-		// Calculate sql statement
238
-
239
-		// Perform the query
240
-		return (int) $wpdb->get_var(
241
-			"SELECT COUNT(distinct(p.id)) FROM $wpdb->posts as p JOIN {$wpdb->prefix}wl_relation_instances as r ON p.id = r.subject_id AND p.post_type = 'post' AND p.post_status = 'publish'"
242
-		);
243
-
244
-	}
245
-
246
-	/**
247
-	 * Calculate the average entities rating.
248
-	 *
249
-	 * @return int Average entities rating.
250
-	 * @since 3.4.0
251
-	 *
252
-	 * @since 3.20.0 this method is public.
253
-	 */
254
-	public function average_entities_rating() {
255
-
256
-		// Prepare interaction with db
257
-		global $wpdb;
258
-
259
-		// Perform the query.
260
-		return $this->rating_service->convert_raw_score_to_percentage(
261
-			$wpdb->get_var(
262
-				$wpdb->prepare(
263
-					"SELECT AVG(meta_value) FROM $wpdb->postmeta where meta_key = %s",
264
-					Wordlift_Rating_Service::RATING_RAW_SCORE_META_KEY
265
-				)
266
-			)
267
-		);
268
-	}
160
+    }
161
+
162
+    /**
163
+     * Return stats
164
+     *
165
+     * @since 3.4.0
166
+     */
167
+    public function add_dashboard_widgets() {
168
+        wp_add_dashboard_widget(
169
+            'wordlift-dashboard-widget',
170
+            'WordLift Dashboard',
171
+            array(
172
+                $this,
173
+                'dashboard_widget_callback',
174
+            )
175
+        );
176
+    }
177
+
178
+    /**
179
+     * Return stats
180
+     *
181
+     * @uses  https://codex.wordpress.org/Function_Reference/set_transient
182
+     *
183
+     * @since 3.4.0
184
+     */
185
+    public function ajax_get_stats() {
186
+
187
+        // If needed, the transient is force to reloaded.
188
+        if ( isset( $_GET['force_reload'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
189
+            delete_transient( self::TRANSIENT_NAME );
190
+        }
191
+
192
+        // Try to retrieve the transient
193
+        $stats = get_transient( self::TRANSIENT_NAME );
194
+
195
+        if ( ! $stats ) {
196
+            // Calculate stats
197
+            $count_triples = $this->count_triples();
198
+            $stats         = array(
199
+                'entities'        => $this->entity_service->count(),
200
+                'posts'           => $this->count_posts(),
201
+                'annotated_posts' => $this->count_annotated_posts(),
202
+                'triples'         => $count_triples ? $count_triples : '-',
203
+                'rating'          => $this->average_entities_rating(),
204
+            );
205
+            // Cache stats results trough transient
206
+            set_transient( self::TRANSIENT_NAME, $stats, self::TRANSIENT_EXPIRATION );
207
+        }
208
+        // Return stats as json object
209
+        wl_core_send_json( $stats );
210
+    }
211
+
212
+    /**
213
+     * Calculate total number of published posts
214
+     *
215
+     * @uses  https://codex.wordpress.org/it:Riferimento_funzioni/wp_count_posts
216
+     * @since 3.4.0
217
+     *
218
+     * @return int Total number of published posts.
219
+     */
220
+    public function count_posts() {
221
+
222
+        return (int) wp_count_posts()->publish;
223
+    }
224
+
225
+    /**
226
+     * Calculate total number of annotated published posts
227
+     *
228
+     * @return int Total number of annotated published posts.
229
+     * @since 3.4.0
230
+     */
231
+    public function count_annotated_posts() {
232
+
233
+        // Prepare interaction with db
234
+        global $wpdb;
235
+        // Retrieve Wordlift relation instances table name
236
+        // $table_name = wl_core_get_relation_instances_table_name();
237
+        // Calculate sql statement
238
+
239
+        // Perform the query
240
+        return (int) $wpdb->get_var(
241
+            "SELECT COUNT(distinct(p.id)) FROM $wpdb->posts as p JOIN {$wpdb->prefix}wl_relation_instances as r ON p.id = r.subject_id AND p.post_type = 'post' AND p.post_status = 'publish'"
242
+        );
243
+
244
+    }
245
+
246
+    /**
247
+     * Calculate the average entities rating.
248
+     *
249
+     * @return int Average entities rating.
250
+     * @since 3.4.0
251
+     *
252
+     * @since 3.20.0 this method is public.
253
+     */
254
+    public function average_entities_rating() {
255
+
256
+        // Prepare interaction with db
257
+        global $wpdb;
258
+
259
+        // Perform the query.
260
+        return $this->rating_service->convert_raw_score_to_percentage(
261
+            $wpdb->get_var(
262
+                $wpdb->prepare(
263
+                    "SELECT AVG(meta_value) FROM $wpdb->postmeta where meta_key = %s",
264
+                    Wordlift_Rating_Service::RATING_RAW_SCORE_META_KEY
265
+                )
266
+            )
267
+        );
268
+    }
269 269
 
270 270
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	private static $instance;
66 66
 
67 67
 	public static function get_instance() {
68
-		if ( ! isset( self::$instance ) ) {
68
+		if ( ! isset(self::$instance)) {
69 69
 			self::$instance = new self();
70 70
 		}
71 71
 
@@ -78,62 +78,62 @@  discard block
 block discarded – undo
78 78
 	 * @since 3.4.0
79 79
 	 */
80 80
     // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
81
-	public function dashboard_widget_callback( $post ) {
82
-		$caption_kses           = array( 'a' => array( 'href' => array() ) );
83
-		$enriched_posts_title   = __( 'enriched posts', 'wordlift' );
81
+	public function dashboard_widget_callback($post) {
82
+		$caption_kses           = array('a' => array('href' => array()));
83
+		$enriched_posts_title   = __('enriched posts', 'wordlift');
84 84
 		$enriched_posts_caption = sprintf(
85 85
 			wp_kses(
86 86
 				/* translators: 1: Percentage of annotated posts, 2: Link to the edit screen, 3: Number of annotated posts, 4: Total posts. */
87
-				__( '%1$s, of your <a href="%2$s">posts</a> are annotated. This means %3$s annotated posts on %4$s.', 'wordlift' ),
88
-				array( 'a' => array( 'href' => array() ) )
87
+				__('%1$s, of your <a href="%2$s">posts</a> are annotated. This means %3$s annotated posts on %4$s.', 'wordlift'),
88
+				array('a' => array('href' => array()))
89 89
 			),
90
-			$this->render_stat_param( 'annotatedPostsPercentage' ),
91
-			esc_url( admin_url( 'edit.php' ) ),
92
-			$this->render_stat_param( 'annotated_posts' ),
93
-			$this->render_stat_param( 'posts' )
90
+			$this->render_stat_param('annotatedPostsPercentage'),
91
+			esc_url(admin_url('edit.php')),
92
+			$this->render_stat_param('annotated_posts'),
93
+			$this->render_stat_param('posts')
94 94
 		);
95 95
 
96
-		$rating_title   = __( 'average entity rating', 'wordlift' );
96
+		$rating_title   = __('average entity rating', 'wordlift');
97 97
 		$rating_caption = sprintf(
98 98
 			wp_kses(
99 99
 					/* translators: 1: The entities count, 2: The link to the vocabulary, 3: The average rating. */
100
-				__( 'You have %1$s entities in your <a href="%2$s">vocabulary</a> with an average rating of %3$s.', 'wordlift' ),
101
-				array( 'a' => array( 'href' => array() ) )
100
+				__('You have %1$s entities in your <a href="%2$s">vocabulary</a> with an average rating of %3$s.', 'wordlift'),
101
+				array('a' => array('href' => array()))
102 102
 			),
103
-			$this->render_stat_param( 'entities' ),
104
-			esc_url( admin_url( 'edit.php?post_type=entity' ) ),
105
-			$this->render_stat_param( 'rating' )
103
+			$this->render_stat_param('entities'),
104
+			esc_url(admin_url('edit.php?post_type=entity')),
105
+			$this->render_stat_param('rating')
106 106
 		);
107 107
 
108
-		$graph_title   = __( 'triples in your graph', 'wordlift' );
108
+		$graph_title   = __('triples in your graph', 'wordlift');
109 109
 		$graph_caption = sprintf(
110 110
 			wp_kses(
111 111
 					/* translators: 1: The percentage of the graph size compared to Wikidata, 2: The link to Wikidata. */
112
-				__( 'Your graphs size corresponds to %1$s of <a href="%2$s">Wikidata</a>.', 'wordlift' ),
113
-				array( 'a' => array( 'href' => array() ) )
112
+				__('Your graphs size corresponds to %1$s of <a href="%2$s">Wikidata</a>.', 'wordlift'),
113
+				array('a' => array('href' => array()))
114 114
 			),
115
-			$this->render_stat_param( 'wikidata' ),
116
-			esc_url( 'https://www.wikidata.org/' )
115
+			$this->render_stat_param('wikidata'),
116
+			esc_url('https://www.wikidata.org/')
117 117
 		);
118 118
 
119
-		$triples_label = __( 'triples', 'wordlift' );
119
+		$triples_label = __('triples', 'wordlift');
120 120
 
121 121
 		?>
122 122
 		<div id="wl-dashboard-widget-inner-wrapper">
123 123
 			<div class="wl-stat-card">
124 124
 				<div class="wl-stat-graph-wrapper">
125
-					<h4><?php echo esc_html( $enriched_posts_title ); ?> <a
125
+					<h4><?php echo esc_html($enriched_posts_title); ?> <a
126 126
 								href="http://docs.wordlift.it/en/latest/faq.html#what-is-content-enrichment"
127 127
 								target="_blank"><i class="wl-info"></i></a></h4>
128 128
 					<svg id="wl-posts-pie-chart" viewBox="0 0 32 32">
129 129
 						<circle r="16" cx="16" cy="16"/>
130 130
 					</svg>
131 131
 				</div>
132
-				<p><?php echo wp_kses( $enriched_posts_caption, $caption_kses ); ?> </p>
132
+				<p><?php echo wp_kses($enriched_posts_caption, $caption_kses); ?> </p>
133 133
 			</div>
134 134
 			<div class="wl-stat-card">
135 135
 				<div class="wl-stat-graph-wrapper">
136
-					<h4><?php echo esc_html( $rating_title ); ?> <a
136
+					<h4><?php echo esc_html($rating_title); ?> <a
137 137
 								href="http://docs.wordlift.it/en/latest/faq.html#what-factors-determine-the-rating-of-an-entity"
138 138
 								target="_blank"><i class="wl-info"></i></a></h4>
139 139
 					<svg id="wl-entities-gauge-chart" viewBox="0 0 32 32">
@@ -141,18 +141,18 @@  discard block
 block discarded – undo
141 141
 						<circle r="16" cx="16" cy="16" class="stat"/>
142 142
 					</svg>
143 143
 				</div>
144
-				<p><?php echo wp_kses( $rating_caption, $caption_kses ); ?></p>
144
+				<p><?php echo wp_kses($rating_caption, $caption_kses); ?></p>
145 145
 			</div>
146 146
 			<div class="wl-stat-card">
147 147
 				<div class="wl-stat-graph-wrapper">
148
-					<h4><?php echo esc_html( $graph_title ); ?><a href="http://docs.wordlift.it/en/latest/faq.html#what-is-a-triple"
148
+					<h4><?php echo esc_html($graph_title); ?><a href="http://docs.wordlift.it/en/latest/faq.html#what-is-a-triple"
149 149
 										target="_blank"><i class="wl-info"></i></a></h4>
150 150
 					<div class="wl-triples">
151 151
 						<span id="wl-dashboard-widget-triples"></span>
152
-						<span class="wl-triples-label"><?php echo esc_html( $triples_label ); ?></span>
152
+						<span class="wl-triples-label"><?php echo esc_html($triples_label); ?></span>
153 153
 					</div>
154 154
 				</div>
155
-				<p><?php echo wp_kses( $graph_caption, $caption_kses ); ?></p>
155
+				<p><?php echo wp_kses($graph_caption, $caption_kses); ?></p>
156 156
 			</div>
157 157
 		</div>
158 158
 		<?php
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
 	public function ajax_get_stats() {
186 186
 
187 187
 		// If needed, the transient is force to reloaded.
188
-		if ( isset( $_GET['force_reload'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
189
-			delete_transient( self::TRANSIENT_NAME );
188
+		if (isset($_GET['force_reload'])) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
189
+			delete_transient(self::TRANSIENT_NAME);
190 190
 		}
191 191
 
192 192
 		// Try to retrieve the transient
193
-		$stats = get_transient( self::TRANSIENT_NAME );
193
+		$stats = get_transient(self::TRANSIENT_NAME);
194 194
 
195
-		if ( ! $stats ) {
195
+		if ( ! $stats) {
196 196
 			// Calculate stats
197 197
 			$count_triples = $this->count_triples();
198 198
 			$stats         = array(
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
 				'rating'          => $this->average_entities_rating(),
204 204
 			);
205 205
 			// Cache stats results trough transient
206
-			set_transient( self::TRANSIENT_NAME, $stats, self::TRANSIENT_EXPIRATION );
206
+			set_transient(self::TRANSIENT_NAME, $stats, self::TRANSIENT_EXPIRATION);
207 207
 		}
208 208
 		// Return stats as json object
209
-		wl_core_send_json( $stats );
209
+		wl_core_send_json($stats);
210 210
 	}
211 211
 
212 212
 	/**
Please login to merge, or discard this patch.
src/admin/class-wordlift-primashop-adapter.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -7,32 +7,32 @@
 block discarded – undo
7 7
  */
8 8
 class Wordlift_PrimaShop_Adapter {
9 9
 
10
-	/**
11
-	 * Create a Wordlift_PrimaShop_Adapter instance.
12
-	 *
13
-	 * @since 3.2.3
14
-	 */
15
-	public function __construct() {
10
+    /**
11
+     * Create a Wordlift_PrimaShop_Adapter instance.
12
+     *
13
+     * @since 3.2.3
14
+     */
15
+    public function __construct() {
16 16
 
17
-		// Tell WP (and PrimaShop) that we support the *prima-layout-settings*. This will display the Content Settings
18
-		// in the entity edit page.
19
-		add_post_type_support( Wordlift_Entity_Service::TYPE_NAME, 'prima-layout-settings' );
17
+        // Tell WP (and PrimaShop) that we support the *prima-layout-settings*. This will display the Content Settings
18
+        // in the entity edit page.
19
+        add_post_type_support( Wordlift_Entity_Service::TYPE_NAME, 'prima-layout-settings' );
20 20
 
21
-	}
21
+    }
22 22
 
23
-	/**
24
-	 * Intercept the <em>prima_metabox_entity_header_args</em> filter and return what a call to the related <em>post</em>
25
-	 * would have returned.
26
-	 *
27
-	 * @since 3.2.3
28
-	 *
29
-	 * @param array $meta The meta array.
30
-	 *
31
-	 * @return array A meta array.
32
-	 */
33
-	public function prima_metabox_entity_header_args( $meta ) {
23
+    /**
24
+     * Intercept the <em>prima_metabox_entity_header_args</em> filter and return what a call to the related <em>post</em>
25
+     * would have returned.
26
+     *
27
+     * @since 3.2.3
28
+     *
29
+     * @param array $meta The meta array.
30
+     *
31
+     * @return array A meta array.
32
+     */
33
+    public function prima_metabox_entity_header_args( $meta ) {
34 34
 
35
-		return apply_filters( 'prima_metabox_post_header_args', $meta, 'post' );
36
-	}
35
+        return apply_filters( 'prima_metabox_post_header_args', $meta, 'post' );
36
+    }
37 37
 
38 38
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 		// Tell WP (and PrimaShop) that we support the *prima-layout-settings*. This will display the Content Settings
18 18
 		// in the entity edit page.
19
-		add_post_type_support( Wordlift_Entity_Service::TYPE_NAME, 'prima-layout-settings' );
19
+		add_post_type_support(Wordlift_Entity_Service::TYPE_NAME, 'prima-layout-settings');
20 20
 
21 21
 	}
22 22
 
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return array A meta array.
32 32
 	 */
33
-	public function prima_metabox_entity_header_args( $meta ) {
33
+	public function prima_metabox_entity_header_args($meta) {
34 34
 
35
-		return apply_filters( 'prima_metabox_post_header_args', $meta, 'post' );
35
+		return apply_filters('prima_metabox_post_header_args', $meta, 'post');
36 36
 	}
37 37
 
38 38
 }
Please login to merge, or discard this patch.
src/admin/class-wordlift-entity-type-admin-service.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -20,82 +20,82 @@
 block discarded – undo
20 20
  */
21 21
 class Wordlift_Entity_Type_Admin_Service {
22 22
 
23
-	/**
24
-	 * Create a {@link Wordlift_Entity_List_Service} instance.
25
-	 *
26
-	 * Set up the relevant filters and actions.
27
-	 *
28
-	 * @since 3.15.0
29
-	 */
30
-	public function __construct() {
23
+    /**
24
+     * Create a {@link Wordlift_Entity_List_Service} instance.
25
+     *
26
+     * Set up the relevant filters and actions.
27
+     *
28
+     * @since 3.15.0
29
+     */
30
+    public function __construct() {
31 31
 
32
-		add_action( 'admin_init', array( $this, 'hide_entity_type_metabox' ) );
33
-		add_action(
34
-			'admin_init',
35
-			array(
36
-				$this,
37
-				'set_filters_to_hide_entity_type_from_lists',
38
-			)
39
-		);
40
-	}
32
+        add_action( 'admin_init', array( $this, 'hide_entity_type_metabox' ) );
33
+        add_action(
34
+            'admin_init',
35
+            array(
36
+                $this,
37
+                'set_filters_to_hide_entity_type_from_lists',
38
+            )
39
+        );
40
+    }
41 41
 
42
-	/**
43
-	 * Hide the entity type metabox from non entity edit screens if user is not
44
-	 * allowed to configure entity types.
45
-	 *
46
-	 * @since 3.15.0
47
-	 */
48
-	public function hide_entity_type_metabox() {
42
+    /**
43
+     * Hide the entity type metabox from non entity edit screens if user is not
44
+     * allowed to configure entity types.
45
+     *
46
+     * @since 3.15.0
47
+     */
48
+    public function hide_entity_type_metabox() {
49 49
 
50
-		// Bail out if the user can edit entities.
51
-		if ( current_user_can( 'edit_wordlift_entity' ) ) {
52
-			return;
53
-		}
50
+        // Bail out if the user can edit entities.
51
+        if ( current_user_can( 'edit_wordlift_entity' ) ) {
52
+            return;
53
+        }
54 54
 
55
-		// Loop over all the non entity post types which support entities and turn off the metabox.
56
-		foreach ( $this->get_types_no_entity() as $type ) {
57
-			remove_meta_box( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . 'div', $type, 'side' );
58
-		}
55
+        // Loop over all the non entity post types which support entities and turn off the metabox.
56
+        foreach ( $this->get_types_no_entity() as $type ) {
57
+            remove_meta_box( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . 'div', $type, 'side' );
58
+        }
59 59
 
60
-	}
60
+    }
61 61
 
62
-	/**
63
-	 * Hide the entity type metabox from non entity list screens if user is not
64
-	 * allowed to configure entity types.
65
-	 *
66
-	 * @since 3.15.0
67
-	 */
68
-	public function set_filters_to_hide_entity_type_from_lists() {
62
+    /**
63
+     * Hide the entity type metabox from non entity list screens if user is not
64
+     * allowed to configure entity types.
65
+     *
66
+     * @since 3.15.0
67
+     */
68
+    public function set_filters_to_hide_entity_type_from_lists() {
69 69
 
70
-		// Bail out if the user can edit entities.
71
-		if ( current_user_can( 'edit_wordlift_entity' ) ) {
72
-			return;
73
-		}
70
+        // Bail out if the user can edit entities.
71
+        if ( current_user_can( 'edit_wordlift_entity' ) ) {
72
+            return;
73
+        }
74 74
 
75
-		// Loop over all the non entity post types which support entities and turn off the taxonomy column.
76
-		foreach ( $this->get_types_no_entity() as $type ) {
77
-			add_filter(
78
-				'manage_taxonomies_for_' . $type . '_columns',
79
-				function ( $taxonomies ) {
80
-					unset( $taxonomies[ Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ] );
75
+        // Loop over all the non entity post types which support entities and turn off the taxonomy column.
76
+        foreach ( $this->get_types_no_entity() as $type ) {
77
+            add_filter(
78
+                'manage_taxonomies_for_' . $type . '_columns',
79
+                function ( $taxonomies ) {
80
+                    unset( $taxonomies[ Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ] );
81 81
 
82
-					return $taxonomies;
83
-				}
84
-			);
85
-		}
82
+                    return $taxonomies;
83
+                }
84
+            );
85
+        }
86 86
 
87
-	}
87
+    }
88 88
 
89
-	/**
90
-	 * Get the types which are not the entity post type.
91
-	 *
92
-	 * @since 3.15.0
93
-	 *
94
-	 * @return array An array of types' names.
95
-	 */
96
-	private function get_types_no_entity() {
89
+    /**
90
+     * Get the types which are not the entity post type.
91
+     *
92
+     * @since 3.15.0
93
+     *
94
+     * @return array An array of types' names.
95
+     */
96
+    private function get_types_no_entity() {
97 97
 
98
-		return array_diff( Wordlift_Entity_Service::valid_entity_post_types(), (array) Wordlift_Entity_Service::TYPE_NAME );
99
-	}
98
+        return array_diff( Wordlift_Entity_Service::valid_entity_post_types(), (array) Wordlift_Entity_Service::TYPE_NAME );
99
+    }
100 100
 
101 101
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function __construct() {
31 31
 
32
-		add_action( 'admin_init', array( $this, 'hide_entity_type_metabox' ) );
32
+		add_action('admin_init', array($this, 'hide_entity_type_metabox'));
33 33
 		add_action(
34 34
 			'admin_init',
35 35
 			array(
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 	public function hide_entity_type_metabox() {
49 49
 
50 50
 		// Bail out if the user can edit entities.
51
-		if ( current_user_can( 'edit_wordlift_entity' ) ) {
51
+		if (current_user_can('edit_wordlift_entity')) {
52 52
 			return;
53 53
 		}
54 54
 
55 55
 		// Loop over all the non entity post types which support entities and turn off the metabox.
56
-		foreach ( $this->get_types_no_entity() as $type ) {
57
-			remove_meta_box( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . 'div', $type, 'side' );
56
+		foreach ($this->get_types_no_entity() as $type) {
57
+			remove_meta_box(Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME.'div', $type, 'side');
58 58
 		}
59 59
 
60 60
 	}
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
 	public function set_filters_to_hide_entity_type_from_lists() {
69 69
 
70 70
 		// Bail out if the user can edit entities.
71
-		if ( current_user_can( 'edit_wordlift_entity' ) ) {
71
+		if (current_user_can('edit_wordlift_entity')) {
72 72
 			return;
73 73
 		}
74 74
 
75 75
 		// Loop over all the non entity post types which support entities and turn off the taxonomy column.
76
-		foreach ( $this->get_types_no_entity() as $type ) {
76
+		foreach ($this->get_types_no_entity() as $type) {
77 77
 			add_filter(
78
-				'manage_taxonomies_for_' . $type . '_columns',
79
-				function ( $taxonomies ) {
80
-					unset( $taxonomies[ Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ] );
78
+				'manage_taxonomies_for_'.$type.'_columns',
79
+				function($taxonomies) {
80
+					unset($taxonomies[Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME]);
81 81
 
82 82
 					return $taxonomies;
83 83
 				}
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	private function get_types_no_entity() {
97 97
 
98
-		return array_diff( Wordlift_Entity_Service::valid_entity_post_types(), (array) Wordlift_Entity_Service::TYPE_NAME );
98
+		return array_diff(Wordlift_Entity_Service::valid_entity_post_types(), (array) Wordlift_Entity_Service::TYPE_NAME);
99 99
 	}
100 100
 
101 101
 }
Please login to merge, or discard this patch.
src/admin/wordlift-admin-edit-post.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -16,37 +16,37 @@
 block discarded – undo
16 16
  */
17 17
 function wl_admin_permalink_html( $html, $post_id ) {
18 18
 
19
-	// Get the entity service instance.
20
-	$entity_service = Wordlift_Entity_Service::get_instance();
19
+    // Get the entity service instance.
20
+    $entity_service = Wordlift_Entity_Service::get_instance();
21 21
 
22
-	// Show the View Linked Data button only for entities.
23
-	//
24
-	// See https://github.com/insideout10/wordlift-plugin/issues/668.
25
-	$uri = $entity_service->get_uri( $post_id );
26
-	if ( 'publish' === get_post_status( $post_id ) && $uri ) {
22
+    // Show the View Linked Data button only for entities.
23
+    //
24
+    // See https://github.com/insideout10/wordlift-plugin/issues/668.
25
+    $uri = $entity_service->get_uri( $post_id );
26
+    if ( 'publish' === get_post_status( $post_id ) && $uri ) {
27 27
 
28
-		$lod_view_href = esc_attr( $uri );
29
-		/*
28
+        $lod_view_href = esc_attr( $uri );
29
+        /*
30 30
 		 * Add the `.html` extension to the link to have Chrome open the html version instead of RDF one.
31 31
 		 *
32 32
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/931
33 33
 		 * @since 3.21.1
34 34
 		 */
35
-		// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
36
-		$html .= apply_filters( 'wl_feature__enable__view-linked-data', true ) ? "<span id='view-post-btn'><a href='$lod_view_href.html' class='button button-small wl-button' target='_blank'>" .
37
-						  esc_html__( 'View Linked Data', 'wordlift' ) .
38
-						  "</a></span>\n" : '';
35
+        // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
36
+        $html .= apply_filters( 'wl_feature__enable__view-linked-data', true ) ? "<span id='view-post-btn'><a href='$lod_view_href.html' class='button button-small wl-button' target='_blank'>" .
37
+                            esc_html__( 'View Linked Data', 'wordlift' ) .
38
+                            "</a></span>\n" : '';
39 39
 
40
-	}
40
+    }
41 41
 
42
-	// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
43
-	$html .= apply_filters( 'wl_feature__enable__test-sd', true ) ? "<span id='view-post-btn'><a href='" . WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL .
44
-			rawurlencode( get_permalink( $post_id ) ) .
45
-			 "' class='button button-small wl-button' target='_blank'>" .
46
-			 esc_html__( 'Test Google Rich Snippets', 'wordlift' ) .
47
-			 "</a></span>\n" : '';
42
+    // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
43
+    $html .= apply_filters( 'wl_feature__enable__test-sd', true ) ? "<span id='view-post-btn'><a href='" . WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL .
44
+            rawurlencode( get_permalink( $post_id ) ) .
45
+                "' class='button button-small wl-button' target='_blank'>" .
46
+                esc_html__( 'Test Google Rich Snippets', 'wordlift' ) .
47
+                "</a></span>\n" : '';
48 48
 
49
-	return $html;
49
+    return $html;
50 50
 }
51 51
 
52 52
 add_filter( 'get_sample_permalink_html', 'wl_admin_permalink_html', PHP_INT_MAX, 2 );
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  *
15 15
  * @return string The enhanced html.
16 16
  */
17
-function wl_admin_permalink_html( $html, $post_id ) {
17
+function wl_admin_permalink_html($html, $post_id) {
18 18
 
19 19
 	// Get the entity service instance.
20 20
 	$entity_service = Wordlift_Entity_Service::get_instance();
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
 	// Show the View Linked Data button only for entities.
23 23
 	//
24 24
 	// See https://github.com/insideout10/wordlift-plugin/issues/668.
25
-	$uri = $entity_service->get_uri( $post_id );
26
-	if ( 'publish' === get_post_status( $post_id ) && $uri ) {
25
+	$uri = $entity_service->get_uri($post_id);
26
+	if ('publish' === get_post_status($post_id) && $uri) {
27 27
 
28
-		$lod_view_href = esc_attr( $uri );
28
+		$lod_view_href = esc_attr($uri);
29 29
 		/*
30 30
 		 * Add the `.html` extension to the link to have Chrome open the html version instead of RDF one.
31 31
 		 *
@@ -33,20 +33,20 @@  discard block
 block discarded – undo
33 33
 		 * @since 3.21.1
34 34
 		 */
35 35
 		// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
36
-		$html .= apply_filters( 'wl_feature__enable__view-linked-data', true ) ? "<span id='view-post-btn'><a href='$lod_view_href.html' class='button button-small wl-button' target='_blank'>" .
37
-						  esc_html__( 'View Linked Data', 'wordlift' ) .
36
+		$html .= apply_filters('wl_feature__enable__view-linked-data', true) ? "<span id='view-post-btn'><a href='$lod_view_href.html' class='button button-small wl-button' target='_blank'>".
37
+						  esc_html__('View Linked Data', 'wordlift').
38 38
 						  "</a></span>\n" : '';
39 39
 
40 40
 	}
41 41
 
42 42
 	// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
43
-	$html .= apply_filters( 'wl_feature__enable__test-sd', true ) ? "<span id='view-post-btn'><a href='" . WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL .
44
-			rawurlencode( get_permalink( $post_id ) ) .
45
-			 "' class='button button-small wl-button' target='_blank'>" .
46
-			 esc_html__( 'Test Google Rich Snippets', 'wordlift' ) .
43
+	$html .= apply_filters('wl_feature__enable__test-sd', true) ? "<span id='view-post-btn'><a href='".WL_CONFIG_TEST_GOOGLE_RICH_SNIPPETS_URL.
44
+			rawurlencode(get_permalink($post_id)).
45
+			 "' class='button button-small wl-button' target='_blank'>".
46
+			 esc_html__('Test Google Rich Snippets', 'wordlift').
47 47
 			 "</a></span>\n" : '';
48 48
 
49 49
 	return $html;
50 50
 }
51 51
 
52
-add_filter( 'get_sample_permalink_html', 'wl_admin_permalink_html', PHP_INT_MAX, 2 );
52
+add_filter('get_sample_permalink_html', 'wl_admin_permalink_html', PHP_INT_MAX, 2);
Please login to merge, or discard this patch.
src/admin/class-wordlift-admin-download-your-data-page.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 		// Add a callback to our 'page' function.
56 56
 		add_submenu_page(
57 57
 			'wl_admin_menu',
58
-			_x( 'Download Your Data', 'Page title', 'wordlift' ),
59
-			_x( 'Download Your Data', 'Menu title', 'wordlift' ),
58
+			_x('Download Your Data', 'Page title', 'wordlift'),
59
+			_x('Download Your Data', 'Menu title', 'wordlift'),
60 60
 			'manage_options',
61 61
 			'wl_download_your_data',
62
-			array( $this, 'page' )
62
+			array($this, 'page')
63 63
 		);
64 64
 
65 65
 	}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	public function page() {
73 73
 
74 74
 		// Include the partial.
75
-		include plugin_dir_path( __FILE__ ) . 'partials/wordlift-admin-download-your-data.php';
75
+		include plugin_dir_path(__FILE__).'partials/wordlift-admin-download-your-data.php';
76 76
 
77 77
 	}
78 78
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		$default_api_service = Default_Api_Service::get_instance();
87 87
 
88 88
 		// Avoid PHP notices when buffer is empty.
89
-		if ( ob_get_contents() ) {
89
+		if (ob_get_contents()) {
90 90
 			ob_end_clean();
91 91
 		}
92 92
 
@@ -94,44 +94,44 @@  discard block
 block discarded – undo
94 94
 		$suffix = 'json';
95 95
 
96 96
 		// Check if there is suffix.
97
-		if ( isset( $_GET['out'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
98
-			$suffix = sanitize_text_field( wp_unslash( $_GET['out'] ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended
97
+		if (isset($_GET['out'])) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
98
+			$suffix = sanitize_text_field(wp_unslash($_GET['out'])); //phpcs:ignore WordPress.Security.NonceVerification.Recommended
99 99
 		}
100 100
 
101 101
 		// Create filename.
102
-		$filename = 'dataset.' . $suffix;
102
+		$filename = 'dataset.'.$suffix;
103 103
 
104
-		if ( ! in_array( $suffix, $this->allowed_formats, true ) ) {
104
+		if ( ! in_array($suffix, $this->allowed_formats, true)) {
105 105
 			// The file type is not from allowed types.
106
-			wp_die( esc_html__( 'The format is not supported.', 'wordlift' ) );
106
+			wp_die(esc_html__('The format is not supported.', 'wordlift'));
107 107
 		}
108 108
 
109
-		$accept_header_format = $this->allowed_headers[ $suffix ];
109
+		$accept_header_format = $this->allowed_headers[$suffix];
110 110
 
111 111
 		$headers = array(
112 112
 			'Accept' => $accept_header_format,
113 113
 		);
114 114
 
115
-		$response = $default_api_service->get( '/dataset/export', $headers );
115
+		$response = $default_api_service->get('/dataset/export', $headers);
116 116
 
117 117
 		$response = $response->get_response();
118 118
 
119 119
 		if (
120
-			is_wp_error( $response ) ||
120
+			is_wp_error($response) ||
121 121
 			200 !== (int) $response['response']['code']
122 122
 		) {
123 123
 			// Something is not working properly, so display error message.
124
-			wp_die( esc_html__( 'There was an error trying to connect to the server. Please try again later.', 'wordlift' ) );
124
+			wp_die(esc_html__('There was an error trying to connect to the server. Please try again later.', 'wordlift'));
125 125
 		}
126 126
 
127 127
 		// Get response body.
128
-		$body     = wp_remote_retrieve_body( $response );
129
-		$type     = wp_remote_retrieve_header( $response, 'content-type' );
130
-		$filename = 'dataset-' . gmdate( 'Y-m-d-H-i-s' ) . '.' . $suffix;
128
+		$body     = wp_remote_retrieve_body($response);
129
+		$type     = wp_remote_retrieve_header($response, 'content-type');
130
+		$filename = 'dataset-'.gmdate('Y-m-d-H-i-s').'.'.$suffix;
131 131
 
132 132
 		// Add proper file headers.
133
-		header( "Content-Disposition: attachment; filename=$filename" );
134
-		header( "Content-Type: $type" );
133
+		header("Content-Disposition: attachment; filename=$filename");
134
+		header("Content-Type: $type");
135 135
 
136 136
 		/*
137 137
 		 * Echo the response body. As this is not HTML we can not escape it
Please login to merge, or discard this patch.
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -18,128 +18,128 @@
 block discarded – undo
18 18
  * @since 3.6.0
19 19
  */
20 20
 class Wordlift_Admin_Download_Your_Data_Page {
21
-	/**
22
-	 * Used to check if the requested file is supported.
23
-	 *
24
-	 * @since  3.16.0
25
-	 * @access private
26
-	 * @var $allowed_formats array Allowed formats.
27
-	 */
28
-	private $allowed_formats = array(
29
-		'json',
30
-		'rdf',
31
-		'ttl',
32
-		'n3',
33
-	);
34
-
35
-	/**
36
-	 * The list of headers allowed by the endpoint.
37
-	 *
38
-	 * @since 3.28.2
39
-	 * @var string[]
40
-	 */
41
-	private $allowed_headers = array(
42
-		'json' => 'application/ld+json',
43
-		'rdf'  => 'application/rdf+xml',
44
-		'n3'   => 'text/n3',
45
-		'ttl'  => 'text/turtle',
46
-	);
47
-
48
-	/**
49
-	 * Hook to 'admin_menu' to add the 'Download Your Data' page.
50
-	 *
51
-	 * @since 3.6.0
52
-	 */
53
-	public function admin_menu() {
54
-
55
-		// Add a callback to our 'page' function.
56
-		add_submenu_page(
57
-			'wl_admin_menu',
58
-			_x( 'Download Your Data', 'Page title', 'wordlift' ),
59
-			_x( 'Download Your Data', 'Menu title', 'wordlift' ),
60
-			'manage_options',
61
-			'wl_download_your_data',
62
-			array( $this, 'page' )
63
-		);
64
-
65
-	}
66
-
67
-	/**
68
-	 * The admin menu callback to render the page.
69
-	 *
70
-	 * @since 3.6.0
71
-	 */
72
-	public function page() {
73
-
74
-		// Include the partial.
75
-		include plugin_dir_path( __FILE__ ) . 'partials/wordlift-admin-download-your-data.php';
76
-
77
-	}
78
-
79
-	/**
80
-	 * Ajax call to redirect to a download URL.
81
-	 *
82
-	 * @since 3.6.0
83
-	 */
84
-	public function download_your_data() {
85
-
86
-		$default_api_service = Default_Api_Service::get_instance();
87
-
88
-		// Avoid PHP notices when buffer is empty.
89
-		if ( ob_get_contents() ) {
90
-			ob_end_clean();
91
-		}
92
-
93
-		// Use json suffix by default.
94
-		$suffix = 'json';
95
-
96
-		// Check if there is suffix.
97
-		if ( isset( $_GET['out'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
98
-			$suffix = sanitize_text_field( wp_unslash( $_GET['out'] ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended
99
-		}
100
-
101
-		// Create filename.
102
-		$filename = 'dataset.' . $suffix;
103
-
104
-		if ( ! in_array( $suffix, $this->allowed_formats, true ) ) {
105
-			// The file type is not from allowed types.
106
-			wp_die( esc_html__( 'The format is not supported.', 'wordlift' ) );
107
-		}
108
-
109
-		$accept_header_format = $this->allowed_headers[ $suffix ];
110
-
111
-		$headers = array(
112
-			'Accept' => $accept_header_format,
113
-		);
114
-
115
-		$response = $default_api_service->get( '/dataset/export', $headers );
116
-
117
-		$response = $response->get_response();
118
-
119
-		if (
120
-			is_wp_error( $response ) ||
121
-			200 !== (int) $response['response']['code']
122
-		) {
123
-			// Something is not working properly, so display error message.
124
-			wp_die( esc_html__( 'There was an error trying to connect to the server. Please try again later.', 'wordlift' ) );
125
-		}
126
-
127
-		// Get response body.
128
-		$body     = wp_remote_retrieve_body( $response );
129
-		$type     = wp_remote_retrieve_header( $response, 'content-type' );
130
-		$filename = 'dataset-' . gmdate( 'Y-m-d-H-i-s' ) . '.' . $suffix;
131
-
132
-		// Add proper file headers.
133
-		header( "Content-Disposition: attachment; filename=$filename" );
134
-		header( "Content-Type: $type" );
135
-
136
-		/*
21
+    /**
22
+     * Used to check if the requested file is supported.
23
+     *
24
+     * @since  3.16.0
25
+     * @access private
26
+     * @var $allowed_formats array Allowed formats.
27
+     */
28
+    private $allowed_formats = array(
29
+        'json',
30
+        'rdf',
31
+        'ttl',
32
+        'n3',
33
+    );
34
+
35
+    /**
36
+     * The list of headers allowed by the endpoint.
37
+     *
38
+     * @since 3.28.2
39
+     * @var string[]
40
+     */
41
+    private $allowed_headers = array(
42
+        'json' => 'application/ld+json',
43
+        'rdf'  => 'application/rdf+xml',
44
+        'n3'   => 'text/n3',
45
+        'ttl'  => 'text/turtle',
46
+    );
47
+
48
+    /**
49
+     * Hook to 'admin_menu' to add the 'Download Your Data' page.
50
+     *
51
+     * @since 3.6.0
52
+     */
53
+    public function admin_menu() {
54
+
55
+        // Add a callback to our 'page' function.
56
+        add_submenu_page(
57
+            'wl_admin_menu',
58
+            _x( 'Download Your Data', 'Page title', 'wordlift' ),
59
+            _x( 'Download Your Data', 'Menu title', 'wordlift' ),
60
+            'manage_options',
61
+            'wl_download_your_data',
62
+            array( $this, 'page' )
63
+        );
64
+
65
+    }
66
+
67
+    /**
68
+     * The admin menu callback to render the page.
69
+     *
70
+     * @since 3.6.0
71
+     */
72
+    public function page() {
73
+
74
+        // Include the partial.
75
+        include plugin_dir_path( __FILE__ ) . 'partials/wordlift-admin-download-your-data.php';
76
+
77
+    }
78
+
79
+    /**
80
+     * Ajax call to redirect to a download URL.
81
+     *
82
+     * @since 3.6.0
83
+     */
84
+    public function download_your_data() {
85
+
86
+        $default_api_service = Default_Api_Service::get_instance();
87
+
88
+        // Avoid PHP notices when buffer is empty.
89
+        if ( ob_get_contents() ) {
90
+            ob_end_clean();
91
+        }
92
+
93
+        // Use json suffix by default.
94
+        $suffix = 'json';
95
+
96
+        // Check if there is suffix.
97
+        if ( isset( $_GET['out'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended
98
+            $suffix = sanitize_text_field( wp_unslash( $_GET['out'] ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended
99
+        }
100
+
101
+        // Create filename.
102
+        $filename = 'dataset.' . $suffix;
103
+
104
+        if ( ! in_array( $suffix, $this->allowed_formats, true ) ) {
105
+            // The file type is not from allowed types.
106
+            wp_die( esc_html__( 'The format is not supported.', 'wordlift' ) );
107
+        }
108
+
109
+        $accept_header_format = $this->allowed_headers[ $suffix ];
110
+
111
+        $headers = array(
112
+            'Accept' => $accept_header_format,
113
+        );
114
+
115
+        $response = $default_api_service->get( '/dataset/export', $headers );
116
+
117
+        $response = $response->get_response();
118
+
119
+        if (
120
+            is_wp_error( $response ) ||
121
+            200 !== (int) $response['response']['code']
122
+        ) {
123
+            // Something is not working properly, so display error message.
124
+            wp_die( esc_html__( 'There was an error trying to connect to the server. Please try again later.', 'wordlift' ) );
125
+        }
126
+
127
+        // Get response body.
128
+        $body     = wp_remote_retrieve_body( $response );
129
+        $type     = wp_remote_retrieve_header( $response, 'content-type' );
130
+        $filename = 'dataset-' . gmdate( 'Y-m-d-H-i-s' ) . '.' . $suffix;
131
+
132
+        // Add proper file headers.
133
+        header( "Content-Disposition: attachment; filename=$filename" );
134
+        header( "Content-Type: $type" );
135
+
136
+        /*
137 137
 		 * Echo the response body. As this is not HTML we can not escape it
138 138
 		 * and neither sanitize it, therefor turning off the linter notice.
139 139
 		 */
140
-		echo $body; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- This is an RDF file which is downloaded to the client (see the `Content-Disposition: attachment` header above).
140
+        echo $body; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- This is an RDF file which is downloaded to the client (see the `Content-Disposition: attachment` header above).
141 141
 
142
-		// Exit in both cases.
143
-		exit;
144
-	}
142
+        // Exit in both cases.
143
+        exit;
144
+    }
145 145
 }
Please login to merge, or discard this patch.
src/admin/partials/admin-setup/step-3.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,24 +6,24 @@
 block discarded – undo
6 6
 
7 7
 	<p class="page-txt">
8 8
 		<?php
9
-		$grab_a_key_link_html = sprintf(
10
-			'<a target="_blank" href="%s">%s</a>',
11
-			esc_attr__( 'https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key', 'wordlift' ),
12
-			esc_html__( 'grab a key', 'wordlift' )
13
-		);
9
+        $grab_a_key_link_html = sprintf(
10
+            '<a target="_blank" href="%s">%s</a>',
11
+            esc_attr__( 'https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key', 'wordlift' ),
12
+            esc_html__( 'grab a key', 'wordlift' )
13
+        );
14 14
 
15
-		echo wp_kses(
16
-			sprintf(
17
-					/* translators: %s: Link to Grab a Key. */
18
-				esc_html__(
19
-					'If you already purchased a plan, check your email, get the activation key from your inbox and insert it in the field below. Otherwise %s!',
20
-					'wordlift'
21
-				),
22
-				$grab_a_key_link_html
23
-			),
24
-			array( 'a' => array( 'href' => array() ) )
25
-		);
26
-		?>
15
+        echo wp_kses(
16
+            sprintf(
17
+                    /* translators: %s: Link to Grab a Key. */
18
+                esc_html__(
19
+                    'If you already purchased a plan, check your email, get the activation key from your inbox and insert it in the field below. Otherwise %s!',
20
+                    'wordlift'
21
+                ),
22
+                $grab_a_key_link_html
23
+            ),
24
+            array( 'a' => array( 'href' => array() ) )
25
+        );
26
+        ?>
27 27
 	</p>
28 28
 	<input
29 29
 		type="text"
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <!-- Pane 3 content -->
2 2
 <script type="text/html" id="page-2">
3 3
 	<h2 class="page-title">
4
-		<?php esc_html_e( 'License Key', 'wordlift' ); ?>
4
+		<?php esc_html_e('License Key', 'wordlift'); ?>
5 5
 	</h2>
6 6
 
7 7
 	<p class="page-txt">
8 8
 		<?php
9 9
 		$grab_a_key_link_html = sprintf(
10 10
 			'<a target="_blank" href="%s">%s</a>',
11
-			esc_attr__( 'https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key', 'wordlift' ),
12
-			esc_html__( 'grab a key', 'wordlift' )
11
+			esc_attr__('https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key', 'wordlift'),
12
+			esc_html__('grab a key', 'wordlift')
13 13
 		);
14 14
 
15 15
 		echo wp_kses(
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 				),
22 22
 				$grab_a_key_link_html
23 23
 			),
24
-			array( 'a' => array( 'href' => array() ) )
24
+			array('a' => array('href' => array()))
25 25
 		);
26 26
 		?>
27 27
 	</p>
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		name="key"
34 34
 		value=""
35 35
 		autocomplete="off"
36
-		placeholder="<?php echo esc_attr_x( 'License Key', 'Input text placeholder', 'wordlift' ); ?>"
36
+		placeholder="<?php echo esc_attr_x('License Key', 'Input text placeholder', 'wordlift'); ?>"
37 37
 	>
38 38
 	<div>
39 39
 		<p class="wl-val-key-error">
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 			target="_tab"
47 47
 			class="button wl-default-action"
48 48
 		>
49
-			<?php esc_html_e( 'Grab a Key!', 'wordlift' ); ?>
49
+			<?php esc_html_e('Grab a Key!', 'wordlift'); ?>
50 50
 		</a>
51 51
 
52 52
 		<input
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 			type="button"
55 55
 			data-wl-next="wl-next"
56 56
 			class="button"
57
-			value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>"
57
+			value="<?php esc_attr_e('Next', 'wordlift'); ?>"
58 58
 		>
59 59
 	</div>
60 60
 </script>
Please login to merge, or discard this patch.