Completed
Push — develop ( 8e3bd3...934407 )
by Naveen
02:05 queued 57s
created
src/admin/wordlift-admin-menu.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,25 +15,25 @@  discard block
 block discarded – undo
15 15
  */
16 16
 function wl_admin_menu() {
17 17
 
18
-	$menu_slug  = 'wl_admin_menu';
19
-	$capability = 'manage_options';
18
+    $menu_slug  = 'wl_admin_menu';
19
+    $capability = 'manage_options';
20 20
 
21
-	// see http://codex.wordpress.org/Function_Reference/add_menu_page
22
-	add_menu_page(
23
-		__( 'WordLift', 'wordlift' ), // page title
24
-		__( 'WordLift', 'wordlift' ), // menu title
25
-		$capability,                 // capabilities
26
-		$menu_slug,                  // menu slug
27
-		// 'wl_admin_menu_callback',  // TODO: function callback to draw the coming dashboard
28
-		'wl_configuration_admin_menu_callback',
29
-		WP_CONTENT_URL . '/plugins/wordlift/images/svg/wl-logo-icon.svg'
30
-	);  // icon URL 20x20 px
21
+    // see http://codex.wordpress.org/Function_Reference/add_menu_page
22
+    add_menu_page(
23
+        __( 'WordLift', 'wordlift' ), // page title
24
+        __( 'WordLift', 'wordlift' ), // menu title
25
+        $capability,                 // capabilities
26
+        $menu_slug,                  // menu slug
27
+        // 'wl_admin_menu_callback',  // TODO: function callback to draw the coming dashboard
28
+        'wl_configuration_admin_menu_callback',
29
+        WP_CONTENT_URL . '/plugins/wordlift/images/svg/wl-logo-icon.svg'
30
+    );  // icon URL 20x20 px
31 31
 
32
-	// Call hooked functions.
33
-	do_action( 'wl_admin_menu', $menu_slug, $capability );
32
+    // Call hooked functions.
33
+    do_action( 'wl_admin_menu', $menu_slug, $capability );
34 34
 
35
-	// Remove duplicate 'WordLift' subpage created by WordPress.
36
-	remove_submenu_page( $menu_slug, $menu_slug );
35
+    // Remove duplicate 'WordLift' subpage created by WordPress.
36
+    remove_submenu_page( $menu_slug, $menu_slug );
37 37
 
38 38
 }
39 39
 
@@ -47,20 +47,20 @@  discard block
 block discarded – undo
47 47
  * @since 3.15.0
48 48
  */
49 49
 function wl_remove_entity_type_menu() {
50
-	/*
50
+    /*
51 51
 	 * Remove from the menu links to the entity type admin page when
52 52
 	 * under non entity hierarchy.
53 53
 	 */
54
-	foreach ( Wordlift_Entity_Service::valid_entity_post_types() as $post_type ) {
55
-		// In the context of admin menues post has no explicit indication of post type in the urls.
56
-		if ( 'post' !== $post_type ) {
57
-			remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
58
-		}
54
+    foreach ( Wordlift_Entity_Service::valid_entity_post_types() as $post_type ) {
55
+        // In the context of admin menues post has no explicit indication of post type in the urls.
56
+        if ( 'post' !== $post_type ) {
57
+            remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
58
+        }
59 59
 
60
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post_type ) {
61
-			remove_submenu_page( 'edit.php?post_type=' . $post_type, 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '&post_type=' . $post_type );
62
-		}
63
-	}
60
+        if ( Wordlift_Entity_Service::TYPE_NAME !== $post_type ) {
61
+            remove_submenu_page( 'edit.php?post_type=' . $post_type, 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '&post_type=' . $post_type );
62
+        }
63
+    }
64 64
 }
65 65
 
66 66
 add_action( 'admin_menu', 'wl_remove_entity_type_menu', 100 );
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function wl_admin_menu_callback() {
74 74
 
75
-	if ( ! current_user_can( 'manage_options' ) ) {
76
-		wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'default' ) );
77
-	}
75
+    if ( ! current_user_can( 'manage_options' ) ) {
76
+        wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'default' ) );
77
+    }
78 78
 
79
-	echo '<div class="wrap">';
80
-	echo '<p>Here is where the form would go if I actually had options.</p>';
81
-	echo '</div>';
79
+    echo '<div class="wrap">';
80
+    echo '<p>Here is where the form would go if I actually had options.</p>';
81
+    echo '</div>';
82 82
 
83 83
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -20,24 +20,24 @@  discard block
 block discarded – undo
20 20
 
21 21
 	// see http://codex.wordpress.org/Function_Reference/add_menu_page
22 22
 	add_menu_page(
23
-		__( 'WordLift', 'wordlift' ), // page title
24
-		__( 'WordLift', 'wordlift' ), // menu title
25
-		$capability,                 // capabilities
26
-		$menu_slug,                  // menu slug
23
+		__('WordLift', 'wordlift'), // page title
24
+		__('WordLift', 'wordlift'), // menu title
25
+		$capability, // capabilities
26
+		$menu_slug, // menu slug
27 27
 		// 'wl_admin_menu_callback',  // TODO: function callback to draw the coming dashboard
28 28
 		'wl_configuration_admin_menu_callback',
29
-		WP_CONTENT_URL . '/plugins/wordlift/images/svg/wl-logo-icon.svg'
30
-	);  // icon URL 20x20 px
29
+		WP_CONTENT_URL.'/plugins/wordlift/images/svg/wl-logo-icon.svg'
30
+	); // icon URL 20x20 px
31 31
 
32 32
 	// Call hooked functions.
33
-	do_action( 'wl_admin_menu', $menu_slug, $capability );
33
+	do_action('wl_admin_menu', $menu_slug, $capability);
34 34
 
35 35
 	// Remove duplicate 'WordLift' subpage created by WordPress.
36
-	remove_submenu_page( $menu_slug, $menu_slug );
36
+	remove_submenu_page($menu_slug, $menu_slug);
37 37
 
38 38
 }
39 39
 
40
-add_action( 'admin_menu', 'wl_admin_menu' );
40
+add_action('admin_menu', 'wl_admin_menu');
41 41
 
42 42
 /**
43 43
  * This function is called by the *admin_menu* hook to remove for the admin menu
@@ -51,19 +51,19 @@  discard block
 block discarded – undo
51 51
 	 * Remove from the menu links to the entity type admin page when
52 52
 	 * under non entity hierarchy.
53 53
 	 */
54
-	foreach ( Wordlift_Entity_Service::valid_entity_post_types() as $post_type ) {
54
+	foreach (Wordlift_Entity_Service::valid_entity_post_types() as $post_type) {
55 55
 		// In the context of admin menues post has no explicit indication of post type in the urls.
56
-		if ( 'post' !== $post_type ) {
57
-			remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
56
+		if ('post' !== $post_type) {
57
+			remove_submenu_page('edit.php', 'edit-tags.php?taxonomy='.Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
58 58
 		}
59 59
 
60
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post_type ) {
61
-			remove_submenu_page( 'edit.php?post_type=' . $post_type, 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '&amp;post_type=' . $post_type );
60
+		if (Wordlift_Entity_Service::TYPE_NAME !== $post_type) {
61
+			remove_submenu_page('edit.php?post_type='.$post_type, 'edit-tags.php?taxonomy='.Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME.'&amp;post_type='.$post_type);
62 62
 		}
63 63
 	}
64 64
 }
65 65
 
66
-add_action( 'admin_menu', 'wl_remove_entity_type_menu', 100 );
66
+add_action('admin_menu', 'wl_remove_entity_type_menu', 100);
67 67
 
68 68
 /**
69 69
  * This function is called as a callback by the *wl_admin_menu* to display the actual page.
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function wl_admin_menu_callback() {
74 74
 
75
-	if ( ! current_user_can( 'manage_options' ) ) {
76
-		wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'default' ) );
75
+	if ( ! current_user_can('manage_options')) {
76
+		wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'default'));
77 77
 	}
78 78
 
79 79
 	echo '<div class="wrap">';
Please login to merge, or discard this patch.
src/admin/class-wordlift-admin-settings-page-action-link.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -18,50 +18,50 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Admin_Settings_Page_Action_Link {
20 20
 
21
-	/**
22
-	 * The {@link Wordlift_Admin_Settings_Page} instance.
23
-	 *
24
-	 * @since  3.11.0
25
-	 * @access private
26
-	 * @var Wordlift_Admin_Settings_Page $settings_page The {@link Wordlift_Admin_Settings_Page} instance.
27
-	 */
28
-	private $settings_page;
21
+    /**
22
+     * The {@link Wordlift_Admin_Settings_Page} instance.
23
+     *
24
+     * @since  3.11.0
25
+     * @access private
26
+     * @var Wordlift_Admin_Settings_Page $settings_page The {@link Wordlift_Admin_Settings_Page} instance.
27
+     */
28
+    private $settings_page;
29 29
 
30
-	/**
31
-	 * Create a {@link Wordlift_Admin_Settings_Page_Action_Link} instance.
32
-	 *
33
-	 * @param Wordlift_Admin_Settings_Page $settings_page The {@link Wordlift_Admin_Settings_Page} instance.
34
-	 *
35
-	 * @since  3.11.0
36
-	 */
37
-	public function __construct( $settings_page ) {
30
+    /**
31
+     * Create a {@link Wordlift_Admin_Settings_Page_Action_Link} instance.
32
+     *
33
+     * @param Wordlift_Admin_Settings_Page $settings_page The {@link Wordlift_Admin_Settings_Page} instance.
34
+     *
35
+     * @since  3.11.0
36
+     */
37
+    public function __construct( $settings_page ) {
38 38
 
39
-		$this->settings_page = $settings_page;
39
+        $this->settings_page = $settings_page;
40 40
 
41
-	}
41
+    }
42 42
 
43
-	/**
44
-	 * Create a link to the WordLift settings page.
45
-	 *
46
-	 * @param array $links An array of links.
47
-	 *
48
-	 * @return array An array of links including those added by the plugin.
49
-	 * @since 3.11.0
50
-	 */
51
-	public function action_links( $links ) {
43
+    /**
44
+     * Create a link to the WordLift settings page.
45
+     *
46
+     * @param array $links An array of links.
47
+     *
48
+     * @return array An array of links including those added by the plugin.
49
+     * @since 3.11.0
50
+     */
51
+    public function action_links( $links ) {
52 52
 
53
-		// Get the menu slug from the page, then prepare the path, hence the url.
54
-		$menu_slug = $this->settings_page->get_menu_slug();
55
-		$path      = "admin.php?page=$menu_slug";
56
-		$url       = get_admin_url( null, $path );
53
+        // Get the menu slug from the page, then prepare the path, hence the url.
54
+        $menu_slug = $this->settings_page->get_menu_slug();
55
+        $path      = "admin.php?page=$menu_slug";
56
+        $url       = get_admin_url( null, $path );
57 57
 
58
-		// Add our own link to the list of links.
59
-		return array_merge(
60
-			$links,
61
-			array(
62
-				sprintf( "<a href='$url'>%s</a>", __( 'Settings', 'wordlift' ) ),
63
-			)
64
-		);
65
-	}
58
+        // Add our own link to the list of links.
59
+        return array_merge(
60
+            $links,
61
+            array(
62
+                sprintf( "<a href='$url'>%s</a>", __( 'Settings', 'wordlift' ) ),
63
+            )
64
+        );
65
+    }
66 66
 
67 67
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @since  3.11.0
36 36
 	 */
37
-	public function __construct( $settings_page ) {
37
+	public function __construct($settings_page) {
38 38
 
39 39
 		$this->settings_page = $settings_page;
40 40
 
@@ -48,18 +48,18 @@  discard block
 block discarded – undo
48 48
 	 * @return array An array of links including those added by the plugin.
49 49
 	 * @since 3.11.0
50 50
 	 */
51
-	public function action_links( $links ) {
51
+	public function action_links($links) {
52 52
 
53 53
 		// Get the menu slug from the page, then prepare the path, hence the url.
54 54
 		$menu_slug = $this->settings_page->get_menu_slug();
55 55
 		$path      = "admin.php?page=$menu_slug";
56
-		$url       = get_admin_url( null, $path );
56
+		$url       = get_admin_url(null, $path);
57 57
 
58 58
 		// Add our own link to the list of links.
59 59
 		return array_merge(
60 60
 			$links,
61 61
 			array(
62
-				sprintf( "<a href='$url'>%s</a>", __( 'Settings', 'wordlift' ) ),
62
+				sprintf("<a href='$url'>%s</a>", __('Settings', 'wordlift')),
63 63
 			)
64 64
 		);
65 65
 	}
Please login to merge, or discard this patch.
src/admin/class-wordlift-dashboard-latest-news.php 2 patches
Indentation   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -20,163 +20,163 @@
 block discarded – undo
20 20
  */
21 21
 class Wordlift_Dashboard_Latest_News {
22 22
 
23
-	/**
24
-	 * Add needed hooks for the latest news widget.
25
-	 */
26
-	public function __construct() {
27
-		add_action(
28
-			'wp_ajax_wordlift_get_latest_news',
29
-			array(
30
-				$this,
31
-				'ajax_get_latest_news',
32
-			)
33
-		);
34
-		add_action(
35
-			'wp_dashboard_setup',
36
-			array(
37
-				$this,
38
-				'add_dashboard_latest_news_widget',
39
-			)
40
-		);
41
-
42
-	}
43
-
44
-	/**
45
-	 * Return latest news html.
46
-	 */
47
-	public function render() {
48
-
49
-		wp_enqueue_script( 'wl-admin-dashboard', plugin_dir_url( __DIR__ ) . 'admin/js/wordlift-admin-dashboard.js', array( 'jquery' ), '3.22.0', true );
50
-
51
-		include plugin_dir_path( __FILE__ ) . 'partials/wordlift-admin-news-widget.php';
52
-	}
53
-
54
-	/**
55
-	 * Returns latest news data filtered by $start_position.
56
-	 *
57
-	 * @param int $start_position (news array key start position).
58
-	 *
59
-	 * @return array Latest posts data.
60
-	 */
61
-	public function get_last_wordlift_articles( $start_position = 0 ) {
62
-		$feed_articles = $this->get_wordlift_articles_data();
63
-
64
-		// Filter articles by $start_position
65
-		if ( ! empty( $feed_articles ) ) {
66
-			return array(
67
-				'posts_data'     => array_slice( $feed_articles, $start_position, 3 ),
68
-				'count'          => count( $feed_articles ),
69
-				'start_position' => $start_position,
70
-			);
71
-		}
72
-
73
-		return false;
74
-	}
75
-
76
-	/**
77
-	 * Returns latest news array data.
78
-	 *
79
-	 * @uses  https://codex.wordpress.org/Function_Reference/fetch_feed
80
-	 * @uses  https://codex.wordpress.org/Function_Reference/get_locale
81
-	 *
82
-	 * @param int $articles_number (articles total number).
83
-	 *
84
-	 * @return array Latest $articles_number feed posts.
85
-	 */
86
-	public function get_wordlift_articles_data( $articles_number = 10 ) {
87
-		// Init cache class
88
-		$cache_sistem_lib = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'articles/' );
89
-		$locale           = get_locale();
90
-		$cache_id         = 'news_' . gmdate( 'Y_m_d' ) . '_' . $locale;
91
-		$posts_data       = array();
92
-
93
-		// Get latest articles from cache
94
-		$feed_articles = $cache_sistem_lib->get_cache( $cache_id );
95
-		if ( false === $feed_articles ) {
96
-			// Check WordPress installation language to define articles rss url
97
-			$feed_uri = ( 'it_IT' === $locale ) ? 'https://wordlift.io/blog/it/feed/' : 'https://wordlift.io/blog/en/feed/';
98
-
99
-			// Get rss feed data, the response is cached by default for 12 hours
100
-			$feed = fetch_feed( $feed_uri );
101
-			if ( ! is_wp_error( $feed ) ) {
102
-				// Build an array of requested $articles_number, starting with element 0
103
-				$feed_articles = $feed->get_items( 0, $articles_number );
104
-				// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
105
-				foreach ( $feed_articles as $key => $item ) {
106
-					$data = array(
107
-						// fetch_feed will return the title html decoded.
108
-						'post_title'       => $item->get_title(),
109
-						'post_date'        => $item->get_date( 'j F Y | g:i a' ),
110
-						'post_url'         => self::add_utm_parameter( $item->get_permalink() ),
111
-						// fetch_feed will return the description html (not decoded).
112
-						'post_description' => $item->get_description(),
113
-					);
114
-					array_push( $posts_data, $data );
115
-				}
116
-				// Set articles in cache.
117
-				$cache_sistem_lib->set_cache( $cache_id, $posts_data );
118
-				$feed_articles = $posts_data;
119
-			}
120
-		}
121
-
122
-		return $feed_articles;
123
-	}
124
-
125
-	/**
126
-	 * Add the `utm` parameter for GA.
127
-	 *
128
-	 * @param string $url The URL.
129
-	 *
130
-	 * @return string The URL with the `utm` parameter prepended by `&` or by `?`.
131
-	 * @since 3.19.0
132
-	 */
133
-	private static function add_utm_parameter( $url ) {
134
-
135
-		if ( false === strpos( $url, '?' ) ) {
136
-			return $url . '?utm=wl_dash';
137
-		}
138
-
139
-		return $url . '&utm=wl_dash';
140
-	}
141
-
142
-	/**
143
-	 * Ajax call for more latest news.
144
-	 *
145
-	 * @uses  https://codex.wordpress.org/Function_Reference/wp_send_json_success
146
-	 */
147
-	public function ajax_get_latest_news() {
148
-		// Get wordlift articles
149
-		$more_posts_link_id = isset( $_POST['more_posts_link_id'] ) ? sanitize_text_field( wp_unslash( (string) $_POST['more_posts_link_id'] ) ) : '';//phpcs:ignore WordPress.Security.NonceVerification.Missing
150
-		$start_position     = explode( '_', $more_posts_link_id );
151
-		$data               = $this->get_last_wordlift_articles( $start_position[ count( $start_position ) - 1 ] );
152
-
153
-		// Return response as json object
154
-		wp_send_json_success( $data );
155
-	}
156
-
157
-	/**
158
-	 * Add latest news widget to the administration dashboard.
159
-	 */
160
-	public function add_dashboard_latest_news_widget() {
161
-
162
-		/**
163
-		 * Filter name: wl_feature__enable__wordlift-news
164
-		 * Feature flag to enable / disable news widget.
165
-		 *
166
-		 * @since 3.30.0
167
-		 */
168
-		// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
169
-		if ( apply_filters( 'wl_feature__enable__wordlift-news', true ) ) {
170
-
171
-			wp_add_dashboard_widget(
172
-				'wordlift-dashboard-latest-news-widget',
173
-				'Latest WordLift News',
174
-				array(
175
-					$this,
176
-					'render',
177
-				)
178
-			);
179
-		}
180
-	}
23
+    /**
24
+     * Add needed hooks for the latest news widget.
25
+     */
26
+    public function __construct() {
27
+        add_action(
28
+            'wp_ajax_wordlift_get_latest_news',
29
+            array(
30
+                $this,
31
+                'ajax_get_latest_news',
32
+            )
33
+        );
34
+        add_action(
35
+            'wp_dashboard_setup',
36
+            array(
37
+                $this,
38
+                'add_dashboard_latest_news_widget',
39
+            )
40
+        );
41
+
42
+    }
43
+
44
+    /**
45
+     * Return latest news html.
46
+     */
47
+    public function render() {
48
+
49
+        wp_enqueue_script( 'wl-admin-dashboard', plugin_dir_url( __DIR__ ) . 'admin/js/wordlift-admin-dashboard.js', array( 'jquery' ), '3.22.0', true );
50
+
51
+        include plugin_dir_path( __FILE__ ) . 'partials/wordlift-admin-news-widget.php';
52
+    }
53
+
54
+    /**
55
+     * Returns latest news data filtered by $start_position.
56
+     *
57
+     * @param int $start_position (news array key start position).
58
+     *
59
+     * @return array Latest posts data.
60
+     */
61
+    public function get_last_wordlift_articles( $start_position = 0 ) {
62
+        $feed_articles = $this->get_wordlift_articles_data();
63
+
64
+        // Filter articles by $start_position
65
+        if ( ! empty( $feed_articles ) ) {
66
+            return array(
67
+                'posts_data'     => array_slice( $feed_articles, $start_position, 3 ),
68
+                'count'          => count( $feed_articles ),
69
+                'start_position' => $start_position,
70
+            );
71
+        }
72
+
73
+        return false;
74
+    }
75
+
76
+    /**
77
+     * Returns latest news array data.
78
+     *
79
+     * @uses  https://codex.wordpress.org/Function_Reference/fetch_feed
80
+     * @uses  https://codex.wordpress.org/Function_Reference/get_locale
81
+     *
82
+     * @param int $articles_number (articles total number).
83
+     *
84
+     * @return array Latest $articles_number feed posts.
85
+     */
86
+    public function get_wordlift_articles_data( $articles_number = 10 ) {
87
+        // Init cache class
88
+        $cache_sistem_lib = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'articles/' );
89
+        $locale           = get_locale();
90
+        $cache_id         = 'news_' . gmdate( 'Y_m_d' ) . '_' . $locale;
91
+        $posts_data       = array();
92
+
93
+        // Get latest articles from cache
94
+        $feed_articles = $cache_sistem_lib->get_cache( $cache_id );
95
+        if ( false === $feed_articles ) {
96
+            // Check WordPress installation language to define articles rss url
97
+            $feed_uri = ( 'it_IT' === $locale ) ? 'https://wordlift.io/blog/it/feed/' : 'https://wordlift.io/blog/en/feed/';
98
+
99
+            // Get rss feed data, the response is cached by default for 12 hours
100
+            $feed = fetch_feed( $feed_uri );
101
+            if ( ! is_wp_error( $feed ) ) {
102
+                // Build an array of requested $articles_number, starting with element 0
103
+                $feed_articles = $feed->get_items( 0, $articles_number );
104
+                // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
105
+                foreach ( $feed_articles as $key => $item ) {
106
+                    $data = array(
107
+                        // fetch_feed will return the title html decoded.
108
+                        'post_title'       => $item->get_title(),
109
+                        'post_date'        => $item->get_date( 'j F Y | g:i a' ),
110
+                        'post_url'         => self::add_utm_parameter( $item->get_permalink() ),
111
+                        // fetch_feed will return the description html (not decoded).
112
+                        'post_description' => $item->get_description(),
113
+                    );
114
+                    array_push( $posts_data, $data );
115
+                }
116
+                // Set articles in cache.
117
+                $cache_sistem_lib->set_cache( $cache_id, $posts_data );
118
+                $feed_articles = $posts_data;
119
+            }
120
+        }
121
+
122
+        return $feed_articles;
123
+    }
124
+
125
+    /**
126
+     * Add the `utm` parameter for GA.
127
+     *
128
+     * @param string $url The URL.
129
+     *
130
+     * @return string The URL with the `utm` parameter prepended by `&` or by `?`.
131
+     * @since 3.19.0
132
+     */
133
+    private static function add_utm_parameter( $url ) {
134
+
135
+        if ( false === strpos( $url, '?' ) ) {
136
+            return $url . '?utm=wl_dash';
137
+        }
138
+
139
+        return $url . '&utm=wl_dash';
140
+    }
141
+
142
+    /**
143
+     * Ajax call for more latest news.
144
+     *
145
+     * @uses  https://codex.wordpress.org/Function_Reference/wp_send_json_success
146
+     */
147
+    public function ajax_get_latest_news() {
148
+        // Get wordlift articles
149
+        $more_posts_link_id = isset( $_POST['more_posts_link_id'] ) ? sanitize_text_field( wp_unslash( (string) $_POST['more_posts_link_id'] ) ) : '';//phpcs:ignore WordPress.Security.NonceVerification.Missing
150
+        $start_position     = explode( '_', $more_posts_link_id );
151
+        $data               = $this->get_last_wordlift_articles( $start_position[ count( $start_position ) - 1 ] );
152
+
153
+        // Return response as json object
154
+        wp_send_json_success( $data );
155
+    }
156
+
157
+    /**
158
+     * Add latest news widget to the administration dashboard.
159
+     */
160
+    public function add_dashboard_latest_news_widget() {
161
+
162
+        /**
163
+         * Filter name: wl_feature__enable__wordlift-news
164
+         * Feature flag to enable / disable news widget.
165
+         *
166
+         * @since 3.30.0
167
+         */
168
+        // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
169
+        if ( apply_filters( 'wl_feature__enable__wordlift-news', true ) ) {
170
+
171
+            wp_add_dashboard_widget(
172
+                'wordlift-dashboard-latest-news-widget',
173
+                'Latest WordLift News',
174
+                array(
175
+                    $this,
176
+                    'render',
177
+                )
178
+            );
179
+        }
180
+    }
181 181
 
182 182
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function render() {
48 48
 
49
-		wp_enqueue_script( 'wl-admin-dashboard', plugin_dir_url( __DIR__ ) . 'admin/js/wordlift-admin-dashboard.js', array( 'jquery' ), '3.22.0', true );
49
+		wp_enqueue_script('wl-admin-dashboard', plugin_dir_url(__DIR__).'admin/js/wordlift-admin-dashboard.js', array('jquery'), '3.22.0', true);
50 50
 
51
-		include plugin_dir_path( __FILE__ ) . 'partials/wordlift-admin-news-widget.php';
51
+		include plugin_dir_path(__FILE__).'partials/wordlift-admin-news-widget.php';
52 52
 	}
53 53
 
54 54
 	/**
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @return array Latest posts data.
60 60
 	 */
61
-	public function get_last_wordlift_articles( $start_position = 0 ) {
61
+	public function get_last_wordlift_articles($start_position = 0) {
62 62
 		$feed_articles = $this->get_wordlift_articles_data();
63 63
 
64 64
 		// Filter articles by $start_position
65
-		if ( ! empty( $feed_articles ) ) {
65
+		if ( ! empty($feed_articles)) {
66 66
 			return array(
67
-				'posts_data'     => array_slice( $feed_articles, $start_position, 3 ),
68
-				'count'          => count( $feed_articles ),
67
+				'posts_data'     => array_slice($feed_articles, $start_position, 3),
68
+				'count'          => count($feed_articles),
69 69
 				'start_position' => $start_position,
70 70
 			);
71 71
 		}
@@ -83,38 +83,38 @@  discard block
 block discarded – undo
83 83
 	 *
84 84
 	 * @return array Latest $articles_number feed posts.
85 85
 	 */
86
-	public function get_wordlift_articles_data( $articles_number = 10 ) {
86
+	public function get_wordlift_articles_data($articles_number = 10) {
87 87
 		// Init cache class
88
-		$cache_sistem_lib = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'articles/' );
88
+		$cache_sistem_lib = new Wordlift_File_Cache_Service(WL_TEMP_DIR.'articles/');
89 89
 		$locale           = get_locale();
90
-		$cache_id         = 'news_' . gmdate( 'Y_m_d' ) . '_' . $locale;
90
+		$cache_id         = 'news_'.gmdate('Y_m_d').'_'.$locale;
91 91
 		$posts_data       = array();
92 92
 
93 93
 		// Get latest articles from cache
94
-		$feed_articles = $cache_sistem_lib->get_cache( $cache_id );
95
-		if ( false === $feed_articles ) {
94
+		$feed_articles = $cache_sistem_lib->get_cache($cache_id);
95
+		if (false === $feed_articles) {
96 96
 			// Check WordPress installation language to define articles rss url
97
-			$feed_uri = ( 'it_IT' === $locale ) ? 'https://wordlift.io/blog/it/feed/' : 'https://wordlift.io/blog/en/feed/';
97
+			$feed_uri = ('it_IT' === $locale) ? 'https://wordlift.io/blog/it/feed/' : 'https://wordlift.io/blog/en/feed/';
98 98
 
99 99
 			// Get rss feed data, the response is cached by default for 12 hours
100
-			$feed = fetch_feed( $feed_uri );
101
-			if ( ! is_wp_error( $feed ) ) {
100
+			$feed = fetch_feed($feed_uri);
101
+			if ( ! is_wp_error($feed)) {
102 102
 				// Build an array of requested $articles_number, starting with element 0
103
-				$feed_articles = $feed->get_items( 0, $articles_number );
103
+				$feed_articles = $feed->get_items(0, $articles_number);
104 104
 				// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
105
-				foreach ( $feed_articles as $key => $item ) {
105
+				foreach ($feed_articles as $key => $item) {
106 106
 					$data = array(
107 107
 						// fetch_feed will return the title html decoded.
108 108
 						'post_title'       => $item->get_title(),
109
-						'post_date'        => $item->get_date( 'j F Y | g:i a' ),
110
-						'post_url'         => self::add_utm_parameter( $item->get_permalink() ),
109
+						'post_date'        => $item->get_date('j F Y | g:i a'),
110
+						'post_url'         => self::add_utm_parameter($item->get_permalink()),
111 111
 						// fetch_feed will return the description html (not decoded).
112 112
 						'post_description' => $item->get_description(),
113 113
 					);
114
-					array_push( $posts_data, $data );
114
+					array_push($posts_data, $data);
115 115
 				}
116 116
 				// Set articles in cache.
117
-				$cache_sistem_lib->set_cache( $cache_id, $posts_data );
117
+				$cache_sistem_lib->set_cache($cache_id, $posts_data);
118 118
 				$feed_articles = $posts_data;
119 119
 			}
120 120
 		}
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 	 * @return string The URL with the `utm` parameter prepended by `&` or by `?`.
131 131
 	 * @since 3.19.0
132 132
 	 */
133
-	private static function add_utm_parameter( $url ) {
133
+	private static function add_utm_parameter($url) {
134 134
 
135
-		if ( false === strpos( $url, '?' ) ) {
136
-			return $url . '?utm=wl_dash';
135
+		if (false === strpos($url, '?')) {
136
+			return $url.'?utm=wl_dash';
137 137
 		}
138 138
 
139
-		return $url . '&utm=wl_dash';
139
+		return $url.'&utm=wl_dash';
140 140
 	}
141 141
 
142 142
 	/**
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	public function ajax_get_latest_news() {
148 148
 		// Get wordlift articles
149
-		$more_posts_link_id = isset( $_POST['more_posts_link_id'] ) ? sanitize_text_field( wp_unslash( (string) $_POST['more_posts_link_id'] ) ) : '';//phpcs:ignore WordPress.Security.NonceVerification.Missing
150
-		$start_position     = explode( '_', $more_posts_link_id );
151
-		$data               = $this->get_last_wordlift_articles( $start_position[ count( $start_position ) - 1 ] );
149
+		$more_posts_link_id = isset($_POST['more_posts_link_id']) ? sanitize_text_field(wp_unslash((string) $_POST['more_posts_link_id'])) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing
150
+		$start_position     = explode('_', $more_posts_link_id);
151
+		$data               = $this->get_last_wordlift_articles($start_position[count($start_position) - 1]);
152 152
 
153 153
 		// Return response as json object
154
-		wp_send_json_success( $data );
154
+		wp_send_json_success($data);
155 155
 	}
156 156
 
157 157
 	/**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 		 * @since 3.30.0
167 167
 		 */
168 168
 		// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
169
-		if ( apply_filters( 'wl_feature__enable__wordlift-news', true ) ) {
169
+		if (apply_filters('wl_feature__enable__wordlift-news', true)) {
170 170
 
171 171
 			wp_add_dashboard_widget(
172 172
 				'wordlift-dashboard-latest-news-widget',
Please login to merge, or discard this patch.
src/admin/wordlift-admin-shortcodes.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * Loads the buttons in TinyMCE.
10 10
  */
11 11
 function wl_admin_shortcode_buttons() {
12
-	// Only add hooks when the current user has permissions AND is in Rich Text editor mode
13
-	if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) {
14
-		// add_filter( 'mce_external_plugins', 'wl_admin_shortcode_buttons_register_tinymce_javascript' );
15
-		add_filter( 'mce_buttons', 'wl_admin_shortcode_register_buttons' );
16
-	}
12
+    // Only add hooks when the current user has permissions AND is in Rich Text editor mode
13
+    if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) {
14
+        // add_filter( 'mce_external_plugins', 'wl_admin_shortcode_buttons_register_tinymce_javascript' );
15
+        add_filter( 'mce_buttons', 'wl_admin_shortcode_register_buttons' );
16
+    }
17 17
 }
18 18
 
19 19
 /**
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
  * @return array The buttons array including the *wl_shortcodes_menu*.
25 25
  */
26 26
 function wl_admin_shortcode_register_buttons( $buttons ) {
27
-	array_push( $buttons, 'wl_shortcodes_menu' );
27
+    array_push( $buttons, 'wl_shortcodes_menu' );
28 28
 
29
-	return $buttons;
29
+    return $buttons;
30 30
 }
31 31
 
32 32
 // init process for button control
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  discard block
 block discarded – undo
10 10
  */
11 11
 function wl_admin_shortcode_buttons() {
12 12
 	// Only add hooks when the current user has permissions AND is in Rich Text editor mode
13
-	if ( ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) && get_user_option( 'rich_editing' ) ) {
13
+	if ((current_user_can('edit_posts') || current_user_can('edit_pages')) && get_user_option('rich_editing')) {
14 14
 		// add_filter( 'mce_external_plugins', 'wl_admin_shortcode_buttons_register_tinymce_javascript' );
15
-		add_filter( 'mce_buttons', 'wl_admin_shortcode_register_buttons' );
15
+		add_filter('mce_buttons', 'wl_admin_shortcode_register_buttons');
16 16
 	}
17 17
 }
18 18
 
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array The buttons array including the *wl_shortcodes_menu*.
25 25
  */
26
-function wl_admin_shortcode_register_buttons( $buttons ) {
27
-	array_push( $buttons, 'wl_shortcodes_menu' );
26
+function wl_admin_shortcode_register_buttons($buttons) {
27
+	array_push($buttons, 'wl_shortcodes_menu');
28 28
 
29 29
 	return $buttons;
30 30
 }
31 31
 
32 32
 // init process for button control
33
-add_action( 'admin_init', 'wl_admin_shortcode_buttons' );
33
+add_action('admin_init', 'wl_admin_shortcode_buttons');
Please login to merge, or discard this patch.
src/admin/class-wordlift-admin-user-profile-page.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @since 3.14.0
48 48
 	 */
49
-	public function __construct( $author_element, $user_service ) {
49
+	public function __construct($author_element, $user_service) {
50 50
 
51 51
 		$this->author_element = $author_element;
52 52
 		$this->user_service   = $user_service;
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 		 * It is too early in the WordPress boot to do user capabilities filtering
58 58
 		 * here and it is deferred to the handler.
59 59
 		 */
60
-		add_action( 'show_user_profile', array( $this, 'edit_user_profile' ) );
61
-		add_action( 'edit_user_profile', array( $this, 'edit_user_profile' ) );
60
+		add_action('show_user_profile', array($this, 'edit_user_profile'));
61
+		add_action('edit_user_profile', array($this, 'edit_user_profile'));
62 62
 		add_action(
63 63
 			'edit_user_profile_update',
64 64
 			array(
@@ -84,25 +84,25 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @since 3.14.0
86 86
 	 */
87
-	public function edit_user_profile( $user ) {
87
+	public function edit_user_profile($user) {
88 88
 
89 89
 		// In case it is a user editing his own profile, make sure he has admin
90 90
 		// like capabilities.
91
-		if ( ! current_user_can( 'edit_users' ) ) {
91
+		if ( ! current_user_can('edit_users')) {
92 92
 			return;
93 93
 		}
94 94
 
95 95
 		?>
96
-		<h2><?php esc_html_e( 'WordLift', 'wordlift' ); ?></h2>
97
-		<?php wp_nonce_field( 'wordlift_user_save', 'wordlift_user_save_nonce', false ); ?>
96
+		<h2><?php esc_html_e('WordLift', 'wordlift'); ?></h2>
97
+		<?php wp_nonce_field('wordlift_user_save', 'wordlift_user_save_nonce', false); ?>
98 98
 		<table class="form-table">
99 99
 			<?php
100 100
 			// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
101
-			if ( apply_filters( 'wl_feature__enable__user-author', true ) ) {
101
+			if (apply_filters('wl_feature__enable__user-author', true)) {
102 102
 				?>
103 103
 				<tr class="user-description-wrap">
104 104
 					<th><label
105
-								for="wl_person"><?php esc_html_e( 'Author from the vocabulary', 'wordlift' ); ?></label>
105
+								for="wl_person"><?php esc_html_e('Author from the vocabulary', 'wordlift'); ?></label>
106 106
 					</th>
107 107
 					<td>
108 108
 						<?php
@@ -110,24 +110,24 @@  discard block
 block discarded – undo
110 110
 							array(
111 111
 								'id'             => 'wl_person',
112 112
 								'name'           => 'wl_person',
113
-								'current_entity' => $this->user_service->get_entity( $user->ID ),
113
+								'current_entity' => $this->user_service->get_entity($user->ID),
114 114
 							)
115 115
 						);
116 116
 						?>
117
-						<p class="description"><?php esc_html_e( 'The entity, person or organization, from the vocabulary to associate with this author.', 'wordlift' ); ?></p>
117
+						<p class="description"><?php esc_html_e('The entity, person or organization, from the vocabulary to associate with this author.', 'wordlift'); ?></p>
118 118
 					</td>
119 119
 				</tr>
120 120
 			<?php } ?>
121
-			<?php if ( $this->user_service->is_editor( $user->ID ) ) { ?>
121
+			<?php if ($this->user_service->is_editor($user->ID)) { ?>
122 122
 			<tr>
123 123
 				<th>
124 124
 					<label
125
-							for="wl_can_create_entities"><?php esc_html_e( 'Can create new entities', 'wordlift' ); ?></label>
125
+							for="wl_can_create_entities"><?php esc_html_e('Can create new entities', 'wordlift'); ?></label>
126 126
 				</th>
127 127
 				<td>
128 128
 					<input id="wl_can_create_entities"
129 129
 						   name="wl_can_create_entities"
130
-						   type="checkbox" <?php checked( $this->user_service->editor_can_create_entities( $user->ID ) ); ?>
130
+						   type="checkbox" <?php checked($this->user_service->editor_can_create_entities($user->ID)); ?>
131 131
 				</td>
132 132
 				<?php } ?>
133 133
 				<?php
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 				 *
138 138
 				 * @since 3.30.0
139 139
 				 */
140
-				do_action( 'wordlift_user_settings_page' );
140
+				do_action('wordlift_user_settings_page');
141 141
 				?>
142 142
 		</table>
143 143
 		<?php
@@ -150,25 +150,25 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @since 3.14.0
152 152
 	 */
153
-	public function edit_user_profile_update( $user_id ) {
153
+	public function edit_user_profile_update($user_id) {
154 154
 
155 155
 		// In case it is a user editing his own profile, make sure he has admin
156 156
 		// like capabilities.
157
-		if ( ! current_user_can( 'edit_users' ) ) {
157
+		if ( ! current_user_can('edit_users')) {
158 158
 			return;
159 159
 		}
160 160
 
161
-		check_admin_referer( 'wordlift_user_save', 'wordlift_user_save_nonce' );
161
+		check_admin_referer('wordlift_user_save', 'wordlift_user_save_nonce');
162 162
 
163 163
 		// Link an entity to the user.
164
-		$this->link_entity( $user_id, $_POST );
164
+		$this->link_entity($user_id, $_POST);
165 165
 
166 166
 		// Deny and enable the edit entity capability
167
-		if ( isset( $_POST['wl_can_create_entities'] ) ) {
167
+		if (isset($_POST['wl_can_create_entities'])) {
168 168
 			// User has capability so remove the deny indication if present.
169
-			$this->user_service->allow_editor_entity_create( $user_id );
169
+			$this->user_service->allow_editor_entity_create($user_id);
170 170
 		} else {
171
-			$this->user_service->deny_editor_entity_create( $user_id );
171
+			$this->user_service->deny_editor_entity_create($user_id);
172 172
 		}
173 173
 
174 174
 	}
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * @since 3.14.0
184 184
 	 */
185
-	private function link_entity( $user_id, $post ) {
185
+	private function link_entity($user_id, $post) {
186 186
 
187 187
 		// Bail out if the `wl_person` parameter isn't set.
188
-		if ( ! isset( $post['wl_person'] ) || ! is_numeric( $post['wl_person'] ) ) {
188
+		if ( ! isset($post['wl_person']) || ! is_numeric($post['wl_person'])) {
189 189
 			return;
190 190
 		}
191 191
 
192
-		$this->user_service->set_entity( $user_id, intval( $post['wl_person'] ) );
192
+		$this->user_service->set_entity($user_id, intval($post['wl_person']));
193 193
 
194 194
 	}
195 195
 
Please login to merge, or discard this patch.
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -18,102 +18,102 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Admin_User_Profile_Page {
20 20
 
21
-	/**
22
-	 * The {@link Wordlift_Admin_Person_Element} instance.
23
-	 *
24
-	 * @since  3.14.0
25
-	 * @access private
26
-	 * @var \Wordlift_Admin_Author_Element $plugin The person entity
27
-	 *                selection element rendering the possible persons.
28
-	 */
29
-	private $author_element;
30
-
31
-	/**
32
-	 * The {@link Wordlift_User_Service} instance.
33
-	 *
34
-	 * @since  3.14.0
35
-	 * @access private
36
-	 * @var \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance.
37
-	 */
38
-	private $user_service;
39
-
40
-	/**
41
-	 * Create the {@link Wordlift_Admin_User_Profile_Page} instance.
42
-	 *
43
-	 * @param \Wordlift_Admin_Author_Element $author_element The person entity selection
44
-	 *                                                       element rendering the possible persons.
45
-	 * @param \Wordlift_User_Service         $user_service The {@link Wordlift_User_Service} instance.
46
-	 *
47
-	 * @since 3.14.0
48
-	 */
49
-	public function __construct( $author_element, $user_service ) {
50
-
51
-		$this->author_element = $author_element;
52
-		$this->user_service   = $user_service;
53
-
54
-		/*
21
+    /**
22
+     * The {@link Wordlift_Admin_Person_Element} instance.
23
+     *
24
+     * @since  3.14.0
25
+     * @access private
26
+     * @var \Wordlift_Admin_Author_Element $plugin The person entity
27
+     *                selection element rendering the possible persons.
28
+     */
29
+    private $author_element;
30
+
31
+    /**
32
+     * The {@link Wordlift_User_Service} instance.
33
+     *
34
+     * @since  3.14.0
35
+     * @access private
36
+     * @var \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance.
37
+     */
38
+    private $user_service;
39
+
40
+    /**
41
+     * Create the {@link Wordlift_Admin_User_Profile_Page} instance.
42
+     *
43
+     * @param \Wordlift_Admin_Author_Element $author_element The person entity selection
44
+     *                                                       element rendering the possible persons.
45
+     * @param \Wordlift_User_Service         $user_service The {@link Wordlift_User_Service} instance.
46
+     *
47
+     * @since 3.14.0
48
+     */
49
+    public function __construct( $author_element, $user_service ) {
50
+
51
+        $this->author_element = $author_element;
52
+        $this->user_service   = $user_service;
53
+
54
+        /*
55 55
 		 * When an admin (or similar permissions) edits his own profile a
56 56
 		 * different action than the usual is being triggered.
57 57
 		 * It is too early in the WordPress boot to do user capabilities filtering
58 58
 		 * here and it is deferred to the handler.
59 59
 		 */
60
-		add_action( 'show_user_profile', array( $this, 'edit_user_profile' ) );
61
-		add_action( 'edit_user_profile', array( $this, 'edit_user_profile' ) );
62
-		add_action(
63
-			'edit_user_profile_update',
64
-			array(
65
-				$this,
66
-				'edit_user_profile_update',
67
-			)
68
-		);
69
-		add_action(
70
-			'personal_options_update',
71
-			array(
72
-				$this,
73
-				'edit_user_profile_update',
74
-			)
75
-		);
76
-
77
-	}
78
-
79
-	/**
80
-	 * Add a WordLift section in the user profile which lets
81
-	 * the admin to associate a WordPress user with a person entity.
82
-	 *
83
-	 * @param WP_User $user The current WP_User object of the user being edited.
84
-	 *
85
-	 * @since 3.14.0
86
-	 */
87
-	public function edit_user_profile( $user ) {
88
-
89
-		// In case it is a user editing his own profile, make sure he has admin
90
-		// like capabilities.
91
-		if ( ! current_user_can( 'edit_users' ) ) {
92
-			return;
93
-		}
94
-
95
-		?>
60
+        add_action( 'show_user_profile', array( $this, 'edit_user_profile' ) );
61
+        add_action( 'edit_user_profile', array( $this, 'edit_user_profile' ) );
62
+        add_action(
63
+            'edit_user_profile_update',
64
+            array(
65
+                $this,
66
+                'edit_user_profile_update',
67
+            )
68
+        );
69
+        add_action(
70
+            'personal_options_update',
71
+            array(
72
+                $this,
73
+                'edit_user_profile_update',
74
+            )
75
+        );
76
+
77
+    }
78
+
79
+    /**
80
+     * Add a WordLift section in the user profile which lets
81
+     * the admin to associate a WordPress user with a person entity.
82
+     *
83
+     * @param WP_User $user The current WP_User object of the user being edited.
84
+     *
85
+     * @since 3.14.0
86
+     */
87
+    public function edit_user_profile( $user ) {
88
+
89
+        // In case it is a user editing his own profile, make sure he has admin
90
+        // like capabilities.
91
+        if ( ! current_user_can( 'edit_users' ) ) {
92
+            return;
93
+        }
94
+
95
+        ?>
96 96
 		<h2><?php esc_html_e( 'WordLift', 'wordlift' ); ?></h2>
97 97
 		<?php wp_nonce_field( 'wordlift_user_save', 'wordlift_user_save_nonce', false ); ?>
98 98
 		<table class="form-table">
99 99
 			<?php
100
-			// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
101
-			if ( apply_filters( 'wl_feature__enable__user-author', true ) ) {
102
-				?>
100
+            // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
101
+            if ( apply_filters( 'wl_feature__enable__user-author', true ) ) {
102
+                ?>
103 103
 				<tr class="user-description-wrap">
104 104
 					<th><label
105 105
 								for="wl_person"><?php esc_html_e( 'Author from the vocabulary', 'wordlift' ); ?></label>
106 106
 					</th>
107 107
 					<td>
108 108
 						<?php
109
-						$this->author_element->render(
110
-							array(
111
-								'id'             => 'wl_person',
112
-								'name'           => 'wl_person',
113
-								'current_entity' => $this->user_service->get_entity( $user->ID ),
114
-							)
115
-						);
116
-						?>
109
+                        $this->author_element->render(
110
+                            array(
111
+                                'id'             => 'wl_person',
112
+                                'name'           => 'wl_person',
113
+                                'current_entity' => $this->user_service->get_entity( $user->ID ),
114
+                            )
115
+                        );
116
+                        ?>
117 117
 						<p class="description"><?php esc_html_e( 'The entity, person or organization, from the vocabulary to associate with this author.', 'wordlift' ); ?></p>
118 118
 					</td>
119 119
 				</tr>
@@ -131,66 +131,66 @@  discard block
 block discarded – undo
131 131
 				</td>
132 132
 				<?php } ?>
133 133
 				<?php
134
-				/**
135
-				 * Action name: wordlift_user_settings_page
136
-				 * An action to render the wordlift user settings.
137
-				 *
138
-				 * @since 3.30.0
139
-				 */
140
-				do_action( 'wordlift_user_settings_page' );
141
-				?>
134
+                /**
135
+                 * Action name: wordlift_user_settings_page
136
+                 * An action to render the wordlift user settings.
137
+                 *
138
+                 * @since 3.30.0
139
+                 */
140
+                do_action( 'wordlift_user_settings_page' );
141
+                ?>
142 142
 		</table>
143 143
 		<?php
144
-	}
145
-
146
-	/**
147
-	 * Handle storing the person entity associated with the user.
148
-	 *
149
-	 * @param int $user_id The user id of the user being saved.
150
-	 *
151
-	 * @since 3.14.0
152
-	 */
153
-	public function edit_user_profile_update( $user_id ) {
154
-
155
-		// In case it is a user editing his own profile, make sure he has admin
156
-		// like capabilities.
157
-		if ( ! current_user_can( 'edit_users' ) ) {
158
-			return;
159
-		}
160
-
161
-		check_admin_referer( 'wordlift_user_save', 'wordlift_user_save_nonce' );
162
-
163
-		// Link an entity to the user.
164
-		$this->link_entity( $user_id, $_POST );
165
-
166
-		// Deny and enable the edit entity capability
167
-		if ( isset( $_POST['wl_can_create_entities'] ) ) {
168
-			// User has capability so remove the deny indication if present.
169
-			$this->user_service->allow_editor_entity_create( $user_id );
170
-		} else {
171
-			$this->user_service->deny_editor_entity_create( $user_id );
172
-		}
173
-
174
-	}
175
-
176
-	/**
177
-	 * Link an entity (specified in the `$_POST` array) to the {@link WP_User}
178
-	 * with the specified `id`.
179
-	 *
180
-	 * @param int   $user_id The {@link WP_User} `id`.
181
-	 * @param array $post The `$_POST` array.
182
-	 *
183
-	 * @since 3.14.0
184
-	 */
185
-	private function link_entity( $user_id, $post ) {
186
-
187
-		// Bail out if the `wl_person` parameter isn't set.
188
-		if ( ! isset( $post['wl_person'] ) || ! is_numeric( $post['wl_person'] ) ) {
189
-			return;
190
-		}
191
-
192
-		$this->user_service->set_entity( $user_id, intval( $post['wl_person'] ) );
193
-
194
-	}
144
+    }
145
+
146
+    /**
147
+     * Handle storing the person entity associated with the user.
148
+     *
149
+     * @param int $user_id The user id of the user being saved.
150
+     *
151
+     * @since 3.14.0
152
+     */
153
+    public function edit_user_profile_update( $user_id ) {
154
+
155
+        // In case it is a user editing his own profile, make sure he has admin
156
+        // like capabilities.
157
+        if ( ! current_user_can( 'edit_users' ) ) {
158
+            return;
159
+        }
160
+
161
+        check_admin_referer( 'wordlift_user_save', 'wordlift_user_save_nonce' );
162
+
163
+        // Link an entity to the user.
164
+        $this->link_entity( $user_id, $_POST );
165
+
166
+        // Deny and enable the edit entity capability
167
+        if ( isset( $_POST['wl_can_create_entities'] ) ) {
168
+            // User has capability so remove the deny indication if present.
169
+            $this->user_service->allow_editor_entity_create( $user_id );
170
+        } else {
171
+            $this->user_service->deny_editor_entity_create( $user_id );
172
+        }
173
+
174
+    }
175
+
176
+    /**
177
+     * Link an entity (specified in the `$_POST` array) to the {@link WP_User}
178
+     * with the specified `id`.
179
+     *
180
+     * @param int   $user_id The {@link WP_User} `id`.
181
+     * @param array $post The `$_POST` array.
182
+     *
183
+     * @since 3.14.0
184
+     */
185
+    private function link_entity( $user_id, $post ) {
186
+
187
+        // Bail out if the `wl_person` parameter isn't set.
188
+        if ( ! isset( $post['wl_person'] ) || ! is_numeric( $post['wl_person'] ) ) {
189
+            return;
190
+        }
191
+
192
+        $this->user_service->set_entity( $user_id, intval( $post['wl_person'] ) );
193
+
194
+    }
195 195
 
196 196
 }
Please login to merge, or discard this patch.
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.