Completed
Push — develop ( fc3971...71605d )
by David
03:09 queued 11s
created
src/shortcodes/wordlift_shortcode_geomap.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,6 @@
 block discarded – undo
10 10
 /**
11 11
  * Print both global or post related places in json. It's executed via Ajax
12 12
  *
13
- * @param array $places An array of place posts.
14 13
  *
15 14
  * @return array An array of place posts.
16 15
  *
Please login to merge, or discard this patch.
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -16,110 +16,110 @@  discard block
 block discarded – undo
16 16
  *
17 17
  */
18 18
 function wl_shortcode_geomap_ajax() {
19
-	// Get the post Id.
20
-	$post_id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : null );
19
+    // Get the post Id.
20
+    $post_id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : null );
21 21
 
22
-	$map_data = ( is_numeric( $post_id )
23
-		? wl_shortcode_geomap_ajax_single_post( $post_id )
24
-		: wl_shortcode_geomap_ajax_all_posts() );
22
+    $map_data = ( is_numeric( $post_id )
23
+        ? wl_shortcode_geomap_ajax_single_post( $post_id )
24
+        : wl_shortcode_geomap_ajax_all_posts() );
25 25
 
26
-	wl_core_send_json( wl_shortcode_geomap_format_results( $map_data, $post_id ) );
26
+    wl_core_send_json( wl_shortcode_geomap_format_results( $map_data, $post_id ) );
27 27
 }
28 28
 
29 29
 function wl_shortcode_geomap_ajax_all_posts() {
30
-	global $wpdb;
31
-
32
-	return $wpdb->get_results( $wpdb->prepare(
33
-		"SELECT DISTINCT p1.ID, p1.post_title, pm1.meta_value AS longitude, pm2.meta_value AS latitude"
34
-		. " FROM {$wpdb->posts} p1 "
35
-		. " INNER JOIN {$wpdb->prefix}wl_relation_instances ri"
36
-		. "  ON ri.object_id = p1.ID AND ri.predicate = %s"
37
-		. " INNER JOIN {$wpdb->postmeta} pm1"
38
-		. "  ON pm1.post_id = p1.ID AND pm1.meta_key = %s AND '0' != pm1.meta_value"
39
-		. " INNER JOIN {$wpdb->postmeta} pm2"
40
-		. "  ON pm2.post_id = p1.ID AND pm2.meta_key = %s AND '0' != pm2.meta_value"
41
-		. " WHERE p1.post_status = %s",
42
-		'where',
43
-		'wl_geo_latitude',
44
-		'wl_geo_longitude',
45
-		'publish'
46
-	) );
30
+    global $wpdb;
31
+
32
+    return $wpdb->get_results( $wpdb->prepare(
33
+        "SELECT DISTINCT p1.ID, p1.post_title, pm1.meta_value AS longitude, pm2.meta_value AS latitude"
34
+        . " FROM {$wpdb->posts} p1 "
35
+        . " INNER JOIN {$wpdb->prefix}wl_relation_instances ri"
36
+        . "  ON ri.object_id = p1.ID AND ri.predicate = %s"
37
+        . " INNER JOIN {$wpdb->postmeta} pm1"
38
+        . "  ON pm1.post_id = p1.ID AND pm1.meta_key = %s AND '0' != pm1.meta_value"
39
+        . " INNER JOIN {$wpdb->postmeta} pm2"
40
+        . "  ON pm2.post_id = p1.ID AND pm2.meta_key = %s AND '0' != pm2.meta_value"
41
+        . " WHERE p1.post_status = %s",
42
+        'where',
43
+        'wl_geo_latitude',
44
+        'wl_geo_longitude',
45
+        'publish'
46
+    ) );
47 47
 }
48 48
 
49 49
 function wl_shortcode_geomap_ajax_single_post( $post_id ) {
50
-	global $wpdb;
51
-
52
-	return $wpdb->get_results( $wpdb->prepare(
53
-		"SELECT p2.ID, p2.post_title, pm1.meta_value AS longitude, pm2.meta_value AS latitude"
54
-		. " FROM {$wpdb->posts} p1 "
55
-		. " INNER JOIN {$wpdb->prefix}wl_relation_instances ri"
56
-		. "  ON ri.subject_id = p1.ID AND ri.predicate = %s"
57
-		. " INNER JOIN {$wpdb->posts} p2"
58
-		. "  ON p2.ID = ri.object_id AND p2.post_status = %s"
59
-		. " INNER JOIN {$wpdb->postmeta} pm1"
60
-		. "  ON pm1.post_id = p2.ID AND pm1.meta_key = %s AND '0' != pm1.meta_value"
61
-		. " INNER JOIN {$wpdb->postmeta} pm2"
62
-		. "  ON pm2.post_id = p2.ID AND pm2.meta_key = %s AND '0' != pm2.meta_value"
63
-		. " WHERE p1.ID = %d",
64
-		'where',
65
-		'publish',
66
-		'wl_geo_latitude',
67
-		'wl_geo_longitude',
68
-		$post_id
69
-	) );
50
+    global $wpdb;
51
+
52
+    return $wpdb->get_results( $wpdb->prepare(
53
+        "SELECT p2.ID, p2.post_title, pm1.meta_value AS longitude, pm2.meta_value AS latitude"
54
+        . " FROM {$wpdb->posts} p1 "
55
+        . " INNER JOIN {$wpdb->prefix}wl_relation_instances ri"
56
+        . "  ON ri.subject_id = p1.ID AND ri.predicate = %s"
57
+        . " INNER JOIN {$wpdb->posts} p2"
58
+        . "  ON p2.ID = ri.object_id AND p2.post_status = %s"
59
+        . " INNER JOIN {$wpdb->postmeta} pm1"
60
+        . "  ON pm1.post_id = p2.ID AND pm1.meta_key = %s AND '0' != pm1.meta_value"
61
+        . " INNER JOIN {$wpdb->postmeta} pm2"
62
+        . "  ON pm2.post_id = p2.ID AND pm2.meta_key = %s AND '0' != pm2.meta_value"
63
+        . " WHERE p1.ID = %d",
64
+        'where',
65
+        'publish',
66
+        'wl_geo_latitude',
67
+        'wl_geo_longitude',
68
+        $post_id
69
+    ) );
70 70
 }
71 71
 
72 72
 function wl_shortcode_geomap_get_subjects( $post_id, $exclude_post_id ) {
73 73
 
74
-	global $wpdb;
75
-
76
-	return $wpdb->get_results( $wpdb->prepare(
77
-		"SELECT p.ID, p.post_title"
78
-		. " FROM {$wpdb->prefix}wl_relation_instances ri" .
79
-		" INNER JOIN {$wpdb->posts} p" .
80
-		"  ON p.ID = ri.subject_id AND p.post_status = %s AND p.ID != %d" .
81
-		" WHERE ri.object_id = %d AND ri.predicate = %s",
82
-		'publish',
83
-		$exclude_post_id,
84
-		$post_id,
85
-		'where'
86
-	) );
74
+    global $wpdb;
75
+
76
+    return $wpdb->get_results( $wpdb->prepare(
77
+        "SELECT p.ID, p.post_title"
78
+        . " FROM {$wpdb->prefix}wl_relation_instances ri" .
79
+        " INNER JOIN {$wpdb->posts} p" .
80
+        "  ON p.ID = ri.subject_id AND p.post_status = %s AND p.ID != %d" .
81
+        " WHERE ri.object_id = %d AND ri.predicate = %s",
82
+        'publish',
83
+        $exclude_post_id,
84
+        $post_id,
85
+        'where'
86
+    ) );
87 87
 }
88 88
 
89 89
 function wl_shortcode_geomap_format_results( $results, $post_id = null ) {
90 90
 
91
-	$boundaries = array();
92
-	$features   = array_map( function ( $item ) use ( &$boundaries, $post_id ) {
91
+    $boundaries = array();
92
+    $features   = array_map( function ( $item ) use ( &$boundaries, $post_id ) {
93 93
 
94
-		$thumbnail_url  = get_the_post_thumbnail_url( $item->ID );
95
-		$thumbnail_html = ( $thumbnail_url ? "<img src='$thumbnail_url' width='100%'>" : '' );
94
+        $thumbnail_url  = get_the_post_thumbnail_url( $item->ID );
95
+        $thumbnail_html = ( $thumbnail_url ? "<img src='$thumbnail_url' width='100%'>" : '' );
96 96
 
97
-		// Related posts.
98
-		$subjects            = wl_shortcode_geomap_get_subjects( $item->ID, $post_id );
99
-		$subjects_inner_html = array_reduce( $subjects, function ( $carry, $subject ) {
97
+        // Related posts.
98
+        $subjects            = wl_shortcode_geomap_get_subjects( $item->ID, $post_id );
99
+        $subjects_inner_html = array_reduce( $subjects, function ( $carry, $subject ) {
100 100
 
101
-			$permalink = get_permalink( $subject->ID );
101
+            $permalink = get_permalink( $subject->ID );
102 102
 
103
-			return $carry . sprintf( '<li><a href="%s">%s</a></li>', $permalink, esc_html( $subject->post_title ) );
104
-		}, '' );
105
-		$subjects_html       = ( ! empty( $subjects_inner_html ) ? '<ul>' . $subjects_inner_html . '</ul>' : '' );
103
+            return $carry . sprintf( '<li><a href="%s">%s</a></li>', $permalink, esc_html( $subject->post_title ) );
104
+        }, '' );
105
+        $subjects_html       = ( ! empty( $subjects_inner_html ) ? '<ul>' . $subjects_inner_html . '</ul>' : '' );
106 106
 
107
-		$popup_content = sprintf( '<a href="%s"><h6>%s</h6>%s</a>%s', get_permalink( $item->ID ), $thumbnail_html, esc_html( $item->post_title ), $subjects_html );
108
-		$latitude      = floatval( $item->latitude );
109
-		$longitude     = floatval( $item->longitude );
110
-		$coordinates   = array( $latitude, $longitude, );
111
-		$geometry      = array( 'type' => 'Point', 'coordinates' => $coordinates, );
107
+        $popup_content = sprintf( '<a href="%s"><h6>%s</h6>%s</a>%s', get_permalink( $item->ID ), $thumbnail_html, esc_html( $item->post_title ), $subjects_html );
108
+        $latitude      = floatval( $item->latitude );
109
+        $longitude     = floatval( $item->longitude );
110
+        $coordinates   = array( $latitude, $longitude, );
111
+        $geometry      = array( 'type' => 'Point', 'coordinates' => $coordinates, );
112 112
 
113
-		$boundaries[] = array( $longitude, $latitude, );
113
+        $boundaries[] = array( $longitude, $latitude, );
114 114
 
115
-		return array(
116
-			'type'       => 'Feature',
117
-			'properties' => array( 'popupContent' => $popup_content ),
118
-			'geometry'   => $geometry,
119
-		);
120
-	}, $results );
115
+        return array(
116
+            'type'       => 'Feature',
117
+            'properties' => array( 'popupContent' => $popup_content ),
118
+            'geometry'   => $geometry,
119
+        );
120
+    }, $results );
121 121
 
122
-	return array( 'features' => $features, 'boundaries' => $boundaries, );
122
+    return array( 'features' => $features, 'boundaries' => $boundaries, );
123 123
 }
124 124
 
125 125
 add_action( 'wp_ajax_wl_geomap', 'wl_shortcode_geomap_ajax' );
@@ -130,36 +130,36 @@  discard block
 block discarded – undo
130 130
  */
131 131
 add_action( 'init', function () {
132 132
 
133
-	// Bail out if the `register_block_type` function isn't available.
134
-	if ( ! function_exists( 'register_block_type' ) ) {
135
-		return;
136
-	}
137
-
138
-	register_block_type( 'wordlift/geomap', array(
139
-		'editor_script'   => 'wl-block-editor',
140
-		'render_callback' => function ( $attributes ) {
141
-			$attr_code = '';
142
-			foreach ( $attributes as $key => $value ) {
143
-				$attr_code .= $key . '="' . $value . '" ';
144
-			}
145
-
146
-			return '[wl_geomap ' . $attr_code . ']';
147
-		},
148
-		'attributes'      => array(
149
-			'width'  => array(
150
-				'type'    => 'string',
151
-				'default' => '100%'
152
-			),
153
-			'height' => array(
154
-				'type'    => 'string',
155
-				'default' => '300px'
156
-			),
157
-			'global' => array(
158
-				'type'    => 'bool',
159
-				'default' => false
160
-			),
161
-		)
162
-	) );
133
+    // Bail out if the `register_block_type` function isn't available.
134
+    if ( ! function_exists( 'register_block_type' ) ) {
135
+        return;
136
+    }
137
+
138
+    register_block_type( 'wordlift/geomap', array(
139
+        'editor_script'   => 'wl-block-editor',
140
+        'render_callback' => function ( $attributes ) {
141
+            $attr_code = '';
142
+            foreach ( $attributes as $key => $value ) {
143
+                $attr_code .= $key . '="' . $value . '" ';
144
+            }
145
+
146
+            return '[wl_geomap ' . $attr_code . ']';
147
+        },
148
+        'attributes'      => array(
149
+            'width'  => array(
150
+                'type'    => 'string',
151
+                'default' => '100%'
152
+            ),
153
+            'height' => array(
154
+                'type'    => 'string',
155
+                'default' => '300px'
156
+            ),
157
+            'global' => array(
158
+                'type'    => 'bool',
159
+                'default' => false
160
+            ),
161
+        )
162
+    ) );
163 163
 } );
164 164
 
165 165
 ///**
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
  */
18 18
 function wl_shortcode_geomap_ajax() {
19 19
 	// Get the post Id.
20
-	$post_id = ( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : null );
20
+	$post_id = (isset($_REQUEST['post_id']) ? $_REQUEST['post_id'] : null);
21 21
 
22
-	$map_data = ( is_numeric( $post_id )
23
-		? wl_shortcode_geomap_ajax_single_post( $post_id )
24
-		: wl_shortcode_geomap_ajax_all_posts() );
22
+	$map_data = (is_numeric($post_id)
23
+		? wl_shortcode_geomap_ajax_single_post($post_id)
24
+		: wl_shortcode_geomap_ajax_all_posts());
25 25
 
26
-	wl_core_send_json( wl_shortcode_geomap_format_results( $map_data, $post_id ) );
26
+	wl_core_send_json(wl_shortcode_geomap_format_results($map_data, $post_id));
27 27
 }
28 28
 
29 29
 function wl_shortcode_geomap_ajax_all_posts() {
30 30
 	global $wpdb;
31 31
 
32
-	return $wpdb->get_results( $wpdb->prepare(
32
+	return $wpdb->get_results($wpdb->prepare(
33 33
 		"SELECT DISTINCT p1.ID, p1.post_title, pm1.meta_value AS longitude, pm2.meta_value AS latitude"
34 34
 		. " FROM {$wpdb->posts} p1 "
35 35
 		. " INNER JOIN {$wpdb->prefix}wl_relation_instances ri"
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 		'wl_geo_latitude',
44 44
 		'wl_geo_longitude',
45 45
 		'publish'
46
-	) );
46
+	));
47 47
 }
48 48
 
49
-function wl_shortcode_geomap_ajax_single_post( $post_id ) {
49
+function wl_shortcode_geomap_ajax_single_post($post_id) {
50 50
 	global $wpdb;
51 51
 
52
-	return $wpdb->get_results( $wpdb->prepare(
52
+	return $wpdb->get_results($wpdb->prepare(
53 53
 		"SELECT p2.ID, p2.post_title, pm1.meta_value AS longitude, pm2.meta_value AS latitude"
54 54
 		. " FROM {$wpdb->posts} p1 "
55 55
 		. " INNER JOIN {$wpdb->prefix}wl_relation_instances ri"
@@ -66,84 +66,84 @@  discard block
 block discarded – undo
66 66
 		'wl_geo_latitude',
67 67
 		'wl_geo_longitude',
68 68
 		$post_id
69
-	) );
69
+	));
70 70
 }
71 71
 
72
-function wl_shortcode_geomap_get_subjects( $post_id, $exclude_post_id ) {
72
+function wl_shortcode_geomap_get_subjects($post_id, $exclude_post_id) {
73 73
 
74 74
 	global $wpdb;
75 75
 
76
-	return $wpdb->get_results( $wpdb->prepare(
76
+	return $wpdb->get_results($wpdb->prepare(
77 77
 		"SELECT p.ID, p.post_title"
78
-		. " FROM {$wpdb->prefix}wl_relation_instances ri" .
79
-		" INNER JOIN {$wpdb->posts} p" .
80
-		"  ON p.ID = ri.subject_id AND p.post_status = %s AND p.ID != %d" .
78
+		. " FROM {$wpdb->prefix}wl_relation_instances ri".
79
+		" INNER JOIN {$wpdb->posts} p".
80
+		"  ON p.ID = ri.subject_id AND p.post_status = %s AND p.ID != %d".
81 81
 		" WHERE ri.object_id = %d AND ri.predicate = %s",
82 82
 		'publish',
83 83
 		$exclude_post_id,
84 84
 		$post_id,
85 85
 		'where'
86
-	) );
86
+	));
87 87
 }
88 88
 
89
-function wl_shortcode_geomap_format_results( $results, $post_id = null ) {
89
+function wl_shortcode_geomap_format_results($results, $post_id = null) {
90 90
 
91 91
 	$boundaries = array();
92
-	$features   = array_map( function ( $item ) use ( &$boundaries, $post_id ) {
92
+	$features   = array_map(function($item) use (&$boundaries, $post_id) {
93 93
 
94
-		$thumbnail_url  = get_the_post_thumbnail_url( $item->ID );
95
-		$thumbnail_html = ( $thumbnail_url ? "<img src='$thumbnail_url' width='100%'>" : '' );
94
+		$thumbnail_url  = get_the_post_thumbnail_url($item->ID);
95
+		$thumbnail_html = ($thumbnail_url ? "<img src='$thumbnail_url' width='100%'>" : '');
96 96
 
97 97
 		// Related posts.
98
-		$subjects            = wl_shortcode_geomap_get_subjects( $item->ID, $post_id );
99
-		$subjects_inner_html = array_reduce( $subjects, function ( $carry, $subject ) {
98
+		$subjects            = wl_shortcode_geomap_get_subjects($item->ID, $post_id);
99
+		$subjects_inner_html = array_reduce($subjects, function($carry, $subject) {
100 100
 
101
-			$permalink = get_permalink( $subject->ID );
101
+			$permalink = get_permalink($subject->ID);
102 102
 
103
-			return $carry . sprintf( '<li><a href="%s">%s</a></li>', $permalink, esc_html( $subject->post_title ) );
104
-		}, '' );
105
-		$subjects_html       = ( ! empty( $subjects_inner_html ) ? '<ul>' . $subjects_inner_html . '</ul>' : '' );
103
+			return $carry.sprintf('<li><a href="%s">%s</a></li>', $permalink, esc_html($subject->post_title));
104
+		}, '');
105
+		$subjects_html = ( ! empty($subjects_inner_html) ? '<ul>'.$subjects_inner_html.'</ul>' : '');
106 106
 
107
-		$popup_content = sprintf( '<a href="%s"><h6>%s</h6>%s</a>%s', get_permalink( $item->ID ), $thumbnail_html, esc_html( $item->post_title ), $subjects_html );
108
-		$latitude      = floatval( $item->latitude );
109
-		$longitude     = floatval( $item->longitude );
110
-		$coordinates   = array( $latitude, $longitude, );
111
-		$geometry      = array( 'type' => 'Point', 'coordinates' => $coordinates, );
107
+		$popup_content = sprintf('<a href="%s"><h6>%s</h6>%s</a>%s', get_permalink($item->ID), $thumbnail_html, esc_html($item->post_title), $subjects_html);
108
+		$latitude      = floatval($item->latitude);
109
+		$longitude     = floatval($item->longitude);
110
+		$coordinates   = array($latitude, $longitude,);
111
+		$geometry      = array('type' => 'Point', 'coordinates' => $coordinates,);
112 112
 
113
-		$boundaries[] = array( $longitude, $latitude, );
113
+		$boundaries[] = array($longitude, $latitude,);
114 114
 
115 115
 		return array(
116 116
 			'type'       => 'Feature',
117
-			'properties' => array( 'popupContent' => $popup_content ),
117
+			'properties' => array('popupContent' => $popup_content),
118 118
 			'geometry'   => $geometry,
119 119
 		);
120
-	}, $results );
120
+	}, $results);
121 121
 
122
-	return array( 'features' => $features, 'boundaries' => $boundaries, );
122
+	return array('features' => $features, 'boundaries' => $boundaries,);
123 123
 }
124 124
 
125
-add_action( 'wp_ajax_wl_geomap', 'wl_shortcode_geomap_ajax' );
126
-add_action( 'wp_ajax_nopriv_wl_geomap', 'wl_shortcode_geomap_ajax' );
125
+add_action('wp_ajax_wl_geomap', 'wl_shortcode_geomap_ajax');
126
+add_action('wp_ajax_nopriv_wl_geomap', 'wl_shortcode_geomap_ajax');
127 127
 
128 128
 /**
129 129
  * register_block_type for Gutenberg blocks
130 130
  */
131
-add_action( 'init', function () {
131
+add_action('init', function() {
132 132
 
133 133
 	// Bail out if the `register_block_type` function isn't available.
134
-	if ( ! function_exists( 'register_block_type' ) ) {
134
+	if ( ! function_exists('register_block_type')) {
135 135
 		return;
136 136
 	}
137 137
 
138
-	register_block_type( 'wordlift/geomap', array(
138
+	register_block_type('wordlift/geomap', array(
139 139
 		'editor_script'   => 'wl-block-editor',
140
-		'render_callback' => function ( $attributes ) {
140
+		'render_callback' => function($attributes) {
141 141
 			$attr_code = '';
142
-			foreach ( $attributes as $key => $value ) {
143
-				$attr_code .= $key . '="' . $value . '" ';
142
+			foreach ($attributes as $key => $value) {
143
+				$attr_code .= $key.'="'.$value.'" ';
144 144
 			}
145 145
 
146
-			return '[wl_geomap ' . $attr_code . ']';
146
+			return '[wl_geomap '.$attr_code.']';
147 147
 		},
148 148
 		'attributes'      => array(
149 149
 			'width'  => array(
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 				'default' => false
160 160
 			),
161 161
 		)
162
-	) );
162
+	));
163 163
 } );
164 164
 
165 165
 ///**
Please login to merge, or discard this patch.
src/wordlift/autocomplete/class-linked-data-autocomplete-service.php 3 patches
Doc Comments   +7 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,6 +108,9 @@  discard block
 block discarded – undo
108 108
 		return $mapped_results;
109 109
 	}
110 110
 
111
+	/**
112
+	 * @param string $query
113
+	 */
111 114
 	private function do_query( $query, $scope = 'cloud', $exclude = '' ) {
112 115
 		$url = $this->build_request_url( $query, $exclude, $scope );
113 116
 
@@ -139,7 +142,7 @@  discard block
 block discarded – undo
139 142
 	 * Build the autocomplete url.
140 143
 	 *
141 144
 	 * @param string $query The search string.
142
-	 * @param array|string $exclude The exclude parameter.
145
+	 * @param string $exclude The exclude parameter.
143 146
 	 * @param string $scope The search scope: "local" will search only in the local dataset; "cloud" will search also
144 147
 	 *                      in Wikipedia. By default is "cloud".
145 148
 	 *
@@ -171,6 +174,9 @@  discard block
 block discarded – undo
171 174
 		return $request_url;
172 175
 	}
173 176
 
177
+	/**
178
+	 * @param \WP_Post|null $post
179
+	 */
174 180
 	private function post_to_autocomplete_result( $uri, $post ) {
175 181
 
176 182
 		return array(
Please login to merge, or discard this patch.
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -15,177 +15,177 @@
 block discarded – undo
15 15
 
16 16
 class Linked_Data_Autocomplete_Service implements Autocomplete_Service {
17 17
 
18
-	/**
19
-	 * The {@link Wordlift_Configuration_Service} instance.
20
-	 *
21
-	 * @since  3.15.0
22
-	 * @access private
23
-	 * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
24
-	 */
25
-	private $configuration_service;
26
-
27
-	/**
28
-	 * A {@link Wordlift_Log_Service} instance.
29
-	 *
30
-	 * @since  3.15.0
31
-	 * @access private
32
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
33
-	 */
34
-	private $log;
35
-	private $entity_helper;
36
-	private $entity_uri_service;
37
-	/**
38
-	 * @var \Wordlift_Entity_Service
39
-	 */
40
-	private $entity_service;
41
-
42
-	/**
43
-	 * The {@link Class_Wordlift_Autocomplete_Service} instance.
44
-	 *
45
-	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
46
-	 * @param Entity_Helper $entity_helper
47
-	 * @param \Wordlift_Entity_Uri_Service $entity_uri_service
48
-	 * @param \Wordlift_Entity_Service $entity_service
49
-	 *
50
-	 * @since 3.15.0
51
-	 */
52
-	public function __construct( $configuration_service, $entity_helper, $entity_uri_service, $entity_service ) {
53
-
54
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Autocomplete_Service' );
55
-
56
-		$this->configuration_service = $configuration_service;
57
-		$this->entity_helper         = $entity_helper;
58
-		$this->entity_uri_service    = $entity_uri_service;
59
-		$this->entity_service        = $entity_service;
60
-
61
-	}
62
-
63
-	/**
64
-	 * Make request to external API and return the response.
65
-	 *
66
-	 * @param string $query The search string.
67
-	 * @param string $scope The search scope: "local" will search only in the local dataset; "cloud" will search also
68
-	 *                      in Wikipedia. By default is "cloud".
69
-	 * @param array|string $excludes The exclude parameter string.
70
-	 *
71
-	 * @return array $response The API response.
72
-	 * @since 3.15.0
73
-	 *
74
-	 */
75
-	public function query( $query, $scope = 'cloud', $excludes = array() ) {
76
-
77
-		$results = $this->do_query( $query, $scope, $excludes );
78
-
79
-		$uris = array_reduce( $results, function ( $carry, $result ) {
80
-
81
-			$carry[] = $result['id'];
82
-
83
-			return array_merge( $carry, $result['sameAss'] );
84
-		}, array() );
85
-
86
-		$mappings = $this->entity_helper->map_many_to_local( $uris );
87
-
88
-		$that           = $this;
89
-		$mapped_results = array_map( function ( $result ) use ( $that, $mappings ) {
90
-
91
-			if ( $that->entity_uri_service->is_internal( $result['id'] ) ) {
92
-				return $result;
93
-			}
94
-
95
-			$uris = array_merge( (array) $result['id'], $result['sameAss'] );
96
-
97
-			foreach ( $uris as $uri ) {
98
-				if ( isset( $mappings[ $uri ] ) ) {
99
-					$local_entity = $that->entity_uri_service->get_entity( $mappings[ $uri ] );
100
-
101
-					return $that->post_to_autocomplete_result( $mappings[ $uri ], $local_entity );
102
-				}
103
-			}
104
-
105
-			return $result;
106
-		}, $results );
107
-
108
-		return $mapped_results;
109
-	}
110
-
111
-	private function do_query( $query, $scope = 'cloud', $exclude = '' ) {
112
-		$url = $this->build_request_url( $query, $exclude, $scope );
113
-
114
-		// Return the response.
115
-		$response = wp_remote_get( $url, array(
116
-			'timeout' => 30
117
-		) );
118
-
119
-		// If the response is valid, then send the suggestions.
120
-		if ( ! is_wp_error( $response ) && 200 === (int) $response['response']['code'] ) {
121
-			// Echo the response.
122
-			return json_decode( wp_remote_retrieve_body( $response ), true );
123
-		} else {
124
-			// Default error message.
125
-			$error_message = 'Something went wrong.';
126
-
127
-			// Get the real error message if there is WP_Error.
128
-			if ( is_wp_error( $response ) ) {
129
-				$error_message = $response->get_error_message();
130
-			}
131
-
132
-			$this->log->error( $error_message );
133
-
134
-			return array();
135
-		}
136
-	}
137
-
138
-	/**
139
-	 * Build the autocomplete url.
140
-	 *
141
-	 * @param string $query The search string.
142
-	 * @param array|string $exclude The exclude parameter.
143
-	 * @param string $scope The search scope: "local" will search only in the local dataset; "cloud" will search also
144
-	 *                      in Wikipedia. By default is "cloud".
145
-	 *
146
-	 * @return string Built url.
147
-	 * @since 3.15.0
148
-	 *
149
-	 */
150
-	private function build_request_url( $query, $exclude, $scope ) {
151
-		$args = array(
152
-			'key'      => $this->configuration_service->get_key(),
153
-			'language' => $this->configuration_service->get_language_code(),
154
-			'query'    => $query,
155
-			'scope'    => $scope,
156
-			'limit'    => 10,
157
-		);
158
-
159
-		// Add args to URL.
160
-		$request_url = add_query_arg(
161
-			urlencode_deep( $args ),
162
-			$this->configuration_service->get_autocomplete_url()
163
-		);
164
-
165
-		// Add the exclude parameter.
166
-		if ( ! empty( $exclude ) ) {
167
-			$request_url .= "&exclude=" . implode( '&exclude=', array_map( 'urlencode', (array) $exclude ) );
168
-		}
169
-
170
-		// return the built url.
171
-		return $request_url;
172
-	}
173
-
174
-	private function post_to_autocomplete_result( $uri, $post ) {
175
-
176
-		return array(
177
-			'id'           => $uri,
178
-			'label'        => array( $post->post_title ),
179
-			'labels'       => $this->entity_service->get_alternative_labels( $post->ID ),
180
-			'descriptions' => array( Wordlift_Post_Excerpt_Helper::get_text_excerpt( $post ) ),
181
-			'scope'        => 'local',
182
-			'sameAss'      => get_post_meta( $post->ID, \Wordlift_Schema_Service::FIELD_SAME_AS ),
183
-			// The following properties are less relevant because we're linking entities that exist already in the
184
-			// vocabulary. That's why we don't make an effort to load the real data.
185
-			'types'        => array( 'http://schema.org/Thing' ),
186
-			'urls'         => array(),
187
-			'images'       => array(),
188
-		);
189
-	}
18
+    /**
19
+     * The {@link Wordlift_Configuration_Service} instance.
20
+     *
21
+     * @since  3.15.0
22
+     * @access private
23
+     * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
24
+     */
25
+    private $configuration_service;
26
+
27
+    /**
28
+     * A {@link Wordlift_Log_Service} instance.
29
+     *
30
+     * @since  3.15.0
31
+     * @access private
32
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
33
+     */
34
+    private $log;
35
+    private $entity_helper;
36
+    private $entity_uri_service;
37
+    /**
38
+     * @var \Wordlift_Entity_Service
39
+     */
40
+    private $entity_service;
41
+
42
+    /**
43
+     * The {@link Class_Wordlift_Autocomplete_Service} instance.
44
+     *
45
+     * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
46
+     * @param Entity_Helper $entity_helper
47
+     * @param \Wordlift_Entity_Uri_Service $entity_uri_service
48
+     * @param \Wordlift_Entity_Service $entity_service
49
+     *
50
+     * @since 3.15.0
51
+     */
52
+    public function __construct( $configuration_service, $entity_helper, $entity_uri_service, $entity_service ) {
53
+
54
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Autocomplete_Service' );
55
+
56
+        $this->configuration_service = $configuration_service;
57
+        $this->entity_helper         = $entity_helper;
58
+        $this->entity_uri_service    = $entity_uri_service;
59
+        $this->entity_service        = $entity_service;
60
+
61
+    }
62
+
63
+    /**
64
+     * Make request to external API and return the response.
65
+     *
66
+     * @param string $query The search string.
67
+     * @param string $scope The search scope: "local" will search only in the local dataset; "cloud" will search also
68
+     *                      in Wikipedia. By default is "cloud".
69
+     * @param array|string $excludes The exclude parameter string.
70
+     *
71
+     * @return array $response The API response.
72
+     * @since 3.15.0
73
+     *
74
+     */
75
+    public function query( $query, $scope = 'cloud', $excludes = array() ) {
76
+
77
+        $results = $this->do_query( $query, $scope, $excludes );
78
+
79
+        $uris = array_reduce( $results, function ( $carry, $result ) {
80
+
81
+            $carry[] = $result['id'];
82
+
83
+            return array_merge( $carry, $result['sameAss'] );
84
+        }, array() );
85
+
86
+        $mappings = $this->entity_helper->map_many_to_local( $uris );
87
+
88
+        $that           = $this;
89
+        $mapped_results = array_map( function ( $result ) use ( $that, $mappings ) {
90
+
91
+            if ( $that->entity_uri_service->is_internal( $result['id'] ) ) {
92
+                return $result;
93
+            }
94
+
95
+            $uris = array_merge( (array) $result['id'], $result['sameAss'] );
96
+
97
+            foreach ( $uris as $uri ) {
98
+                if ( isset( $mappings[ $uri ] ) ) {
99
+                    $local_entity = $that->entity_uri_service->get_entity( $mappings[ $uri ] );
100
+
101
+                    return $that->post_to_autocomplete_result( $mappings[ $uri ], $local_entity );
102
+                }
103
+            }
104
+
105
+            return $result;
106
+        }, $results );
107
+
108
+        return $mapped_results;
109
+    }
110
+
111
+    private function do_query( $query, $scope = 'cloud', $exclude = '' ) {
112
+        $url = $this->build_request_url( $query, $exclude, $scope );
113
+
114
+        // Return the response.
115
+        $response = wp_remote_get( $url, array(
116
+            'timeout' => 30
117
+        ) );
118
+
119
+        // If the response is valid, then send the suggestions.
120
+        if ( ! is_wp_error( $response ) && 200 === (int) $response['response']['code'] ) {
121
+            // Echo the response.
122
+            return json_decode( wp_remote_retrieve_body( $response ), true );
123
+        } else {
124
+            // Default error message.
125
+            $error_message = 'Something went wrong.';
126
+
127
+            // Get the real error message if there is WP_Error.
128
+            if ( is_wp_error( $response ) ) {
129
+                $error_message = $response->get_error_message();
130
+            }
131
+
132
+            $this->log->error( $error_message );
133
+
134
+            return array();
135
+        }
136
+    }
137
+
138
+    /**
139
+     * Build the autocomplete url.
140
+     *
141
+     * @param string $query The search string.
142
+     * @param array|string $exclude The exclude parameter.
143
+     * @param string $scope The search scope: "local" will search only in the local dataset; "cloud" will search also
144
+     *                      in Wikipedia. By default is "cloud".
145
+     *
146
+     * @return string Built url.
147
+     * @since 3.15.0
148
+     *
149
+     */
150
+    private function build_request_url( $query, $exclude, $scope ) {
151
+        $args = array(
152
+            'key'      => $this->configuration_service->get_key(),
153
+            'language' => $this->configuration_service->get_language_code(),
154
+            'query'    => $query,
155
+            'scope'    => $scope,
156
+            'limit'    => 10,
157
+        );
158
+
159
+        // Add args to URL.
160
+        $request_url = add_query_arg(
161
+            urlencode_deep( $args ),
162
+            $this->configuration_service->get_autocomplete_url()
163
+        );
164
+
165
+        // Add the exclude parameter.
166
+        if ( ! empty( $exclude ) ) {
167
+            $request_url .= "&exclude=" . implode( '&exclude=', array_map( 'urlencode', (array) $exclude ) );
168
+        }
169
+
170
+        // return the built url.
171
+        return $request_url;
172
+    }
173
+
174
+    private function post_to_autocomplete_result( $uri, $post ) {
175
+
176
+        return array(
177
+            'id'           => $uri,
178
+            'label'        => array( $post->post_title ),
179
+            'labels'       => $this->entity_service->get_alternative_labels( $post->ID ),
180
+            'descriptions' => array( Wordlift_Post_Excerpt_Helper::get_text_excerpt( $post ) ),
181
+            'scope'        => 'local',
182
+            'sameAss'      => get_post_meta( $post->ID, \Wordlift_Schema_Service::FIELD_SAME_AS ),
183
+            // The following properties are less relevant because we're linking entities that exist already in the
184
+            // vocabulary. That's why we don't make an effort to load the real data.
185
+            'types'        => array( 'http://schema.org/Thing' ),
186
+            'urls'         => array(),
187
+            'images'       => array(),
188
+        );
189
+    }
190 190
 
191 191
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @since 3.15.0
51 51
 	 */
52
-	public function __construct( $configuration_service, $entity_helper, $entity_uri_service, $entity_service ) {
52
+	public function __construct($configuration_service, $entity_helper, $entity_uri_service, $entity_service) {
53 53
 
54
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Autocomplete_Service' );
54
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Autocomplete_Service');
55 55
 
56 56
 		$this->configuration_service = $configuration_service;
57 57
 		$this->entity_helper         = $entity_helper;
@@ -72,64 +72,64 @@  discard block
 block discarded – undo
72 72
 	 * @since 3.15.0
73 73
 	 *
74 74
 	 */
75
-	public function query( $query, $scope = 'cloud', $excludes = array() ) {
75
+	public function query($query, $scope = 'cloud', $excludes = array()) {
76 76
 
77
-		$results = $this->do_query( $query, $scope, $excludes );
77
+		$results = $this->do_query($query, $scope, $excludes);
78 78
 
79
-		$uris = array_reduce( $results, function ( $carry, $result ) {
79
+		$uris = array_reduce($results, function($carry, $result) {
80 80
 
81 81
 			$carry[] = $result['id'];
82 82
 
83
-			return array_merge( $carry, $result['sameAss'] );
84
-		}, array() );
83
+			return array_merge($carry, $result['sameAss']);
84
+		}, array());
85 85
 
86
-		$mappings = $this->entity_helper->map_many_to_local( $uris );
86
+		$mappings = $this->entity_helper->map_many_to_local($uris);
87 87
 
88 88
 		$that           = $this;
89
-		$mapped_results = array_map( function ( $result ) use ( $that, $mappings ) {
89
+		$mapped_results = array_map(function($result) use ($that, $mappings) {
90 90
 
91
-			if ( $that->entity_uri_service->is_internal( $result['id'] ) ) {
91
+			if ($that->entity_uri_service->is_internal($result['id'])) {
92 92
 				return $result;
93 93
 			}
94 94
 
95
-			$uris = array_merge( (array) $result['id'], $result['sameAss'] );
95
+			$uris = array_merge((array) $result['id'], $result['sameAss']);
96 96
 
97
-			foreach ( $uris as $uri ) {
98
-				if ( isset( $mappings[ $uri ] ) ) {
99
-					$local_entity = $that->entity_uri_service->get_entity( $mappings[ $uri ] );
97
+			foreach ($uris as $uri) {
98
+				if (isset($mappings[$uri])) {
99
+					$local_entity = $that->entity_uri_service->get_entity($mappings[$uri]);
100 100
 
101
-					return $that->post_to_autocomplete_result( $mappings[ $uri ], $local_entity );
101
+					return $that->post_to_autocomplete_result($mappings[$uri], $local_entity);
102 102
 				}
103 103
 			}
104 104
 
105 105
 			return $result;
106
-		}, $results );
106
+		}, $results);
107 107
 
108 108
 		return $mapped_results;
109 109
 	}
110 110
 
111
-	private function do_query( $query, $scope = 'cloud', $exclude = '' ) {
112
-		$url = $this->build_request_url( $query, $exclude, $scope );
111
+	private function do_query($query, $scope = 'cloud', $exclude = '') {
112
+		$url = $this->build_request_url($query, $exclude, $scope);
113 113
 
114 114
 		// Return the response.
115
-		$response = wp_remote_get( $url, array(
115
+		$response = wp_remote_get($url, array(
116 116
 			'timeout' => 30
117
-		) );
117
+		));
118 118
 
119 119
 		// If the response is valid, then send the suggestions.
120
-		if ( ! is_wp_error( $response ) && 200 === (int) $response['response']['code'] ) {
120
+		if ( ! is_wp_error($response) && 200 === (int) $response['response']['code']) {
121 121
 			// Echo the response.
122
-			return json_decode( wp_remote_retrieve_body( $response ), true );
122
+			return json_decode(wp_remote_retrieve_body($response), true);
123 123
 		} else {
124 124
 			// Default error message.
125 125
 			$error_message = 'Something went wrong.';
126 126
 
127 127
 			// Get the real error message if there is WP_Error.
128
-			if ( is_wp_error( $response ) ) {
128
+			if (is_wp_error($response)) {
129 129
 				$error_message = $response->get_error_message();
130 130
 			}
131 131
 
132
-			$this->log->error( $error_message );
132
+			$this->log->error($error_message);
133 133
 
134 134
 			return array();
135 135
 		}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @since 3.15.0
148 148
 	 *
149 149
 	 */
150
-	private function build_request_url( $query, $exclude, $scope ) {
150
+	private function build_request_url($query, $exclude, $scope) {
151 151
 		$args = array(
152 152
 			'key'      => $this->configuration_service->get_key(),
153 153
 			'language' => $this->configuration_service->get_language_code(),
@@ -158,31 +158,31 @@  discard block
 block discarded – undo
158 158
 
159 159
 		// Add args to URL.
160 160
 		$request_url = add_query_arg(
161
-			urlencode_deep( $args ),
161
+			urlencode_deep($args),
162 162
 			$this->configuration_service->get_autocomplete_url()
163 163
 		);
164 164
 
165 165
 		// Add the exclude parameter.
166
-		if ( ! empty( $exclude ) ) {
167
-			$request_url .= "&exclude=" . implode( '&exclude=', array_map( 'urlencode', (array) $exclude ) );
166
+		if ( ! empty($exclude)) {
167
+			$request_url .= "&exclude=".implode('&exclude=', array_map('urlencode', (array) $exclude));
168 168
 		}
169 169
 
170 170
 		// return the built url.
171 171
 		return $request_url;
172 172
 	}
173 173
 
174
-	private function post_to_autocomplete_result( $uri, $post ) {
174
+	private function post_to_autocomplete_result($uri, $post) {
175 175
 
176 176
 		return array(
177 177
 			'id'           => $uri,
178
-			'label'        => array( $post->post_title ),
179
-			'labels'       => $this->entity_service->get_alternative_labels( $post->ID ),
180
-			'descriptions' => array( Wordlift_Post_Excerpt_Helper::get_text_excerpt( $post ) ),
178
+			'label'        => array($post->post_title),
179
+			'labels'       => $this->entity_service->get_alternative_labels($post->ID),
180
+			'descriptions' => array(Wordlift_Post_Excerpt_Helper::get_text_excerpt($post)),
181 181
 			'scope'        => 'local',
182
-			'sameAss'      => get_post_meta( $post->ID, \Wordlift_Schema_Service::FIELD_SAME_AS ),
182
+			'sameAss'      => get_post_meta($post->ID, \Wordlift_Schema_Service::FIELD_SAME_AS),
183 183
 			// The following properties are less relevant because we're linking entities that exist already in the
184 184
 			// vocabulary. That's why we don't make an effort to load the real data.
185
-			'types'        => array( 'http://schema.org/Thing' ),
185
+			'types'        => array('http://schema.org/Thing'),
186 186
 			'urls'         => array(),
187 187
 			'images'       => array(),
188 188
 		);
Please login to merge, or discard this patch.
src/modules/analyzer/wordlift_analyzer.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function wl_ajax_analyze_action() {
16 16
 
17
-	check_admin_referer( 'wl_analyze' );
17
+    check_admin_referer( 'wl_analyze' );
18 18
 
19
-	$data = filter_input( INPUT_POST, 'data' );
19
+    $data = filter_input( INPUT_POST, 'data' );
20 20
 
21
-	wp_send_json_success( wl_analyze_content( $data, 'application/json; ' . get_bloginfo( 'charset' ) ) );
21
+    wp_send_json_success( wl_analyze_content( $data, 'application/json; ' . get_bloginfo( 'charset' ) ) );
22 22
 
23 23
 }
24 24
 
@@ -45,47 +45,47 @@  discard block
 block discarded – undo
45 45
 //	// Set the content type to the request content type or to text/plain by default.
46 46
 //	$content_type = isset( $_SERVER['CONTENT_TYPE'] ) ? $_SERVER['CONTENT_TYPE'] : 'text/plain';
47 47
 
48
-	add_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' );
49
-	$json = Wordlift_Api_Service::get_instance()
50
-	                            ->post_custom_content_type( 'analysis/single', $data, $content_type );
51
-	remove_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' );
48
+    add_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' );
49
+    $json = Wordlift_Api_Service::get_instance()
50
+                                ->post_custom_content_type( 'analysis/single', $data, $content_type );
51
+    remove_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' );
52 52
 
53
-	// If it's an error log it.
54
-	if ( is_wp_error( $json ) ) {
55
-		$request_body = json_decode( $data, true );
53
+    // If it's an error log it.
54
+    if ( is_wp_error( $json ) ) {
55
+        $request_body = json_decode( $data, true );
56 56
 
57
-		return Analysis_Response_Ops_Factory::get_instance()
58
-		                                    ->create( json_decode( '{ "entities": {}, "annotations": {}, "topics": {} }' ) )
59
-		                                    ->make_entities_local()
60
-		                                    ->add_occurrences( $request_body['content'] )
61
-		                                    ->get_json();
62
-	}
57
+        return Analysis_Response_Ops_Factory::get_instance()
58
+                                            ->create( json_decode( '{ "entities": {}, "annotations": {}, "topics": {} }' ) )
59
+                                            ->make_entities_local()
60
+                                            ->add_occurrences( $request_body['content'] )
61
+                                            ->get_json();
62
+    }
63 63
 
64
-	/*
64
+    /*
65 65
 	 * We pass the response to the Analysis_Response_Ops to ensure that we make remote entities local.
66 66
 	 *
67 67
 	 * @see https://github.com/insideout10/wordlift-plugin/issues/944
68 68
 	 * @since 3.21.5
69 69
 	 */
70 70
 
71
-	// Get the actual content sent to the analysis, so that we can pass it to the Analysis_Response_Ops to populate
72
-	// the occurrences for the local entities.
73
-	if ( 0 === strpos( $content_type, 'application/json' ) ) {
74
-		$request_json    = json_decode( $data );
75
-		$request_content = $request_json->content;
76
-	} else {
77
-		$request_content = $data;
78
-	}
79
-
80
-	return Analysis_Response_Ops_Factory::get_instance()
81
-	                                    ->create( $json )
82
-	                                    ->make_entities_local()
83
-	                                    ->add_occurrences( $request_content )
84
-	                                    ->get_json();
71
+    // Get the actual content sent to the analysis, so that we can pass it to the Analysis_Response_Ops to populate
72
+    // the occurrences for the local entities.
73
+    if ( 0 === strpos( $content_type, 'application/json' ) ) {
74
+        $request_json    = json_decode( $data );
75
+        $request_content = $request_json->content;
76
+    } else {
77
+        $request_content = $data;
78
+    }
79
+
80
+    return Analysis_Response_Ops_Factory::get_instance()
81
+                                        ->create( $json )
82
+                                        ->make_entities_local()
83
+                                        ->add_occurrences( $request_content )
84
+                                        ->get_json();
85 85
 
86 86
 }
87 87
 
88 88
 function wl_use_analysis_on_api_wordlift_io( $value ) {
89 89
 
90
-	return preg_replace( '|https://api\.wordlift\.it/|', 'https://api.wordlift.io/', $value );
90
+    return preg_replace( '|https://api\.wordlift\.it/|', 'https://api.wordlift.io/', $value );
91 91
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function wl_ajax_analyze_action() {
16 16
 
17
-	check_admin_referer( 'wl_analyze' );
17
+	check_admin_referer('wl_analyze');
18 18
 
19
-	$data = filter_input( INPUT_POST, 'data' );
19
+	$data = filter_input(INPUT_POST, 'data');
20 20
 
21
-	wp_send_json_success( wl_analyze_content( $data, 'application/json; ' . get_bloginfo( 'charset' ) ) );
21
+	wp_send_json_success(wl_analyze_content($data, 'application/json; '.get_bloginfo('charset')));
22 22
 
23 23
 }
24 24
 
25
-add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' );
25
+add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_action');
26 26
 
27 27
 /**
28 28
  * Analyze the provided content. The analysis will make use of the method *wl_ajax_analyze_action*
@@ -40,24 +40,24 @@  discard block
 block discarded – undo
40 40
  * @since 3.24.2 We don't return an error anymore, but an empty analysis response. This is required to allow the editor
41 41
  *   to manage entities or to manually add them even when analysis isn't available.
42 42
  */
43
-function wl_analyze_content( $data, $content_type ) {
43
+function wl_analyze_content($data, $content_type) {
44 44
 
45 45
 //	// Set the content type to the request content type or to text/plain by default.
46 46
 //	$content_type = isset( $_SERVER['CONTENT_TYPE'] ) ? $_SERVER['CONTENT_TYPE'] : 'text/plain';
47 47
 
48
-	add_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' );
48
+	add_filter('wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io');
49 49
 	$json = Wordlift_Api_Service::get_instance()
50
-	                            ->post_custom_content_type( 'analysis/single', $data, $content_type );
51
-	remove_filter( 'wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io' );
50
+	                            ->post_custom_content_type('analysis/single', $data, $content_type);
51
+	remove_filter('wl_api_service_api_url_path', 'wl_use_analysis_on_api_wordlift_io');
52 52
 
53 53
 	// If it's an error log it.
54
-	if ( is_wp_error( $json ) ) {
55
-		$request_body = json_decode( $data, true );
54
+	if (is_wp_error($json)) {
55
+		$request_body = json_decode($data, true);
56 56
 
57 57
 		return Analysis_Response_Ops_Factory::get_instance()
58
-		                                    ->create( json_decode( '{ "entities": {}, "annotations": {}, "topics": {} }' ) )
58
+		                                    ->create(json_decode('{ "entities": {}, "annotations": {}, "topics": {} }'))
59 59
 		                                    ->make_entities_local()
60
-		                                    ->add_occurrences( $request_body['content'] )
60
+		                                    ->add_occurrences($request_body['content'])
61 61
 		                                    ->get_json();
62 62
 	}
63 63
 
@@ -70,22 +70,22 @@  discard block
 block discarded – undo
70 70
 
71 71
 	// Get the actual content sent to the analysis, so that we can pass it to the Analysis_Response_Ops to populate
72 72
 	// the occurrences for the local entities.
73
-	if ( 0 === strpos( $content_type, 'application/json' ) ) {
74
-		$request_json    = json_decode( $data );
73
+	if (0 === strpos($content_type, 'application/json')) {
74
+		$request_json    = json_decode($data);
75 75
 		$request_content = $request_json->content;
76 76
 	} else {
77 77
 		$request_content = $data;
78 78
 	}
79 79
 
80 80
 	return Analysis_Response_Ops_Factory::get_instance()
81
-	                                    ->create( $json )
81
+	                                    ->create($json)
82 82
 	                                    ->make_entities_local()
83
-	                                    ->add_occurrences( $request_content )
83
+	                                    ->add_occurrences($request_content)
84 84
 	                                    ->get_json();
85 85
 
86 86
 }
87 87
 
88
-function wl_use_analysis_on_api_wordlift_io( $value ) {
88
+function wl_use_analysis_on_api_wordlift_io($value) {
89 89
 
90
-	return preg_replace( '|https://api\.wordlift\.it/|', 'https://api.wordlift.io/', $value );
90
+	return preg_replace('|https://api\.wordlift\.it/|', 'https://api.wordlift.io/', $value);
91 91
 }
Please login to merge, or discard this patch.
src/public/class-wordlift-public.php 2 patches
Indentation   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -22,109 +22,109 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class Wordlift_Public {
24 24
 
25
-	/**
26
-	 * The ID of this plugin.
27
-	 *
28
-	 * @since    1.0.0
29
-	 * @access   private
30
-	 * @var      string $plugin_name The ID of this plugin.
31
-	 */
32
-	private $plugin_name;
33
-
34
-	/**
35
-	 * The version of this plugin.
36
-	 *
37
-	 * @since    1.0.0
38
-	 * @access   private
39
-	 * @var      string $version The current version of this plugin.
40
-	 */
41
-	private $version;
42
-
43
-	/**
44
-	 * Initialize the class and set its properties.
45
-	 *
46
-	 * @param string $plugin_name The name of the plugin.
47
-	 * @param string $version The version of this plugin.
48
-	 *
49
-	 * @since    1.0.0
50
-	 *
51
-	 */
52
-	public function __construct( $plugin_name, $version ) {
53
-
54
-		$this->plugin_name = $plugin_name;
55
-		$this->version     = $version;
56
-
57
-	}
58
-
59
-	/**
60
-	 * Register the stylesheets for the public-facing side of the site.
61
-	 *
62
-	 * @since 3.19.3 Register the `wordlift-ui` css.
63
-	 * @since 3.19.2 The call to this function is commented out in `class-wordlift.php` because `wordlift-public.css`
64
-	 *               is empty.
65
-	 * @since 1.0.0
66
-	 */
67
-	public function enqueue_styles() {
68
-
69
-		/**
70
-		 * An instance of this class should be passed to the run() function
71
-		 * defined in Wordlift_Loader as all of the hooks are defined
72
-		 * in that particular class.
73
-		 *
74
-		 * The Wordlift_Loader will then create the relationship
75
-		 * between the defined hooks and the functions defined in this
76
-		 * class.
77
-		 */
78
-
79
-		/**
80
-		 * Add the `wordlift-font-awesome` unless some 3rd party sets the flag to false.
81
-		 *
82
-		 * @param bool $include Whether to include or not font-awesome (default true).
83
-		 *
84
-		 * @since 3.19.3
85
-		 *
86
-		 */
87
-		$deps = apply_filters( 'wl_include_font_awesome', true )
88
-			? array( 'wordlift-font-awesome' )
89
-			: array();
90
-		wp_register_style( 'wordlift-font-awesome', plugin_dir_url( dirname( __FILE__ ) ) . 'css/wordlift-font-awesome' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.css', array(), $this->version, 'all' );
91
-		wp_register_style( 'wordlift-ui', plugin_dir_url( dirname( __FILE__ ) ) . 'css/wordlift-ui' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.css', $deps, $this->version, 'all' );
92
-
93
-		// You need to re-enable the enqueue_styles in `class-wordlift.php` to make this effective.
94
-		//
95
-		// @see https://github.com/insideout10/wordlift-plugin/issues/821
96
-		//
97
-		// wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-public.css', array(), $this->version, 'all' );
98
-
99
-	}
100
-
101
-	/**
102
-	 * Register the stylesheets for the public-facing side of the site.
103
-	 *
104
-	 * @since    1.0.0
105
-	 */
106
-	public function enqueue_scripts() {
107
-
108
-		/**
109
-		 * This function is provided for demonstration purposes only.
110
-		 *
111
-		 * An instance of this class should be passed to the run() function
112
-		 * defined in Wordlift_Loader as all of the hooks are defined
113
-		 * in that particular class.
114
-		 *
115
-		 * The Wordlift_Loader will then create the relationship
116
-		 * between the defined hooks and the functions defined in this
117
-		 * class.
118
-		 */
119
-
120
-		$settings = self::get_settings();
121
-
122
-		// Note that we switched the js to be loaded in footer, since it is loading
123
-		// the json-ld representation.
124
-		wp_enqueue_script( $this->plugin_name, self::get_public_js_url(), array(), $this->version, true );
125
-		wp_localize_script( $this->plugin_name, 'wlSettings', $settings );
126
-
127
-		/*
25
+    /**
26
+     * The ID of this plugin.
27
+     *
28
+     * @since    1.0.0
29
+     * @access   private
30
+     * @var      string $plugin_name The ID of this plugin.
31
+     */
32
+    private $plugin_name;
33
+
34
+    /**
35
+     * The version of this plugin.
36
+     *
37
+     * @since    1.0.0
38
+     * @access   private
39
+     * @var      string $version The current version of this plugin.
40
+     */
41
+    private $version;
42
+
43
+    /**
44
+     * Initialize the class and set its properties.
45
+     *
46
+     * @param string $plugin_name The name of the plugin.
47
+     * @param string $version The version of this plugin.
48
+     *
49
+     * @since    1.0.0
50
+     *
51
+     */
52
+    public function __construct( $plugin_name, $version ) {
53
+
54
+        $this->plugin_name = $plugin_name;
55
+        $this->version     = $version;
56
+
57
+    }
58
+
59
+    /**
60
+     * Register the stylesheets for the public-facing side of the site.
61
+     *
62
+     * @since 3.19.3 Register the `wordlift-ui` css.
63
+     * @since 3.19.2 The call to this function is commented out in `class-wordlift.php` because `wordlift-public.css`
64
+     *               is empty.
65
+     * @since 1.0.0
66
+     */
67
+    public function enqueue_styles() {
68
+
69
+        /**
70
+         * An instance of this class should be passed to the run() function
71
+         * defined in Wordlift_Loader as all of the hooks are defined
72
+         * in that particular class.
73
+         *
74
+         * The Wordlift_Loader will then create the relationship
75
+         * between the defined hooks and the functions defined in this
76
+         * class.
77
+         */
78
+
79
+        /**
80
+         * Add the `wordlift-font-awesome` unless some 3rd party sets the flag to false.
81
+         *
82
+         * @param bool $include Whether to include or not font-awesome (default true).
83
+         *
84
+         * @since 3.19.3
85
+         *
86
+         */
87
+        $deps = apply_filters( 'wl_include_font_awesome', true )
88
+            ? array( 'wordlift-font-awesome' )
89
+            : array();
90
+        wp_register_style( 'wordlift-font-awesome', plugin_dir_url( dirname( __FILE__ ) ) . 'css/wordlift-font-awesome' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.css', array(), $this->version, 'all' );
91
+        wp_register_style( 'wordlift-ui', plugin_dir_url( dirname( __FILE__ ) ) . 'css/wordlift-ui' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.css', $deps, $this->version, 'all' );
92
+
93
+        // You need to re-enable the enqueue_styles in `class-wordlift.php` to make this effective.
94
+        //
95
+        // @see https://github.com/insideout10/wordlift-plugin/issues/821
96
+        //
97
+        // wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-public.css', array(), $this->version, 'all' );
98
+
99
+    }
100
+
101
+    /**
102
+     * Register the stylesheets for the public-facing side of the site.
103
+     *
104
+     * @since    1.0.0
105
+     */
106
+    public function enqueue_scripts() {
107
+
108
+        /**
109
+         * This function is provided for demonstration purposes only.
110
+         *
111
+         * An instance of this class should be passed to the run() function
112
+         * defined in Wordlift_Loader as all of the hooks are defined
113
+         * in that particular class.
114
+         *
115
+         * The Wordlift_Loader will then create the relationship
116
+         * between the defined hooks and the functions defined in this
117
+         * class.
118
+         */
119
+
120
+        $settings = self::get_settings();
121
+
122
+        // Note that we switched the js to be loaded in footer, since it is loading
123
+        // the json-ld representation.
124
+        wp_enqueue_script( $this->plugin_name, self::get_public_js_url(), array(), $this->version, true );
125
+        wp_localize_script( $this->plugin_name, 'wlSettings', $settings );
126
+
127
+        /*
128 128
 		 * Add WordLift's version.
129 129
 		 * Can be disabled via filter 'wl_disable_version_js' since 3.21.1
130 130
 		 *
@@ -133,96 +133,96 @@  discard block
 block discarded – undo
133 133
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/843.
134 134
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/926.
135 135
 		 */
136
-		$show_version_default = false;
137
-		$show_version         = apply_filters( 'wl_disable_version_js', $show_version_default );
136
+        $show_version_default = false;
137
+        $show_version         = apply_filters( 'wl_disable_version_js', $show_version_default );
138 138
 
139
-		if ( $show_version ) {
140
-			wp_localize_script( $this->plugin_name, 'wordlift', array(
141
-				'version' => $this->version,
142
-			) );
143
-		}
139
+        if ( $show_version ) {
140
+            wp_localize_script( $this->plugin_name, 'wordlift', array(
141
+                'version' => $this->version,
142
+            ) );
143
+        }
144 144
 
145
-		/*
145
+        /*
146 146
 		 * Register wordlift-cloud script which is shared by
147 147
 		 * Context Cards and Navigator
148 148
 		 *
149 149
 		 * @since 3.22.0
150 150
 		 *
151 151
 		 */
152
-		wp_register_script( 'wordlift-cloud', self::get_cloud_js_url(), array(), Wordlift::get_instance()->get_version(), true );
153
-
154
-	}
155
-
156
-	/**
157
-	 * Get the settings array.
158
-	 *
159
-	 * @return array An array with the settings.
160
-	 * @since 3.19.1
161
-	 *
162
-	 */
163
-	public static function get_settings() {
164
-
165
-		// Prepare a settings array for client-side functions.
166
-		$settings = array(
167
-			'ajaxUrl'    => admin_url( 'admin-ajax.php' ),
168
-			'apiUrl'     => get_home_url( null, 'wl-api/' ),
169
-			'jsonld_url' => rest_url( '/wordlift/v1/jsonld/' )
170
-		);
171
-
172
-		// If we're in a single page, then print out the post id.
173
-		if ( is_singular() ) {
174
-			$settings['postId'] = get_the_ID();
175
-		}
176
-
177
-		// Add flag that we are on home/blog page.
178
-		if ( is_home() || is_front_page() ) {
179
-			$settings['isHome'] = true;
180
-		}
181
-
182
-		// As of 2020-02-15, we publish the JSON-LD in the head, see Jsonld_Adaper.
183
-		$settings['jsonld_enabled'] = false;
184
-
185
-		// By default only enable JSON-LD on supported entity pages (includes
186
-		// `page`, `post` and `entity` by default) and on the home page.
187
-		//
188
-		// @see https://github.com/insideout10/wordlift-plugin/issues/733
189
-		//	$jsonld_enabled = is_home() || is_front_page() || Wordlift_Entity_Type_Service::is_valid_entity_post_type( get_post_type() );
190
-
191
-		// Add the JSON-LD enabled flag, when set to false, the JSON-LD won't
192
-		// be loaded.
193
-		//
194
-		// @see https://github.com/insideout10/wordlift-plugin/issues/642.
195
-		// $settings['jsonld_enabled'] = apply_filters( 'wl_jsonld_enabled', $jsonld_enabled );
196
-
197
-		return $settings;
198
-	}
199
-
200
-	/**
201
-	 * Get the public JavaScript URL.
202
-	 *
203
-	 * Using this function is encouraged, since the public JavaScript is also used by the {@link Wordlift_WpRocket_Adapter}
204
-	 * in order to avoid breaking optimizations.
205
-	 *
206
-	 * @return string The URL to the public JavaScript.
207
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/842.
208
-	 *
209
-	 * @since 3.19.4
210
-	 *
211
-	 */
212
-	public static function get_public_js_url() {
213
-
214
-		return plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/bundle.js';
215
-	}
216
-
217
-	/**
218
-	 * Get the Cloud JavaScript URL.
219
-	 *
220
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/971
221
-	 * @since 3.23.0
222
-	 * @return string The URL to the Cloud JavaScript.
223
-	 */
224
-	public static function get_cloud_js_url() {
225
-
226
-		return plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/wordlift-cloud.js';
227
-	}
152
+        wp_register_script( 'wordlift-cloud', self::get_cloud_js_url(), array(), Wordlift::get_instance()->get_version(), true );
153
+
154
+    }
155
+
156
+    /**
157
+     * Get the settings array.
158
+     *
159
+     * @return array An array with the settings.
160
+     * @since 3.19.1
161
+     *
162
+     */
163
+    public static function get_settings() {
164
+
165
+        // Prepare a settings array for client-side functions.
166
+        $settings = array(
167
+            'ajaxUrl'    => admin_url( 'admin-ajax.php' ),
168
+            'apiUrl'     => get_home_url( null, 'wl-api/' ),
169
+            'jsonld_url' => rest_url( '/wordlift/v1/jsonld/' )
170
+        );
171
+
172
+        // If we're in a single page, then print out the post id.
173
+        if ( is_singular() ) {
174
+            $settings['postId'] = get_the_ID();
175
+        }
176
+
177
+        // Add flag that we are on home/blog page.
178
+        if ( is_home() || is_front_page() ) {
179
+            $settings['isHome'] = true;
180
+        }
181
+
182
+        // As of 2020-02-15, we publish the JSON-LD in the head, see Jsonld_Adaper.
183
+        $settings['jsonld_enabled'] = false;
184
+
185
+        // By default only enable JSON-LD on supported entity pages (includes
186
+        // `page`, `post` and `entity` by default) and on the home page.
187
+        //
188
+        // @see https://github.com/insideout10/wordlift-plugin/issues/733
189
+        //	$jsonld_enabled = is_home() || is_front_page() || Wordlift_Entity_Type_Service::is_valid_entity_post_type( get_post_type() );
190
+
191
+        // Add the JSON-LD enabled flag, when set to false, the JSON-LD won't
192
+        // be loaded.
193
+        //
194
+        // @see https://github.com/insideout10/wordlift-plugin/issues/642.
195
+        // $settings['jsonld_enabled'] = apply_filters( 'wl_jsonld_enabled', $jsonld_enabled );
196
+
197
+        return $settings;
198
+    }
199
+
200
+    /**
201
+     * Get the public JavaScript URL.
202
+     *
203
+     * Using this function is encouraged, since the public JavaScript is also used by the {@link Wordlift_WpRocket_Adapter}
204
+     * in order to avoid breaking optimizations.
205
+     *
206
+     * @return string The URL to the public JavaScript.
207
+     * @see https://github.com/insideout10/wordlift-plugin/issues/842.
208
+     *
209
+     * @since 3.19.4
210
+     *
211
+     */
212
+    public static function get_public_js_url() {
213
+
214
+        return plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/bundle.js';
215
+    }
216
+
217
+    /**
218
+     * Get the Cloud JavaScript URL.
219
+     *
220
+     * @see https://github.com/insideout10/wordlift-plugin/issues/971
221
+     * @since 3.23.0
222
+     * @return string The URL to the Cloud JavaScript.
223
+     */
224
+    public static function get_cloud_js_url() {
225
+
226
+        return plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/wordlift-cloud.js';
227
+    }
228 228
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @since    1.0.0
50 50
 	 *
51 51
 	 */
52
-	public function __construct( $plugin_name, $version ) {
52
+	public function __construct($plugin_name, $version) {
53 53
 
54 54
 		$this->plugin_name = $plugin_name;
55 55
 		$this->version     = $version;
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 		 * @since 3.19.3
85 85
 		 *
86 86
 		 */
87
-		$deps = apply_filters( 'wl_include_font_awesome', true )
88
-			? array( 'wordlift-font-awesome' )
87
+		$deps = apply_filters('wl_include_font_awesome', true)
88
+			? array('wordlift-font-awesome')
89 89
 			: array();
90
-		wp_register_style( 'wordlift-font-awesome', plugin_dir_url( dirname( __FILE__ ) ) . 'css/wordlift-font-awesome' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.css', array(), $this->version, 'all' );
91
-		wp_register_style( 'wordlift-ui', plugin_dir_url( dirname( __FILE__ ) ) . 'css/wordlift-ui' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.css', $deps, $this->version, 'all' );
90
+		wp_register_style('wordlift-font-awesome', plugin_dir_url(dirname(__FILE__)).'css/wordlift-font-awesome'.( ! defined('SCRIPT_DEBUG') || ! SCRIPT_DEBUG ? '.min' : '').'.css', array(), $this->version, 'all');
91
+		wp_register_style('wordlift-ui', plugin_dir_url(dirname(__FILE__)).'css/wordlift-ui'.( ! defined('SCRIPT_DEBUG') || ! SCRIPT_DEBUG ? '.min' : '').'.css', $deps, $this->version, 'all');
92 92
 
93 93
 		// You need to re-enable the enqueue_styles in `class-wordlift.php` to make this effective.
94 94
 		//
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 
122 122
 		// Note that we switched the js to be loaded in footer, since it is loading
123 123
 		// the json-ld representation.
124
-		wp_enqueue_script( $this->plugin_name, self::get_public_js_url(), array(), $this->version, true );
125
-		wp_localize_script( $this->plugin_name, 'wlSettings', $settings );
124
+		wp_enqueue_script($this->plugin_name, self::get_public_js_url(), array(), $this->version, true);
125
+		wp_localize_script($this->plugin_name, 'wlSettings', $settings);
126 126
 
127 127
 		/*
128 128
 		 * Add WordLift's version.
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/926.
135 135
 		 */
136 136
 		$show_version_default = false;
137
-		$show_version         = apply_filters( 'wl_disable_version_js', $show_version_default );
137
+		$show_version         = apply_filters('wl_disable_version_js', $show_version_default);
138 138
 
139
-		if ( $show_version ) {
140
-			wp_localize_script( $this->plugin_name, 'wordlift', array(
139
+		if ($show_version) {
140
+			wp_localize_script($this->plugin_name, 'wordlift', array(
141 141
 				'version' => $this->version,
142
-			) );
142
+			));
143 143
 		}
144 144
 
145 145
 		/*
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		 * @since 3.22.0
150 150
 		 *
151 151
 		 */
152
-		wp_register_script( 'wordlift-cloud', self::get_cloud_js_url(), array(), Wordlift::get_instance()->get_version(), true );
152
+		wp_register_script('wordlift-cloud', self::get_cloud_js_url(), array(), Wordlift::get_instance()->get_version(), true);
153 153
 
154 154
 	}
155 155
 
@@ -164,18 +164,18 @@  discard block
 block discarded – undo
164 164
 
165 165
 		// Prepare a settings array for client-side functions.
166 166
 		$settings = array(
167
-			'ajaxUrl'    => admin_url( 'admin-ajax.php' ),
168
-			'apiUrl'     => get_home_url( null, 'wl-api/' ),
169
-			'jsonld_url' => rest_url( '/wordlift/v1/jsonld/' )
167
+			'ajaxUrl'    => admin_url('admin-ajax.php'),
168
+			'apiUrl'     => get_home_url(null, 'wl-api/'),
169
+			'jsonld_url' => rest_url('/wordlift/v1/jsonld/')
170 170
 		);
171 171
 
172 172
 		// If we're in a single page, then print out the post id.
173
-		if ( is_singular() ) {
173
+		if (is_singular()) {
174 174
 			$settings['postId'] = get_the_ID();
175 175
 		}
176 176
 
177 177
 		// Add flag that we are on home/blog page.
178
-		if ( is_home() || is_front_page() ) {
178
+		if (is_home() || is_front_page()) {
179 179
 			$settings['isHome'] = true;
180 180
 		}
181 181
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 */
212 212
 	public static function get_public_js_url() {
213 213
 
214
-		return plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/bundle.js';
214
+		return plugin_dir_url(dirname(__FILE__)).'js/dist/bundle.js';
215 215
 	}
216 216
 
217 217
 	/**
@@ -223,6 +223,6 @@  discard block
 block discarded – undo
223 223
 	 */
224 224
 	public static function get_cloud_js_url() {
225 225
 
226
-		return plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/wordlift-cloud.js';
226
+		return plugin_dir_url(dirname(__FILE__)).'js/dist/wordlift-cloud.js';
227 227
 	}
228 228
 }
Please login to merge, or discard this patch.
src/wordlift_entity_type.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
  */
12 12
 function wl_set_entity_main_type( $post_id, $type_uri ) {
13 13
 
14
-	Wordlift_Entity_Type_Service::get_instance()
15
-	                            ->set( $post_id, $type_uri );
14
+    Wordlift_Entity_Type_Service::get_instance()
15
+                                ->set( $post_id, $type_uri );
16 16
 
17 17
 }
18 18
 
@@ -21,35 +21,35 @@  discard block
 block discarded – undo
21 21
  */
22 22
 function wl_print_entity_type_inline_js() {
23 23
 
24
-	$terms = get_terms( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'get' => 'all', ) );
24
+    $terms = get_terms( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'get' => 'all', ) );
25 25
 
26
-	// Load the type data.
27
-	$schema_service = Wordlift_Schema_Service::get_instance();
28
-	$entity_types   = array_reduce( $terms, function ( $carry, $term ) use ( $schema_service ) {
29
-		$type = $schema_service->get_schema( $term->slug );
26
+    // Load the type data.
27
+    $schema_service = Wordlift_Schema_Service::get_instance();
28
+    $entity_types   = array_reduce( $terms, function ( $carry, $term ) use ( $schema_service ) {
29
+        $type = $schema_service->get_schema( $term->slug );
30 30
 
31
-		// Skip if no `uri`.
32
-		if ( empty( $type['uri'] ) ) {
33
-			return $carry;
34
-		}
31
+        // Skip if no `uri`.
32
+        if ( empty( $type['uri'] ) ) {
33
+            return $carry;
34
+        }
35 35
 
36
-		$carry[] = array(
37
-			'label'     => $term->name,
38
-			'uri'       => $type['uri'],
39
-			'css'       => $type['css_class'],
40
-			'sameAs'    => isset( $type['same_as'] ) ? $type['same_as'] : array(),
41
-			'slug'      => $term->slug,
42
-			'templates' => ( isset( $type['templates'] ) ? $type['templates'] : array() ),
43
-		);
36
+        $carry[] = array(
37
+            'label'     => $term->name,
38
+            'uri'       => $type['uri'],
39
+            'css'       => $type['css_class'],
40
+            'sameAs'    => isset( $type['same_as'] ) ? $type['same_as'] : array(),
41
+            'slug'      => $term->slug,
42
+            'templates' => ( isset( $type['templates'] ) ? $type['templates'] : array() ),
43
+        );
44 44
 
45
-		return $carry;
46
-	}, array() );
45
+        return $carry;
46
+    }, array() );
47 47
 
48
-	// Hook to the Block Editor script.
49
-	wp_localize_script( 'wl-block-editor', '_wlEntityTypes', $entity_types );
48
+    // Hook to the Block Editor script.
49
+    wp_localize_script( 'wl-block-editor', '_wlEntityTypes', $entity_types );
50 50
 
51
-	// Hook to the Classic Editor script, see Wordlift_Admin_Post_Edit_Page.
52
-	wp_localize_script( 'wl-classic-editor', '_wlEntityTypes', $entity_types );
51
+    // Hook to the Classic Editor script, see Wordlift_Admin_Post_Edit_Page.
52
+    wp_localize_script( 'wl-classic-editor', '_wlEntityTypes', $entity_types );
53 53
 
54 54
 }
55 55
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
  * @deprecated use Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri )
10 10
  *
11 11
  */
12
-function wl_set_entity_main_type( $post_id, $type_uri ) {
12
+function wl_set_entity_main_type($post_id, $type_uri) {
13 13
 
14 14
 	Wordlift_Entity_Type_Service::get_instance()
15
-	                            ->set( $post_id, $type_uri );
15
+	                            ->set($post_id, $type_uri);
16 16
 
17 17
 }
18 18
 
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
21 21
  */
22 22
 function wl_print_entity_type_inline_js() {
23 23
 
24
-	$terms = get_terms( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'get' => 'all', ) );
24
+	$terms = get_terms(Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array('get' => 'all',));
25 25
 
26 26
 	// Load the type data.
27 27
 	$schema_service = Wordlift_Schema_Service::get_instance();
28
-	$entity_types   = array_reduce( $terms, function ( $carry, $term ) use ( $schema_service ) {
29
-		$type = $schema_service->get_schema( $term->slug );
28
+	$entity_types   = array_reduce($terms, function($carry, $term) use ($schema_service) {
29
+		$type = $schema_service->get_schema($term->slug);
30 30
 
31 31
 		// Skip if no `uri`.
32
-		if ( empty( $type['uri'] ) ) {
32
+		if (empty($type['uri'])) {
33 33
 			return $carry;
34 34
 		}
35 35
 
@@ -37,22 +37,22 @@  discard block
 block discarded – undo
37 37
 			'label'     => $term->name,
38 38
 			'uri'       => $type['uri'],
39 39
 			'css'       => $type['css_class'],
40
-			'sameAs'    => isset( $type['same_as'] ) ? $type['same_as'] : array(),
40
+			'sameAs'    => isset($type['same_as']) ? $type['same_as'] : array(),
41 41
 			'slug'      => $term->slug,
42
-			'templates' => ( isset( $type['templates'] ) ? $type['templates'] : array() ),
42
+			'templates' => (isset($type['templates']) ? $type['templates'] : array()),
43 43
 		);
44 44
 
45 45
 		return $carry;
46
-	}, array() );
46
+	}, array());
47 47
 
48 48
 	// Hook to the Block Editor script.
49
-	wp_localize_script( 'wl-block-editor', '_wlEntityTypes', $entity_types );
49
+	wp_localize_script('wl-block-editor', '_wlEntityTypes', $entity_types);
50 50
 
51 51
 	// Hook to the Classic Editor script, see Wordlift_Admin_Post_Edit_Page.
52
-	wp_localize_script( 'wl-classic-editor', '_wlEntityTypes', $entity_types );
52
+	wp_localize_script('wl-classic-editor', '_wlEntityTypes', $entity_types);
53 53
 
54 54
 }
55 55
 
56 56
 // Allow Classic and Block Editor scripts to register first.
57
-add_action( 'admin_print_scripts-post.php', 'wl_print_entity_type_inline_js', 11 );
58
-add_action( 'admin_print_scripts-post-new.php', 'wl_print_entity_type_inline_js', 11 );
57
+add_action('admin_print_scripts-post.php', 'wl_print_entity_type_inline_js', 11);
58
+add_action('admin_print_scripts-post-new.php', 'wl_print_entity_type_inline_js', 11);
Please login to merge, or discard this patch.
src/admin/class-wordlift-admin-dashboard-v2.php 2 patches
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -5,133 +5,133 @@  discard block
 block discarded – undo
5 5
 
6 6
 class Wordlift_Admin_Dashboard_V2 {
7 7
 
8
-	const TODAYS_TIP = 'wl_todays_tip_data';
9
-	const AVERAGE_POSITION = 'wl_search_rankings_average_position';
10
-
11
-	/**
12
-	 * The {@link Wordlift_Admin_Search_Rankings_Service} instance.
13
-	 *
14
-	 * @since 3.20.0
15
-	 * @access private
16
-	 * @var \Wordlift_Admin_Search_Rankings_Service $search_rankings_service The {@link Wordlift_Admin_Search_Rankings_Service} instance.
17
-	 */
18
-	private $search_rankings_service;
19
-
20
-	/**
21
-	 * The {@link Wordlift_Dashboard_Service} instance.
22
-	 *
23
-	 * @var \Wordlift_Dashboard_Service $dashboard_service The {@link Wordlift_Dashboard_Service} instance.
24
-	 * @access private
25
-	 * @since 3.20.0
26
-	 */
27
-	private $dashboard_service;
28
-
29
-	/**
30
-	 * @var \Wordlift_Entity_Service $entity_service
31
-	 */
32
-	private $entity_service;
33
-
34
-	/**
35
-	 * Wordlift_Admin_Dashboard_V2 constructor.
36
-	 *
37
-	 * @param \Wordlift_Admin_Search_Rankings_Service $search_rankings_service The {@link Wordlift_Admin_Search_Rankings_Service} instance.
38
-	 * @param                                         $dashboard_service
39
-	 *
40
-	 * @since 3.20.0
41
-	 *
42
-	 */
43
-	public function __construct( $search_rankings_service, $dashboard_service, $entity_service ) {
44
-
45
-		add_action( 'wp_dashboard_setup', array( $this, 'dashboard_setup' ) );
46
-
47
-		// Define where to access the tip.
48
-		defined( 'WL_TODAYS_TIP_JSON_URL' ) || define( 'WL_TODAYS_TIP_JSON_URL', 'https://wordlift.io/blog' );
49
-		defined( 'WL_TODAYS_TIP_JSON_URL_IT' ) || define( 'WL_TODAYS_TIP_JSON_URL_IT', '/it/wp-json/wp/v2/posts?context=embed&per_page=1&categories=27' );
50
-		defined( 'WL_TODAYS_TIP_JSON_URL_EN' ) || define( 'WL_TODAYS_TIP_JSON_URL_EN', '/en/wp-json/wp/v2/posts?context=embed&per_page=1&categories=38' );
51
-
52
-		$this->search_rankings_service = $search_rankings_service;
53
-		$this->dashboard_service       = $dashboard_service;
54
-		$this->entity_service          = $entity_service;
55
-
56
-	}
57
-
58
-	/**
59
-	 * Set up the dashboard metabox.
60
-	 *
61
-	 * @since 3.20.0
62
-	 */
63
-	public function dashboard_setup() {
64
-
65
-		wp_add_dashboard_widget(
66
-			'wl-dashboard-v2',
67
-			__( 'WordLift Dashboard', 'wordlift' ),
68
-			array( $this, 'dashboard_setup_callback' )
69
-		);
70
-
71
-	}
72
-
73
-	/**
74
-	 * The dashboard setup callback.
75
-	 *
76
-	 * @since 3.20.0
77
-	 */
78
-	public function dashboard_setup_callback() {
79
-
80
-		// Get the average position.
81
-		$average_position_string = $this->get_average_position();
82
-
83
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-dashboard-v2.php';
84
-
85
-	}
86
-
87
-	/**
88
-	 * Get the keyword average position.
89
-	 *
90
-	 * @return string The formatted average position string (or `n/a` if not available).
91
-	 * @since 3.20.0
92
-	 *
93
-	 */
94
-	private function get_average_position() {
95
-
96
-		// Get the cache value.
97
-		$average_position = get_transient( self::AVERAGE_POSITION );
98
-
99
-		// If there's no cached value, load it.
100
-		if ( false === $average_position ) {
101
-			// Get the average position from Search Ranking Service.
102
-			$average_position = @$this->search_rankings_service->get_average_position();
103
-
104
-			// If there was an error return 'n/a'.
105
-			if ( false === $average_position ) {
106
-				return esc_html( _x( 'n/a', 'Dashboard', 'wordlift' ) );
107
-			}
108
-		}
109
-
110
-		// Store the value for one day.
111
-		set_transient( self::AVERAGE_POSITION, $average_position, 86400 ); // One day.
112
-
113
-		// Format the average position with one decimal.
114
-		return number_format( $average_position, 1 );
115
-	}
116
-
117
-	/**
118
-	 * Get the top entities.
119
-	 *
120
-	 * @return array|object|null An array of top entities.
121
-	 * @since 3.20.0
122
-	 *
123
-	 */
124
-	private function get_top_entities() {
125
-
126
-		// Get the cached results.
127
-		$results = get_transient( '_wl_admin_dashboard_v2__top_entities' );
128
-		if ( false !== $results ) {
129
-			return $results;
130
-		}
131
-
132
-		global $wpdb;
133
-
134
-		$query = <<<EOF
8
+    const TODAYS_TIP = 'wl_todays_tip_data';
9
+    const AVERAGE_POSITION = 'wl_search_rankings_average_position';
10
+
11
+    /**
12
+     * The {@link Wordlift_Admin_Search_Rankings_Service} instance.
13
+     *
14
+     * @since 3.20.0
15
+     * @access private
16
+     * @var \Wordlift_Admin_Search_Rankings_Service $search_rankings_service The {@link Wordlift_Admin_Search_Rankings_Service} instance.
17
+     */
18
+    private $search_rankings_service;
19
+
20
+    /**
21
+     * The {@link Wordlift_Dashboard_Service} instance.
22
+     *
23
+     * @var \Wordlift_Dashboard_Service $dashboard_service The {@link Wordlift_Dashboard_Service} instance.
24
+     * @access private
25
+     * @since 3.20.0
26
+     */
27
+    private $dashboard_service;
28
+
29
+    /**
30
+     * @var \Wordlift_Entity_Service $entity_service
31
+     */
32
+    private $entity_service;
33
+
34
+    /**
35
+     * Wordlift_Admin_Dashboard_V2 constructor.
36
+     *
37
+     * @param \Wordlift_Admin_Search_Rankings_Service $search_rankings_service The {@link Wordlift_Admin_Search_Rankings_Service} instance.
38
+     * @param                                         $dashboard_service
39
+     *
40
+     * @since 3.20.0
41
+     *
42
+     */
43
+    public function __construct( $search_rankings_service, $dashboard_service, $entity_service ) {
44
+
45
+        add_action( 'wp_dashboard_setup', array( $this, 'dashboard_setup' ) );
46
+
47
+        // Define where to access the tip.
48
+        defined( 'WL_TODAYS_TIP_JSON_URL' ) || define( 'WL_TODAYS_TIP_JSON_URL', 'https://wordlift.io/blog' );
49
+        defined( 'WL_TODAYS_TIP_JSON_URL_IT' ) || define( 'WL_TODAYS_TIP_JSON_URL_IT', '/it/wp-json/wp/v2/posts?context=embed&per_page=1&categories=27' );
50
+        defined( 'WL_TODAYS_TIP_JSON_URL_EN' ) || define( 'WL_TODAYS_TIP_JSON_URL_EN', '/en/wp-json/wp/v2/posts?context=embed&per_page=1&categories=38' );
51
+
52
+        $this->search_rankings_service = $search_rankings_service;
53
+        $this->dashboard_service       = $dashboard_service;
54
+        $this->entity_service          = $entity_service;
55
+
56
+    }
57
+
58
+    /**
59
+     * Set up the dashboard metabox.
60
+     *
61
+     * @since 3.20.0
62
+     */
63
+    public function dashboard_setup() {
64
+
65
+        wp_add_dashboard_widget(
66
+            'wl-dashboard-v2',
67
+            __( 'WordLift Dashboard', 'wordlift' ),
68
+            array( $this, 'dashboard_setup_callback' )
69
+        );
70
+
71
+    }
72
+
73
+    /**
74
+     * The dashboard setup callback.
75
+     *
76
+     * @since 3.20.0
77
+     */
78
+    public function dashboard_setup_callback() {
79
+
80
+        // Get the average position.
81
+        $average_position_string = $this->get_average_position();
82
+
83
+        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-dashboard-v2.php';
84
+
85
+    }
86
+
87
+    /**
88
+     * Get the keyword average position.
89
+     *
90
+     * @return string The formatted average position string (or `n/a` if not available).
91
+     * @since 3.20.0
92
+     *
93
+     */
94
+    private function get_average_position() {
95
+
96
+        // Get the cache value.
97
+        $average_position = get_transient( self::AVERAGE_POSITION );
98
+
99
+        // If there's no cached value, load it.
100
+        if ( false === $average_position ) {
101
+            // Get the average position from Search Ranking Service.
102
+            $average_position = @$this->search_rankings_service->get_average_position();
103
+
104
+            // If there was an error return 'n/a'.
105
+            if ( false === $average_position ) {
106
+                return esc_html( _x( 'n/a', 'Dashboard', 'wordlift' ) );
107
+            }
108
+        }
109
+
110
+        // Store the value for one day.
111
+        set_transient( self::AVERAGE_POSITION, $average_position, 86400 ); // One day.
112
+
113
+        // Format the average position with one decimal.
114
+        return number_format( $average_position, 1 );
115
+    }
116
+
117
+    /**
118
+     * Get the top entities.
119
+     *
120
+     * @return array|object|null An array of top entities.
121
+     * @since 3.20.0
122
+     *
123
+     */
124
+    private function get_top_entities() {
125
+
126
+        // Get the cached results.
127
+        $results = get_transient( '_wl_admin_dashboard_v2__top_entities' );
128
+        if ( false !== $results ) {
129
+            return $results;
130
+        }
131
+
132
+        global $wpdb;
133
+
134
+        $query = <<<EOF
135 135
 SELECT p.ID
136 136
      , p.post_title
137 137
      , coalesce(sum(case when obj_t.slug is null then 1 end), 0)     entities
@@ -161,26 +161,26 @@  discard block
 block discarded – undo
161 161
 LIMIT 20;
162 162
 EOF;
163 163
 
164
-		$results = $wpdb->get_results( $query );
165
-		set_transient( '_wl_admin_dashboard_v2__top_entities', $results, 900 );
164
+        $results = $wpdb->get_results( $query );
165
+        set_transient( '_wl_admin_dashboard_v2__top_entities', $results, 900 );
166 166
 
167
-		return $results;
168
-	}
167
+        return $results;
168
+    }
169 169
 
170
-	/**
171
-	 * Get the today's tip block.
172
-	 *
173
-	 * @since 3.20.0
174
-	 */
175
-	public static function get_todays_tip_block() {
170
+    /**
171
+     * Get the today's tip block.
172
+     *
173
+     * @since 3.20.0
174
+     */
175
+    public static function get_todays_tip_block() {
176 176
 
177
-		$data = @self::get_todays_tip_data();
177
+        $data = @self::get_todays_tip_data();
178 178
 
179
-		// Unable to get data from the local cache, nor from the remote URL.
180
-		if ( false === $data ) {
181
-			return;
182
-		}
183
-		?>
179
+        // Unable to get data from the local cache, nor from the remote URL.
180
+        if ( false === $data ) {
181
+            return;
182
+        }
183
+        ?>
184 184
 
185 185
         <div id="wl-todays-tip" class="wl-dashboard__block wl-dashboard__block--todays-tip">
186 186
             <header>
@@ -195,53 +195,53 @@  discard block
 block discarded – undo
195 195
         </div>
196 196
 		<?php
197 197
 
198
-	}
199
-
200
-	/**
201
-	 * Get the today's tip data.
202
-	 *
203
-	 * @return array|false The today's tip data or false in case of error.
204
-	 * @since 3.20.0
205
-	 *
206
-	 */
207
-	private static function get_todays_tip_data() {
208
-
209
-		// Return the transient.
210
-		if ( false !== get_transient( self::TODAYS_TIP ) ) {
211
-			return get_transient( self::TODAYS_TIP );
212
-		}
213
-
214
-		// If the transient isn't available, query the remote web site.
215
-		$url = WL_TODAYS_TIP_JSON_URL
216
-		       . ( 'it' === get_bloginfo( 'language' ) ? WL_TODAYS_TIP_JSON_URL_IT : WL_TODAYS_TIP_JSON_URL_EN );
217
-
218
-		$response = wp_remote_get( $url );
219
-
220
-		if ( is_wp_error( $response )
221
-		     || ! isset( $response['response']['code'] )
222
-		     || 2 !== (int) $response['response']['code'] / 100 ) {
223
-			return false;
224
-		}
225
-
226
-		$json = json_decode( $response['body'], true );
227
-
228
-		if ( empty( $json )
229
-		     || ! isset( $json[0]['title']['rendered'] )
230
-		     || ! isset( $json[0]['excerpt']['rendered'] )
231
-		     || ! isset( $json[0]['link'] ) ) {
232
-			return false;
233
-		}
234
-
235
-		$value = array(
236
-			'title'   => $json[0]['title']['rendered'],
237
-			'excerpt' => '<!-- cached -->' . $json[0]['excerpt']['rendered'],
238
-			'link'    => $json[0]['link'],
239
-		);
240
-
241
-		// Store the results for one day.
242
-		set_transient( self::TODAYS_TIP, $value, 86400 );
243
-
244
-		return $value;
245
-	}
198
+    }
199
+
200
+    /**
201
+     * Get the today's tip data.
202
+     *
203
+     * @return array|false The today's tip data or false in case of error.
204
+     * @since 3.20.0
205
+     *
206
+     */
207
+    private static function get_todays_tip_data() {
208
+
209
+        // Return the transient.
210
+        if ( false !== get_transient( self::TODAYS_TIP ) ) {
211
+            return get_transient( self::TODAYS_TIP );
212
+        }
213
+
214
+        // If the transient isn't available, query the remote web site.
215
+        $url = WL_TODAYS_TIP_JSON_URL
216
+                . ( 'it' === get_bloginfo( 'language' ) ? WL_TODAYS_TIP_JSON_URL_IT : WL_TODAYS_TIP_JSON_URL_EN );
217
+
218
+        $response = wp_remote_get( $url );
219
+
220
+        if ( is_wp_error( $response )
221
+             || ! isset( $response['response']['code'] )
222
+             || 2 !== (int) $response['response']['code'] / 100 ) {
223
+            return false;
224
+        }
225
+
226
+        $json = json_decode( $response['body'], true );
227
+
228
+        if ( empty( $json )
229
+             || ! isset( $json[0]['title']['rendered'] )
230
+             || ! isset( $json[0]['excerpt']['rendered'] )
231
+             || ! isset( $json[0]['link'] ) ) {
232
+            return false;
233
+        }
234
+
235
+        $value = array(
236
+            'title'   => $json[0]['title']['rendered'],
237
+            'excerpt' => '<!-- cached -->' . $json[0]['excerpt']['rendered'],
238
+            'link'    => $json[0]['link'],
239
+        );
240
+
241
+        // Store the results for one day.
242
+        set_transient( self::TODAYS_TIP, $value, 86400 );
243
+
244
+        return $value;
245
+    }
246 246
 
247 247
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 	 * @since 3.20.0
41 41
 	 *
42 42
 	 */
43
-	public function __construct( $search_rankings_service, $dashboard_service, $entity_service ) {
43
+	public function __construct($search_rankings_service, $dashboard_service, $entity_service) {
44 44
 
45
-		add_action( 'wp_dashboard_setup', array( $this, 'dashboard_setup' ) );
45
+		add_action('wp_dashboard_setup', array($this, 'dashboard_setup'));
46 46
 
47 47
 		// Define where to access the tip.
48
-		defined( 'WL_TODAYS_TIP_JSON_URL' ) || define( 'WL_TODAYS_TIP_JSON_URL', 'https://wordlift.io/blog' );
49
-		defined( 'WL_TODAYS_TIP_JSON_URL_IT' ) || define( 'WL_TODAYS_TIP_JSON_URL_IT', '/it/wp-json/wp/v2/posts?context=embed&per_page=1&categories=27' );
50
-		defined( 'WL_TODAYS_TIP_JSON_URL_EN' ) || define( 'WL_TODAYS_TIP_JSON_URL_EN', '/en/wp-json/wp/v2/posts?context=embed&per_page=1&categories=38' );
48
+		defined('WL_TODAYS_TIP_JSON_URL') || define('WL_TODAYS_TIP_JSON_URL', 'https://wordlift.io/blog');
49
+		defined('WL_TODAYS_TIP_JSON_URL_IT') || define('WL_TODAYS_TIP_JSON_URL_IT', '/it/wp-json/wp/v2/posts?context=embed&per_page=1&categories=27');
50
+		defined('WL_TODAYS_TIP_JSON_URL_EN') || define('WL_TODAYS_TIP_JSON_URL_EN', '/en/wp-json/wp/v2/posts?context=embed&per_page=1&categories=38');
51 51
 
52 52
 		$this->search_rankings_service = $search_rankings_service;
53 53
 		$this->dashboard_service       = $dashboard_service;
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 
65 65
 		wp_add_dashboard_widget(
66 66
 			'wl-dashboard-v2',
67
-			__( 'WordLift Dashboard', 'wordlift' ),
68
-			array( $this, 'dashboard_setup_callback' )
67
+			__('WordLift Dashboard', 'wordlift'),
68
+			array($this, 'dashboard_setup_callback')
69 69
 		);
70 70
 
71 71
 	}
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		// Get the average position.
81 81
 		$average_position_string = $this->get_average_position();
82 82
 
83
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-dashboard-v2.php';
83
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/partials/wordlift-admin-dashboard-v2.php';
84 84
 
85 85
 	}
86 86
 
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
 	private function get_average_position() {
95 95
 
96 96
 		// Get the cache value.
97
-		$average_position = get_transient( self::AVERAGE_POSITION );
97
+		$average_position = get_transient(self::AVERAGE_POSITION);
98 98
 
99 99
 		// If there's no cached value, load it.
100
-		if ( false === $average_position ) {
100
+		if (false === $average_position) {
101 101
 			// Get the average position from Search Ranking Service.
102 102
 			$average_position = @$this->search_rankings_service->get_average_position();
103 103
 
104 104
 			// If there was an error return 'n/a'.
105
-			if ( false === $average_position ) {
106
-				return esc_html( _x( 'n/a', 'Dashboard', 'wordlift' ) );
105
+			if (false === $average_position) {
106
+				return esc_html(_x('n/a', 'Dashboard', 'wordlift'));
107 107
 			}
108 108
 		}
109 109
 
110 110
 		// Store the value for one day.
111
-		set_transient( self::AVERAGE_POSITION, $average_position, 86400 ); // One day.
111
+		set_transient(self::AVERAGE_POSITION, $average_position, 86400); // One day.
112 112
 
113 113
 		// Format the average position with one decimal.
114
-		return number_format( $average_position, 1 );
114
+		return number_format($average_position, 1);
115 115
 	}
116 116
 
117 117
 	/**
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 	private function get_top_entities() {
125 125
 
126 126
 		// Get the cached results.
127
-		$results = get_transient( '_wl_admin_dashboard_v2__top_entities' );
128
-		if ( false !== $results ) {
127
+		$results = get_transient('_wl_admin_dashboard_v2__top_entities');
128
+		if (false !== $results) {
129 129
 			return $results;
130 130
 		}
131 131
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 LIMIT 20;
162 162
 EOF;
163 163
 
164
-		$results = $wpdb->get_results( $query );
165
-		set_transient( '_wl_admin_dashboard_v2__top_entities', $results, 900 );
164
+		$results = $wpdb->get_results($query);
165
+		set_transient('_wl_admin_dashboard_v2__top_entities', $results, 900);
166 166
 
167 167
 		return $results;
168 168
 	}
@@ -177,20 +177,20 @@  discard block
 block discarded – undo
177 177
 		$data = @self::get_todays_tip_data();
178 178
 
179 179
 		// Unable to get data from the local cache, nor from the remote URL.
180
-		if ( false === $data ) {
180
+		if (false === $data) {
181 181
 			return;
182 182
 		}
183 183
 		?>
184 184
 
185 185
         <div id="wl-todays-tip" class="wl-dashboard__block wl-dashboard__block--todays-tip">
186 186
             <header>
187
-                <h3><?php echo __( "Today's Tip", 'wordlift' ); ?></h3>
187
+                <h3><?php echo __("Today's Tip", 'wordlift'); ?></h3>
188 188
             </header>
189 189
             <article>
190
-                <p><strong><?php echo esc_html( wp_strip_all_tags( $data['title'] ) ); ?></strong>
191
-					<?php echo esc_html( wp_strip_all_tags( $data['excerpt'] ) ); ?>
190
+                <p><strong><?php echo esc_html(wp_strip_all_tags($data['title'])); ?></strong>
191
+					<?php echo esc_html(wp_strip_all_tags($data['excerpt'])); ?>
192 192
                     <a target="_blank"
193
-                       href="<?php echo esc_attr( $data['link'] ); ?>"><?php echo esc_html( __( 'Read more', 'wordlift' ) ); ?></a>
193
+                       href="<?php echo esc_attr($data['link']); ?>"><?php echo esc_html(__('Read more', 'wordlift')); ?></a>
194 194
                 </p>
195 195
         </div>
196 196
 		<?php
@@ -207,39 +207,39 @@  discard block
 block discarded – undo
207 207
 	private static function get_todays_tip_data() {
208 208
 
209 209
 		// Return the transient.
210
-		if ( false !== get_transient( self::TODAYS_TIP ) ) {
211
-			return get_transient( self::TODAYS_TIP );
210
+		if (false !== get_transient(self::TODAYS_TIP)) {
211
+			return get_transient(self::TODAYS_TIP);
212 212
 		}
213 213
 
214 214
 		// If the transient isn't available, query the remote web site.
215 215
 		$url = WL_TODAYS_TIP_JSON_URL
216
-		       . ( 'it' === get_bloginfo( 'language' ) ? WL_TODAYS_TIP_JSON_URL_IT : WL_TODAYS_TIP_JSON_URL_EN );
216
+		       . ('it' === get_bloginfo('language') ? WL_TODAYS_TIP_JSON_URL_IT : WL_TODAYS_TIP_JSON_URL_EN);
217 217
 
218
-		$response = wp_remote_get( $url );
218
+		$response = wp_remote_get($url);
219 219
 
220
-		if ( is_wp_error( $response )
221
-		     || ! isset( $response['response']['code'] )
222
-		     || 2 !== (int) $response['response']['code'] / 100 ) {
220
+		if (is_wp_error($response)
221
+		     || ! isset($response['response']['code'])
222
+		     || 2 !== (int) $response['response']['code'] / 100) {
223 223
 			return false;
224 224
 		}
225 225
 
226
-		$json = json_decode( $response['body'], true );
226
+		$json = json_decode($response['body'], true);
227 227
 
228
-		if ( empty( $json )
229
-		     || ! isset( $json[0]['title']['rendered'] )
230
-		     || ! isset( $json[0]['excerpt']['rendered'] )
231
-		     || ! isset( $json[0]['link'] ) ) {
228
+		if (empty($json)
229
+		     || ! isset($json[0]['title']['rendered'])
230
+		     || ! isset($json[0]['excerpt']['rendered'])
231
+		     || ! isset($json[0]['link'])) {
232 232
 			return false;
233 233
 		}
234 234
 
235 235
 		$value = array(
236 236
 			'title'   => $json[0]['title']['rendered'],
237
-			'excerpt' => '<!-- cached -->' . $json[0]['excerpt']['rendered'],
237
+			'excerpt' => '<!-- cached -->'.$json[0]['excerpt']['rendered'],
238 238
 			'link'    => $json[0]['link'],
239 239
 		);
240 240
 
241 241
 		// Store the results for one day.
242
-		set_transient( self::TODAYS_TIP, $value, 86400 );
242
+		set_transient(self::TODAYS_TIP, $value, 86400);
243 243
 
244 244
 		return $value;
245 245
 	}
Please login to merge, or discard this patch.
src/admin/class-wordlift-admin-search-rankings-ajax-adapter.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -14,54 +14,54 @@
 block discarded – undo
14 14
  */
15 15
 class Wordlift_Admin_Search_Rankings_Ajax_Adapter {
16 16
 
17
-	/**
18
-	 * The {@link Wordlift_Admin_Search_Rankings_Service} instance.
19
-	 *
20
-	 * @since 3.20.0
21
-	 * @access private
22
-	 * @var \Wordlift_Admin_Search_Rankings_Service The {@link Wordlift_Admin_Search_Rankings_Service} instance.
23
-	 */
24
-	private $service;
17
+    /**
18
+     * The {@link Wordlift_Admin_Search_Rankings_Service} instance.
19
+     *
20
+     * @since 3.20.0
21
+     * @access private
22
+     * @var \Wordlift_Admin_Search_Rankings_Service The {@link Wordlift_Admin_Search_Rankings_Service} instance.
23
+     */
24
+    private $service;
25 25
 
26
-	/**
27
-	 * Wordlift_Admin_Search_Rankings_Ajax_Adapter constructor.
28
-	 *
29
-	 * @param $service \Wordlift_Admin_Search_Rankings_Service The {@link Wordlift_Admin_Search_Rankings_Service} instance.
30
-	 *
31
-	 * @since 3.20.0
32
-	 */
33
-	public function __construct( $service ) {
26
+    /**
27
+     * Wordlift_Admin_Search_Rankings_Ajax_Adapter constructor.
28
+     *
29
+     * @param $service \Wordlift_Admin_Search_Rankings_Service The {@link Wordlift_Admin_Search_Rankings_Service} instance.
30
+     *
31
+     * @since 3.20.0
32
+     */
33
+    public function __construct( $service ) {
34 34
 
35
-		$this->service = $service;
35
+        $this->service = $service;
36 36
 
37
-		add_action( 'wp_ajax_wl_search_rankings', array( $this, 'search_rankings' ) );
37
+        add_action( 'wp_ajax_wl_search_rankings', array( $this, 'search_rankings' ) );
38 38
 
39
-	}
39
+    }
40 40
 
41
-	/**
42
-	 * Get the Search Rankings.
43
-	 *
44
-	 * The Search Rankings are printed to the output as `application/json`.
45
-	 *
46
-	 * @since 3.20.0
47
-	 */
48
-	public function search_rankings() {
41
+    /**
42
+     * Get the Search Rankings.
43
+     *
44
+     * The Search Rankings are printed to the output as `application/json`.
45
+     *
46
+     * @since 3.20.0
47
+     */
48
+    public function search_rankings() {
49 49
 
50
-		$value = $this->service->get();
50
+        $value = $this->service->get();
51 51
 
52
-		if ( is_wp_error( $value ) ) {
53
-			wp_send_json_error( $value );
54
-		} else {
55
-			wp_send_json_success( $value );
56
-		}
52
+        if ( is_wp_error( $value ) ) {
53
+            wp_send_json_error( $value );
54
+        } else {
55
+            wp_send_json_success( $value );
56
+        }
57 57
 
58
-		// We use this to maintain compatibility with WP 4.4.0.
59
-		if ( apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
60
-			wp_die();
61
-		} else {
62
-			die;
63
-		}
58
+        // We use this to maintain compatibility with WP 4.4.0.
59
+        if ( apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
60
+            wp_die();
61
+        } else {
62
+            die;
63
+        }
64 64
 
65
-	}
65
+    }
66 66
 
67 67
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 3.20.0
32 32
 	 */
33
-	public function __construct( $service ) {
33
+	public function __construct($service) {
34 34
 
35 35
 		$this->service = $service;
36 36
 
37
-		add_action( 'wp_ajax_wl_search_rankings', array( $this, 'search_rankings' ) );
37
+		add_action('wp_ajax_wl_search_rankings', array($this, 'search_rankings'));
38 38
 
39 39
 	}
40 40
 
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
 
50 50
 		$value = $this->service->get();
51 51
 
52
-		if ( is_wp_error( $value ) ) {
53
-			wp_send_json_error( $value );
52
+		if (is_wp_error($value)) {
53
+			wp_send_json_error($value);
54 54
 		} else {
55
-			wp_send_json_success( $value );
55
+			wp_send_json_success($value);
56 56
 		}
57 57
 
58 58
 		// We use this to maintain compatibility with WP 4.4.0.
59
-		if ( apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
59
+		if (apply_filters('wp_doing_ajax', defined('DOING_AJAX') && DOING_AJAX)) {
60 60
 			wp_die();
61 61
 		} else {
62 62
 			die;
Please login to merge, or discard this patch.
src/admin/class-wordlift-admin-post-edit-page.php 2 patches
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -20,116 +20,116 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class Wordlift_Admin_Post_Edit_Page {
22 22
 
23
-	/**
24
-	 * The {@link Wordlift} plugin instance.
25
-	 *
26
-	 * @since 3.11.0
27
-	 *
28
-	 * @var \Wordlift $plugin The {@link Wordlift} plugin instance.
29
-	 */
30
-	private $plugin;
31
-
32
-	/**
33
-	 * A {@link Wordlift_Log_Service} instance.
34
-	 *
35
-	 * @since 3.15.4
36
-	 *
37
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
38
-	 */
39
-	private $log;
40
-
41
-	/**
42
-	 * Create the {@link Wordlift_Admin_Post_Edit_Page} instance.
43
-	 *
44
-	 * @param \Wordlift $plugin The {@link Wordlift} plugin instance.
45
-	 *
46
-	 * @since 3.11.0
47
-	 *
48
-	 */
49
-	function __construct( $plugin ) {
50
-
51
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
52
-
53
-		// Bail out if we're in the UX Builder editor.
54
-		if ( $this->is_ux_builder_editor() ) {
55
-			$this->log->info( 'WordLift will not show, since we are in UX Builder editor.' );
56
-
57
-			return;
58
-		}
59
-
60
-		// Define the callbacks.
61
-		$callback                  = array( $this, 'enqueue_scripts', );
62
-
63
-		// Set a hook to enqueue scripts only when the edit page is displayed.
64
-		add_action( 'admin_print_scripts-post.php', $callback );
65
-		add_action( 'admin_print_scripts-post-new.php', $callback );
66
-		add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_scripts_gutenberg', ) );
67
-
68
-		$this->plugin = $plugin;
69
-	}
70
-
71
-	/**
72
-	 * Check whether the current post opens with G'berg or not.
73
-	 *
74
-	 * @return bool True if G'berg is used otherwise false.
75
-	 * @since 3.22.3
76
-	 */
77
-	function is_gutenberg_page() {
78
-		if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) {
79
-			// The Gutenberg plugin is on.
80
-			return true;
81
-		}
82
-
83
-		$current_screen = get_current_screen();
84
-		if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) {
85
-			// Gutenberg page on 5+.
86
-			return true;
87
-		}
88
-
89
-		return false;
90
-	}
91
-
92
-	/**
93
-	 * Check if we're in UX builder.
94
-	 *
95
-	 * @see   https://github.com/insideout10/wordlift-plugin/issues/691
96
-	 *
97
-	 * @since 3.15.4
98
-	 *
99
-	 * @return bool True if we're in UX builder, otherwise false.
100
-	 */
101
-	private function is_ux_builder_editor() {
102
-
103
-		return function_exists( 'ux_builder_is_editor' )
104
-		       && ux_builder_is_editor();
105
-	}
106
-
107
-	/**
108
-	 * Enqueue scripts and styles for the edit page.
109
-	 *
110
-	 * @since 3.11.0
111
-	 */
112
-	public function enqueue_scripts() {
113
-
114
-		// Bail out if this is G'berg.
115
-		if ( $this->is_gutenberg_page() ) {
116
-			return;
117
-		}
118
-
119
-		// Dequeue potentially conflicting ontrapages angular scripts which any *are not* used on the edit screen.
120
-		//
121
-		// @see https://github.com/insideout10/wordlift-plugin/issues/832
122
-		wp_dequeue_script( 'ontrapagesAngular' );
123
-		wp_dequeue_script( 'ontrapagesApp' );
124
-		wp_dequeue_script( 'ontrapagesController' );
125
-
126
-		// If Gutenberg is enabled for the post, do not load the legacy edit.js.
127
-		if ( function_exists( 'use_block_editor_for_post' ) && use_block_editor_for_post( get_post() ) ) {
128
-			return;
129
-		}
130
-
131
-
132
-		/*
23
+    /**
24
+     * The {@link Wordlift} plugin instance.
25
+     *
26
+     * @since 3.11.0
27
+     *
28
+     * @var \Wordlift $plugin The {@link Wordlift} plugin instance.
29
+     */
30
+    private $plugin;
31
+
32
+    /**
33
+     * A {@link Wordlift_Log_Service} instance.
34
+     *
35
+     * @since 3.15.4
36
+     *
37
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
38
+     */
39
+    private $log;
40
+
41
+    /**
42
+     * Create the {@link Wordlift_Admin_Post_Edit_Page} instance.
43
+     *
44
+     * @param \Wordlift $plugin The {@link Wordlift} plugin instance.
45
+     *
46
+     * @since 3.11.0
47
+     *
48
+     */
49
+    function __construct( $plugin ) {
50
+
51
+        $this->log = Wordlift_Log_Service::get_logger( get_class() );
52
+
53
+        // Bail out if we're in the UX Builder editor.
54
+        if ( $this->is_ux_builder_editor() ) {
55
+            $this->log->info( 'WordLift will not show, since we are in UX Builder editor.' );
56
+
57
+            return;
58
+        }
59
+
60
+        // Define the callbacks.
61
+        $callback                  = array( $this, 'enqueue_scripts', );
62
+
63
+        // Set a hook to enqueue scripts only when the edit page is displayed.
64
+        add_action( 'admin_print_scripts-post.php', $callback );
65
+        add_action( 'admin_print_scripts-post-new.php', $callback );
66
+        add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_scripts_gutenberg', ) );
67
+
68
+        $this->plugin = $plugin;
69
+    }
70
+
71
+    /**
72
+     * Check whether the current post opens with G'berg or not.
73
+     *
74
+     * @return bool True if G'berg is used otherwise false.
75
+     * @since 3.22.3
76
+     */
77
+    function is_gutenberg_page() {
78
+        if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) {
79
+            // The Gutenberg plugin is on.
80
+            return true;
81
+        }
82
+
83
+        $current_screen = get_current_screen();
84
+        if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) {
85
+            // Gutenberg page on 5+.
86
+            return true;
87
+        }
88
+
89
+        return false;
90
+    }
91
+
92
+    /**
93
+     * Check if we're in UX builder.
94
+     *
95
+     * @see   https://github.com/insideout10/wordlift-plugin/issues/691
96
+     *
97
+     * @since 3.15.4
98
+     *
99
+     * @return bool True if we're in UX builder, otherwise false.
100
+     */
101
+    private function is_ux_builder_editor() {
102
+
103
+        return function_exists( 'ux_builder_is_editor' )
104
+               && ux_builder_is_editor();
105
+    }
106
+
107
+    /**
108
+     * Enqueue scripts and styles for the edit page.
109
+     *
110
+     * @since 3.11.0
111
+     */
112
+    public function enqueue_scripts() {
113
+
114
+        // Bail out if this is G'berg.
115
+        if ( $this->is_gutenberg_page() ) {
116
+            return;
117
+        }
118
+
119
+        // Dequeue potentially conflicting ontrapages angular scripts which any *are not* used on the edit screen.
120
+        //
121
+        // @see https://github.com/insideout10/wordlift-plugin/issues/832
122
+        wp_dequeue_script( 'ontrapagesAngular' );
123
+        wp_dequeue_script( 'ontrapagesApp' );
124
+        wp_dequeue_script( 'ontrapagesController' );
125
+
126
+        // If Gutenberg is enabled for the post, do not load the legacy edit.js.
127
+        if ( function_exists( 'use_block_editor_for_post' ) && use_block_editor_for_post( get_post() ) ) {
128
+            return;
129
+        }
130
+
131
+
132
+        /*
133 133
 		 * Enqueue the edit screen JavaScript. The `wordlift-admin.bundle.js` file
134 134
 		 * is scheduled to replace the older `wordlift-admin.min.js` once client-side
135 135
 		 * code is properly refactored.
@@ -138,129 +138,129 @@  discard block
 block discarded – undo
138 138
 		 *
139 139
 		 * @since 3.20.0 edit.js has been migrated to the new webpack configuration.
140 140
 		 */
141
-		$script_name = plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/edit';
142
-		/**
143
-		 * Scripts_Helper introduced.
144
-		 *
145
-		 * @since 3.25.0 Scripts are loaded using script helper to ensure WP 4.4 compatibiility.
146
-		 * @since 3.25.1 The handle is used to hook the wp_localize_script for the _wlEntityTypes global object.
147
-		 */
148
-		Scripts_Helper::enqueue_based_on_wordpress_version(
149
-			'wl-classic-editor',
150
-			$script_name,
151
-			array(
152
-				$this->plugin->get_plugin_name(),
153
-				'jquery',
154
-				// Require wp.ajax.
155
-				'wp-util',
156
-				// @@todo: provide the following dependencies when we're in WP < 5.0 (i.e. when these dependencies aren't already defined).
157
-				'react',
158
-				'react-dom',
159
-				'wp-element',
160
-				'wp-polyfill',
161
-				/*
141
+        $script_name = plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/edit';
142
+        /**
143
+         * Scripts_Helper introduced.
144
+         *
145
+         * @since 3.25.0 Scripts are loaded using script helper to ensure WP 4.4 compatibiility.
146
+         * @since 3.25.1 The handle is used to hook the wp_localize_script for the _wlEntityTypes global object.
147
+         */
148
+        Scripts_Helper::enqueue_based_on_wordpress_version(
149
+            'wl-classic-editor',
150
+            $script_name,
151
+            array(
152
+                $this->plugin->get_plugin_name(),
153
+                'jquery',
154
+                // Require wp.ajax.
155
+                'wp-util',
156
+                // @@todo: provide the following dependencies when we're in WP < 5.0 (i.e. when these dependencies aren't already defined).
157
+                'react',
158
+                'react-dom',
159
+                'wp-element',
160
+                'wp-polyfill',
161
+                /*
162 162
 				* Angular isn't loaded anymore remotely, but it is loaded within wordlift-reloaded.js.
163 163
 				*
164 164
 				* See https://github.com/insideout10/wordlift-plugin/issues/865.
165 165
 				*
166 166
 				* @since 3.19.6
167 167
 				*/
168
-				//				// Require Angular.
169
-				//				'wl-angular',
170
-				//				'wl-angular-geolocation',
171
-				//				'wl-angular-touch',
172
-				//				'wl-angular-animate',
173
-				/**
174
-				 * We need the `wp.hooks` global to allow the edit.js script to send actions.
175
-				 *
176
-				 * @since 3.23.0
177
-				 */
178
-				'wp-hooks',
179
-			)
180
-		);
181
-
182
-		wp_enqueue_style( 'wl-classic-editor', "$script_name.css", array(), $this->plugin->get_version() );
183
-
184
-	}
185
-
186
-	/**
187
-	 * This function loads the javascript file according to the WordPress version.
188
-	 *
189
-	 * For WordPress < 5.0 it'll load the javascript file using the `.full` suffix i.e. the file that embeds all the
190
-	 * dependencies.
191
-	 *
192
-	 * For WordPress >= 5.0 it'll load the stripped down js.
193
-	 *
194
-	 * @param string $handle The handle name.
195
-	 * @param string $script_name The full script URL without the `.js` extension.
196
-	 * @param array $dependencies An array of dependencies to be added only in WordPress > 5.0.
197
-	 */
198
-	private function enqueue_based_on_wordpress_version( $handle, $script_name, $dependencies ) {
199
-		global $wp_version;
200
-
201
-		if ( version_compare( $wp_version, '5.0', '<' ) ) {
202
-			$actual_script_name  = "$script_name.full.js";
203
-			$actual_dependencies = array();
204
-		} else {
205
-			$actual_script_name  = "$script_name.js";
206
-			$actual_dependencies = $dependencies;
207
-		}
208
-
209
-		wp_enqueue_script( $handle, $actual_script_name, $actual_dependencies, $this->plugin->get_version(), false );
210
-
211
-	}
212
-
213
-	/**
214
-	 * Enqueue scripts and styles for the gutenberg edit page.
215
-	 *
216
-	 * @since 3.21.0
217
-	 */
218
-	public function enqueue_scripts_gutenberg() {
219
-
220
-		wp_register_script(
221
-			'wl-block-editor',
222
-			plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/block-editor.js',
223
-			array(
224
-				'react',
225
-				'wordlift',
226
-				'wp-hooks',
227
-				'wp-data',
228
-				'wp-rich-text',
229
-				'wp-blocks',
230
-				'wp-plugins',
231
-				'wp-edit-post',
232
-			),
233
-			$this->plugin->get_version()
234
-		);
235
-		wp_localize_script( 'wl-block-editor', '_wlBlockEditorSettings', array(
236
-			'root'  => esc_url_raw( rest_url() ),
237
-			'nonce' => wp_create_nonce( 'wp_rest' )
238
-		) );
239
-
240
-		/*
168
+                //				// Require Angular.
169
+                //				'wl-angular',
170
+                //				'wl-angular-geolocation',
171
+                //				'wl-angular-touch',
172
+                //				'wl-angular-animate',
173
+                /**
174
+                 * We need the `wp.hooks` global to allow the edit.js script to send actions.
175
+                 *
176
+                 * @since 3.23.0
177
+                 */
178
+                'wp-hooks',
179
+            )
180
+        );
181
+
182
+        wp_enqueue_style( 'wl-classic-editor', "$script_name.css", array(), $this->plugin->get_version() );
183
+
184
+    }
185
+
186
+    /**
187
+     * This function loads the javascript file according to the WordPress version.
188
+     *
189
+     * For WordPress < 5.0 it'll load the javascript file using the `.full` suffix i.e. the file that embeds all the
190
+     * dependencies.
191
+     *
192
+     * For WordPress >= 5.0 it'll load the stripped down js.
193
+     *
194
+     * @param string $handle The handle name.
195
+     * @param string $script_name The full script URL without the `.js` extension.
196
+     * @param array $dependencies An array of dependencies to be added only in WordPress > 5.0.
197
+     */
198
+    private function enqueue_based_on_wordpress_version( $handle, $script_name, $dependencies ) {
199
+        global $wp_version;
200
+
201
+        if ( version_compare( $wp_version, '5.0', '<' ) ) {
202
+            $actual_script_name  = "$script_name.full.js";
203
+            $actual_dependencies = array();
204
+        } else {
205
+            $actual_script_name  = "$script_name.js";
206
+            $actual_dependencies = $dependencies;
207
+        }
208
+
209
+        wp_enqueue_script( $handle, $actual_script_name, $actual_dependencies, $this->plugin->get_version(), false );
210
+
211
+    }
212
+
213
+    /**
214
+     * Enqueue scripts and styles for the gutenberg edit page.
215
+     *
216
+     * @since 3.21.0
217
+     */
218
+    public function enqueue_scripts_gutenberg() {
219
+
220
+        wp_register_script(
221
+            'wl-block-editor',
222
+            plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/block-editor.js',
223
+            array(
224
+                'react',
225
+                'wordlift',
226
+                'wp-hooks',
227
+                'wp-data',
228
+                'wp-rich-text',
229
+                'wp-blocks',
230
+                'wp-plugins',
231
+                'wp-edit-post',
232
+            ),
233
+            $this->plugin->get_version()
234
+        );
235
+        wp_localize_script( 'wl-block-editor', '_wlBlockEditorSettings', array(
236
+            'root'  => esc_url_raw( rest_url() ),
237
+            'nonce' => wp_create_nonce( 'wp_rest' )
238
+        ) );
239
+
240
+        /*
241 241
 		 * @since 3.25.1 The hook is used by the wp_localize_script to register the _wlEntityTypes global object.
242 242
 		 */
243
-		wp_enqueue_style(
244
-			'wl-block-editor',
245
-			plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/block-editor.css',
246
-			array(),
247
-			$this->plugin->get_version()
248
-		);
249
-
250
-		wp_enqueue_script(
251
-			'wl-autocomplete-select',
252
-			plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/autocomplete-select.js',
253
-			array(),
254
-			$this->plugin->get_version(),
255
-			true
256
-		);
257
-
258
-		wp_enqueue_style(
259
-			'wl-autocomplete-select',
260
-			plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/autocomplete-select.css',
261
-			array(),
262
-			$this->plugin->get_version()
263
-		);
264
-	}
243
+        wp_enqueue_style(
244
+            'wl-block-editor',
245
+            plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/block-editor.css',
246
+            array(),
247
+            $this->plugin->get_version()
248
+        );
249
+
250
+        wp_enqueue_script(
251
+            'wl-autocomplete-select',
252
+            plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/autocomplete-select.js',
253
+            array(),
254
+            $this->plugin->get_version(),
255
+            true
256
+        );
257
+
258
+        wp_enqueue_style(
259
+            'wl-autocomplete-select',
260
+            plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/autocomplete-select.css',
261
+            array(),
262
+            $this->plugin->get_version()
263
+        );
264
+    }
265 265
 
266 266
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
 	 * @since 3.11.0
47 47
 	 *
48 48
 	 */
49
-	function __construct( $plugin ) {
49
+	function __construct($plugin) {
50 50
 
51
-		$this->log = Wordlift_Log_Service::get_logger( get_class() );
51
+		$this->log = Wordlift_Log_Service::get_logger(get_class());
52 52
 
53 53
 		// Bail out if we're in the UX Builder editor.
54
-		if ( $this->is_ux_builder_editor() ) {
55
-			$this->log->info( 'WordLift will not show, since we are in UX Builder editor.' );
54
+		if ($this->is_ux_builder_editor()) {
55
+			$this->log->info('WordLift will not show, since we are in UX Builder editor.');
56 56
 
57 57
 			return;
58 58
 		}
59 59
 
60 60
 		// Define the callbacks.
61
-		$callback                  = array( $this, 'enqueue_scripts', );
61
+		$callback = array($this, 'enqueue_scripts',);
62 62
 
63 63
 		// Set a hook to enqueue scripts only when the edit page is displayed.
64
-		add_action( 'admin_print_scripts-post.php', $callback );
65
-		add_action( 'admin_print_scripts-post-new.php', $callback );
66
-		add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_scripts_gutenberg', ) );
64
+		add_action('admin_print_scripts-post.php', $callback);
65
+		add_action('admin_print_scripts-post-new.php', $callback);
66
+		add_action('enqueue_block_editor_assets', array($this, 'enqueue_scripts_gutenberg',));
67 67
 
68 68
 		$this->plugin = $plugin;
69 69
 	}
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
 	 * @since 3.22.3
76 76
 	 */
77 77
 	function is_gutenberg_page() {
78
-		if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) {
78
+		if (function_exists('is_gutenberg_page') && is_gutenberg_page()) {
79 79
 			// The Gutenberg plugin is on.
80 80
 			return true;
81 81
 		}
82 82
 
83 83
 		$current_screen = get_current_screen();
84
-		if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) {
84
+		if (method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor()) {
85 85
 			// Gutenberg page on 5+.
86 86
 			return true;
87 87
 		}
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	private function is_ux_builder_editor() {
102 102
 
103
-		return function_exists( 'ux_builder_is_editor' )
103
+		return function_exists('ux_builder_is_editor')
104 104
 		       && ux_builder_is_editor();
105 105
 	}
106 106
 
@@ -112,19 +112,19 @@  discard block
 block discarded – undo
112 112
 	public function enqueue_scripts() {
113 113
 
114 114
 		// Bail out if this is G'berg.
115
-		if ( $this->is_gutenberg_page() ) {
115
+		if ($this->is_gutenberg_page()) {
116 116
 			return;
117 117
 		}
118 118
 
119 119
 		// Dequeue potentially conflicting ontrapages angular scripts which any *are not* used on the edit screen.
120 120
 		//
121 121
 		// @see https://github.com/insideout10/wordlift-plugin/issues/832
122
-		wp_dequeue_script( 'ontrapagesAngular' );
123
-		wp_dequeue_script( 'ontrapagesApp' );
124
-		wp_dequeue_script( 'ontrapagesController' );
122
+		wp_dequeue_script('ontrapagesAngular');
123
+		wp_dequeue_script('ontrapagesApp');
124
+		wp_dequeue_script('ontrapagesController');
125 125
 
126 126
 		// If Gutenberg is enabled for the post, do not load the legacy edit.js.
127
-		if ( function_exists( 'use_block_editor_for_post' ) && use_block_editor_for_post( get_post() ) ) {
127
+		if (function_exists('use_block_editor_for_post') && use_block_editor_for_post(get_post())) {
128 128
 			return;
129 129
 		}
130 130
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		 *
139 139
 		 * @since 3.20.0 edit.js has been migrated to the new webpack configuration.
140 140
 		 */
141
-		$script_name = plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/edit';
141
+		$script_name = plugin_dir_url(dirname(__FILE__)).'js/dist/edit';
142 142
 		/**
143 143
 		 * Scripts_Helper introduced.
144 144
 		 *
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			)
180 180
 		);
181 181
 
182
-		wp_enqueue_style( 'wl-classic-editor', "$script_name.css", array(), $this->plugin->get_version() );
182
+		wp_enqueue_style('wl-classic-editor', "$script_name.css", array(), $this->plugin->get_version());
183 183
 
184 184
 	}
185 185
 
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 	 * @param string $script_name The full script URL without the `.js` extension.
196 196
 	 * @param array $dependencies An array of dependencies to be added only in WordPress > 5.0.
197 197
 	 */
198
-	private function enqueue_based_on_wordpress_version( $handle, $script_name, $dependencies ) {
198
+	private function enqueue_based_on_wordpress_version($handle, $script_name, $dependencies) {
199 199
 		global $wp_version;
200 200
 
201
-		if ( version_compare( $wp_version, '5.0', '<' ) ) {
201
+		if (version_compare($wp_version, '5.0', '<')) {
202 202
 			$actual_script_name  = "$script_name.full.js";
203 203
 			$actual_dependencies = array();
204 204
 		} else {
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 			$actual_dependencies = $dependencies;
207 207
 		}
208 208
 
209
-		wp_enqueue_script( $handle, $actual_script_name, $actual_dependencies, $this->plugin->get_version(), false );
209
+		wp_enqueue_script($handle, $actual_script_name, $actual_dependencies, $this->plugin->get_version(), false);
210 210
 
211 211
 	}
212 212
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
 		wp_register_script(
221 221
 			'wl-block-editor',
222
-			plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/block-editor.js',
222
+			plugin_dir_url(dirname(__FILE__)).'js/dist/block-editor.js',
223 223
 			array(
224 224
 				'react',
225 225
 				'wordlift',
@@ -232,24 +232,24 @@  discard block
 block discarded – undo
232 232
 			),
233 233
 			$this->plugin->get_version()
234 234
 		);
235
-		wp_localize_script( 'wl-block-editor', '_wlBlockEditorSettings', array(
236
-			'root'  => esc_url_raw( rest_url() ),
237
-			'nonce' => wp_create_nonce( 'wp_rest' )
238
-		) );
235
+		wp_localize_script('wl-block-editor', '_wlBlockEditorSettings', array(
236
+			'root'  => esc_url_raw(rest_url()),
237
+			'nonce' => wp_create_nonce('wp_rest')
238
+		));
239 239
 
240 240
 		/*
241 241
 		 * @since 3.25.1 The hook is used by the wp_localize_script to register the _wlEntityTypes global object.
242 242
 		 */
243 243
 		wp_enqueue_style(
244 244
 			'wl-block-editor',
245
-			plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/block-editor.css',
245
+			plugin_dir_url(dirname(__FILE__)).'js/dist/block-editor.css',
246 246
 			array(),
247 247
 			$this->plugin->get_version()
248 248
 		);
249 249
 
250 250
 		wp_enqueue_script(
251 251
 			'wl-autocomplete-select',
252
-			plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/autocomplete-select.js',
252
+			plugin_dir_url(dirname(__FILE__)).'js/dist/autocomplete-select.js',
253 253
 			array(),
254 254
 			$this->plugin->get_version(),
255 255
 			true
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 
258 258
 		wp_enqueue_style(
259 259
 			'wl-autocomplete-select',
260
-			plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/autocomplete-select.css',
260
+			plugin_dir_url(dirname(__FILE__)).'js/dist/autocomplete-select.css',
261 261
 			array(),
262 262
 			$this->plugin->get_version()
263 263
 		);
Please login to merge, or discard this patch.
src/admin/wordlift_admin_meta_box_entities.php 2 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
  */
11 11
 function wl_register_metaboxes() {
12 12
 
13
-	// Load metabox classes.
14
-	require_once( 'WL_Metabox/class-wl-metabox.php' );
13
+    // Load metabox classes.
14
+    require_once( 'WL_Metabox/class-wl-metabox.php' );
15 15
 
16
-	$wl_metabox = new WL_Metabox();     // Everything is done inside here with the correct timing.
16
+    $wl_metabox = new WL_Metabox();     // Everything is done inside here with the correct timing.
17 17
 }
18 18
 
19 19
 if ( is_admin() ) {
20
-	add_action( 'load-post.php', 'wl_register_metaboxes' );
21
-	add_action( 'load-post-new.php', 'wl_register_metaboxes' );
20
+    add_action( 'load-post.php', 'wl_register_metaboxes' );
21
+    add_action( 'load-post-new.php', 'wl_register_metaboxes' );
22 22
 }
23 23
 
24 24
 /**
@@ -28,28 +28,28 @@  discard block
 block discarded – undo
28 28
  */
29 29
 function wl_admin_add_entities_meta_box( $post_type ) {
30 30
 
31
-	/*
31
+    /*
32 32
 	 * Call the `wl_can_see_classification_box` filter to determine whether we can display the classification box.
33 33
 	 *
34 34
 	 * @since 3.20.3
35 35
 	 *
36 36
 	 * @see https://github.com/insideout10/wordlift-plugin/issues/914
37 37
 	 */
38
-	if ( ! apply_filters( 'wl_can_see_classification_box', true ) ) {
39
-		return;
40
-	}
41
-
42
-	// Bail out if the post type doesn't support a TinyMCE editor.
43
-	if ( ! wl_post_type_supports_editor( $post_type ) ) {
44
-		return;
45
-	}
46
-
47
-	if ( ! Wordlift_Admin::is_gutenberg() ) {
48
-		// Add main meta box for related entities and 4W only if not Gutenberg
49
-		add_meta_box(
50
-			'wordlift_entities_box', __( 'WordLift', 'wordlift' ), 'wl_entities_box_content', $post_type, 'side', 'high'
51
-		);
52
-	}
38
+    if ( ! apply_filters( 'wl_can_see_classification_box', true ) ) {
39
+        return;
40
+    }
41
+
42
+    // Bail out if the post type doesn't support a TinyMCE editor.
43
+    if ( ! wl_post_type_supports_editor( $post_type ) ) {
44
+        return;
45
+    }
46
+
47
+    if ( ! Wordlift_Admin::is_gutenberg() ) {
48
+        // Add main meta box for related entities and 4W only if not Gutenberg
49
+        add_meta_box(
50
+            'wordlift_entities_box', __( 'WordLift', 'wordlift' ), 'wl_entities_box_content', $post_type, 'side', 'high'
51
+        );
52
+    }
53 53
 
54 54
 }
55 55
 
@@ -66,19 +66,19 @@  discard block
 block discarded – undo
66 66
  */
67 67
 function wl_post_type_supports_editor( $post_type ) {
68 68
 
69
-	$default = post_type_supports( $post_type, 'editor' );
70
-
71
-	/**
72
-	 * Allow 3rd parties to force the classification to load.
73
-	 *
74
-	 * @param bool $default The preset value as gathered by the `post_type_supports` call.
75
-	 *
76
-	 * @see https://github.com/insideout10/wordlift-plugin/issues/847.
77
-	 *
78
-	 * @since 3.19.4
79
-	 *
80
-	 */
81
-	return apply_filters( 'wl_post_type_supports_editor', $default, $post_type );
69
+    $default = post_type_supports( $post_type, 'editor' );
70
+
71
+    /**
72
+     * Allow 3rd parties to force the classification to load.
73
+     *
74
+     * @param bool $default The preset value as gathered by the `post_type_supports` call.
75
+     *
76
+     * @see https://github.com/insideout10/wordlift-plugin/issues/847.
77
+     *
78
+     * @since 3.19.4
79
+     *
80
+     */
81
+    return apply_filters( 'wl_post_type_supports_editor', $default, $post_type );
82 82
 }
83 83
 
84 84
 /**
@@ -88,112 +88,112 @@  discard block
 block discarded – undo
88 88
  */
89 89
 function wl_entities_box_content( $post, $wrapper = true ) {
90 90
 
91
-	// Angularjs edit-post widget wrapper.
92
-	if ( $wrapper ) {
93
-		echo '<div id="wordlift-edit-post-outer-wrapper"></div>';
94
-	}
91
+    // Angularjs edit-post widget wrapper.
92
+    if ( $wrapper ) {
93
+        echo '<div id="wordlift-edit-post-outer-wrapper"></div>';
94
+    }
95 95
 }
96 96
 
97 97
 function wl_entities_box_content_scripts() {
98
-	$post = get_post();
98
+    $post = get_post();
99 99
 
100
-	// Angularjs edit-post widget classification boxes configuration.
101
-	$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
100
+    // Angularjs edit-post widget classification boxes configuration.
101
+    $classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
102 102
 
103
-	// Array to store all related entities ids.
104
-	$all_referenced_entities_ids = array();
103
+    // Array to store all related entities ids.
104
+    $all_referenced_entities_ids = array();
105 105
 
106
-	// Add selected entities to classification_boxes.
107
-	foreach ( $classification_boxes as $i => $box ) {
108
-		// Build the proper relation name.
109
-		$relation_name = $box['id'];
106
+    // Add selected entities to classification_boxes.
107
+    foreach ( $classification_boxes as $i => $box ) {
108
+        // Build the proper relation name.
109
+        $relation_name = $box['id'];
110 110
 
111
-		// Get the entity referenced from the post content.
112
-		/*
111
+        // Get the entity referenced from the post content.
112
+        /*
113 113
 		 * Allow 3rd parties to provide another post content.
114 114
 		 *
115 115
 		 * @since 3.20.0
116 116
 		 */
117
-		$post_content = apply_filters( 'wl_post_content', $post->post_content, $post );
118
-		$entity_uris  = Wordlift_Content_Filter_Service::get_instance()->get_entity_uris( $post_content );
119
-
120
-		// Enhance current box selected entities.
121
-		$classification_boxes[ $i ]['selectedEntities'] = $entity_uris;
122
-
123
-		// Maps the URIs to entity posts.
124
-		$entity_service = Wordlift_Entity_Service::get_instance();
125
-
126
-		// Replace all entity URI's with post ID's if found or null if there is no related post.
127
-		$entity_ids = array_map( function ( $item ) use ( $entity_service ) {
128
-			// Return entity post by the entity URI or null.
129
-			$post = $entity_service->get_entity_post_by_uri( $item );
130
-
131
-			// Check that the post object is not null.
132
-			if ( ! empty( $post ) ) {
133
-				return $post->ID;
134
-			}
135
-		}, $entity_uris );
136
-		// Store the entity ids for all the 4W.
137
-		$all_referenced_entities_ids = array_merge( $all_referenced_entities_ids, $entity_ids );
138
-
139
-	}
140
-
141
-	// Json encoding for classification boxes structure.
142
-	$classification_boxes = wp_json_encode( $classification_boxes );
143
-
144
-	// Ensure there are no repetitions of the referenced entities.
145
-	$all_referenced_entities_ids = array_unique( $all_referenced_entities_ids );
146
-
147
-	// Remove all null, false and empty strings.
148
-	// NULL is being returned in some cases, when there is not related post, so we need to remove it.
149
-	$all_referenced_entities_ids = array_filter( $all_referenced_entities_ids );
150
-
151
-	// Build the entity storage object.
152
-	$referenced_entities_obj = array();
153
-	foreach ( $all_referenced_entities_ids as $referenced_entity ) {
154
-		$entity = wl_serialize_entity( $referenced_entity );
155
-		// Set a default confidence of `PHP_INT_MAX` for already annotated entities.
156
-		$referenced_entities_obj[ $entity['id'] ] = $entity
157
-		                                            + array( 'confidence' => PHP_INT_MAX );
158
-	}
159
-
160
-	$referenced_entities_obj = empty( $referenced_entities_obj ) ?
161
-		'{}' : wp_json_encode( $referenced_entities_obj );
162
-
163
-	$published_place_id  = get_post_meta(
164
-		$post->ID, Wordlift_Schema_Service::FIELD_LOCATION_CREATED, true
165
-	);
166
-	$published_place_obj = ( $published_place_id ) ?
167
-		wp_json_encode( wl_serialize_entity( $published_place_id ) ) :
168
-		'undefined';
169
-
170
-	$topic_id  = get_post_meta(
171
-		$post->ID, Wordlift_Schema_Service::FIELD_TOPIC, true
172
-	);
173
-	$topic_obj = ( $topic_id ) ?
174
-		wp_json_encode( wl_serialize_entity( $topic_id ) ) :
175
-		'undefined';
176
-
177
-	$configuration_service = Wordlift_Configuration_Service::get_instance();
178
-
179
-	$default_thumbnail_path = WL_DEFAULT_THUMBNAIL_PATH;
180
-	$default_path           = WL_DEFAULT_PATH;
181
-	$dataset_uri            = $configuration_service->get_dataset_uri();
182
-	$current_post_uri       = Wordlift_Entity_Service::get_instance()->get_uri( $post->ID );
183
-	$is_entity              = Wordlift_Entity_Service::get_instance()->is_entity( $post->ID );
184
-
185
-	// Retrieve the current post author.
186
-	$post_author = get_userdata( $post->post_author )->display_name;
187
-	// Retrive the published date.
188
-	$published_date = get_the_time( 'Y-m-d', $post->ID );
189
-	// Current language.
190
-	$current_language            = $configuration_service->get_language_code();
191
-	$wordlift_timeline_shortcode = new Wordlift_Timeline_Shortcode();
192
-	$timelinejs_default_options  = json_encode( $wordlift_timeline_shortcode->get_timelinejs_default_options(), JSON_PRETTY_PRINT );
193
-	$addslashes_post_author      = addslashes( $post_author );
194
-	$ajax_url                    = json_encode( admin_url( 'admin-ajax.php' ) );
195
-
196
-	$js_code = <<<JS
117
+        $post_content = apply_filters( 'wl_post_content', $post->post_content, $post );
118
+        $entity_uris  = Wordlift_Content_Filter_Service::get_instance()->get_entity_uris( $post_content );
119
+
120
+        // Enhance current box selected entities.
121
+        $classification_boxes[ $i ]['selectedEntities'] = $entity_uris;
122
+
123
+        // Maps the URIs to entity posts.
124
+        $entity_service = Wordlift_Entity_Service::get_instance();
125
+
126
+        // Replace all entity URI's with post ID's if found or null if there is no related post.
127
+        $entity_ids = array_map( function ( $item ) use ( $entity_service ) {
128
+            // Return entity post by the entity URI or null.
129
+            $post = $entity_service->get_entity_post_by_uri( $item );
130
+
131
+            // Check that the post object is not null.
132
+            if ( ! empty( $post ) ) {
133
+                return $post->ID;
134
+            }
135
+        }, $entity_uris );
136
+        // Store the entity ids for all the 4W.
137
+        $all_referenced_entities_ids = array_merge( $all_referenced_entities_ids, $entity_ids );
138
+
139
+    }
140
+
141
+    // Json encoding for classification boxes structure.
142
+    $classification_boxes = wp_json_encode( $classification_boxes );
143
+
144
+    // Ensure there are no repetitions of the referenced entities.
145
+    $all_referenced_entities_ids = array_unique( $all_referenced_entities_ids );
146
+
147
+    // Remove all null, false and empty strings.
148
+    // NULL is being returned in some cases, when there is not related post, so we need to remove it.
149
+    $all_referenced_entities_ids = array_filter( $all_referenced_entities_ids );
150
+
151
+    // Build the entity storage object.
152
+    $referenced_entities_obj = array();
153
+    foreach ( $all_referenced_entities_ids as $referenced_entity ) {
154
+        $entity = wl_serialize_entity( $referenced_entity );
155
+        // Set a default confidence of `PHP_INT_MAX` for already annotated entities.
156
+        $referenced_entities_obj[ $entity['id'] ] = $entity
157
+                                                    + array( 'confidence' => PHP_INT_MAX );
158
+    }
159
+
160
+    $referenced_entities_obj = empty( $referenced_entities_obj ) ?
161
+        '{}' : wp_json_encode( $referenced_entities_obj );
162
+
163
+    $published_place_id  = get_post_meta(
164
+        $post->ID, Wordlift_Schema_Service::FIELD_LOCATION_CREATED, true
165
+    );
166
+    $published_place_obj = ( $published_place_id ) ?
167
+        wp_json_encode( wl_serialize_entity( $published_place_id ) ) :
168
+        'undefined';
169
+
170
+    $topic_id  = get_post_meta(
171
+        $post->ID, Wordlift_Schema_Service::FIELD_TOPIC, true
172
+    );
173
+    $topic_obj = ( $topic_id ) ?
174
+        wp_json_encode( wl_serialize_entity( $topic_id ) ) :
175
+        'undefined';
176
+
177
+    $configuration_service = Wordlift_Configuration_Service::get_instance();
178
+
179
+    $default_thumbnail_path = WL_DEFAULT_THUMBNAIL_PATH;
180
+    $default_path           = WL_DEFAULT_PATH;
181
+    $dataset_uri            = $configuration_service->get_dataset_uri();
182
+    $current_post_uri       = Wordlift_Entity_Service::get_instance()->get_uri( $post->ID );
183
+    $is_entity              = Wordlift_Entity_Service::get_instance()->is_entity( $post->ID );
184
+
185
+    // Retrieve the current post author.
186
+    $post_author = get_userdata( $post->post_author )->display_name;
187
+    // Retrive the published date.
188
+    $published_date = get_the_time( 'Y-m-d', $post->ID );
189
+    // Current language.
190
+    $current_language            = $configuration_service->get_language_code();
191
+    $wordlift_timeline_shortcode = new Wordlift_Timeline_Shortcode();
192
+    $timelinejs_default_options  = json_encode( $wordlift_timeline_shortcode->get_timelinejs_default_options(), JSON_PRETTY_PRINT );
193
+    $addslashes_post_author      = addslashes( $post_author );
194
+    $ajax_url                    = json_encode( admin_url( 'admin-ajax.php' ) );
195
+
196
+    $js_code = <<<JS
197 197
 		if ('undefined' == typeof window.wordlift) {
198 198
 			window.wordlift = {};
199 199
 			window.wordlift.entities = {};
@@ -217,33 +217,33 @@  discard block
 block discarded – undo
217 217
 		window.wordlift.ajax_url = $ajax_url;
218 218
 JS;
219 219
 
220
-	echo '<script type="text/javascript">' . PHP_EOL . $js_code . PHP_EOL . '</script>';
221
-
222
-	$metabox_settings = array(
223
-		"classificationBoxes"      => json_decode( $classification_boxes ),
224
-		"entities"                 => json_decode( $referenced_entities_obj ),
225
-		"currentPostId"            => intval( $post->ID ),
226
-		"currentPostUri"           => $current_post_uri,
227
-		"currentPostType"          => $post->post_type,
228
-		"isEntity"                 => ! empty( $is_entity ),
229
-		"defaultThumbnailPath"     => $default_thumbnail_path,
230
-		"defaultWordLiftPath"      => $default_path,
231
-		"datasetUri"               => $dataset_uri,
232
-		"currentUser"              => $addslashes_post_author,
233
-		"publishedDate"            => $published_date,
234
-		"publishedPlace"           => $published_place_obj,
235
-		"topic"                    => json_decode( $topic_obj ),
236
-		"currentLanguage"          => $current_language,
237
-		"timelinejsDefaultOptions" => json_decode( $timelinejs_default_options ),
238
-		"ajax_url"                 => admin_url( 'admin-ajax.php' ),
239
-	);
240
-
241
-	// Allow Classic and Block Editor scripts to register first.
242
-	// Hook to the Block Editor script.
243
-	wp_localize_script( 'wl-block-editor', '_wlMetaBoxSettings', array( 'settings' => $metabox_settings ) );
244
-
245
-	// Hook to the Classic Editor script, see Wordlift_Admin_Post_Edit_Page.
246
-	wp_localize_script( 'wl-classic-editor', '_wlMetaBoxSettings', array( 'settings' => $metabox_settings ) );
220
+    echo '<script type="text/javascript">' . PHP_EOL . $js_code . PHP_EOL . '</script>';
221
+
222
+    $metabox_settings = array(
223
+        "classificationBoxes"      => json_decode( $classification_boxes ),
224
+        "entities"                 => json_decode( $referenced_entities_obj ),
225
+        "currentPostId"            => intval( $post->ID ),
226
+        "currentPostUri"           => $current_post_uri,
227
+        "currentPostType"          => $post->post_type,
228
+        "isEntity"                 => ! empty( $is_entity ),
229
+        "defaultThumbnailPath"     => $default_thumbnail_path,
230
+        "defaultWordLiftPath"      => $default_path,
231
+        "datasetUri"               => $dataset_uri,
232
+        "currentUser"              => $addslashes_post_author,
233
+        "publishedDate"            => $published_date,
234
+        "publishedPlace"           => $published_place_obj,
235
+        "topic"                    => json_decode( $topic_obj ),
236
+        "currentLanguage"          => $current_language,
237
+        "timelinejsDefaultOptions" => json_decode( $timelinejs_default_options ),
238
+        "ajax_url"                 => admin_url( 'admin-ajax.php' ),
239
+    );
240
+
241
+    // Allow Classic and Block Editor scripts to register first.
242
+    // Hook to the Block Editor script.
243
+    wp_localize_script( 'wl-block-editor', '_wlMetaBoxSettings', array( 'settings' => $metabox_settings ) );
244
+
245
+    // Hook to the Classic Editor script, see Wordlift_Admin_Post_Edit_Page.
246
+    wp_localize_script( 'wl-classic-editor', '_wlMetaBoxSettings', array( 'settings' => $metabox_settings ) );
247 247
 
248 248
 }
249 249
 
Please login to merge, or discard this patch.
Spacing   +58 added lines, -60 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 function wl_register_metaboxes() {
12 12
 
13 13
 	// Load metabox classes.
14
-	require_once( 'WL_Metabox/class-wl-metabox.php' );
14
+	require_once('WL_Metabox/class-wl-metabox.php');
15 15
 
16
-	$wl_metabox = new WL_Metabox();     // Everything is done inside here with the correct timing.
16
+	$wl_metabox = new WL_Metabox(); // Everything is done inside here with the correct timing.
17 17
 }
18 18
 
19
-if ( is_admin() ) {
20
-	add_action( 'load-post.php', 'wl_register_metaboxes' );
21
-	add_action( 'load-post-new.php', 'wl_register_metaboxes' );
19
+if (is_admin()) {
20
+	add_action('load-post.php', 'wl_register_metaboxes');
21
+	add_action('load-post-new.php', 'wl_register_metaboxes');
22 22
 }
23 23
 
24 24
 /**
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @param string $post_type The type of the current open post.
28 28
  */
29
-function wl_admin_add_entities_meta_box( $post_type ) {
29
+function wl_admin_add_entities_meta_box($post_type) {
30 30
 
31 31
 	/*
32 32
 	 * Call the `wl_can_see_classification_box` filter to determine whether we can display the classification box.
@@ -35,25 +35,25 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @see https://github.com/insideout10/wordlift-plugin/issues/914
37 37
 	 */
38
-	if ( ! apply_filters( 'wl_can_see_classification_box', true ) ) {
38
+	if ( ! apply_filters('wl_can_see_classification_box', true)) {
39 39
 		return;
40 40
 	}
41 41
 
42 42
 	// Bail out if the post type doesn't support a TinyMCE editor.
43
-	if ( ! wl_post_type_supports_editor( $post_type ) ) {
43
+	if ( ! wl_post_type_supports_editor($post_type)) {
44 44
 		return;
45 45
 	}
46 46
 
47
-	if ( ! Wordlift_Admin::is_gutenberg() ) {
47
+	if ( ! Wordlift_Admin::is_gutenberg()) {
48 48
 		// Add main meta box for related entities and 4W only if not Gutenberg
49 49
 		add_meta_box(
50
-			'wordlift_entities_box', __( 'WordLift', 'wordlift' ), 'wl_entities_box_content', $post_type, 'side', 'high'
50
+			'wordlift_entities_box', __('WordLift', 'wordlift'), 'wl_entities_box_content', $post_type, 'side', 'high'
51 51
 		);
52 52
 	}
53 53
 
54 54
 }
55 55
 
56
-add_action( 'add_meta_boxes', 'wl_admin_add_entities_meta_box' );
56
+add_action('add_meta_boxes', 'wl_admin_add_entities_meta_box');
57 57
 
58 58
 /**
59 59
  * Whether the post type supports the editor UI.
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
  *
65 65
  * @return bool True if the editor UI is supported otherwise false.
66 66
  */
67
-function wl_post_type_supports_editor( $post_type ) {
67
+function wl_post_type_supports_editor($post_type) {
68 68
 
69
-	$default = post_type_supports( $post_type, 'editor' );
69
+	$default = post_type_supports($post_type, 'editor');
70 70
 
71 71
 	/**
72 72
 	 * Allow 3rd parties to force the classification to load.
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @since 3.19.4
79 79
 	 *
80 80
 	 */
81
-	return apply_filters( 'wl_post_type_supports_editor', $default, $post_type );
81
+	return apply_filters('wl_post_type_supports_editor', $default, $post_type);
82 82
 }
83 83
 
84 84
 /**
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
  *
87 87
  * @param WP_Post $post The current post.
88 88
  */
89
-function wl_entities_box_content( $post, $wrapper = true ) {
89
+function wl_entities_box_content($post, $wrapper = true) {
90 90
 
91 91
 	// Angularjs edit-post widget wrapper.
92
-	if ( $wrapper ) {
92
+	if ($wrapper) {
93 93
 		echo '<div id="wordlift-edit-post-outer-wrapper"></div>';
94 94
 	}
95 95
 }
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
 	$post = get_post();
99 99
 
100 100
 	// Angularjs edit-post widget classification boxes configuration.
101
-	$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
101
+	$classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES);
102 102
 
103 103
 	// Array to store all related entities ids.
104 104
 	$all_referenced_entities_ids = array();
105 105
 
106 106
 	// Add selected entities to classification_boxes.
107
-	foreach ( $classification_boxes as $i => $box ) {
107
+	foreach ($classification_boxes as $i => $box) {
108 108
 		// Build the proper relation name.
109 109
 		$relation_name = $box['id'];
110 110
 
@@ -114,84 +114,82 @@  discard block
 block discarded – undo
114 114
 		 *
115 115
 		 * @since 3.20.0
116 116
 		 */
117
-		$post_content = apply_filters( 'wl_post_content', $post->post_content, $post );
118
-		$entity_uris  = Wordlift_Content_Filter_Service::get_instance()->get_entity_uris( $post_content );
117
+		$post_content = apply_filters('wl_post_content', $post->post_content, $post);
118
+		$entity_uris  = Wordlift_Content_Filter_Service::get_instance()->get_entity_uris($post_content);
119 119
 
120 120
 		// Enhance current box selected entities.
121
-		$classification_boxes[ $i ]['selectedEntities'] = $entity_uris;
121
+		$classification_boxes[$i]['selectedEntities'] = $entity_uris;
122 122
 
123 123
 		// Maps the URIs to entity posts.
124 124
 		$entity_service = Wordlift_Entity_Service::get_instance();
125 125
 
126 126
 		// Replace all entity URI's with post ID's if found or null if there is no related post.
127
-		$entity_ids = array_map( function ( $item ) use ( $entity_service ) {
127
+		$entity_ids = array_map(function($item) use ($entity_service) {
128 128
 			// Return entity post by the entity URI or null.
129
-			$post = $entity_service->get_entity_post_by_uri( $item );
129
+			$post = $entity_service->get_entity_post_by_uri($item);
130 130
 
131 131
 			// Check that the post object is not null.
132
-			if ( ! empty( $post ) ) {
132
+			if ( ! empty($post)) {
133 133
 				return $post->ID;
134 134
 			}
135
-		}, $entity_uris );
135
+		}, $entity_uris);
136 136
 		// Store the entity ids for all the 4W.
137
-		$all_referenced_entities_ids = array_merge( $all_referenced_entities_ids, $entity_ids );
137
+		$all_referenced_entities_ids = array_merge($all_referenced_entities_ids, $entity_ids);
138 138
 
139 139
 	}
140 140
 
141 141
 	// Json encoding for classification boxes structure.
142
-	$classification_boxes = wp_json_encode( $classification_boxes );
142
+	$classification_boxes = wp_json_encode($classification_boxes);
143 143
 
144 144
 	// Ensure there are no repetitions of the referenced entities.
145
-	$all_referenced_entities_ids = array_unique( $all_referenced_entities_ids );
145
+	$all_referenced_entities_ids = array_unique($all_referenced_entities_ids);
146 146
 
147 147
 	// Remove all null, false and empty strings.
148 148
 	// NULL is being returned in some cases, when there is not related post, so we need to remove it.
149
-	$all_referenced_entities_ids = array_filter( $all_referenced_entities_ids );
149
+	$all_referenced_entities_ids = array_filter($all_referenced_entities_ids);
150 150
 
151 151
 	// Build the entity storage object.
152 152
 	$referenced_entities_obj = array();
153
-	foreach ( $all_referenced_entities_ids as $referenced_entity ) {
154
-		$entity = wl_serialize_entity( $referenced_entity );
153
+	foreach ($all_referenced_entities_ids as $referenced_entity) {
154
+		$entity = wl_serialize_entity($referenced_entity);
155 155
 		// Set a default confidence of `PHP_INT_MAX` for already annotated entities.
156
-		$referenced_entities_obj[ $entity['id'] ] = $entity
157
-		                                            + array( 'confidence' => PHP_INT_MAX );
156
+		$referenced_entities_obj[$entity['id']] = $entity
157
+		                                            + array('confidence' => PHP_INT_MAX);
158 158
 	}
159 159
 
160
-	$referenced_entities_obj = empty( $referenced_entities_obj ) ?
161
-		'{}' : wp_json_encode( $referenced_entities_obj );
160
+	$referenced_entities_obj = empty($referenced_entities_obj) ?
161
+		'{}' : wp_json_encode($referenced_entities_obj);
162 162
 
163 163
 	$published_place_id  = get_post_meta(
164 164
 		$post->ID, Wordlift_Schema_Service::FIELD_LOCATION_CREATED, true
165 165
 	);
166
-	$published_place_obj = ( $published_place_id ) ?
167
-		wp_json_encode( wl_serialize_entity( $published_place_id ) ) :
168
-		'undefined';
166
+	$published_place_obj = ($published_place_id) ?
167
+		wp_json_encode(wl_serialize_entity($published_place_id)) : 'undefined';
169 168
 
170 169
 	$topic_id  = get_post_meta(
171 170
 		$post->ID, Wordlift_Schema_Service::FIELD_TOPIC, true
172 171
 	);
173
-	$topic_obj = ( $topic_id ) ?
174
-		wp_json_encode( wl_serialize_entity( $topic_id ) ) :
175
-		'undefined';
172
+	$topic_obj = ($topic_id) ?
173
+		wp_json_encode(wl_serialize_entity($topic_id)) : 'undefined';
176 174
 
177 175
 	$configuration_service = Wordlift_Configuration_Service::get_instance();
178 176
 
179 177
 	$default_thumbnail_path = WL_DEFAULT_THUMBNAIL_PATH;
180 178
 	$default_path           = WL_DEFAULT_PATH;
181 179
 	$dataset_uri            = $configuration_service->get_dataset_uri();
182
-	$current_post_uri       = Wordlift_Entity_Service::get_instance()->get_uri( $post->ID );
183
-	$is_entity              = Wordlift_Entity_Service::get_instance()->is_entity( $post->ID );
180
+	$current_post_uri       = Wordlift_Entity_Service::get_instance()->get_uri($post->ID);
181
+	$is_entity              = Wordlift_Entity_Service::get_instance()->is_entity($post->ID);
184 182
 
185 183
 	// Retrieve the current post author.
186
-	$post_author = get_userdata( $post->post_author )->display_name;
184
+	$post_author = get_userdata($post->post_author)->display_name;
187 185
 	// Retrive the published date.
188
-	$published_date = get_the_time( 'Y-m-d', $post->ID );
186
+	$published_date = get_the_time('Y-m-d', $post->ID);
189 187
 	// Current language.
190 188
 	$current_language            = $configuration_service->get_language_code();
191 189
 	$wordlift_timeline_shortcode = new Wordlift_Timeline_Shortcode();
192
-	$timelinejs_default_options  = json_encode( $wordlift_timeline_shortcode->get_timelinejs_default_options(), JSON_PRETTY_PRINT );
193
-	$addslashes_post_author      = addslashes( $post_author );
194
-	$ajax_url                    = json_encode( admin_url( 'admin-ajax.php' ) );
190
+	$timelinejs_default_options  = json_encode($wordlift_timeline_shortcode->get_timelinejs_default_options(), JSON_PRETTY_PRINT);
191
+	$addslashes_post_author      = addslashes($post_author);
192
+	$ajax_url                    = json_encode(admin_url('admin-ajax.php'));
195 193
 
196 194
 	$js_code = <<<JS
197 195
 		if ('undefined' == typeof window.wordlift) {
@@ -217,35 +215,35 @@  discard block
 block discarded – undo
217 215
 		window.wordlift.ajax_url = $ajax_url;
218 216
 JS;
219 217
 
220
-	echo '<script type="text/javascript">' . PHP_EOL . $js_code . PHP_EOL . '</script>';
218
+	echo '<script type="text/javascript">'.PHP_EOL.$js_code.PHP_EOL.'</script>';
221 219
 
222 220
 	$metabox_settings = array(
223
-		"classificationBoxes"      => json_decode( $classification_boxes ),
224
-		"entities"                 => json_decode( $referenced_entities_obj ),
225
-		"currentPostId"            => intval( $post->ID ),
221
+		"classificationBoxes"      => json_decode($classification_boxes),
222
+		"entities"                 => json_decode($referenced_entities_obj),
223
+		"currentPostId"            => intval($post->ID),
226 224
 		"currentPostUri"           => $current_post_uri,
227 225
 		"currentPostType"          => $post->post_type,
228
-		"isEntity"                 => ! empty( $is_entity ),
226
+		"isEntity"                 => ! empty($is_entity),
229 227
 		"defaultThumbnailPath"     => $default_thumbnail_path,
230 228
 		"defaultWordLiftPath"      => $default_path,
231 229
 		"datasetUri"               => $dataset_uri,
232 230
 		"currentUser"              => $addslashes_post_author,
233 231
 		"publishedDate"            => $published_date,
234 232
 		"publishedPlace"           => $published_place_obj,
235
-		"topic"                    => json_decode( $topic_obj ),
233
+		"topic"                    => json_decode($topic_obj),
236 234
 		"currentLanguage"          => $current_language,
237
-		"timelinejsDefaultOptions" => json_decode( $timelinejs_default_options ),
238
-		"ajax_url"                 => admin_url( 'admin-ajax.php' ),
235
+		"timelinejsDefaultOptions" => json_decode($timelinejs_default_options),
236
+		"ajax_url"                 => admin_url('admin-ajax.php'),
239 237
 	);
240 238
 
241 239
 	// Allow Classic and Block Editor scripts to register first.
242 240
 	// Hook to the Block Editor script.
243
-	wp_localize_script( 'wl-block-editor', '_wlMetaBoxSettings', array( 'settings' => $metabox_settings ) );
241
+	wp_localize_script('wl-block-editor', '_wlMetaBoxSettings', array('settings' => $metabox_settings));
244 242
 
245 243
 	// Hook to the Classic Editor script, see Wordlift_Admin_Post_Edit_Page.
246
-	wp_localize_script( 'wl-classic-editor', '_wlMetaBoxSettings', array( 'settings' => $metabox_settings ) );
244
+	wp_localize_script('wl-classic-editor', '_wlMetaBoxSettings', array('settings' => $metabox_settings));
247 245
 
248 246
 }
249 247
 
250
-add_action( 'admin_print_scripts-post.php', 'wl_entities_box_content_scripts', 11 );
251
-add_action( 'admin_print_scripts-post-new.php', 'wl_entities_box_content_scripts', 11 );
248
+add_action('admin_print_scripts-post.php', 'wl_entities_box_content_scripts', 11);
249
+add_action('admin_print_scripts-post-new.php', 'wl_entities_box_content_scripts', 11);
Please login to merge, or discard this patch.