Completed
Pull Request — develop (#1554)
by Naveen
48s
created
src/includes/linked-data/storage/class-wordlift-post-property-storage.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -18,75 +18,75 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Post_Property_Storage extends Wordlift_Storage {
20 20
 
21
-	/**
22
-	 * The `post_title` property.
23
-	 */
24
-	const TITLE = 'title';
25
-
26
-	/**
27
-	 * The `post_content` property stripped of tags and shortcodes.
28
-	 */
29
-	const DESCRIPTION_NO_TAGS_NO_SHORTCODES = 'description_no_tags_no_shortcodes';
30
-
31
-	/**
32
-	 * The `post_author` property.
33
-	 */
34
-	const AUTHOR = 'author';
35
-
36
-	/**
37
-	 * The {@link WP_Post} property to retrieve.
38
-	 *
39
-	 * @since  3.15.0
40
-	 * @access private
41
-	 * @var string $property The {@link WP_Post} property to retrieve.
42
-	 */
43
-	private $property;
44
-
45
-	/**
46
-	 * Create a {@link Wordlift_Post_Property_Storage} instance.
47
-	 *
48
-	 * @since 3.15.0
49
-	 *
50
-	 * @param string $property A post property.
51
-	 */
52
-	public function __construct( $property ) {
53
-
54
-		$this->property = $property;
55
-
56
-	}
57
-
58
-	/**
59
-	 * Get the property value.
60
-	 *
61
-	 * @since 3.15.0
62
-	 *
63
-	 * @param int $post_id The {@link WP_Post}'s id.
64
-	 *
65
-	 * @return array|string|null A single string, or an array of values or null
66
-	 *                           if the property isn't recognized.
67
-	 */
68
-	public function get( $post_id ) {
69
-
70
-		// Get the post.
71
-		$post = get_post( $post_id );
72
-
73
-		// Switch according to the selected property.
74
-		switch ( $this->property ) {
75
-
76
-			// Title.
77
-			case self::TITLE:
78
-				return $post->post_title;
79
-
80
-			// Description.
81
-			case self::DESCRIPTION_NO_TAGS_NO_SHORTCODES:
82
-				return wp_strip_all_tags( preg_replace( '/\[[^]]+\]/', '', do_shortcode( $post->post_content ) ) );
83
-
84
-			// Author.
85
-			case self::AUTHOR:
86
-				return $post->post_author;
87
-		}
88
-
89
-		return null;
90
-	}
21
+    /**
22
+     * The `post_title` property.
23
+     */
24
+    const TITLE = 'title';
25
+
26
+    /**
27
+     * The `post_content` property stripped of tags and shortcodes.
28
+     */
29
+    const DESCRIPTION_NO_TAGS_NO_SHORTCODES = 'description_no_tags_no_shortcodes';
30
+
31
+    /**
32
+     * The `post_author` property.
33
+     */
34
+    const AUTHOR = 'author';
35
+
36
+    /**
37
+     * The {@link WP_Post} property to retrieve.
38
+     *
39
+     * @since  3.15.0
40
+     * @access private
41
+     * @var string $property The {@link WP_Post} property to retrieve.
42
+     */
43
+    private $property;
44
+
45
+    /**
46
+     * Create a {@link Wordlift_Post_Property_Storage} instance.
47
+     *
48
+     * @since 3.15.0
49
+     *
50
+     * @param string $property A post property.
51
+     */
52
+    public function __construct( $property ) {
53
+
54
+        $this->property = $property;
55
+
56
+    }
57
+
58
+    /**
59
+     * Get the property value.
60
+     *
61
+     * @since 3.15.0
62
+     *
63
+     * @param int $post_id The {@link WP_Post}'s id.
64
+     *
65
+     * @return array|string|null A single string, or an array of values or null
66
+     *                           if the property isn't recognized.
67
+     */
68
+    public function get( $post_id ) {
69
+
70
+        // Get the post.
71
+        $post = get_post( $post_id );
72
+
73
+        // Switch according to the selected property.
74
+        switch ( $this->property ) {
75
+
76
+            // Title.
77
+            case self::TITLE:
78
+                return $post->post_title;
79
+
80
+            // Description.
81
+            case self::DESCRIPTION_NO_TAGS_NO_SHORTCODES:
82
+                return wp_strip_all_tags( preg_replace( '/\[[^]]+\]/', '', do_shortcode( $post->post_content ) ) );
83
+
84
+            // Author.
85
+            case self::AUTHOR:
86
+                return $post->post_author;
87
+        }
88
+
89
+        return null;
90
+    }
91 91
 
92 92
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @param string $property A post property.
51 51
 	 */
52
-	public function __construct( $property ) {
52
+	public function __construct($property) {
53 53
 
54 54
 		$this->property = $property;
55 55
 
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 	 * @return array|string|null A single string, or an array of values or null
66 66
 	 *                           if the property isn't recognized.
67 67
 	 */
68
-	public function get( $post_id ) {
68
+	public function get($post_id) {
69 69
 
70 70
 		// Get the post.
71
-		$post = get_post( $post_id );
71
+		$post = get_post($post_id);
72 72
 
73 73
 		// Switch according to the selected property.
74
-		switch ( $this->property ) {
74
+		switch ($this->property) {
75 75
 
76 76
 			// Title.
77 77
 			case self::TITLE:
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
 			// Description.
81 81
 			case self::DESCRIPTION_NO_TAGS_NO_SHORTCODES:
82
-				return wp_strip_all_tags( preg_replace( '/\[[^]]+\]/', '', do_shortcode( $post->post_content ) ) );
82
+				return wp_strip_all_tags(preg_replace('/\[[^]]+\]/', '', do_shortcode($post->post_content)));
83 83
 
84 84
 			// Author.
85 85
 			case self::AUTHOR:
Please login to merge, or discard this patch.
src/admin/elements/class-wordlift-admin-input-element.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -44,35 +44,35 @@
 block discarded – undo
44 44
 	 *
45 45
 	 * @return $this|Wordlift_Admin_Element
46 46
 	 */
47
-	public function render( $args ) {
47
+	public function render($args) {
48 48
 
49 49
 		/*
50 50
 		 * Parse the arguments and merge with default values.
51 51
 		 * Name intentionally do not have a default as it has to be in SyncEvent
52 52
 		 * with form handling code
53 53
 		 */
54
-		$pre_params = wp_parse_args( $args, array(
55
-			'id'          => uniqid( 'wl-input-' ),
54
+		$pre_params = wp_parse_args($args, array(
55
+			'id'          => uniqid('wl-input-'),
56 56
 			'value'       => '',
57 57
 			'readonly'    => false,
58 58
 			'css_class'   => '',
59 59
 			'description' => '',
60
-		) );
61
-		$params     = apply_filters( 'wl_admin_input_element_params', $pre_params );
60
+		));
61
+		$params = apply_filters('wl_admin_input_element_params', $pre_params);
62 62
 
63 63
 		// Set the readonly and class attributes and the description.
64 64
 		$readonly    = $params['readonly'] ? ' readonly="readonly"' : '';
65
-		$css_class   = ! empty( $params['css_class'] ) ? ' class="' . esc_attr( $params['css_class'] ) . '"' : '';
66
-		$description = ! empty( $params['description'] ) ? '<p>' . wp_kses( $params['description'], array( 'a' => array( 'href' => array() ) ) ) . '</p>' : '';
65
+		$css_class   = ! empty($params['css_class']) ? ' class="'.esc_attr($params['css_class']).'"' : '';
66
+		$description = ! empty($params['description']) ? '<p>'.wp_kses($params['description'], array('a' => array('href' => array()))).'</p>' : '';
67 67
 
68 68
 		// allow different types of input - default to 'text'.
69
-		$input_type = ! empty( $params['type'] ) ? $params['type'] : 'text';
69
+		$input_type = ! empty($params['type']) ? $params['type'] : 'text';
70 70
 		?>
71 71
 
72
-		<input type="<?php echo esc_attr( $input_type ); ?>"
73
-		       id="<?php echo esc_attr( $params['id'] ); ?>"
74
-		       name="<?php echo esc_attr( $params['name'] ); ?>"
75
-		       value="<?php echo esc_attr( $params['value'] ); ?>"
72
+		<input type="<?php echo esc_attr($input_type); ?>"
73
+		       id="<?php echo esc_attr($params['id']); ?>"
74
+		       name="<?php echo esc_attr($params['name']); ?>"
75
+		       value="<?php echo esc_attr($params['value']); ?>"
76 76
 			<?php echo $readonly; ?>
77 77
 			<?php echo $css_class; ?>
78 78
 		/>
Please login to merge, or discard this patch.
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -18,56 +18,56 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Admin_Input_Element implements Wordlift_Admin_Element {
20 20
 
21
-	/**
22
-	 * Output the HTML for an input box type settings_page
23
-	 *
24
-	 * @param array $args An array with the following keys:
25
-	 *                    Parameters controlling the result.
26
-	 *
27
-	 * @type string name The name attribute of the input element. Mandatory.
28
-	 *
29
-	 * @type string id    The id attribute of the input element. Optional.
30
-	 * @type string id    The id attribute of the input element.
31
-	 *                            Optional, randomly generated one is used if not supplied.
32
-	 * @type string value    The value of the input element.
33
-	 *                            Optional, defaults to empty string.
34
-	 * @type bool readonly    Indicates whether the input is read only.
35
-	 *                            Optional, defaults to read-write
36
-	 * @type string css_class    The class attribute for the input element.
37
-	 *                            If empty string no class attribute will be added.
38
-	 *                            Optional, defaults to empty string.
39
-	 * @type string description    The descriptio text to be displayed below the element.
40
-	 *                            Can include some HTML element.
41
-	 *                            If empty string no description will be displayed.
42
-	 *                            Optional, defaults to empty string.
43
-	 * @since 3.21.0 added the ability to use a $type arg.
44
-	 *
45
-	 * @return $this|Wordlift_Admin_Element
46
-	 */
47
-	public function render( $args ) {
21
+    /**
22
+     * Output the HTML for an input box type settings_page
23
+     *
24
+     * @param array $args An array with the following keys:
25
+     *                    Parameters controlling the result.
26
+     *
27
+     * @type string name The name attribute of the input element. Mandatory.
28
+     *
29
+     * @type string id    The id attribute of the input element. Optional.
30
+     * @type string id    The id attribute of the input element.
31
+     *                            Optional, randomly generated one is used if not supplied.
32
+     * @type string value    The value of the input element.
33
+     *                            Optional, defaults to empty string.
34
+     * @type bool readonly    Indicates whether the input is read only.
35
+     *                            Optional, defaults to read-write
36
+     * @type string css_class    The class attribute for the input element.
37
+     *                            If empty string no class attribute will be added.
38
+     *                            Optional, defaults to empty string.
39
+     * @type string description    The descriptio text to be displayed below the element.
40
+     *                            Can include some HTML element.
41
+     *                            If empty string no description will be displayed.
42
+     *                            Optional, defaults to empty string.
43
+     * @since 3.21.0 added the ability to use a $type arg.
44
+     *
45
+     * @return $this|Wordlift_Admin_Element
46
+     */
47
+    public function render( $args ) {
48 48
 
49
-		/*
49
+        /*
50 50
 		 * Parse the arguments and merge with default values.
51 51
 		 * Name intentionally do not have a default as it has to be in SyncEvent
52 52
 		 * with form handling code
53 53
 		 */
54
-		$pre_params = wp_parse_args( $args, array(
55
-			'id'          => uniqid( 'wl-input-' ),
56
-			'value'       => '',
57
-			'readonly'    => false,
58
-			'css_class'   => '',
59
-			'description' => '',
60
-		) );
61
-		$params     = apply_filters( 'wl_admin_input_element_params', $pre_params );
54
+        $pre_params = wp_parse_args( $args, array(
55
+            'id'          => uniqid( 'wl-input-' ),
56
+            'value'       => '',
57
+            'readonly'    => false,
58
+            'css_class'   => '',
59
+            'description' => '',
60
+        ) );
61
+        $params     = apply_filters( 'wl_admin_input_element_params', $pre_params );
62 62
 
63
-		// Set the readonly and class attributes and the description.
64
-		$readonly    = $params['readonly'] ? ' readonly="readonly"' : '';
65
-		$css_class   = ! empty( $params['css_class'] ) ? ' class="' . esc_attr( $params['css_class'] ) . '"' : '';
66
-		$description = ! empty( $params['description'] ) ? '<p>' . wp_kses( $params['description'], array( 'a' => array( 'href' => array() ) ) ) . '</p>' : '';
63
+        // Set the readonly and class attributes and the description.
64
+        $readonly    = $params['readonly'] ? ' readonly="readonly"' : '';
65
+        $css_class   = ! empty( $params['css_class'] ) ? ' class="' . esc_attr( $params['css_class'] ) . '"' : '';
66
+        $description = ! empty( $params['description'] ) ? '<p>' . wp_kses( $params['description'], array( 'a' => array( 'href' => array() ) ) ) . '</p>' : '';
67 67
 
68
-		// allow different types of input - default to 'text'.
69
-		$input_type = ! empty( $params['type'] ) ? $params['type'] : 'text';
70
-		?>
68
+        // allow different types of input - default to 'text'.
69
+        $input_type = ! empty( $params['type'] ) ? $params['type'] : 'text';
70
+        ?>
71 71
 
72 72
 		<input type="<?php echo esc_attr( $input_type ); ?>"
73 73
 		       id="<?php echo esc_attr( $params['id'] ); ?>"
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
 		<?php
82 82
 
83
-		return $this;
84
-	}
83
+        return $this;
84
+    }
85 85
 
86 86
 }
Please login to merge, or discard this patch.
src/admin/class-wordlift-admin-settings-analytics-page-action-link.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -19,52 +19,52 @@
 block discarded – undo
19 19
  */
20 20
 class Wordlift_Admin_Settings_Analytics_Page_Action_Link {
21 21
 
22
-	/**
23
-	 * The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
24
-	 *
25
-	 * @since  3.11.0
26
-	 * @access private
27
-	 * @var \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
28
-	 */
29
-	private $settings_page;
22
+    /**
23
+     * The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
24
+     *
25
+     * @since  3.11.0
26
+     * @access private
27
+     * @var \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
28
+     */
29
+    private $settings_page;
30 30
 
31
-	/**
32
-	 * Create a {@link Wordlift_Admin_Settings_Analytics_Page_Action_Link} instance.
33
-	 *
34
-	 * @since  3.11.0
35
-	 *
36
-	 * @param \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
37
-	 */
38
-	public function __construct( $settings_page ) {
31
+    /**
32
+     * Create a {@link Wordlift_Admin_Settings_Analytics_Page_Action_Link} instance.
33
+     *
34
+     * @since  3.11.0
35
+     *
36
+     * @param \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
37
+     */
38
+    public function __construct( $settings_page ) {
39 39
 
40
-		$this->settings_page = $settings_page;
40
+        $this->settings_page = $settings_page;
41 41
 
42
-	}
42
+    }
43 43
 
44
-	/**
45
-	 * Create a link to the WordLift settings page.
46
-	 *
47
-	 * @since 3.11.0
48
-	 *
49
-	 * @param array $links An array of links.
50
-	 *
51
-	 * @return array An array of links including those added by the plugin.
52
-	 */
53
-	public function action_links( $links ) {
44
+    /**
45
+     * Create a link to the WordLift settings page.
46
+     *
47
+     * @since 3.11.0
48
+     *
49
+     * @param array $links An array of links.
50
+     *
51
+     * @return array An array of links including those added by the plugin.
52
+     */
53
+    public function action_links( $links ) {
54 54
 
55
-		// Get the menu slug from the page, then prepare the path, hence the url.
56
-		$menu_slug = $this->settings_page->get_menu_slug();
57
-		$path      = "admin.php?page=$menu_slug";
58
-		$url       = get_admin_url( null, $path );
55
+        // Get the menu slug from the page, then prepare the path, hence the url.
56
+        $menu_slug = $this->settings_page->get_menu_slug();
57
+        $path      = "admin.php?page=$menu_slug";
58
+        $url       = get_admin_url( null, $path );
59 59
 
60
-		// Add our own link to the list of links.
61
-		return array_merge( $links, array(
62
-			sprintf(
63
-				'<a href="%1$s">%2$s</a>',
64
-				esc_url( $url ),
65
-				esc_html__( 'Analytics Settings', 'wordlift' )
66
-			),
67
-		) );
68
-	}
60
+        // Add our own link to the list of links.
61
+        return array_merge( $links, array(
62
+            sprintf(
63
+                '<a href="%1$s">%2$s</a>',
64
+                esc_url( $url ),
65
+                esc_html__( 'Analytics Settings', 'wordlift' )
66
+            ),
67
+        ) );
68
+    }
69 69
 
70 70
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance.
37 37
 	 */
38
-	public function __construct( $settings_page ) {
38
+	public function __construct($settings_page) {
39 39
 
40 40
 		$this->settings_page = $settings_page;
41 41
 
@@ -50,21 +50,21 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @return array An array of links including those added by the plugin.
52 52
 	 */
53
-	public function action_links( $links ) {
53
+	public function action_links($links) {
54 54
 
55 55
 		// Get the menu slug from the page, then prepare the path, hence the url.
56 56
 		$menu_slug = $this->settings_page->get_menu_slug();
57 57
 		$path      = "admin.php?page=$menu_slug";
58
-		$url       = get_admin_url( null, $path );
58
+		$url       = get_admin_url(null, $path);
59 59
 
60 60
 		// Add our own link to the list of links.
61
-		return array_merge( $links, array(
61
+		return array_merge($links, array(
62 62
 			sprintf(
63 63
 				'<a href="%1$s">%2$s</a>',
64
-				esc_url( $url ),
65
-				esc_html__( 'Analytics Settings', 'wordlift' )
64
+				esc_url($url),
65
+				esc_html__('Analytics Settings', 'wordlift')
66 66
 			),
67
-		) );
67
+		));
68 68
 	}
69 69
 
70 70
 }
Please login to merge, or discard this patch.
src/includes/linked-data/storage/class-wordlift-post-meta-uri-storage.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -18,50 +18,50 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Post_Meta_Uri_Storage extends Wordlift_Post_Meta_Storage {
20 20
 
21
-	/**
22
-	 * The {@link Wordlift_Entity_Service} instance.
23
-	 *
24
-	 * @since  3.15.0
25
-	 * @access private
26
-	 * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
27
-	 */
28
-	private $entity_service;
21
+    /**
22
+     * The {@link Wordlift_Entity_Service} instance.
23
+     *
24
+     * @since  3.15.0
25
+     * @access private
26
+     * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
27
+     */
28
+    private $entity_service;
29 29
 
30
-	/**
31
-	 * Create a {@link Wordlift_Post_Meta_Uri_Storage} instance.
32
-	 *
33
-	 * @since 3.15.0
34
-	 *
35
-	 * @param string                   $meta_key       The meta key to read data from.
36
-	 * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
37
-	 */
38
-	public function __construct( $meta_key, $entity_service ) {
39
-		parent::__construct( $meta_key );
30
+    /**
31
+     * Create a {@link Wordlift_Post_Meta_Uri_Storage} instance.
32
+     *
33
+     * @since 3.15.0
34
+     *
35
+     * @param string                   $meta_key       The meta key to read data from.
36
+     * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
37
+     */
38
+    public function __construct( $meta_key, $entity_service ) {
39
+        parent::__construct( $meta_key );
40 40
 
41
-		$this->entity_service = $entity_service;
41
+        $this->entity_service = $entity_service;
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Get the value for the specified meta key.
47
-	 *
48
-	 * The value is expected to be an entity post, for which the URI is loaded
49
-	 * and returned.
50
-	 *
51
-	 * @since 3.15.0
52
-	 *
53
-	 * @param int $post_id The {@link WP_Post}'s id.
54
-	 *
55
-	 * @return array An array of URIs (or an empty array if nothing is set).
56
-	 */
57
-	public function get( $post_id ) {
58
-		$values = parent::get( $post_id );
45
+    /**
46
+     * Get the value for the specified meta key.
47
+     *
48
+     * The value is expected to be an entity post, for which the URI is loaded
49
+     * and returned.
50
+     *
51
+     * @since 3.15.0
52
+     *
53
+     * @param int $post_id The {@link WP_Post}'s id.
54
+     *
55
+     * @return array An array of URIs (or an empty array if nothing is set).
56
+     */
57
+    public function get( $post_id ) {
58
+        $values = parent::get( $post_id );
59 59
 
60
-		$entity_service = $this->entity_service;
60
+        $entity_service = $this->entity_service;
61 61
 
62
-		return array_map( function ( $item ) use ( $entity_service ) {
63
-			return $entity_service->get_uri( $item );
64
-		}, $values );
65
-	}
62
+        return array_map( function ( $item ) use ( $entity_service ) {
63
+            return $entity_service->get_uri( $item );
64
+        }, $values );
65
+    }
66 66
 
67 67
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 	 * @param string                   $meta_key       The meta key to read data from.
36 36
 	 * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
37 37
 	 */
38
-	public function __construct( $meta_key, $entity_service ) {
39
-		parent::__construct( $meta_key );
38
+	public function __construct($meta_key, $entity_service) {
39
+		parent::__construct($meta_key);
40 40
 
41 41
 		$this->entity_service = $entity_service;
42 42
 
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return array An array of URIs (or an empty array if nothing is set).
56 56
 	 */
57
-	public function get( $post_id ) {
58
-		$values = parent::get( $post_id );
57
+	public function get($post_id) {
58
+		$values = parent::get($post_id);
59 59
 
60 60
 		$entity_service = $this->entity_service;
61 61
 
62
-		return array_map( function ( $item ) use ( $entity_service ) {
63
-			return $entity_service->get_uri( $item );
64
-		}, $values );
62
+		return array_map(function($item) use ($entity_service) {
63
+			return $entity_service->get_uri($item);
64
+		}, $values);
65 65
 	}
66 66
 
67 67
 }
Please login to merge, or discard this patch.
src/admin/partials/wordlift-admin-settings-analytics-page.php 2 patches
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 	<?php settings_errors(); ?>
12 12
 	<form action="options.php" method="post">
13 13
 		<?php
14
-		settings_fields( 'wl_analytics_settings' );
15
-		do_settings_sections( 'wl_analytics_settings' );
16
-		submit_button();
17
-		?>
14
+        settings_fields( 'wl_analytics_settings' );
15
+        do_settings_sections( 'wl_analytics_settings' );
16
+        submit_button();
17
+        ?>
18 18
 	</form>
19 19
 	<div class="info">
20 20
 		<b><?php esc_html_e( 'For Google Tag Manager there is additional setup steps needed in the GTM interface. These are the general instructions:', 'wordlift' ); ?></b>
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
 			<li><?php esc_html_e( 'You should already have a configuration variable setup to pass data along to your provider. This is assumed to be Google Analytics and a google analytics configuration object. If you don\'t have this setup then set it up now.', 'wordlift' ); ?></li>
23 23
 			<li>
24 24
 				<?php
25
-				printf(
26
-					esc_html__( 'Visit the GTM dashboard and head to the %1$s menu. Add a new user-defined variable of type %2$s for each of the following items:', 'wordlift' ),
27
-					'<b>Variables</b>',
28
-					'<i>Data Layer Variable</i>'
29
-				);
30
-				?>
25
+                printf(
26
+                    esc_html__( 'Visit the GTM dashboard and head to the %1$s menu. Add a new user-defined variable of type %2$s for each of the following items:', 'wordlift' ),
27
+                    '<b>Variables</b>',
28
+                    '<i>Data Layer Variable</i>'
29
+                );
30
+                ?>
31 31
 				<ol>
32 32
 					<li><i>event</i></li>
33 33
 					<li><i>wl_event_action</i></li>
@@ -43,51 +43,51 @@  discard block
 block discarded – undo
43 43
 			</li>
44 44
 			<li>
45 45
 				<?php
46
-				printf(
47
-					esc_html__( 'Create another variable to pass along the 2 custom dimensions with the type %1$s. For each of the 2 items set the following:', 'wordlift' ),
48
-					'<i>Google Analytics Settings</i>'
49
-				);
50
-				?>
46
+                printf(
47
+                    esc_html__( 'Create another variable to pass along the 2 custom dimensions with the type %1$s. For each of the 2 items set the following:', 'wordlift' ),
48
+                    '<i>Google Analytics Settings</i>'
49
+                );
50
+                ?>
51 51
 				<ol>
52 52
 					<li><?php esc_html_e( 'Set the index to the index of the custom event you want to push this into at Google Analytics, this will usually be a number between 1 and 9.', 'wordlift' ); ?></li>
53 53
 					<li>
54 54
 						<?php
55
-						printf(
56
-							esc_html__( 'Set the values of each one to the %1$s and the %2$s respectively.', 'wordlift' ),
57
-							'<i>wl_index_uri</i> - <i>wl_event_uri</i>',
58
-							'<i>wl_index_type</i> - <i>wl_event_type</i>'
59
-						);
60
-						?>
55
+                        printf(
56
+                            esc_html__( 'Set the values of each one to the %1$s and the %2$s respectively.', 'wordlift' ),
57
+                            '<i>wl_index_uri</i> - <i>wl_event_uri</i>',
58
+                            '<i>wl_index_type</i> - <i>wl_event_type</i>'
59
+                        );
60
+                        ?>
61 61
 					</li>
62 62
 				</ol>
63 63
 			</li>
64 64
 			<li>
65 65
 				<?php
66
-				printf(
67
-					esc_html__( 'Go to the %1$s menu and create a new trigger of the type: %2$s.', 'wordlift' ),
68
-					'<b>Triggers</b>',
69
-					'<i>Custom Event</i>'
70
-				);
71
-				?>
66
+                printf(
67
+                    esc_html__( 'Go to the %1$s menu and create a new trigger of the type: %2$s.', 'wordlift' ),
68
+                    '<b>Triggers</b>',
69
+                    '<i>Custom Event</i>'
70
+                );
71
+                ?>
72 72
 				<ol>
73 73
 					<li>
74 74
 
75 75
 						<?php
76
-						printf(
77
-							esc_html__( 'In the %1$s field input %2$s.', 'wordlift' ),
78
-							'<i>Event name</i>',
79
-							'<i>Mentions</i>'
80
-						);
81
-						?>
76
+                        printf(
77
+                            esc_html__( 'In the %1$s field input %2$s.', 'wordlift' ),
78
+                            '<i>Event name</i>',
79
+                            '<i>Mentions</i>'
80
+                        );
81
+                        ?>
82 82
 					</li>
83 83
 					<li>
84 84
 
85 85
 						<?php
86
-						printf(
87
-							esc_html__( 'Set this to fire on %1$s and in the filter set:', 'wordlift' ),
88
-							'<i>Some Custom Events</i>'
89
-						);
90
-						?>
86
+                        printf(
87
+                            esc_html__( 'Set this to fire on %1$s and in the filter set:', 'wordlift' ),
88
+                            '<i>Some Custom Events</i>'
89
+                        );
90
+                        ?>
91 91
 						<ol>
92 92
 							<li><i>event_action</i> - <i>equals</i> - <i>Mentions</i>.</li>
93 93
 						</ol>
@@ -96,77 +96,77 @@  discard block
 block discarded – undo
96 96
 			</li>
97 97
 			<li>
98 98
 				<?php
99
-				printf(
100
-					esc_html__( 'Go to the %1$s menu and create a new tag.', 'wordlift' ),
101
-					'<b>Tags</b>'
102
-				);
103
-				?>
99
+                printf(
100
+                    esc_html__( 'Go to the %1$s menu and create a new tag.', 'wordlift' ),
101
+                    '<b>Tags</b>'
102
+                );
103
+                ?>
104 104
 				<ol>
105 105
 					<li>
106 106
 
107 107
 						<?php
108
-						printf(
109
-							esc_html__( 'In the tag configuration section choose %1$s. Assuming you have used variable names that match those mentioned enter:', 'wordlift' ),
110
-							'<i>Google Analytics - Universal Analytics</i>'
111
-						);
112
-						?>
108
+                        printf(
109
+                            esc_html__( 'In the tag configuration section choose %1$s. Assuming you have used variable names that match those mentioned enter:', 'wordlift' ),
110
+                            '<i>Google Analytics - Universal Analytics</i>'
111
+                        );
112
+                        ?>
113 113
 						<ol>
114 114
 							<li>
115 115
 								<?php
116
-								printf(
117
-									esc_html__( 'Set the %1$s to %2$s.', 'wordlift' ),
118
-									'Track Type',
119
-									'<i>Event</i>'
120
-								);
121
-								?>
116
+                                printf(
117
+                                    esc_html__( 'Set the %1$s to %2$s.', 'wordlift' ),
118
+                                    'Track Type',
119
+                                    '<i>Event</i>'
120
+                                );
121
+                                ?>
122 122
 							</li>
123 123
 							<li>
124 124
 								<?php
125
-								printf(
126
-									esc_html__( 'Set Category to %1$s.', 'wordlift' ),
127
-									'<i>{{wl_event_category}}</i>'
128
-								);
129
-								?>
125
+                                printf(
126
+                                    esc_html__( 'Set Category to %1$s.', 'wordlift' ),
127
+                                    '<i>{{wl_event_category}}</i>'
128
+                                );
129
+                                ?>
130 130
 							</li>
131 131
 							<li>
132 132
 								<?php
133
-								printf(
134
-									esc_html__( 'Set Action to %1$s.', 'wordlift' ),
135
-									'<i>{{wl_event_action}}</i>'
136
-								);
137
-								?>
133
+                                printf(
134
+                                    esc_html__( 'Set Action to %1$s.', 'wordlift' ),
135
+                                    '<i>{{wl_event_action}}</i>'
136
+                                );
137
+                                ?>
138 138
 							</li>
139 139
 							<li>
140 140
 								<?php
141
-								printf(
142
-									esc_html__( 'Set Label to %1$s.', 'wordlift' ),
143
-									'<i>{{wl_event_label}}</i>'
144
-								);
145
-								?>
141
+                                printf(
142
+                                    esc_html__( 'Set Label to %1$s.', 'wordlift' ),
143
+                                    '<i>{{wl_event_label}}</i>'
144
+                                );
145
+                                ?>
146 146
 							</li>
147 147
 							<li>
148 148
 								<?php
149
-								printf(
150
-									esc_html__( 'Set Value to %1$s.', 'wordlift' ),
151
-									'<i>{{wl_event_value}}</i>'
152
-								);
153
-								?>
149
+                                printf(
150
+                                    esc_html__( 'Set Value to %1$s.', 'wordlift' ),
151
+                                    '<i>{{wl_event_value}}</i>'
152
+                                );
153
+                                ?>
154 154
 							</li>
155 155
 							<li>
156 156
 								<?php
157
-								printf(
158
-									esc_html__( 'Set Non-Interaction Hit to %1$s.', 'wordlift' ),
159
-									'<i>True</i>'
160
-								);
161
-								?>
157
+                                printf(
158
+                                    esc_html__( 'Set Non-Interaction Hit to %1$s.', 'wordlift' ),
159
+                                    '<i>True</i>'
160
+                                );
161
+                                ?>
162 162
 							</li>
163 163
 							<li>
164 164
 								<?php
165
-								printf(
166
-									esc_html__( 'Set the %1$s dropdown to the settings object for the Google Analytics tracking.', 'wordlift' ),
167
-									'<i>Google Analytics Settings</i>'
168
-								);
169
-								?>
165
+                                printf(
166
+                                    esc_html__( 'Set the %1$s dropdown to the settings object for the Google Analytics tracking.', 'wordlift' ),
167
+                                    '<i>Google Analytics Settings</i>'
168
+                                );
169
+                                ?>
170 170
 							</li>
171 171
 						</ol>
172 172
 					</li>
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
 	<?php settings_errors(); ?>
12 12
 	<form action="options.php" method="post">
13 13
 		<?php
14
-		settings_fields( 'wl_analytics_settings' );
15
-		do_settings_sections( 'wl_analytics_settings' );
14
+		settings_fields('wl_analytics_settings');
15
+		do_settings_sections('wl_analytics_settings');
16 16
 		submit_button();
17 17
 		?>
18 18
 	</form>
19 19
 	<div class="info">
20
-		<b><?php esc_html_e( 'For Google Tag Manager there is additional setup steps needed in the GTM interface. These are the general instructions:', 'wordlift' ); ?></b>
20
+		<b><?php esc_html_e('For Google Tag Manager there is additional setup steps needed in the GTM interface. These are the general instructions:', 'wordlift'); ?></b>
21 21
 		<ol>
22
-			<li><?php esc_html_e( 'You should already have a configuration variable setup to pass data along to your provider. This is assumed to be Google Analytics and a google analytics configuration object. If you don\'t have this setup then set it up now.', 'wordlift' ); ?></li>
22
+			<li><?php esc_html_e('You should already have a configuration variable setup to pass data along to your provider. This is assumed to be Google Analytics and a google analytics configuration object. If you don\'t have this setup then set it up now.', 'wordlift'); ?></li>
23 23
 			<li>
24 24
 				<?php
25 25
 				printf(
26
-					esc_html__( 'Visit the GTM dashboard and head to the %1$s menu. Add a new user-defined variable of type %2$s for each of the following items:', 'wordlift' ),
26
+					esc_html__('Visit the GTM dashboard and head to the %1$s menu. Add a new user-defined variable of type %2$s for each of the following items:', 'wordlift'),
27 27
 					'<b>Variables</b>',
28 28
 					'<i>Data Layer Variable</i>'
29 29
 				);
@@ -34,26 +34,26 @@  discard block
 block discarded – undo
34 34
 					<li><i>wl_event_category</i></li>
35 35
 					<li><i>wl_event_label</i></li>
36 36
 					<li><i>wl_event_value</i></li>
37
-					<li><i>wl_event_uri</i> <?php esc_html_e( '(which is the first custom dimension number the plugin offers)', 'wordlift' ); ?></li>
38
-					<li><i>wl_index_uri</i> <?php esc_html_e( '(this is the index number sent to use as the custom dimention for uri)', 'wordlift' ); ?></li>
39
-					<li><i>wl_event_type</i> <?php esc_html_e( '(which is the second custom dimension number the plugin offers)', 'wordlift' ); ?></li>
40
-					<li><i>wl_index_type</i> <?php esc_html_e( '(this is the index number sent to use as the custom dimention for type)', 'wordlift' ); ?></li>
37
+					<li><i>wl_event_uri</i> <?php esc_html_e('(which is the first custom dimension number the plugin offers)', 'wordlift'); ?></li>
38
+					<li><i>wl_index_uri</i> <?php esc_html_e('(this is the index number sent to use as the custom dimention for uri)', 'wordlift'); ?></li>
39
+					<li><i>wl_event_type</i> <?php esc_html_e('(which is the second custom dimension number the plugin offers)', 'wordlift'); ?></li>
40
+					<li><i>wl_index_type</i> <?php esc_html_e('(this is the index number sent to use as the custom dimention for type)', 'wordlift'); ?></li>
41 41
 
42 42
 				</ol>
43 43
 			</li>
44 44
 			<li>
45 45
 				<?php
46 46
 				printf(
47
-					esc_html__( 'Create another variable to pass along the 2 custom dimensions with the type %1$s. For each of the 2 items set the following:', 'wordlift' ),
47
+					esc_html__('Create another variable to pass along the 2 custom dimensions with the type %1$s. For each of the 2 items set the following:', 'wordlift'),
48 48
 					'<i>Google Analytics Settings</i>'
49 49
 				);
50 50
 				?>
51 51
 				<ol>
52
-					<li><?php esc_html_e( 'Set the index to the index of the custom event you want to push this into at Google Analytics, this will usually be a number between 1 and 9.', 'wordlift' ); ?></li>
52
+					<li><?php esc_html_e('Set the index to the index of the custom event you want to push this into at Google Analytics, this will usually be a number between 1 and 9.', 'wordlift'); ?></li>
53 53
 					<li>
54 54
 						<?php
55 55
 						printf(
56
-							esc_html__( 'Set the values of each one to the %1$s and the %2$s respectively.', 'wordlift' ),
56
+							esc_html__('Set the values of each one to the %1$s and the %2$s respectively.', 'wordlift'),
57 57
 							'<i>wl_index_uri</i> - <i>wl_event_uri</i>',
58 58
 							'<i>wl_index_type</i> - <i>wl_event_type</i>'
59 59
 						);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 			<li>
65 65
 				<?php
66 66
 				printf(
67
-					esc_html__( 'Go to the %1$s menu and create a new trigger of the type: %2$s.', 'wordlift' ),
67
+					esc_html__('Go to the %1$s menu and create a new trigger of the type: %2$s.', 'wordlift'),
68 68
 					'<b>Triggers</b>',
69 69
 					'<i>Custom Event</i>'
70 70
 				);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 
75 75
 						<?php
76 76
 						printf(
77
-							esc_html__( 'In the %1$s field input %2$s.', 'wordlift' ),
77
+							esc_html__('In the %1$s field input %2$s.', 'wordlift'),
78 78
 							'<i>Event name</i>',
79 79
 							'<i>Mentions</i>'
80 80
 						);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 						<?php
86 86
 						printf(
87
-							esc_html__( 'Set this to fire on %1$s and in the filter set:', 'wordlift' ),
87
+							esc_html__('Set this to fire on %1$s and in the filter set:', 'wordlift'),
88 88
 							'<i>Some Custom Events</i>'
89 89
 						);
90 90
 						?>
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			<li>
98 98
 				<?php
99 99
 				printf(
100
-					esc_html__( 'Go to the %1$s menu and create a new tag.', 'wordlift' ),
100
+					esc_html__('Go to the %1$s menu and create a new tag.', 'wordlift'),
101 101
 					'<b>Tags</b>'
102 102
 				);
103 103
 				?>
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
 						<?php
108 108
 						printf(
109
-							esc_html__( 'In the tag configuration section choose %1$s. Assuming you have used variable names that match those mentioned enter:', 'wordlift' ),
109
+							esc_html__('In the tag configuration section choose %1$s. Assuming you have used variable names that match those mentioned enter:', 'wordlift'),
110 110
 							'<i>Google Analytics - Universal Analytics</i>'
111 111
 						);
112 112
 						?>
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 							<li>
115 115
 								<?php
116 116
 								printf(
117
-									esc_html__( 'Set the %1$s to %2$s.', 'wordlift' ),
117
+									esc_html__('Set the %1$s to %2$s.', 'wordlift'),
118 118
 									'Track Type',
119 119
 									'<i>Event</i>'
120 120
 								);
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 							<li>
124 124
 								<?php
125 125
 								printf(
126
-									esc_html__( 'Set Category to %1$s.', 'wordlift' ),
126
+									esc_html__('Set Category to %1$s.', 'wordlift'),
127 127
 									'<i>{{wl_event_category}}</i>'
128 128
 								);
129 129
 								?>
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 							<li>
132 132
 								<?php
133 133
 								printf(
134
-									esc_html__( 'Set Action to %1$s.', 'wordlift' ),
134
+									esc_html__('Set Action to %1$s.', 'wordlift'),
135 135
 									'<i>{{wl_event_action}}</i>'
136 136
 								);
137 137
 								?>
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 							<li>
140 140
 								<?php
141 141
 								printf(
142
-									esc_html__( 'Set Label to %1$s.', 'wordlift' ),
142
+									esc_html__('Set Label to %1$s.', 'wordlift'),
143 143
 									'<i>{{wl_event_label}}</i>'
144 144
 								);
145 145
 								?>
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 							<li>
148 148
 								<?php
149 149
 								printf(
150
-									esc_html__( 'Set Value to %1$s.', 'wordlift' ),
150
+									esc_html__('Set Value to %1$s.', 'wordlift'),
151 151
 									'<i>{{wl_event_value}}</i>'
152 152
 								);
153 153
 								?>
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 							<li>
156 156
 								<?php
157 157
 								printf(
158
-									esc_html__( 'Set Non-Interaction Hit to %1$s.', 'wordlift' ),
158
+									esc_html__('Set Non-Interaction Hit to %1$s.', 'wordlift'),
159 159
 									'<i>True</i>'
160 160
 								);
161 161
 								?>
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 							<li>
164 164
 								<?php
165 165
 								printf(
166
-									esc_html__( 'Set the %1$s dropdown to the settings object for the Google Analytics tracking.', 'wordlift' ),
166
+									esc_html__('Set the %1$s dropdown to the settings object for the Google Analytics tracking.', 'wordlift'),
167 167
 									'<i>Google Analytics Settings</i>'
168 168
 								);
169 169
 								?>
170 170
 							</li>
171 171
 						</ol>
172 172
 					</li>
173
-					<li><?php esc_html_e( 'In the triggering tag select the firing trigger you created previously.', 'wordlift' ); ?></li>
173
+					<li><?php esc_html_e('In the triggering tag select the firing trigger you created previously.', 'wordlift'); ?></li>
174 174
 				</ol>
175 175
 			</li>
176 176
 		</ol>
Please login to merge, or discard this patch.
src/public/class-wordlift-sharethis-service.php 2 patches
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -17,116 +17,116 @@
 block discarded – undo
17 17
  */
18 18
 class Wordlift_ShareThis_Service {
19 19
 
20
-	/**
21
-	 * The ShareThis function which prints the buttons.
22
-	 *
23
-	 * @since 3.2.0
24
-	 */
25
-	const ADD_WIDGET_FUNCTION_NAME = 'st_add_widget';
26
-
27
-	/**
28
-	 * The Log service.
29
-	 *
30
-	 * @since  3.2.0
31
-	 * @access private
32
-	 * @var \Wordlift_Log_Service $log_service The Log service.
33
-	 */
34
-	private $log_service;
35
-
36
-	/**
37
-	 * Create an instance of the ShareThis service.
38
-	 *
39
-	 * @since 3.2.0
40
-	 */
41
-	public function __construct() {
42
-
43
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_ShareThis_Service' );
44
-
45
-	}
46
-
47
-	/**
48
-	 * Receive <em>the_content</em> filter calls from WordPress.
49
-	 *
50
-	 * @since 3.2.0
51
-	 *
52
-	 * @param string $content The post content.
53
-	 *
54
-	 * @return string The updated post content.
55
-	 */
56
-	public function the_content( $content ) {
57
-
58
-		return $this->call_sharethis( 'the_content', $content );
59
-	}
60
-
61
-	/**
62
-	 * Receive <em>the_excerpt</em> filter calls from WordPress.
63
-	 *
64
-	 * @since 3.2.0
65
-	 *
66
-	 * @param string $content The post excerpt.
67
-	 *
68
-	 * @return string The updated post excerpt.
69
-	 */
70
-	public function the_excerpt( $content ) {
71
-
72
-		return $this->call_sharethis( 'the_excerpt', $content );
73
-	}
74
-
75
-	/**
76
-	 * Call the ShareThis function.
77
-	 *
78
-	 * @since 3.2.0
79
-	 *
80
-	 * @param string $tag The filter tag.
81
-	 * @param string $content The post content.
82
-	 *
83
-	 * @return string The updated post content.
84
-	 */
85
-	private function call_sharethis( $tag, $content ) {
86
-
87
-		// Get the current post.
88
-		global $post;
89
-
90
-		// Bail out if the global $post instance isn't set.
91
-		if ( !isset( $post ) ) {
92
-			return $content;
93
-		}
94
-
95
-		// Bail out if the current entity is a post/page since this is already handled by ShareThis.
96
-		//
97
-		// See https://github.com/insideout10/wordlift-plugin/issues/819
98
-		if ( 'post' === $post->post_type || 'page' === $post->post_type ) {
99
-			return $content;
100
-		}
101
-
102
-		// If it's not the entity type, return.
103
-		$entity_service = Wordlift_Entity_Service::get_instance();
104
-		if ( null === $post || ! $entity_service->is_entity( get_the_ID() ) ) {
105
-			return $content;
106
-		}
107
-
108
-		// If the ShareThis function doesn't exist, return.
109
-		if ( ! function_exists( self::ADD_WIDGET_FUNCTION_NAME ) ) {
110
-			return $content;
111
-		}
112
-
113
-		// If ShareThis hasn't been added as a filter, return.
114
-		if ( ! has_filter( $tag, self::ADD_WIDGET_FUNCTION_NAME ) ) {
115
-			return $content;
116
-		}
117
-
118
-		// Temporary pop the post type and replace it with post.
119
-		$post_type       = $post->post_type;
120
-		$post->post_type = 'post';
121
-
122
-		// Call ShareThis (disguised as a post).
123
-		$content = call_user_func_array( self::ADD_WIDGET_FUNCTION_NAME, array( $content ) );
124
-
125
-		// Restore our post type.
126
-		$post->post_type = $post_type;
127
-
128
-		// Finally return the content.
129
-		return $content;
130
-	}
20
+    /**
21
+     * The ShareThis function which prints the buttons.
22
+     *
23
+     * @since 3.2.0
24
+     */
25
+    const ADD_WIDGET_FUNCTION_NAME = 'st_add_widget';
26
+
27
+    /**
28
+     * The Log service.
29
+     *
30
+     * @since  3.2.0
31
+     * @access private
32
+     * @var \Wordlift_Log_Service $log_service The Log service.
33
+     */
34
+    private $log_service;
35
+
36
+    /**
37
+     * Create an instance of the ShareThis service.
38
+     *
39
+     * @since 3.2.0
40
+     */
41
+    public function __construct() {
42
+
43
+        $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_ShareThis_Service' );
44
+
45
+    }
46
+
47
+    /**
48
+     * Receive <em>the_content</em> filter calls from WordPress.
49
+     *
50
+     * @since 3.2.0
51
+     *
52
+     * @param string $content The post content.
53
+     *
54
+     * @return string The updated post content.
55
+     */
56
+    public function the_content( $content ) {
57
+
58
+        return $this->call_sharethis( 'the_content', $content );
59
+    }
60
+
61
+    /**
62
+     * Receive <em>the_excerpt</em> filter calls from WordPress.
63
+     *
64
+     * @since 3.2.0
65
+     *
66
+     * @param string $content The post excerpt.
67
+     *
68
+     * @return string The updated post excerpt.
69
+     */
70
+    public function the_excerpt( $content ) {
71
+
72
+        return $this->call_sharethis( 'the_excerpt', $content );
73
+    }
74
+
75
+    /**
76
+     * Call the ShareThis function.
77
+     *
78
+     * @since 3.2.0
79
+     *
80
+     * @param string $tag The filter tag.
81
+     * @param string $content The post content.
82
+     *
83
+     * @return string The updated post content.
84
+     */
85
+    private function call_sharethis( $tag, $content ) {
86
+
87
+        // Get the current post.
88
+        global $post;
89
+
90
+        // Bail out if the global $post instance isn't set.
91
+        if ( !isset( $post ) ) {
92
+            return $content;
93
+        }
94
+
95
+        // Bail out if the current entity is a post/page since this is already handled by ShareThis.
96
+        //
97
+        // See https://github.com/insideout10/wordlift-plugin/issues/819
98
+        if ( 'post' === $post->post_type || 'page' === $post->post_type ) {
99
+            return $content;
100
+        }
101
+
102
+        // If it's not the entity type, return.
103
+        $entity_service = Wordlift_Entity_Service::get_instance();
104
+        if ( null === $post || ! $entity_service->is_entity( get_the_ID() ) ) {
105
+            return $content;
106
+        }
107
+
108
+        // If the ShareThis function doesn't exist, return.
109
+        if ( ! function_exists( self::ADD_WIDGET_FUNCTION_NAME ) ) {
110
+            return $content;
111
+        }
112
+
113
+        // If ShareThis hasn't been added as a filter, return.
114
+        if ( ! has_filter( $tag, self::ADD_WIDGET_FUNCTION_NAME ) ) {
115
+            return $content;
116
+        }
117
+
118
+        // Temporary pop the post type and replace it with post.
119
+        $post_type       = $post->post_type;
120
+        $post->post_type = 'post';
121
+
122
+        // Call ShareThis (disguised as a post).
123
+        $content = call_user_func_array( self::ADD_WIDGET_FUNCTION_NAME, array( $content ) );
124
+
125
+        // Restore our post type.
126
+        $post->post_type = $post_type;
127
+
128
+        // Finally return the content.
129
+        return $content;
130
+    }
131 131
 
132 132
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function __construct() {
42 42
 
43
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_ShareThis_Service' );
43
+		$this->log_service = Wordlift_Log_Service::get_logger('Wordlift_ShareThis_Service');
44 44
 
45 45
 	}
46 46
 
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return string The updated post content.
55 55
 	 */
56
-	public function the_content( $content ) {
56
+	public function the_content($content) {
57 57
 
58
-		return $this->call_sharethis( 'the_content', $content );
58
+		return $this->call_sharethis('the_content', $content);
59 59
 	}
60 60
 
61 61
 	/**
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @return string The updated post excerpt.
69 69
 	 */
70
-	public function the_excerpt( $content ) {
70
+	public function the_excerpt($content) {
71 71
 
72
-		return $this->call_sharethis( 'the_excerpt', $content );
72
+		return $this->call_sharethis('the_excerpt', $content);
73 73
 	}
74 74
 
75 75
 	/**
@@ -82,36 +82,36 @@  discard block
 block discarded – undo
82 82
 	 *
83 83
 	 * @return string The updated post content.
84 84
 	 */
85
-	private function call_sharethis( $tag, $content ) {
85
+	private function call_sharethis($tag, $content) {
86 86
 
87 87
 		// Get the current post.
88 88
 		global $post;
89 89
 
90 90
 		// Bail out if the global $post instance isn't set.
91
-		if ( !isset( $post ) ) {
91
+		if ( ! isset($post)) {
92 92
 			return $content;
93 93
 		}
94 94
 
95 95
 		// Bail out if the current entity is a post/page since this is already handled by ShareThis.
96 96
 		//
97 97
 		// See https://github.com/insideout10/wordlift-plugin/issues/819
98
-		if ( 'post' === $post->post_type || 'page' === $post->post_type ) {
98
+		if ('post' === $post->post_type || 'page' === $post->post_type) {
99 99
 			return $content;
100 100
 		}
101 101
 
102 102
 		// If it's not the entity type, return.
103 103
 		$entity_service = Wordlift_Entity_Service::get_instance();
104
-		if ( null === $post || ! $entity_service->is_entity( get_the_ID() ) ) {
104
+		if (null === $post || ! $entity_service->is_entity(get_the_ID())) {
105 105
 			return $content;
106 106
 		}
107 107
 
108 108
 		// If the ShareThis function doesn't exist, return.
109
-		if ( ! function_exists( self::ADD_WIDGET_FUNCTION_NAME ) ) {
109
+		if ( ! function_exists(self::ADD_WIDGET_FUNCTION_NAME)) {
110 110
 			return $content;
111 111
 		}
112 112
 
113 113
 		// If ShareThis hasn't been added as a filter, return.
114
-		if ( ! has_filter( $tag, self::ADD_WIDGET_FUNCTION_NAME ) ) {
114
+		if ( ! has_filter($tag, self::ADD_WIDGET_FUNCTION_NAME)) {
115 115
 			return $content;
116 116
 		}
117 117
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$post->post_type = 'post';
121 121
 
122 122
 		// Call ShareThis (disguised as a post).
123
-		$content = call_user_func_array( self::ADD_WIDGET_FUNCTION_NAME, array( $content ) );
123
+		$content = call_user_func_array(self::ADD_WIDGET_FUNCTION_NAME, array($content));
124 124
 
125 125
 		// Restore our post type.
126 126
 		$post->post_type = $post_type;
Please login to merge, or discard this patch.
src/admin/partials/wordlift-admin-deactivation-feedback-popup.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -1,62 +1,62 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 $too_complicate_reason_label = sprintf(
3
-	'<a target="_blank" href="%s">%s</a>',
4
-	/* translators: the link https://wordlift.io/contact-us/ should be changed to language version of the page */
5
-	esc_attr__( 'https://wordlift.io/contact-us/', 'wordlift' ),
6
-	esc_html__( 'Contact Us', 'wordlift' )
3
+    '<a target="_blank" href="%s">%s</a>',
4
+    /* translators: the link https://wordlift.io/contact-us/ should be changed to language version of the page */
5
+    esc_attr__( 'https://wordlift.io/contact-us/', 'wordlift' ),
6
+    esc_html__( 'Contact Us', 'wordlift' )
7 7
 );
8 8
 
9 9
 $reasons = array(
10
-	array(
11
-		'id'      => 'TOO_COMPLICATED',
12
-		'text'    => esc_html__( 'It was too complicated and unclear to me', 'wordlift' ),
13
-		'message' => array(
14
-			'text' => sprintf(
15
-				esc_html__( 'Need help? We are ready to answer your questions. %s', 'wordlift' ),
16
-				$too_complicate_reason_label
17
-			),
18
-		),
19
-	),
20
-	array(
21
-		'id'      => 'NOT_ENOUGH_FEATURES',
22
-		'text'    => esc_html__( 'It misses some important feature to me', 'wordlift' ),
23
-		'message' => array(
24
-			'field' => 'text',
25
-			'text'  => esc_html__( 'Tell us what this feature is.', 'wordlift' ),
26
-		),
27
-	),
28
-	array(
29
-		'id'      => 'COSTS_TOO_MUCH',
30
-		'text'    => esc_html__( 'It costs too much', 'wordlift' ),
31
-		'message' => array(
32
-			'field' => 'text',
33
-			'text'  => esc_html__( 'How much you would like to pay?', 'wordlift' ),
34
-		),
35
-	),
36
-	array(
37
-		'id'      => 'FOUND_ANOTHER_TOOL',
38
-		'text'    => esc_html__( 'I found another tool that I like better', 'wordlift' ),
39
-		'message' => array(
40
-			'field' => 'text',
41
-			'text'  => esc_html__( 'Please tell us some more details.', 'wordlift' ),
42
-		),
43
-	),
44
-	array(
45
-		'id'   => 'I_DONT_USE_IT',
46
-		'text' => esc_html__( 'I\'m not using it right now', 'wordlift' ),
47
-	),
48
-	array(
49
-		'id'   => 'SOMETHING_DIDNT_WORK',
50
-		'text' => esc_html__( 'Something didn\'t work right', 'wordlift' ),
51
-	),
52
-	array(
53
-		'id'      => 'ANOTHER_REASON',
54
-		'text'    => esc_html__( 'Another reason', 'wordlift' ),
55
-		'message' => array(
56
-			'field' => 'textarea',
57
-			'text'  => esc_html__( 'Please tell us the reason so we can improve it.', 'wordlift' ),
58
-		),
59
-	),
10
+    array(
11
+        'id'      => 'TOO_COMPLICATED',
12
+        'text'    => esc_html__( 'It was too complicated and unclear to me', 'wordlift' ),
13
+        'message' => array(
14
+            'text' => sprintf(
15
+                esc_html__( 'Need help? We are ready to answer your questions. %s', 'wordlift' ),
16
+                $too_complicate_reason_label
17
+            ),
18
+        ),
19
+    ),
20
+    array(
21
+        'id'      => 'NOT_ENOUGH_FEATURES',
22
+        'text'    => esc_html__( 'It misses some important feature to me', 'wordlift' ),
23
+        'message' => array(
24
+            'field' => 'text',
25
+            'text'  => esc_html__( 'Tell us what this feature is.', 'wordlift' ),
26
+        ),
27
+    ),
28
+    array(
29
+        'id'      => 'COSTS_TOO_MUCH',
30
+        'text'    => esc_html__( 'It costs too much', 'wordlift' ),
31
+        'message' => array(
32
+            'field' => 'text',
33
+            'text'  => esc_html__( 'How much you would like to pay?', 'wordlift' ),
34
+        ),
35
+    ),
36
+    array(
37
+        'id'      => 'FOUND_ANOTHER_TOOL',
38
+        'text'    => esc_html__( 'I found another tool that I like better', 'wordlift' ),
39
+        'message' => array(
40
+            'field' => 'text',
41
+            'text'  => esc_html__( 'Please tell us some more details.', 'wordlift' ),
42
+        ),
43
+    ),
44
+    array(
45
+        'id'   => 'I_DONT_USE_IT',
46
+        'text' => esc_html__( 'I\'m not using it right now', 'wordlift' ),
47
+    ),
48
+    array(
49
+        'id'   => 'SOMETHING_DIDNT_WORK',
50
+        'text' => esc_html__( 'Something didn\'t work right', 'wordlift' ),
51
+    ),
52
+    array(
53
+        'id'      => 'ANOTHER_REASON',
54
+        'text'    => esc_html__( 'Another reason', 'wordlift' ),
55
+        'message' => array(
56
+            'field' => 'textarea',
57
+            'text'  => esc_html__( 'Please tell us the reason so we can improve it.', 'wordlift' ),
58
+        ),
59
+    ),
60 60
 );
61 61
 ?>
62 62
 <div class="wl-modal-deactivation-feedback" style="display: none">
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
 							<?php if ( ! empty( $reason['message'] ) ) : ?>
92 92
 								<div class="additional-info <?php echo ( ! empty( $reason['message']['field'] ) ) ? 'has-field' : ''; ?>">
93 93
 									<?php
94
-									if ( ! empty( $reason['message']['field'] ) ) {
95
-										if ( $reason['message']['field'] === 'text' ) {
96
-											echo '<input type="text" name="wl-details" class="wl-details"/>';
97
-										} else {
98
-											echo '<textarea name="wl-details" class="wl-details"></textarea>';
99
-										}
100
-									}
101
-									echo wpautop( $reason['message']['text'] )
102
-									?>
94
+                                    if ( ! empty( $reason['message']['field'] ) ) {
95
+                                        if ( $reason['message']['field'] === 'text' ) {
96
+                                            echo '<input type="text" name="wl-details" class="wl-details"/>';
97
+                                        } else {
98
+                                            echo '<textarea name="wl-details" class="wl-details"></textarea>';
99
+                                        }
100
+                                    }
101
+                                    echo wpautop( $reason['message']['text'] )
102
+                                    ?>
103 103
 								</div>
104 104
 							<?php endif ?>
105 105
 						</li>
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 			<div class="notes">
111 111
 				<p>
112 112
 					<?php
113
-					printf(
114
-						__( 'Important notice: Uninstalling the plugin will delete your vocabulary.<br>Maybe you would like to <a href="%s" target="_blank">download your data</a> first.', 'wordlift' ),
115
-						add_query_arg( array( 'page' => 'wl_download_your_data' ), admin_url( 'admin.php' ) )
116
-					);
117
-					?>
113
+                    printf(
114
+                        __( 'Important notice: Uninstalling the plugin will delete your vocabulary.<br>Maybe you would like to <a href="%s" target="_blank">download your data</a> first.', 'wordlift' ),
115
+                        add_query_arg( array( 'page' => 'wl_download_your_data' ), admin_url( 'admin.php' ) )
116
+                    );
117
+                    ?>
118 118
 				</p>
119 119
 			</div>
120 120
 
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -2,59 +2,59 @@  discard block
 block discarded – undo
2 2
 $too_complicate_reason_label = sprintf(
3 3
 	'<a target="_blank" href="%s">%s</a>',
4 4
 	/* translators: the link https://wordlift.io/contact-us/ should be changed to language version of the page */
5
-	esc_attr__( 'https://wordlift.io/contact-us/', 'wordlift' ),
6
-	esc_html__( 'Contact Us', 'wordlift' )
5
+	esc_attr__('https://wordlift.io/contact-us/', 'wordlift'),
6
+	esc_html__('Contact Us', 'wordlift')
7 7
 );
8 8
 
9 9
 $reasons = array(
10 10
 	array(
11 11
 		'id'      => 'TOO_COMPLICATED',
12
-		'text'    => esc_html__( 'It was too complicated and unclear to me', 'wordlift' ),
12
+		'text'    => esc_html__('It was too complicated and unclear to me', 'wordlift'),
13 13
 		'message' => array(
14 14
 			'text' => sprintf(
15
-				esc_html__( 'Need help? We are ready to answer your questions. %s', 'wordlift' ),
15
+				esc_html__('Need help? We are ready to answer your questions. %s', 'wordlift'),
16 16
 				$too_complicate_reason_label
17 17
 			),
18 18
 		),
19 19
 	),
20 20
 	array(
21 21
 		'id'      => 'NOT_ENOUGH_FEATURES',
22
-		'text'    => esc_html__( 'It misses some important feature to me', 'wordlift' ),
22
+		'text'    => esc_html__('It misses some important feature to me', 'wordlift'),
23 23
 		'message' => array(
24 24
 			'field' => 'text',
25
-			'text'  => esc_html__( 'Tell us what this feature is.', 'wordlift' ),
25
+			'text'  => esc_html__('Tell us what this feature is.', 'wordlift'),
26 26
 		),
27 27
 	),
28 28
 	array(
29 29
 		'id'      => 'COSTS_TOO_MUCH',
30
-		'text'    => esc_html__( 'It costs too much', 'wordlift' ),
30
+		'text'    => esc_html__('It costs too much', 'wordlift'),
31 31
 		'message' => array(
32 32
 			'field' => 'text',
33
-			'text'  => esc_html__( 'How much you would like to pay?', 'wordlift' ),
33
+			'text'  => esc_html__('How much you would like to pay?', 'wordlift'),
34 34
 		),
35 35
 	),
36 36
 	array(
37 37
 		'id'      => 'FOUND_ANOTHER_TOOL',
38
-		'text'    => esc_html__( 'I found another tool that I like better', 'wordlift' ),
38
+		'text'    => esc_html__('I found another tool that I like better', 'wordlift'),
39 39
 		'message' => array(
40 40
 			'field' => 'text',
41
-			'text'  => esc_html__( 'Please tell us some more details.', 'wordlift' ),
41
+			'text'  => esc_html__('Please tell us some more details.', 'wordlift'),
42 42
 		),
43 43
 	),
44 44
 	array(
45 45
 		'id'   => 'I_DONT_USE_IT',
46
-		'text' => esc_html__( 'I\'m not using it right now', 'wordlift' ),
46
+		'text' => esc_html__('I\'m not using it right now', 'wordlift'),
47 47
 	),
48 48
 	array(
49 49
 		'id'   => 'SOMETHING_DIDNT_WORK',
50
-		'text' => esc_html__( 'Something didn\'t work right', 'wordlift' ),
50
+		'text' => esc_html__('Something didn\'t work right', 'wordlift'),
51 51
 	),
52 52
 	array(
53 53
 		'id'      => 'ANOTHER_REASON',
54
-		'text'    => esc_html__( 'Another reason', 'wordlift' ),
54
+		'text'    => esc_html__('Another reason', 'wordlift'),
55 55
 		'message' => array(
56 56
 			'field' => 'textarea',
57
-			'text'  => esc_html__( 'Please tell us the reason so we can improve it.', 'wordlift' ),
57
+			'text'  => esc_html__('Please tell us the reason so we can improve it.', 'wordlift'),
58 58
 		),
59 59
 	),
60 60
 );
@@ -63,42 +63,42 @@  discard block
 block discarded – undo
63 63
 	<div class="wl-modal">
64 64
 		<div class="wl-modal-body">
65 65
 			<h2>
66
-				<?php _e( 'We\'re sorry to see you go!', 'wordlift' ); ?>
66
+				<?php _e('We\'re sorry to see you go!', 'wordlift'); ?>
67 67
 			</h2>
68 68
 
69 69
 			<div class="wl-modal-panel active">
70 70
 				<h4>
71
-					<?php _e( 'If you have a moment, please let us know why you are deactivating', 'wordlift' ); ?>:
71
+					<?php _e('If you have a moment, please let us know why you are deactivating', 'wordlift'); ?>:
72 72
 				</h4>
73 73
 
74 74
 				<ul>
75
-					<?php foreach ( $reasons as $reason ) : ?>
76
-						<li class="wl-reason-item <?php echo ( $reason['id'] == 'I_DONT_USE_IT' ) ? 'selected' : ''; ?>">
75
+					<?php foreach ($reasons as $reason) : ?>
76
+						<li class="wl-reason-item <?php echo ($reason['id'] == 'I_DONT_USE_IT') ? 'selected' : ''; ?>">
77 77
 							<label>
78 78
 								<input
79 79
 									type="radio"
80 80
 									name="wl-code"
81 81
 									class="wl-code"
82
-									<?php checked( 'I_DONT_USE_IT', $reason['id'], true ); ?>
83
-									value="<?php echo esc_attr( $reason['id'] ); ?>"
82
+									<?php checked('I_DONT_USE_IT', $reason['id'], true); ?>
83
+									value="<?php echo esc_attr($reason['id']); ?>"
84 84
 								/>
85 85
 
86 86
 								<span class="description">
87
-									<?php echo esc_html( $reason['text'] ); ?>
87
+									<?php echo esc_html($reason['text']); ?>
88 88
 								</span>
89 89
 							</label>
90 90
 
91
-							<?php if ( ! empty( $reason['message'] ) ) : ?>
92
-								<div class="additional-info <?php echo ( ! empty( $reason['message']['field'] ) ) ? 'has-field' : ''; ?>">
91
+							<?php if ( ! empty($reason['message'])) : ?>
92
+								<div class="additional-info <?php echo ( ! empty($reason['message']['field'])) ? 'has-field' : ''; ?>">
93 93
 									<?php
94
-									if ( ! empty( $reason['message']['field'] ) ) {
95
-										if ( $reason['message']['field'] === 'text' ) {
94
+									if ( ! empty($reason['message']['field'])) {
95
+										if ($reason['message']['field'] === 'text') {
96 96
 											echo '<input type="text" name="wl-details" class="wl-details"/>';
97 97
 										} else {
98 98
 											echo '<textarea name="wl-details" class="wl-details"></textarea>';
99 99
 										}
100 100
 									}
101
-									echo wpautop( $reason['message']['text'] )
101
+									echo wpautop($reason['message']['text'])
102 102
 									?>
103 103
 								</div>
104 104
 							<?php endif ?>
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 				<p>
112 112
 					<?php
113 113
 					printf(
114
-						__( 'Important notice: Uninstalling the plugin will delete your vocabulary.<br>Maybe you would like to <a href="%s" target="_blank">download your data</a> first.', 'wordlift' ),
115
-						add_query_arg( array( 'page' => 'wl_download_your_data' ), admin_url( 'admin.php' ) )
114
+						__('Important notice: Uninstalling the plugin will delete your vocabulary.<br>Maybe you would like to <a href="%s" target="_blank">download your data</a> first.', 'wordlift'),
115
+						add_query_arg(array('page' => 'wl_download_your_data'), admin_url('admin.php'))
116 116
 					);
117 117
 					?>
118 118
 				</p>
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
 
124 124
 		<div class="wl-modal-footer">
125 125
 			<a href="#" class="button button-secondary wl-modal-button-close">
126
-				<?php esc_html_e( 'Cancel', 'wordlift' ); ?>
126
+				<?php esc_html_e('Cancel', 'wordlift'); ?>
127 127
 			</a>
128 128
 
129 129
 			<a href="#" class="button button-primary wl-modal-button-deactivate">
130
-				<?php esc_html_e( 'Deactivate', 'wordlift' ); ?>
130
+				<?php esc_html_e('Deactivate', 'wordlift'); ?>
131 131
 			</a>
132 132
 			<div class="clear"></div>
133 133
 		</div>
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 			type="hidden"
137 137
 			name="wl_deactivation_feedback_nonce"
138 138
 			class="wl_deactivation_feedback_nonce"
139
-			value="<?php echo esc_attr( wp_create_nonce( 'wl_deactivation_feedback_nonce' ) ); ?>"
139
+			value="<?php echo esc_attr(wp_create_nonce('wl_deactivation_feedback_nonce')); ?>"
140 140
 		>
141 141
 	</div>
142 142
 </div>
Please login to merge, or discard this patch.
src/includes/mapping/class-wordlift-mapping-service.php 2 patches
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -14,205 +14,205 @@
 block discarded – undo
14 14
  */
15 15
 class Wordlift_Mapping_Service {
16 16
 
17
-	/**
18
-	 * The mapping's options.
19
-	 *
20
-	 * @since 3.20.0
21
-	 * @access private
22
-	 * @var array $options The mapping's options.
23
-	 */
24
-	private $options;
25
-
26
-	/**
27
-	 * The {@link Wordlift_Entity_Type_Service} instance.
28
-	 *
29
-	 * @since 3.20.0
30
-	 * @access private
31
-	 * @var \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance.
32
-	 */
33
-	private $entity_type_service;
34
-
35
-	/**
36
-	 * The singleton instance.
37
-	 *
38
-	 * @since 3.20.0
39
-	 * @access private
40
-	 * @var \Wordlift_Mapping_Service $instance The singleton instance.
41
-	 */
42
-	private static $instance;
43
-
44
-	/**
45
-	 * Create a {@link Wordlift_Mapping_Service} instance.
46
-	 *
47
-	 * @since 3.20.0
48
-	 *
49
-	 * @param \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance.
50
-	 */
51
-	public function __construct( $entity_type_service ) {
52
-
53
-		// Set the entity type service instance.
54
-		$this->entity_type_service = $entity_type_service;
55
-
56
-		// Load the options.
57
-		$this->options = get_option( 'wl_mappings', array() );
58
-
59
-		// Hook to `wl_valid_entity_post_types` and to `wl_default_entity_types_for_post_type`.
60
-		add_filter( 'wl_valid_entity_post_types', array( $this, 'valid_entity_post_types', ), 9 );
61
-		add_filter( 'wl_default_entity_types_for_post_type', array(
62
-			$this,
63
-			'default_entity_types_for_post_type',
64
-		), 9, 2 );
65
-
66
-		// Set the singleton instance.
67
-		self::$instance = $this;
68
-
69
-	}
70
-
71
-	/**
72
-	 * Get the singleton instance.
73
-	 *
74
-	 * @since 3.20.0
75
-	 *
76
-	 * @return \Wordlift_Mapping_Service The singleton instance.
77
-	 */
78
-	public static function get_instance() {
79
-
80
-		return self::$instance;
81
-	}
82
-
83
-	/**
84
-	 * Save the options.
85
-	 *
86
-	 * @since 3.20.0
87
-	 */
88
-	private function save_options() {
89
-
90
-		update_option( 'wl_mappings', $this->options, true );
91
-
92
-	}
93
-
94
-	/**
95
-	 * Set the default entity types for a post type.
96
-	 *
97
-	 * @since 3.20.0
98
-	 *
99
-	 * @param string $post_type Post type.
100
-	 * @param array  $entity_types An array of entity types slugs.
101
-	 */
102
-	public function set_entity_types_for_post_type( $post_type, $entity_types ) {
103
-
104
-		$this->options[ $post_type ] = $entity_types;
105
-		$this->save_options();
106
-
107
-	}
108
-
109
-	/**
110
-	 * Hook to `wl_valid_entity_post_types` to declare schema.org support for the configured post types.
111
-	 *
112
-	 * @since 3.20.0
113
-	 *
114
-	 * @param array $post_types The default post types.
115
-	 *
116
-	 * @return array The supported post types.
117
-	 */
118
-	public function valid_entity_post_types( $post_types ) {
119
-
120
-		return array_merge( $post_types, array_keys( $this->options ) );
121
-	}
122
-
123
-	/**
124
-	 * Hook to `wl_default_entity_types_for_post_type` to declare the entity types for a post type.
125
-	 *
126
-	 * @since 3.20.0
127
-	 *
128
-	 * @param array  $default The default entity types.
129
-	 * @param string $post_type The post type.
130
-	 *
131
-	 * @return array The default entity types.
132
-	 */
133
-	public function default_entity_types_for_post_type( $default, $post_type ) {
134
-
135
-		return isset( $this->options[ $post_type ] ) ? $this->options[ $post_type ] : $default;
136
-	}
137
-
138
-	/**
139
-	 * Update the post type with the entity types, starting at the specified offset.
140
-	 *
141
-	 * @since 3.20.0
142
-	 *
143
-	 * @param string $post_type The post type.
144
-	 * @param array  $entity_types The entity types.
145
-	 * @param int    $offset The offset (0 by default).
146
-	 *
147
-	 * @return array {
148
-	 * The result array.
149
-	 *
150
-	 * @type int     $current The current offset.
151
-	 * @type int     $next The next offset.
152
-	 * @type int     $count The total element count.
153
-	 * }
154
-	 */
155
-	public function update( $post_type, $entity_types, $offset = 0 ) {
156
-
157
-		$entity_type_service = $this->entity_type_service;
158
-		$tax_query           = $this->get_tax_query( $entity_types );
159
-
160
-		return Wordlift_Batch_Action::process( $post_type, $offset, $tax_query, function ( $post_id ) use ( $entity_type_service, $entity_types ) {
161
-			foreach ( $entity_types as $entity_type ) {
162
-				$entity_type_service->set( $post_id, $entity_type, false );
163
-			}
164
-		} );
165
-	}
166
-
167
-	/**
168
-	 * Count the number of posts that need to be assigned with the entity types.
169
-	 *
170
-	 * @since 3.20.0
171
-	 *
172
-	 * @param string $post_type The post type.
173
-	 * @param array  $entity_types An array of entity types.
174
-	 *
175
-	 * @return int The number of posts to be assigned with entity types.
176
-	 */
177
-	public function count( $post_type, $entity_types ) {
178
-
179
-		$tax_query = $this->get_tax_query( $entity_types );
180
-
181
-		return Wordlift_Batch_Action::count( $post_type, $tax_query );
182
-	}
183
-
184
-	/**
185
-	 * Get the taxonomy query for the specified entity types.
186
-	 *
187
-	 * @since 3.20.0
188
-	 *
189
-	 * @param array $entity_types The entity types.
190
-	 *
191
-	 * @return array The tax query.
192
-	 */
193
-	private function get_tax_query( $entity_types ) {
194
-
195
-		$entity_type_service = $this->entity_type_service;
196
-		$entity_types_terms  = array_filter( array_map( function ( $item ) use ( $entity_type_service ) {
197
-			return $entity_type_service->get_term_by_uri( $item );
198
-		}, $entity_types ) );
199
-
200
-		$entity_types_terms_ids = array_map( function ( $term ) {
201
-			return $term->term_id;
202
-		}, $entity_types_terms );
203
-
204
-		$tax_query = array(
205
-			'tax_query' => array(
206
-				array(
207
-					'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
208
-					'field'    => 'term_id',
209
-					'terms'    => $entity_types_terms_ids,
210
-					'operator' => 'NOT IN',
211
-				),
212
-			),
213
-		);
214
-
215
-		return $tax_query;
216
-	}
17
+    /**
18
+     * The mapping's options.
19
+     *
20
+     * @since 3.20.0
21
+     * @access private
22
+     * @var array $options The mapping's options.
23
+     */
24
+    private $options;
25
+
26
+    /**
27
+     * The {@link Wordlift_Entity_Type_Service} instance.
28
+     *
29
+     * @since 3.20.0
30
+     * @access private
31
+     * @var \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance.
32
+     */
33
+    private $entity_type_service;
34
+
35
+    /**
36
+     * The singleton instance.
37
+     *
38
+     * @since 3.20.0
39
+     * @access private
40
+     * @var \Wordlift_Mapping_Service $instance The singleton instance.
41
+     */
42
+    private static $instance;
43
+
44
+    /**
45
+     * Create a {@link Wordlift_Mapping_Service} instance.
46
+     *
47
+     * @since 3.20.0
48
+     *
49
+     * @param \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance.
50
+     */
51
+    public function __construct( $entity_type_service ) {
52
+
53
+        // Set the entity type service instance.
54
+        $this->entity_type_service = $entity_type_service;
55
+
56
+        // Load the options.
57
+        $this->options = get_option( 'wl_mappings', array() );
58
+
59
+        // Hook to `wl_valid_entity_post_types` and to `wl_default_entity_types_for_post_type`.
60
+        add_filter( 'wl_valid_entity_post_types', array( $this, 'valid_entity_post_types', ), 9 );
61
+        add_filter( 'wl_default_entity_types_for_post_type', array(
62
+            $this,
63
+            'default_entity_types_for_post_type',
64
+        ), 9, 2 );
65
+
66
+        // Set the singleton instance.
67
+        self::$instance = $this;
68
+
69
+    }
70
+
71
+    /**
72
+     * Get the singleton instance.
73
+     *
74
+     * @since 3.20.0
75
+     *
76
+     * @return \Wordlift_Mapping_Service The singleton instance.
77
+     */
78
+    public static function get_instance() {
79
+
80
+        return self::$instance;
81
+    }
82
+
83
+    /**
84
+     * Save the options.
85
+     *
86
+     * @since 3.20.0
87
+     */
88
+    private function save_options() {
89
+
90
+        update_option( 'wl_mappings', $this->options, true );
91
+
92
+    }
93
+
94
+    /**
95
+     * Set the default entity types for a post type.
96
+     *
97
+     * @since 3.20.0
98
+     *
99
+     * @param string $post_type Post type.
100
+     * @param array  $entity_types An array of entity types slugs.
101
+     */
102
+    public function set_entity_types_for_post_type( $post_type, $entity_types ) {
103
+
104
+        $this->options[ $post_type ] = $entity_types;
105
+        $this->save_options();
106
+
107
+    }
108
+
109
+    /**
110
+     * Hook to `wl_valid_entity_post_types` to declare schema.org support for the configured post types.
111
+     *
112
+     * @since 3.20.0
113
+     *
114
+     * @param array $post_types The default post types.
115
+     *
116
+     * @return array The supported post types.
117
+     */
118
+    public function valid_entity_post_types( $post_types ) {
119
+
120
+        return array_merge( $post_types, array_keys( $this->options ) );
121
+    }
122
+
123
+    /**
124
+     * Hook to `wl_default_entity_types_for_post_type` to declare the entity types for a post type.
125
+     *
126
+     * @since 3.20.0
127
+     *
128
+     * @param array  $default The default entity types.
129
+     * @param string $post_type The post type.
130
+     *
131
+     * @return array The default entity types.
132
+     */
133
+    public function default_entity_types_for_post_type( $default, $post_type ) {
134
+
135
+        return isset( $this->options[ $post_type ] ) ? $this->options[ $post_type ] : $default;
136
+    }
137
+
138
+    /**
139
+     * Update the post type with the entity types, starting at the specified offset.
140
+     *
141
+     * @since 3.20.0
142
+     *
143
+     * @param string $post_type The post type.
144
+     * @param array  $entity_types The entity types.
145
+     * @param int    $offset The offset (0 by default).
146
+     *
147
+     * @return array {
148
+     * The result array.
149
+     *
150
+     * @type int     $current The current offset.
151
+     * @type int     $next The next offset.
152
+     * @type int     $count The total element count.
153
+     * }
154
+     */
155
+    public function update( $post_type, $entity_types, $offset = 0 ) {
156
+
157
+        $entity_type_service = $this->entity_type_service;
158
+        $tax_query           = $this->get_tax_query( $entity_types );
159
+
160
+        return Wordlift_Batch_Action::process( $post_type, $offset, $tax_query, function ( $post_id ) use ( $entity_type_service, $entity_types ) {
161
+            foreach ( $entity_types as $entity_type ) {
162
+                $entity_type_service->set( $post_id, $entity_type, false );
163
+            }
164
+        } );
165
+    }
166
+
167
+    /**
168
+     * Count the number of posts that need to be assigned with the entity types.
169
+     *
170
+     * @since 3.20.0
171
+     *
172
+     * @param string $post_type The post type.
173
+     * @param array  $entity_types An array of entity types.
174
+     *
175
+     * @return int The number of posts to be assigned with entity types.
176
+     */
177
+    public function count( $post_type, $entity_types ) {
178
+
179
+        $tax_query = $this->get_tax_query( $entity_types );
180
+
181
+        return Wordlift_Batch_Action::count( $post_type, $tax_query );
182
+    }
183
+
184
+    /**
185
+     * Get the taxonomy query for the specified entity types.
186
+     *
187
+     * @since 3.20.0
188
+     *
189
+     * @param array $entity_types The entity types.
190
+     *
191
+     * @return array The tax query.
192
+     */
193
+    private function get_tax_query( $entity_types ) {
194
+
195
+        $entity_type_service = $this->entity_type_service;
196
+        $entity_types_terms  = array_filter( array_map( function ( $item ) use ( $entity_type_service ) {
197
+            return $entity_type_service->get_term_by_uri( $item );
198
+        }, $entity_types ) );
199
+
200
+        $entity_types_terms_ids = array_map( function ( $term ) {
201
+            return $term->term_id;
202
+        }, $entity_types_terms );
203
+
204
+        $tax_query = array(
205
+            'tax_query' => array(
206
+                array(
207
+                    'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
208
+                    'field'    => 'term_id',
209
+                    'terms'    => $entity_types_terms_ids,
210
+                    'operator' => 'NOT IN',
211
+                ),
212
+            ),
213
+        );
214
+
215
+        return $tax_query;
216
+    }
217 217
 
218 218
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -48,20 +48,20 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @param \Wordlift_Entity_Type_Service $entity_type_service The {@link Wordlift_Entity_Type_Service} instance.
50 50
 	 */
51
-	public function __construct( $entity_type_service ) {
51
+	public function __construct($entity_type_service) {
52 52
 
53 53
 		// Set the entity type service instance.
54 54
 		$this->entity_type_service = $entity_type_service;
55 55
 
56 56
 		// Load the options.
57
-		$this->options = get_option( 'wl_mappings', array() );
57
+		$this->options = get_option('wl_mappings', array());
58 58
 
59 59
 		// Hook to `wl_valid_entity_post_types` and to `wl_default_entity_types_for_post_type`.
60
-		add_filter( 'wl_valid_entity_post_types', array( $this, 'valid_entity_post_types', ), 9 );
61
-		add_filter( 'wl_default_entity_types_for_post_type', array(
60
+		add_filter('wl_valid_entity_post_types', array($this, 'valid_entity_post_types',), 9);
61
+		add_filter('wl_default_entity_types_for_post_type', array(
62 62
 			$this,
63 63
 			'default_entity_types_for_post_type',
64
-		), 9, 2 );
64
+		), 9, 2);
65 65
 
66 66
 		// Set the singleton instance.
67 67
 		self::$instance = $this;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	private function save_options() {
89 89
 
90
-		update_option( 'wl_mappings', $this->options, true );
90
+		update_option('wl_mappings', $this->options, true);
91 91
 
92 92
 	}
93 93
 
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	 * @param string $post_type Post type.
100 100
 	 * @param array  $entity_types An array of entity types slugs.
101 101
 	 */
102
-	public function set_entity_types_for_post_type( $post_type, $entity_types ) {
102
+	public function set_entity_types_for_post_type($post_type, $entity_types) {
103 103
 
104
-		$this->options[ $post_type ] = $entity_types;
104
+		$this->options[$post_type] = $entity_types;
105 105
 		$this->save_options();
106 106
 
107 107
 	}
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @return array The supported post types.
117 117
 	 */
118
-	public function valid_entity_post_types( $post_types ) {
118
+	public function valid_entity_post_types($post_types) {
119 119
 
120
-		return array_merge( $post_types, array_keys( $this->options ) );
120
+		return array_merge($post_types, array_keys($this->options));
121 121
 	}
122 122
 
123 123
 	/**
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @return array The default entity types.
132 132
 	 */
133
-	public function default_entity_types_for_post_type( $default, $post_type ) {
133
+	public function default_entity_types_for_post_type($default, $post_type) {
134 134
 
135
-		return isset( $this->options[ $post_type ] ) ? $this->options[ $post_type ] : $default;
135
+		return isset($this->options[$post_type]) ? $this->options[$post_type] : $default;
136 136
 	}
137 137
 
138 138
 	/**
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
 	 * @type int     $count The total element count.
153 153
 	 * }
154 154
 	 */
155
-	public function update( $post_type, $entity_types, $offset = 0 ) {
155
+	public function update($post_type, $entity_types, $offset = 0) {
156 156
 
157 157
 		$entity_type_service = $this->entity_type_service;
158
-		$tax_query           = $this->get_tax_query( $entity_types );
158
+		$tax_query           = $this->get_tax_query($entity_types);
159 159
 
160
-		return Wordlift_Batch_Action::process( $post_type, $offset, $tax_query, function ( $post_id ) use ( $entity_type_service, $entity_types ) {
161
-			foreach ( $entity_types as $entity_type ) {
162
-				$entity_type_service->set( $post_id, $entity_type, false );
160
+		return Wordlift_Batch_Action::process($post_type, $offset, $tax_query, function($post_id) use ($entity_type_service, $entity_types) {
161
+			foreach ($entity_types as $entity_type) {
162
+				$entity_type_service->set($post_id, $entity_type, false);
163 163
 			}
164 164
 		} );
165 165
 	}
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 	 *
175 175
 	 * @return int The number of posts to be assigned with entity types.
176 176
 	 */
177
-	public function count( $post_type, $entity_types ) {
177
+	public function count($post_type, $entity_types) {
178 178
 
179
-		$tax_query = $this->get_tax_query( $entity_types );
179
+		$tax_query = $this->get_tax_query($entity_types);
180 180
 
181
-		return Wordlift_Batch_Action::count( $post_type, $tax_query );
181
+		return Wordlift_Batch_Action::count($post_type, $tax_query);
182 182
 	}
183 183
 
184 184
 	/**
@@ -190,16 +190,16 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @return array The tax query.
192 192
 	 */
193
-	private function get_tax_query( $entity_types ) {
193
+	private function get_tax_query($entity_types) {
194 194
 
195 195
 		$entity_type_service = $this->entity_type_service;
196
-		$entity_types_terms  = array_filter( array_map( function ( $item ) use ( $entity_type_service ) {
197
-			return $entity_type_service->get_term_by_uri( $item );
198
-		}, $entity_types ) );
196
+		$entity_types_terms  = array_filter(array_map(function($item) use ($entity_type_service) {
197
+			return $entity_type_service->get_term_by_uri($item);
198
+		}, $entity_types));
199 199
 
200
-		$entity_types_terms_ids = array_map( function ( $term ) {
200
+		$entity_types_terms_ids = array_map(function($term) {
201 201
 			return $term->term_id;
202
-		}, $entity_types_terms );
202
+		}, $entity_types_terms);
203 203
 
204 204
 		$tax_query = array(
205 205
 			'tax_query' => array(
Please login to merge, or discard this patch.
src/admin/class-wordlift-entity-types-taxonomy-walker-5-3.php 2 patches
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @subpackage Wordlift/includes
11 11
  */
12 12
 if ( ! class_exists( 'Walker_Category_Checklist' ) ) {
13
-	require_once( ABSPATH . 'wp-admin/includes/template.php' );
13
+    require_once( ABSPATH . 'wp-admin/includes/template.php' );
14 14
 }
15 15
 
16 16
 /**
@@ -23,113 +23,113 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class Wordlift_Entity_Types_Taxonomy_Walker extends Walker_Category_Checklist {
25 25
 
26
-	/**
27
-	 * Entity taxonomy metabox must show exclusive options, no checkboxes.
28
-	 *
29
-	 * @since 3.1.0
30
-	 *
31
-	 * @param       $args     {
32
-	 *                        An array of arguments.
33
-	 *
34
-	 * @type string $taxonomy The taxonomy name.
35
-	 *              }
36
-	 *
37
-	 * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy.
38
-	 */
39
-	function terms_checklist_args( $args ) {
40
-
41
-		if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
42
-			return $args;
43
-		}
44
-
45
-		// We override the way WP prints the taxonomy metabox HTML.
46
-		$args['walker']        = $this;
47
-		$args['checked_ontop'] = false;
48
-
49
-		return $args;
50
-
51
-	}
52
-
53
-	/**
54
-	 * Change checkboxes to radios.
55
-	 *
56
-	 * $max_depth = -1 means flatly display every element.
57
-	 * $max_depth = 0 means display all levels.
58
-	 * $max_depth > 0 specifies the number of display levels.
59
-	 *
60
-	 * @since 3.1.0
61
-	 *
62
-	 * @param array $elements  An array of elements.
63
-	 * @param int   $max_depth The maximum hierarchical depth.
64
-	 *
65
-	 * @param array $args      Additional arguments.
66
-	 *
67
-	 * @return string The hierarchical item output.
68
-	 */
69
-	public function walk( $elements, $max_depth, ...$args ) {
70
-
71
-		// `max_depth` force to -1 to display a flat taxonomy.
72
-		//
73
-		// See https://github.com/insideout10/wordlift-plugin/issues/305
74
-		$output = parent::walk( $elements, - 1, ...$args );
75
-
76
-		$output = str_replace(
77
-			array( "type=\"checkbox\"", "type='checkbox'" ),
78
-			array( "type=\"radio\"", "type='radio'" ),
79
-			$output
80
-		);
81
-
82
-		return $output;
83
-	}
84
-
85
-	/**
86
-	 * Start the element output, output nothing in case of article term.
87
-	 *
88
-	 * @since 3.15.0
89
-	 *
90
-	 * @param string $output   Passed by reference. Used to append additional content.
91
-	 * @param object $category The current term object.
92
-	 * @param int    $depth    Depth of the term in reference to parents. Default 0.
93
-	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
94
-	 * @param int    $id       ID of the current term.
95
-	 */
96
-	public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
97
-		global $post;
98
-
99
-		if ( ! isset( $post ) ) {
100
-			return;
101
-		}
102
-
103
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
104
-		     || 'article' !== $category->slug
105
-		     || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
106
-			parent::start_el( $output, $category, $depth, $args, $id );
107
-		}
108
-	}
109
-
110
-	/**
111
-	 * End the element output, output nothing in case of article term.
112
-	 *
113
-	 * @since 3.15.0
114
-	 *
115
-	 * @param string $output   Passed by reference. Used to append additional content.
116
-	 * @param object $category The current term object.
117
-	 * @param int    $depth    Depth of the term in reference to parents. Default 0.
118
-	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
119
-	 */
120
-	public function end_el( &$output, $category, $depth = 0, $args = array() ) {
121
-		global $post;
122
-
123
-		if ( ! isset( $post ) ) {
124
-			return;
125
-		}
126
-
127
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
128
-		     || 'article' !== $category->slug
129
-		     || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
130
-			parent::end_el( $output, $category, $depth, $args );
131
-		}
132
-
133
-	}
26
+    /**
27
+     * Entity taxonomy metabox must show exclusive options, no checkboxes.
28
+     *
29
+     * @since 3.1.0
30
+     *
31
+     * @param       $args     {
32
+     *                        An array of arguments.
33
+     *
34
+     * @type string $taxonomy The taxonomy name.
35
+     *              }
36
+     *
37
+     * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy.
38
+     */
39
+    function terms_checklist_args( $args ) {
40
+
41
+        if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
42
+            return $args;
43
+        }
44
+
45
+        // We override the way WP prints the taxonomy metabox HTML.
46
+        $args['walker']        = $this;
47
+        $args['checked_ontop'] = false;
48
+
49
+        return $args;
50
+
51
+    }
52
+
53
+    /**
54
+     * Change checkboxes to radios.
55
+     *
56
+     * $max_depth = -1 means flatly display every element.
57
+     * $max_depth = 0 means display all levels.
58
+     * $max_depth > 0 specifies the number of display levels.
59
+     *
60
+     * @since 3.1.0
61
+     *
62
+     * @param array $elements  An array of elements.
63
+     * @param int   $max_depth The maximum hierarchical depth.
64
+     *
65
+     * @param array $args      Additional arguments.
66
+     *
67
+     * @return string The hierarchical item output.
68
+     */
69
+    public function walk( $elements, $max_depth, ...$args ) {
70
+
71
+        // `max_depth` force to -1 to display a flat taxonomy.
72
+        //
73
+        // See https://github.com/insideout10/wordlift-plugin/issues/305
74
+        $output = parent::walk( $elements, - 1, ...$args );
75
+
76
+        $output = str_replace(
77
+            array( "type=\"checkbox\"", "type='checkbox'" ),
78
+            array( "type=\"radio\"", "type='radio'" ),
79
+            $output
80
+        );
81
+
82
+        return $output;
83
+    }
84
+
85
+    /**
86
+     * Start the element output, output nothing in case of article term.
87
+     *
88
+     * @since 3.15.0
89
+     *
90
+     * @param string $output   Passed by reference. Used to append additional content.
91
+     * @param object $category The current term object.
92
+     * @param int    $depth    Depth of the term in reference to parents. Default 0.
93
+     * @param array  $args     An array of arguments. @see wp_terms_checklist()
94
+     * @param int    $id       ID of the current term.
95
+     */
96
+    public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
97
+        global $post;
98
+
99
+        if ( ! isset( $post ) ) {
100
+            return;
101
+        }
102
+
103
+        if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
104
+             || 'article' !== $category->slug
105
+             || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
106
+            parent::start_el( $output, $category, $depth, $args, $id );
107
+        }
108
+    }
109
+
110
+    /**
111
+     * End the element output, output nothing in case of article term.
112
+     *
113
+     * @since 3.15.0
114
+     *
115
+     * @param string $output   Passed by reference. Used to append additional content.
116
+     * @param object $category The current term object.
117
+     * @param int    $depth    Depth of the term in reference to parents. Default 0.
118
+     * @param array  $args     An array of arguments. @see wp_terms_checklist()
119
+     */
120
+    public function end_el( &$output, $category, $depth = 0, $args = array() ) {
121
+        global $post;
122
+
123
+        if ( ! isset( $post ) ) {
124
+            return;
125
+        }
126
+
127
+        if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
128
+             || 'article' !== $category->slug
129
+             || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
130
+            parent::end_el( $output, $category, $depth, $args );
131
+        }
132
+
133
+    }
134 134
 
135 135
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
  * @package    Wordlift
10 10
  * @subpackage Wordlift/includes
11 11
  */
12
-if ( ! class_exists( 'Walker_Category_Checklist' ) ) {
13
-	require_once( ABSPATH . 'wp-admin/includes/template.php' );
12
+if ( ! class_exists('Walker_Category_Checklist')) {
13
+	require_once(ABSPATH.'wp-admin/includes/template.php');
14 14
 }
15 15
 
16 16
 /**
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy.
38 38
 	 */
39
-	function terms_checklist_args( $args ) {
39
+	function terms_checklist_args($args) {
40 40
 
41
-		if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
41
+		if ( ! isset($args['taxonomy']) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) {
42 42
 			return $args;
43 43
 		}
44 44
 
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @return string The hierarchical item output.
68 68
 	 */
69
-	public function walk( $elements, $max_depth, ...$args ) {
69
+	public function walk($elements, $max_depth, ...$args) {
70 70
 
71 71
 		// `max_depth` force to -1 to display a flat taxonomy.
72 72
 		//
73 73
 		// See https://github.com/insideout10/wordlift-plugin/issues/305
74
-		$output = parent::walk( $elements, - 1, ...$args );
74
+		$output = parent::walk($elements, - 1, ...$args);
75 75
 
76 76
 		$output = str_replace(
77
-			array( "type=\"checkbox\"", "type='checkbox'" ),
78
-			array( "type=\"radio\"", "type='radio'" ),
77
+			array("type=\"checkbox\"", "type='checkbox'"),
78
+			array("type=\"radio\"", "type='radio'"),
79 79
 			$output
80 80
 		);
81 81
 
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
94 94
 	 * @param int    $id       ID of the current term.
95 95
 	 */
96
-	public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
96
+	public function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) {
97 97
 		global $post;
98 98
 
99
-		if ( ! isset( $post ) ) {
99
+		if ( ! isset($post)) {
100 100
 			return;
101 101
 		}
102 102
 
103
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
103
+		if (Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
104 104
 		     || 'article' !== $category->slug
105
-		     || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
106
-			parent::start_el( $output, $category, $depth, $args, $id );
105
+		     || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) {
106
+			parent::start_el($output, $category, $depth, $args, $id);
107 107
 		}
108 108
 	}
109 109
 
@@ -117,17 +117,17 @@  discard block
 block discarded – undo
117 117
 	 * @param int    $depth    Depth of the term in reference to parents. Default 0.
118 118
 	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
119 119
 	 */
120
-	public function end_el( &$output, $category, $depth = 0, $args = array() ) {
120
+	public function end_el(&$output, $category, $depth = 0, $args = array()) {
121 121
 		global $post;
122 122
 
123
-		if ( ! isset( $post ) ) {
123
+		if ( ! isset($post)) {
124 124
 			return;
125 125
 		}
126 126
 
127
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
127
+		if (Wordlift_Entity_Service::TYPE_NAME !== $post->post_type
128 128
 		     || 'article' !== $category->slug
129
-		     || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) {
130
-			parent::end_el( $output, $category, $depth, $args );
129
+		     || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) {
130
+			parent::end_el($output, $category, $depth, $args);
131 131
 		}
132 132
 
133 133
 	}
Please login to merge, or discard this patch.