Completed
Pull Request — develop (#1554)
by Naveen
48s
created
src/wordlift/tasks/class-task.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -15,43 +15,43 @@
 block discarded – undo
15 15
  */
16 16
 interface Task {
17 17
 
18
-	/**
19
-	 * Define the task ID.
20
-	 *
21
-	 * @return string The task id.
22
-	 * @since 1.0.0
23
-	 */
24
-	function get_id();
25
-
26
-	function get_label();
27
-
28
-	/**
29
-	 * List the items to process.
30
-	 *
31
-	 * @param int $limit
32
-	 * @param int $offset
33
-	 *
34
-	 * @return array An array of items.
35
-	 * @since 1.0.0
36
-	 */
37
-	function list_items( $limit = 10, $offset = 0 );
38
-
39
-	/**
40
-	 * Count the total number of items to process.
41
-	 *
42
-	 * @return int Total number of items to process.
43
-	 * @since 1.0.0
44
-	 */
45
-	function count_items();
46
-
47
-	/**
48
-	 * Process the provided item.
49
-	 *
50
-	 * @param mixed $item Process the provided item.
51
-	 *
52
-	 * @since 1.0.0
53
-	 *
54
-	 */
55
-	function process_item( $item );
18
+    /**
19
+     * Define the task ID.
20
+     *
21
+     * @return string The task id.
22
+     * @since 1.0.0
23
+     */
24
+    function get_id();
25
+
26
+    function get_label();
27
+
28
+    /**
29
+     * List the items to process.
30
+     *
31
+     * @param int $limit
32
+     * @param int $offset
33
+     *
34
+     * @return array An array of items.
35
+     * @since 1.0.0
36
+     */
37
+    function list_items( $limit = 10, $offset = 0 );
38
+
39
+    /**
40
+     * Count the total number of items to process.
41
+     *
42
+     * @return int Total number of items to process.
43
+     * @since 1.0.0
44
+     */
45
+    function count_items();
46
+
47
+    /**
48
+     * Process the provided item.
49
+     *
50
+     * @param mixed $item Process the provided item.
51
+     *
52
+     * @since 1.0.0
53
+     *
54
+     */
55
+    function process_item( $item );
56 56
 
57 57
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @return array An array of items.
35 35
 	 * @since 1.0.0
36 36
 	 */
37
-	function list_items( $limit = 10, $offset = 0 );
37
+	function list_items($limit = 10, $offset = 0);
38 38
 
39 39
 	/**
40 40
 	 * Count the total number of items to process.
@@ -52,6 +52,6 @@  discard block
 block discarded – undo
52 52
 	 * @since 1.0.0
53 53
 	 *
54 54
 	 */
55
-	function process_item( $item );
55
+	function process_item($item);
56 56
 
57 57
 }
Please login to merge, or discard this patch.
src/wordlift/wordpress/class-submenu-page-base.php 2 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -3,83 +3,83 @@
 block discarded – undo
3 3
 namespace Wordlift\Wordpress;
4 4
 
5 5
 abstract class Submenu_Page_Base implements Page {
6
-	/**
7
-	 * @var string
8
-	 */
9
-	private $menu_slug;
10
-	/**
11
-	 * @var string
12
-	 */
13
-	private $page_title;
14
-	/**
15
-	 * @var string
16
-	 */
17
-	private $capability;
18
-	/**
19
-	 * @var string|null
20
-	 */
21
-	private $parent_slug;
22
-	/**
23
-	 * @var string|null
24
-	 */
25
-	private $menu_title;
6
+    /**
7
+     * @var string
8
+     */
9
+    private $menu_slug;
10
+    /**
11
+     * @var string
12
+     */
13
+    private $page_title;
14
+    /**
15
+     * @var string
16
+     */
17
+    private $capability;
18
+    /**
19
+     * @var string|null
20
+     */
21
+    private $parent_slug;
22
+    /**
23
+     * @var string|null
24
+     */
25
+    private $menu_title;
26 26
 
27
-	/**
28
-	 * Abstract_Submenu_Page constructor.
29
-	 *
30
-	 * @param string $menu_slug
31
-	 * @param string $page_title
32
-	 * @param string $capability
33
-	 * @param string|null $parent_slug
34
-	 * @param string|null $menu_title
35
-	 */
36
-	public function __construct( $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null ) {
27
+    /**
28
+     * Abstract_Submenu_Page constructor.
29
+     *
30
+     * @param string $menu_slug
31
+     * @param string $page_title
32
+     * @param string $capability
33
+     * @param string|null $parent_slug
34
+     * @param string|null $menu_title
35
+     */
36
+    public function __construct( $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null ) {
37 37
 
38
-		add_action( 'admin_menu', array( $this, 'admin_menu', ) );
38
+        add_action( 'admin_menu', array( $this, 'admin_menu', ) );
39 39
 
40
-		$this->menu_slug   = $menu_slug;
41
-		$this->page_title  = $page_title;
42
-		$this->capability  = $capability;
43
-		$this->parent_slug = $parent_slug;
44
-		$this->menu_title  = isset( $menu_title ) ? $menu_title : $page_title;
45
-	}
40
+        $this->menu_slug   = $menu_slug;
41
+        $this->page_title  = $page_title;
42
+        $this->capability  = $capability;
43
+        $this->parent_slug = $parent_slug;
44
+        $this->menu_title  = isset( $menu_title ) ? $menu_title : $page_title;
45
+    }
46 46
 
47
-	public function get_menu_slug() {
47
+    public function get_menu_slug() {
48 48
 
49
-		return $this->menu_slug;
50
-	}
49
+        return $this->menu_slug;
50
+    }
51 51
 
52
-	/**
53
-	 * The `admin_menu` callback. Will call {@link add_submenu_page} to add the
54
-	 * page to the admin menu.
55
-	 *
56
-	 * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
57
-	 * @since 1.0.0
58
-	 *
59
-	 */
60
-	public function admin_menu() {
52
+    /**
53
+     * The `admin_menu` callback. Will call {@link add_submenu_page} to add the
54
+     * page to the admin menu.
55
+     *
56
+     * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
57
+     * @since 1.0.0
58
+     *
59
+     */
60
+    public function admin_menu() {
61 61
 
62
-		// Add the sub-menu page.
63
-		//
64
-		// See http://codex.wordpress.org/Function_Reference/add_submenu_page
65
-		$page = add_submenu_page(
66
-			$this->parent_slug,
67
-			$this->page_title,
68
-			$this->menu_title,
69
-			$this->capability,
70
-			$this->menu_slug,
71
-			array( $this, 'render' )
72
-		);
62
+        // Add the sub-menu page.
63
+        //
64
+        // See http://codex.wordpress.org/Function_Reference/add_submenu_page
65
+        $page = add_submenu_page(
66
+            $this->parent_slug,
67
+            $this->page_title,
68
+            $this->menu_title,
69
+            $this->capability,
70
+            $this->menu_slug,
71
+            array( $this, 'render' )
72
+        );
73 73
 
74
-		// Set a hook to enqueue scripts only when the settings page is displayed.
75
-		add_action( 'admin_print_scripts-' . $page, array( $this, 'enqueue_scripts', ) );
74
+        // Set a hook to enqueue scripts only when the settings page is displayed.
75
+        add_action( 'admin_print_scripts-' . $page, array( $this, 'enqueue_scripts', ) );
76 76
 
77
-		// Finally return the page hook_suffix.
78
-		return $page;
79
-	}
77
+        // Finally return the page hook_suffix.
78
+        return $page;
79
+    }
80 80
 
81
-	abstract function enqueue_scripts();
81
+    abstract function enqueue_scripts();
82 82
 
83
-	abstract function render();
83
+    abstract function render();
84 84
 
85 85
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 	 * @param string|null $parent_slug
34 34
 	 * @param string|null $menu_title
35 35
 	 */
36
-	public function __construct( $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null ) {
36
+	public function __construct($menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null) {
37 37
 
38
-		add_action( 'admin_menu', array( $this, 'admin_menu', ) );
38
+		add_action('admin_menu', array($this, 'admin_menu',));
39 39
 
40 40
 		$this->menu_slug   = $menu_slug;
41 41
 		$this->page_title  = $page_title;
42 42
 		$this->capability  = $capability;
43 43
 		$this->parent_slug = $parent_slug;
44
-		$this->menu_title  = isset( $menu_title ) ? $menu_title : $page_title;
44
+		$this->menu_title  = isset($menu_title) ? $menu_title : $page_title;
45 45
 	}
46 46
 
47 47
 	public function get_menu_slug() {
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 			$this->menu_title,
69 69
 			$this->capability,
70 70
 			$this->menu_slug,
71
-			array( $this, 'render' )
71
+			array($this, 'render')
72 72
 		);
73 73
 
74 74
 		// Set a hook to enqueue scripts only when the settings page is displayed.
75
-		add_action( 'admin_print_scripts-' . $page, array( $this, 'enqueue_scripts', ) );
75
+		add_action('admin_print_scripts-'.$page, array($this, 'enqueue_scripts',));
76 76
 
77 77
 		// Finally return the page hook_suffix.
78 78
 		return $page;
Please login to merge, or discard this patch.
src/wordlift/wordpress/class-page.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,6 +4,6 @@
 block discarded – undo
4 4
 
5 5
 interface Page {
6 6
 
7
-	public function get_menu_slug();
7
+    public function get_menu_slug();
8 8
 
9 9
 }
Please login to merge, or discard this patch.
src/wordlift/api/class-user-agent.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,28 +6,28 @@
 block discarded – undo
6 6
 
7 7
 class User_Agent {
8 8
 
9
-	public static function get_user_agent() {
9
+    public static function get_user_agent() {
10 10
 
11
-		// Get WL version.
12
-		$wl_version = Wordlift::get_instance()->get_version();
11
+        // Get WL version.
12
+        $wl_version = Wordlift::get_instance()->get_version();
13 13
 
14
-		// Get the WP version.
15
-		$wp_version = get_bloginfo( 'version' );
14
+        // Get the WP version.
15
+        $wp_version = get_bloginfo( 'version' );
16 16
 
17
-		// Get the home url.
18
-		$home_url = home_url( '/' );
17
+        // Get the home url.
18
+        $home_url = home_url( '/' );
19 19
 
20
-		// Get the locale flag.
21
-		$locale = apply_filters( 'core_version_check_locale', get_locale() );
20
+        // Get the locale flag.
21
+        $locale = apply_filters( 'core_version_check_locale', get_locale() );
22 22
 
23
-		// Get the multisite flag.
24
-		$multisite = is_multisite() ? 'yes' : 'no';
23
+        // Get the multisite flag.
24
+        $multisite = is_multisite() ? 'yes' : 'no';
25 25
 
26
-		// Get the PHP version.
27
-		$php_version = phpversion();
26
+        // Get the PHP version.
27
+        $php_version = phpversion();
28 28
 
29
-		/** @var string $wp_version The variable is defined in `version.php`. */
30
-		return "WordLift/$wl_version WordPress/$wp_version (multisite:$multisite, url:$home_url, locale:$locale) PHP/$php_version";
31
-	}
29
+        /** @var string $wp_version The variable is defined in `version.php`. */
30
+        return "WordLift/$wl_version WordPress/$wp_version (multisite:$multisite, url:$home_url, locale:$locale) PHP/$php_version";
31
+    }
32 32
 
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@
 block discarded – undo
12 12
 		$wl_version = Wordlift::get_instance()->get_version();
13 13
 
14 14
 		// Get the WP version.
15
-		$wp_version = get_bloginfo( 'version' );
15
+		$wp_version = get_bloginfo('version');
16 16
 
17 17
 		// Get the home url.
18
-		$home_url = home_url( '/' );
18
+		$home_url = home_url('/');
19 19
 
20 20
 		// Get the locale flag.
21
-		$locale = apply_filters( 'core_version_check_locale', get_locale() );
21
+		$locale = apply_filters('core_version_check_locale', get_locale());
22 22
 
23 23
 		// Get the multisite flag.
24 24
 		$multisite = is_multisite() ? 'yes' : 'no';
Please login to merge, or discard this patch.
src/wordlift/faq/class-faq-content-filter.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -10,34 +10,34 @@
 block discarded – undo
10 10
 namespace Wordlift\Faq;
11 11
 
12 12
 class Faq_Content_Filter {
13
-	/**
14
-	 * Constants used for replacing the tags in the html string.
15
-	 */
16
-	const FAQ_QUESTION_TAG_NAME = 'wl-faq-question';
17
-	const FAQ_ANSWER_TAG_NAME = 'wl-faq-answer';
18
-	/**
19
-	 * Replaces all the html tags inserted by Faq highlighting code in the front end
20
-	 * @param $content string Post content
21
-	 * @return string String after replacing all the opening and closing tags.
22
-	 */
23
-	public function remove_all_faq_question_and_answer_tags( $content ) {
24
-		/**
25
-		 * Replace all the question tags.
26
-		 */
27
-		$faq_question_opening_tag = '<' . self::FAQ_QUESTION_TAG_NAME . '>';
28
-		$faq_question_closing_tag = '</' . self::FAQ_QUESTION_TAG_NAME . '>';
29
-		$content = preg_replace('/<wl-faq-question class=".+?">/m', '', $content );
30
-		$content = str_replace($faq_question_closing_tag, "", $content);
31
-		/**
32
-		 * Replace all the answer tags.
33
-		 */
34
-		$faq_answer_opening_tag = '<' . self::FAQ_ANSWER_TAG_NAME . '>';
35
-		$faq_answer_closing_tag = '</' . self::FAQ_ANSWER_TAG_NAME . '>';
36
-		$content = preg_replace('/<wl-faq-answer class=".+?">/m', '', $content );
37
-		$content = str_replace($faq_answer_closing_tag, "", $content);
13
+    /**
14
+     * Constants used for replacing the tags in the html string.
15
+     */
16
+    const FAQ_QUESTION_TAG_NAME = 'wl-faq-question';
17
+    const FAQ_ANSWER_TAG_NAME = 'wl-faq-answer';
18
+    /**
19
+     * Replaces all the html tags inserted by Faq highlighting code in the front end
20
+     * @param $content string Post content
21
+     * @return string String after replacing all the opening and closing tags.
22
+     */
23
+    public function remove_all_faq_question_and_answer_tags( $content ) {
24
+        /**
25
+         * Replace all the question tags.
26
+         */
27
+        $faq_question_opening_tag = '<' . self::FAQ_QUESTION_TAG_NAME . '>';
28
+        $faq_question_closing_tag = '</' . self::FAQ_QUESTION_TAG_NAME . '>';
29
+        $content = preg_replace('/<wl-faq-question class=".+?">/m', '', $content );
30
+        $content = str_replace($faq_question_closing_tag, "", $content);
31
+        /**
32
+         * Replace all the answer tags.
33
+         */
34
+        $faq_answer_opening_tag = '<' . self::FAQ_ANSWER_TAG_NAME . '>';
35
+        $faq_answer_closing_tag = '</' . self::FAQ_ANSWER_TAG_NAME . '>';
36
+        $content = preg_replace('/<wl-faq-answer class=".+?">/m', '', $content );
37
+        $content = str_replace($faq_answer_closing_tag, "", $content);
38 38
 
39
-		/** Return all the replaced content */
40
-		return $content;
41
-	}
39
+        /** Return all the replaced content */
40
+        return $content;
41
+    }
42 42
 
43 43
 }
44 44
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,20 +20,20 @@
 block discarded – undo
20 20
 	 * @param $content string Post content
21 21
 	 * @return string String after replacing all the opening and closing tags.
22 22
 	 */
23
-	public function remove_all_faq_question_and_answer_tags( $content ) {
23
+	public function remove_all_faq_question_and_answer_tags($content) {
24 24
 		/**
25 25
 		 * Replace all the question tags.
26 26
 		 */
27
-		$faq_question_opening_tag = '<' . self::FAQ_QUESTION_TAG_NAME . '>';
28
-		$faq_question_closing_tag = '</' . self::FAQ_QUESTION_TAG_NAME . '>';
29
-		$content = preg_replace('/<wl-faq-question class=".+?">/m', '', $content );
27
+		$faq_question_opening_tag = '<'.self::FAQ_QUESTION_TAG_NAME.'>';
28
+		$faq_question_closing_tag = '</'.self::FAQ_QUESTION_TAG_NAME.'>';
29
+		$content = preg_replace('/<wl-faq-question class=".+?">/m', '', $content);
30 30
 		$content = str_replace($faq_question_closing_tag, "", $content);
31 31
 		/**
32 32
 		 * Replace all the answer tags.
33 33
 		 */
34
-		$faq_answer_opening_tag = '<' . self::FAQ_ANSWER_TAG_NAME . '>';
35
-		$faq_answer_closing_tag = '</' . self::FAQ_ANSWER_TAG_NAME . '>';
36
-		$content = preg_replace('/<wl-faq-answer class=".+?">/m', '', $content );
34
+		$faq_answer_opening_tag = '<'.self::FAQ_ANSWER_TAG_NAME.'>';
35
+		$faq_answer_closing_tag = '</'.self::FAQ_ANSWER_TAG_NAME.'>';
36
+		$content = preg_replace('/<wl-faq-answer class=".+?">/m', '', $content);
37 37
 		$content = str_replace($faq_answer_closing_tag, "", $content);
38 38
 
39 39
 		/** Return all the replaced content */
Please login to merge, or discard this patch.
src/wordlift/faq/class-faq-rest-controller.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -195,8 +195,7 @@
 block discarded – undo
195 195
 				$deleted_faq_item['answer'] = '';
196 196
 				$new_value = $deleted_faq_item;
197 197
 				update_post_meta($post_id, self::FAQ_META_KEY, $new_value, $previous_value);
198
-			}
199
-			else if ( $faq_item['field_to_be_deleted'] === self::QUESTION) {
198
+			} else if ( $faq_item['field_to_be_deleted'] === self::QUESTION) {
200 199
 				/**
201 200
 				 * If the question is deleted, then delete the faq item.
202 201
 				 */
Please login to merge, or discard this patch.
Indentation   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -17,232 +17,232 @@
 block discarded – undo
17 17
  *
18 18
  */
19 19
 class Faq_Rest_Controller {
20
-	const FAQ_META_KEY = '_wl_faq';
21
-	/**
22
-	 * Enumerations to determine the field to be deleted on
23
-	 * the DELETE request in API.
24
-	 */
25
-	const QUESTION = 'question';
26
-	const ANSWER = 'answer';
27
-
28
-	public static function register_routes() {
29
-		add_action( 'rest_api_init', 'Wordlift\FAQ\FAQ_Rest_Controller::register_route_callback' );
30
-	}
31
-
32
-	public static function register_route_callback() {
33
-		/**
34
-		 * Specifies the list of arguments to be present for update request.
35
-		 */
36
-		$post_id_validation_settings     = array(
37
-			'required'          => TRUE,
38
-			'validate_callback' => function ( $param, $request, $key ) {
39
-				return is_numeric( $param );
40
-			}
41
-		);
42
-		$faq_items_validation_settings   = array(
43
-			'required'          => TRUE,
44
-			'validate_callback' => function ( $param, $request, $key ) {
45
-				return is_array( $param ) && count( $param ) > 0;
46
-			}
47
-		);
48
-		/**
49
-		 * Array of args to be present in order to
50
-		 * make create, update or delete request.
51
-		 */
52
-		$create_or_update_or_delete_args = array(
53
-			'post_id'   => $post_id_validation_settings,
54
-			'faq_items' => $faq_items_validation_settings
55
-		);
56
-
57
-		/**
58
-		 * Rest route for creating new faq item.
59
-		 */
60
-		register_rest_route(
61
-			WL_REST_ROUTE_DEFAULT_NAMESPACE,
62
-			'/faq',
63
-			array(
64
-				'methods'             => \WP_REST_Server::CREATABLE,
65
-				'callback'            => 'Wordlift\Faq\Faq_Rest_Controller::add_faq_items',
66
-				'permission_callback' => function () {
67
-					return current_user_can( 'publish_posts' );
68
-				},
69
-				'args'                => $create_or_update_or_delete_args
70
-			) );
71
-		/**
72
-		 * Rest route for updating faq items.
73
-		 */
74
-		register_rest_route(
75
-			WL_REST_ROUTE_DEFAULT_NAMESPACE,
76
-			'/faq',
77
-			array(
78
-				'methods'             => \WP_REST_Server::EDITABLE,
79
-				'callback'            => 'Wordlift\Faq\Faq_Rest_Controller::update_faq_items',
80
-				'permission_callback' => function () {
81
-					return current_user_can( 'publish_posts' );
82
-				},
83
-				'args'                => $create_or_update_or_delete_args
84
-			)
85
-		);
86
-		/**
87
-		 * Rest route for getting the faq items.
88
-		 */
89
-		register_rest_route(
90
-			WL_REST_ROUTE_DEFAULT_NAMESPACE,
91
-			'/faq/(?P<post_id>\d+)',
92
-			array(
93
-				'methods'             => \WP_REST_Server::READABLE,
94
-				'callback'            => 'Wordlift\Faq\Faq_Rest_Controller::get_faq_items',
95
-				'permission_callback' => function () {
96
-					return current_user_can( 'publish_posts' );
97
-				},
98
-				'args'                => array( 'post_id' => $post_id_validation_settings )
99
-			)
100
-		);
101
-		/**
102
-		 * Rest route for deleting faq item.
103
-		 */
104
-		register_rest_route(
105
-			WL_REST_ROUTE_DEFAULT_NAMESPACE,
106
-			'/faq',
107
-			array(
108
-				'methods'             => \WP_REST_Server::DELETABLE,
109
-				'callback'            => 'Wordlift\Faq\Faq_Rest_Controller::delete_faq_items',
110
-				'permission_callback' => function () {
111
-					return current_user_can( 'publish_posts' );
112
-				},
113
-				'args'                => $create_or_update_or_delete_args
114
-			)
115
-		);
116
-	}
117
-
118
-	/**
119
-	 * Get all FAQ items for a post id.
120
-	 *
121
-	 * @param $request $request WP_REST_Request $request {@link WP_REST_Request instance}.
122
-	 *
123
-	 * @return array Result array, if post id is not given then error array is returned.
124
-	 */
125
-	public static function get_faq_items( $request ) {
126
-		$data    = $request->get_params();
127
-		$post_id = (int) $data['post_id'];
128
-
129
-		return get_post_meta( $post_id, self::FAQ_META_KEY );
130
-	}
131
-
132
-	/**
133
-	 * Update all FAQ items for a post id.
134
-	 *
135
-	 * @param $request $request WP_REST_Request $request {@link WP_REST_Request instance}.
136
-	 *
137
-	 * @return array Result array, if post id is not given then error array is returned.
138
-	 */
139
-	public static function update_faq_items( $request ) {
140
-		$data      = $request->get_params();
141
-		$post_id   = (int) $data['post_id'];
142
-		$faq_items = (array) $data['faq_items'];
143
-		foreach ( $faq_items as $faq_item ) {
144
-			$previous_value = array(
145
-				'question' => (string) $faq_item['previous_question_value'],
146
-				'answer'   => (string) $faq_item['previous_answer_value'],
147
-				'id'       => (int) $faq_item['id']
148
-			);
149
-			$new_value      = array(
150
-				'question' => (string) $faq_item['question'],
151
-				'answer'   => (string) $faq_item['answer'],
152
-				'id'       => (int) $faq_item['id']
153
-			);
154
-			update_post_meta( $post_id, self::FAQ_META_KEY, $new_value, $previous_value );
155
-		}
156
-
157
-		return array(
158
-			'status'  => 'success',
159
-			'message' => __( 'Faq Items updated successfully' )
160
-		);
161
-
162
-	}
163
-
164
-	/**
165
-	 * Delete Faq items.
166
-	 *
167
-	 * @param $request WP_REST_Request $request {@link WP_REST_Request instance}.
168
-	 *
169
-	 * @return array Associative array whether the faq item is deleted or not.
170
-	 */
171
-	public static function delete_faq_items( $request ) {
172
-		$post_data = $request->get_params();
173
-		$post_id   = $post_data['post_id'];
174
-		$faq_items = $post_data['faq_items'];
175
-		foreach ( $faq_items as $faq_item ) {
176
-			/**
177
-			 * Note: the order of keys is important in order to delete it properly
178
-			 * If the order change, delete operation will fail since it is converted
179
-			 * in to a string when it was stored.
180
-			 * we cant rely on client to post it in correct order, so we create an array
181
-			 * in correct order.
182
-			 **/
183
-			$deleted_faq_item = array(
184
-				'question' => $faq_item['question'],
185
-				'answer'   => $faq_item['answer'],
186
-				'id'       => (int) $faq_item['id']
187
-			);
188
-			/**
189
-			 * If the field to be deleted is answer, then dont delete the faq item,
190
-			 * if it is question then delete the faq item.
191
-			 */
192
-			if ( $faq_item['field_to_be_deleted'] === self::ANSWER) {
193
-				$previous_value = $deleted_faq_item;
194
-				// then dont delete the faq item, set the answer as empty.
195
-				$deleted_faq_item['answer'] = '';
196
-				$new_value = $deleted_faq_item;
197
-				update_post_meta($post_id, self::FAQ_META_KEY, $new_value, $previous_value);
198
-			}
199
-			else if ( $faq_item['field_to_be_deleted'] === self::QUESTION) {
200
-				/**
201
-				 * If the question is deleted, then delete the faq item.
202
-				 */
203
-				delete_post_meta( $post_id, self::FAQ_META_KEY, $deleted_faq_item );
204
-			}
205
-
206
-		}
207
-
208
-		/**
209
-		 * We are returning only the first item id, since the user can select only one text at a time.
210
-		 */
211
-		return array(
212
-			'status'  => 'success',
213
-			'message' => __( 'Faq item successfully deleted.' ),
214
-		);
215
-	}
216
-
217
-	/**
218
-	 * Insert or update FAQ items.
219
-	 *
220
-	 * @param $request WP_REST_Request $request {@link WP_REST_Request instance}.
221
-	 *
222
-	 * @return array Associative array whether the faq item is inserted or not
223
-	 */
224
-	public static function add_faq_items( $request ) {
225
-		$post_data = $request->get_params();
226
-		$post_id   = $post_data['post_id'];
227
-		$faq_items = $post_data['faq_items'];
228
-		foreach ( $faq_items as &$faq_item ) {
229
-			// Add an identifier id to the faq item, it helps to prevent duplication problem.
230
-			/**
231
-			 * We are using time() and a random integer to prevent
232
-			 * duplication problem.
233
-			 */
234
-			$faq_item['id'] = time() + wp_rand( 1, 100 ) + wp_rand( 1, 100 );
235
-			add_post_meta( (int) $post_id, self::FAQ_META_KEY, $faq_item );
236
-		}
237
-
238
-		/**
239
-		 * We are returning only the first item id, since the user can select only one text at a time.
240
-		 */
241
-		return array(
242
-			'status'  => 'success',
243
-			'message' => __( 'Question successfully added.' ),
244
-			'id'      => (int) $faq_items[0]['id'],
245
-		);
246
-
247
-	}
20
+    const FAQ_META_KEY = '_wl_faq';
21
+    /**
22
+     * Enumerations to determine the field to be deleted on
23
+     * the DELETE request in API.
24
+     */
25
+    const QUESTION = 'question';
26
+    const ANSWER = 'answer';
27
+
28
+    public static function register_routes() {
29
+        add_action( 'rest_api_init', 'Wordlift\FAQ\FAQ_Rest_Controller::register_route_callback' );
30
+    }
31
+
32
+    public static function register_route_callback() {
33
+        /**
34
+         * Specifies the list of arguments to be present for update request.
35
+         */
36
+        $post_id_validation_settings     = array(
37
+            'required'          => TRUE,
38
+            'validate_callback' => function ( $param, $request, $key ) {
39
+                return is_numeric( $param );
40
+            }
41
+        );
42
+        $faq_items_validation_settings   = array(
43
+            'required'          => TRUE,
44
+            'validate_callback' => function ( $param, $request, $key ) {
45
+                return is_array( $param ) && count( $param ) > 0;
46
+            }
47
+        );
48
+        /**
49
+         * Array of args to be present in order to
50
+         * make create, update or delete request.
51
+         */
52
+        $create_or_update_or_delete_args = array(
53
+            'post_id'   => $post_id_validation_settings,
54
+            'faq_items' => $faq_items_validation_settings
55
+        );
56
+
57
+        /**
58
+         * Rest route for creating new faq item.
59
+         */
60
+        register_rest_route(
61
+            WL_REST_ROUTE_DEFAULT_NAMESPACE,
62
+            '/faq',
63
+            array(
64
+                'methods'             => \WP_REST_Server::CREATABLE,
65
+                'callback'            => 'Wordlift\Faq\Faq_Rest_Controller::add_faq_items',
66
+                'permission_callback' => function () {
67
+                    return current_user_can( 'publish_posts' );
68
+                },
69
+                'args'                => $create_or_update_or_delete_args
70
+            ) );
71
+        /**
72
+         * Rest route for updating faq items.
73
+         */
74
+        register_rest_route(
75
+            WL_REST_ROUTE_DEFAULT_NAMESPACE,
76
+            '/faq',
77
+            array(
78
+                'methods'             => \WP_REST_Server::EDITABLE,
79
+                'callback'            => 'Wordlift\Faq\Faq_Rest_Controller::update_faq_items',
80
+                'permission_callback' => function () {
81
+                    return current_user_can( 'publish_posts' );
82
+                },
83
+                'args'                => $create_or_update_or_delete_args
84
+            )
85
+        );
86
+        /**
87
+         * Rest route for getting the faq items.
88
+         */
89
+        register_rest_route(
90
+            WL_REST_ROUTE_DEFAULT_NAMESPACE,
91
+            '/faq/(?P<post_id>\d+)',
92
+            array(
93
+                'methods'             => \WP_REST_Server::READABLE,
94
+                'callback'            => 'Wordlift\Faq\Faq_Rest_Controller::get_faq_items',
95
+                'permission_callback' => function () {
96
+                    return current_user_can( 'publish_posts' );
97
+                },
98
+                'args'                => array( 'post_id' => $post_id_validation_settings )
99
+            )
100
+        );
101
+        /**
102
+         * Rest route for deleting faq item.
103
+         */
104
+        register_rest_route(
105
+            WL_REST_ROUTE_DEFAULT_NAMESPACE,
106
+            '/faq',
107
+            array(
108
+                'methods'             => \WP_REST_Server::DELETABLE,
109
+                'callback'            => 'Wordlift\Faq\Faq_Rest_Controller::delete_faq_items',
110
+                'permission_callback' => function () {
111
+                    return current_user_can( 'publish_posts' );
112
+                },
113
+                'args'                => $create_or_update_or_delete_args
114
+            )
115
+        );
116
+    }
117
+
118
+    /**
119
+     * Get all FAQ items for a post id.
120
+     *
121
+     * @param $request $request WP_REST_Request $request {@link WP_REST_Request instance}.
122
+     *
123
+     * @return array Result array, if post id is not given then error array is returned.
124
+     */
125
+    public static function get_faq_items( $request ) {
126
+        $data    = $request->get_params();
127
+        $post_id = (int) $data['post_id'];
128
+
129
+        return get_post_meta( $post_id, self::FAQ_META_KEY );
130
+    }
131
+
132
+    /**
133
+     * Update all FAQ items for a post id.
134
+     *
135
+     * @param $request $request WP_REST_Request $request {@link WP_REST_Request instance}.
136
+     *
137
+     * @return array Result array, if post id is not given then error array is returned.
138
+     */
139
+    public static function update_faq_items( $request ) {
140
+        $data      = $request->get_params();
141
+        $post_id   = (int) $data['post_id'];
142
+        $faq_items = (array) $data['faq_items'];
143
+        foreach ( $faq_items as $faq_item ) {
144
+            $previous_value = array(
145
+                'question' => (string) $faq_item['previous_question_value'],
146
+                'answer'   => (string) $faq_item['previous_answer_value'],
147
+                'id'       => (int) $faq_item['id']
148
+            );
149
+            $new_value      = array(
150
+                'question' => (string) $faq_item['question'],
151
+                'answer'   => (string) $faq_item['answer'],
152
+                'id'       => (int) $faq_item['id']
153
+            );
154
+            update_post_meta( $post_id, self::FAQ_META_KEY, $new_value, $previous_value );
155
+        }
156
+
157
+        return array(
158
+            'status'  => 'success',
159
+            'message' => __( 'Faq Items updated successfully' )
160
+        );
161
+
162
+    }
163
+
164
+    /**
165
+     * Delete Faq items.
166
+     *
167
+     * @param $request WP_REST_Request $request {@link WP_REST_Request instance}.
168
+     *
169
+     * @return array Associative array whether the faq item is deleted or not.
170
+     */
171
+    public static function delete_faq_items( $request ) {
172
+        $post_data = $request->get_params();
173
+        $post_id   = $post_data['post_id'];
174
+        $faq_items = $post_data['faq_items'];
175
+        foreach ( $faq_items as $faq_item ) {
176
+            /**
177
+             * Note: the order of keys is important in order to delete it properly
178
+             * If the order change, delete operation will fail since it is converted
179
+             * in to a string when it was stored.
180
+             * we cant rely on client to post it in correct order, so we create an array
181
+             * in correct order.
182
+             **/
183
+            $deleted_faq_item = array(
184
+                'question' => $faq_item['question'],
185
+                'answer'   => $faq_item['answer'],
186
+                'id'       => (int) $faq_item['id']
187
+            );
188
+            /**
189
+             * If the field to be deleted is answer, then dont delete the faq item,
190
+             * if it is question then delete the faq item.
191
+             */
192
+            if ( $faq_item['field_to_be_deleted'] === self::ANSWER) {
193
+                $previous_value = $deleted_faq_item;
194
+                // then dont delete the faq item, set the answer as empty.
195
+                $deleted_faq_item['answer'] = '';
196
+                $new_value = $deleted_faq_item;
197
+                update_post_meta($post_id, self::FAQ_META_KEY, $new_value, $previous_value);
198
+            }
199
+            else if ( $faq_item['field_to_be_deleted'] === self::QUESTION) {
200
+                /**
201
+                 * If the question is deleted, then delete the faq item.
202
+                 */
203
+                delete_post_meta( $post_id, self::FAQ_META_KEY, $deleted_faq_item );
204
+            }
205
+
206
+        }
207
+
208
+        /**
209
+         * We are returning only the first item id, since the user can select only one text at a time.
210
+         */
211
+        return array(
212
+            'status'  => 'success',
213
+            'message' => __( 'Faq item successfully deleted.' ),
214
+        );
215
+    }
216
+
217
+    /**
218
+     * Insert or update FAQ items.
219
+     *
220
+     * @param $request WP_REST_Request $request {@link WP_REST_Request instance}.
221
+     *
222
+     * @return array Associative array whether the faq item is inserted or not
223
+     */
224
+    public static function add_faq_items( $request ) {
225
+        $post_data = $request->get_params();
226
+        $post_id   = $post_data['post_id'];
227
+        $faq_items = $post_data['faq_items'];
228
+        foreach ( $faq_items as &$faq_item ) {
229
+            // Add an identifier id to the faq item, it helps to prevent duplication problem.
230
+            /**
231
+             * We are using time() and a random integer to prevent
232
+             * duplication problem.
233
+             */
234
+            $faq_item['id'] = time() + wp_rand( 1, 100 ) + wp_rand( 1, 100 );
235
+            add_post_meta( (int) $post_id, self::FAQ_META_KEY, $faq_item );
236
+        }
237
+
238
+        /**
239
+         * We are returning only the first item id, since the user can select only one text at a time.
240
+         */
241
+        return array(
242
+            'status'  => 'success',
243
+            'message' => __( 'Question successfully added.' ),
244
+            'id'      => (int) $faq_items[0]['id'],
245
+        );
246
+
247
+    }
248 248
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -26,23 +26,23 @@  discard block
 block discarded – undo
26 26
 	const ANSWER = 'answer';
27 27
 
28 28
 	public static function register_routes() {
29
-		add_action( 'rest_api_init', 'Wordlift\FAQ\FAQ_Rest_Controller::register_route_callback' );
29
+		add_action('rest_api_init', 'Wordlift\FAQ\FAQ_Rest_Controller::register_route_callback');
30 30
 	}
31 31
 
32 32
 	public static function register_route_callback() {
33 33
 		/**
34 34
 		 * Specifies the list of arguments to be present for update request.
35 35
 		 */
36
-		$post_id_validation_settings     = array(
36
+		$post_id_validation_settings = array(
37 37
 			'required'          => TRUE,
38
-			'validate_callback' => function ( $param, $request, $key ) {
39
-				return is_numeric( $param );
38
+			'validate_callback' => function($param, $request, $key) {
39
+				return is_numeric($param);
40 40
 			}
41 41
 		);
42
-		$faq_items_validation_settings   = array(
42
+		$faq_items_validation_settings = array(
43 43
 			'required'          => TRUE,
44
-			'validate_callback' => function ( $param, $request, $key ) {
45
-				return is_array( $param ) && count( $param ) > 0;
44
+			'validate_callback' => function($param, $request, $key) {
45
+				return is_array($param) && count($param) > 0;
46 46
 			}
47 47
 		);
48 48
 		/**
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 			array(
64 64
 				'methods'             => \WP_REST_Server::CREATABLE,
65 65
 				'callback'            => 'Wordlift\Faq\Faq_Rest_Controller::add_faq_items',
66
-				'permission_callback' => function () {
67
-					return current_user_can( 'publish_posts' );
66
+				'permission_callback' => function() {
67
+					return current_user_can('publish_posts');
68 68
 				},
69 69
 				'args'                => $create_or_update_or_delete_args
70 70
 			) );
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 			array(
78 78
 				'methods'             => \WP_REST_Server::EDITABLE,
79 79
 				'callback'            => 'Wordlift\Faq\Faq_Rest_Controller::update_faq_items',
80
-				'permission_callback' => function () {
81
-					return current_user_can( 'publish_posts' );
80
+				'permission_callback' => function() {
81
+					return current_user_can('publish_posts');
82 82
 				},
83 83
 				'args'                => $create_or_update_or_delete_args
84 84
 			)
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 			array(
93 93
 				'methods'             => \WP_REST_Server::READABLE,
94 94
 				'callback'            => 'Wordlift\Faq\Faq_Rest_Controller::get_faq_items',
95
-				'permission_callback' => function () {
96
-					return current_user_can( 'publish_posts' );
95
+				'permission_callback' => function() {
96
+					return current_user_can('publish_posts');
97 97
 				},
98
-				'args'                => array( 'post_id' => $post_id_validation_settings )
98
+				'args'                => array('post_id' => $post_id_validation_settings)
99 99
 			)
100 100
 		);
101 101
 		/**
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 			array(
108 108
 				'methods'             => \WP_REST_Server::DELETABLE,
109 109
 				'callback'            => 'Wordlift\Faq\Faq_Rest_Controller::delete_faq_items',
110
-				'permission_callback' => function () {
111
-					return current_user_can( 'publish_posts' );
110
+				'permission_callback' => function() {
111
+					return current_user_can('publish_posts');
112 112
 				},
113 113
 				'args'                => $create_or_update_or_delete_args
114 114
 			)
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return array Result array, if post id is not given then error array is returned.
124 124
 	 */
125
-	public static function get_faq_items( $request ) {
125
+	public static function get_faq_items($request) {
126 126
 		$data    = $request->get_params();
127 127
 		$post_id = (int) $data['post_id'];
128 128
 
129
-		return get_post_meta( $post_id, self::FAQ_META_KEY );
129
+		return get_post_meta($post_id, self::FAQ_META_KEY);
130 130
 	}
131 131
 
132 132
 	/**
@@ -136,27 +136,27 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @return array Result array, if post id is not given then error array is returned.
138 138
 	 */
139
-	public static function update_faq_items( $request ) {
139
+	public static function update_faq_items($request) {
140 140
 		$data      = $request->get_params();
141 141
 		$post_id   = (int) $data['post_id'];
142 142
 		$faq_items = (array) $data['faq_items'];
143
-		foreach ( $faq_items as $faq_item ) {
143
+		foreach ($faq_items as $faq_item) {
144 144
 			$previous_value = array(
145 145
 				'question' => (string) $faq_item['previous_question_value'],
146 146
 				'answer'   => (string) $faq_item['previous_answer_value'],
147 147
 				'id'       => (int) $faq_item['id']
148 148
 			);
149
-			$new_value      = array(
149
+			$new_value = array(
150 150
 				'question' => (string) $faq_item['question'],
151 151
 				'answer'   => (string) $faq_item['answer'],
152 152
 				'id'       => (int) $faq_item['id']
153 153
 			);
154
-			update_post_meta( $post_id, self::FAQ_META_KEY, $new_value, $previous_value );
154
+			update_post_meta($post_id, self::FAQ_META_KEY, $new_value, $previous_value);
155 155
 		}
156 156
 
157 157
 		return array(
158 158
 			'status'  => 'success',
159
-			'message' => __( 'Faq Items updated successfully' )
159
+			'message' => __('Faq Items updated successfully')
160 160
 		);
161 161
 
162 162
 	}
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @return array Associative array whether the faq item is deleted or not.
170 170
 	 */
171
-	public static function delete_faq_items( $request ) {
171
+	public static function delete_faq_items($request) {
172 172
 		$post_data = $request->get_params();
173 173
 		$post_id   = $post_data['post_id'];
174 174
 		$faq_items = $post_data['faq_items'];
175
-		foreach ( $faq_items as $faq_item ) {
175
+		foreach ($faq_items as $faq_item) {
176 176
 			/**
177 177
 			 * Note: the order of keys is important in order to delete it properly
178 178
 			 * If the order change, delete operation will fail since it is converted
@@ -189,18 +189,18 @@  discard block
 block discarded – undo
189 189
 			 * If the field to be deleted is answer, then dont delete the faq item,
190 190
 			 * if it is question then delete the faq item.
191 191
 			 */
192
-			if ( $faq_item['field_to_be_deleted'] === self::ANSWER) {
192
+			if ($faq_item['field_to_be_deleted'] === self::ANSWER) {
193 193
 				$previous_value = $deleted_faq_item;
194 194
 				// then dont delete the faq item, set the answer as empty.
195 195
 				$deleted_faq_item['answer'] = '';
196 196
 				$new_value = $deleted_faq_item;
197 197
 				update_post_meta($post_id, self::FAQ_META_KEY, $new_value, $previous_value);
198 198
 			}
199
-			else if ( $faq_item['field_to_be_deleted'] === self::QUESTION) {
199
+			else if ($faq_item['field_to_be_deleted'] === self::QUESTION) {
200 200
 				/**
201 201
 				 * If the question is deleted, then delete the faq item.
202 202
 				 */
203
-				delete_post_meta( $post_id, self::FAQ_META_KEY, $deleted_faq_item );
203
+				delete_post_meta($post_id, self::FAQ_META_KEY, $deleted_faq_item);
204 204
 			}
205 205
 
206 206
 		}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 		 */
211 211
 		return array(
212 212
 			'status'  => 'success',
213
-			'message' => __( 'Faq item successfully deleted.' ),
213
+			'message' => __('Faq item successfully deleted.'),
214 214
 		);
215 215
 	}
216 216
 
@@ -221,18 +221,18 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @return array Associative array whether the faq item is inserted or not
223 223
 	 */
224
-	public static function add_faq_items( $request ) {
224
+	public static function add_faq_items($request) {
225 225
 		$post_data = $request->get_params();
226 226
 		$post_id   = $post_data['post_id'];
227 227
 		$faq_items = $post_data['faq_items'];
228
-		foreach ( $faq_items as &$faq_item ) {
228
+		foreach ($faq_items as &$faq_item) {
229 229
 			// Add an identifier id to the faq item, it helps to prevent duplication problem.
230 230
 			/**
231 231
 			 * We are using time() and a random integer to prevent
232 232
 			 * duplication problem.
233 233
 			 */
234
-			$faq_item['id'] = time() + wp_rand( 1, 100 ) + wp_rand( 1, 100 );
235
-			add_post_meta( (int) $post_id, self::FAQ_META_KEY, $faq_item );
234
+			$faq_item['id'] = time() + wp_rand(1, 100) + wp_rand(1, 100);
235
+			add_post_meta((int) $post_id, self::FAQ_META_KEY, $faq_item);
236 236
 		}
237 237
 
238 238
 		/**
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		 */
241 241
 		return array(
242 242
 			'status'  => 'success',
243
-			'message' => __( 'Question successfully added.' ),
243
+			'message' => __('Question successfully added.'),
244 244
 			'id'      => (int) $faq_items[0]['id'],
245 245
 		);
246 246
 
Please login to merge, or discard this patch.
src/wordlift/faq/class-faq-tinymce-adapter.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -13,40 +13,40 @@
 block discarded – undo
13 13
 
14 14
 class Faq_Tinymce_Adapter {
15 15
 
16
-	const FAQ_TINYMCE_PLUGIN_NAME = "wl_faq_tinymce";
17
-
18
-	const FAQ_TINYMCE_ADD_BUTTON_ID = "wl-faq-toolbar-button";
19
-
20
-	/**
21
-	 * Add a list of custom tags which is to be used by our highlighting program.
22
-	 *
23
-	 * @param $init_array
24
-	 *
25
-	 * @return array
26
-	 */
27
-	public function register_custom_tags( $init_array ) {
28
-		$opts                                  = '~wl-faq-question,~wl-faq-answer';
29
-		$init_array['custom_elements']         .= ( empty( $init_array['custom_elements'] ) ? '' : ',' ) . $opts;
30
-		$init_array['extended_valid_elements'] .= ( empty( $init_array['extended_valid_elements'] ) ? '' : ',' ) . $opts;
31
-
32
-		return $init_array;
33
-	}
34
-
35
-	public function register_faq_tinymce_plugin( $plugins ) {
36
-		/**
37
-		 * Registering the tinymce plugin for FAQ here.
38
-		 * @since 3.26.0
39
-		 */
40
-		$version                                  = Wordlift::get_instance()->get_version();
41
-		$plugins[ self::FAQ_TINYMCE_PLUGIN_NAME ] = plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/tinymce-faq-plugin.full.js?ver=' . $version;
42
-
43
-		return $plugins;
44
-	}
45
-
46
-	public function register_faq_toolbar_button( $buttons ) {
47
-		array_push( $buttons, self::FAQ_TINYMCE_ADD_BUTTON_ID );
48
-
49
-		return $buttons;
50
-	}
16
+    const FAQ_TINYMCE_PLUGIN_NAME = "wl_faq_tinymce";
17
+
18
+    const FAQ_TINYMCE_ADD_BUTTON_ID = "wl-faq-toolbar-button";
19
+
20
+    /**
21
+     * Add a list of custom tags which is to be used by our highlighting program.
22
+     *
23
+     * @param $init_array
24
+     *
25
+     * @return array
26
+     */
27
+    public function register_custom_tags( $init_array ) {
28
+        $opts                                  = '~wl-faq-question,~wl-faq-answer';
29
+        $init_array['custom_elements']         .= ( empty( $init_array['custom_elements'] ) ? '' : ',' ) . $opts;
30
+        $init_array['extended_valid_elements'] .= ( empty( $init_array['extended_valid_elements'] ) ? '' : ',' ) . $opts;
31
+
32
+        return $init_array;
33
+    }
34
+
35
+    public function register_faq_tinymce_plugin( $plugins ) {
36
+        /**
37
+         * Registering the tinymce plugin for FAQ here.
38
+         * @since 3.26.0
39
+         */
40
+        $version                                  = Wordlift::get_instance()->get_version();
41
+        $plugins[ self::FAQ_TINYMCE_PLUGIN_NAME ] = plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/tinymce-faq-plugin.full.js?ver=' . $version;
42
+
43
+        return $plugins;
44
+    }
45
+
46
+    public function register_faq_toolbar_button( $buttons ) {
47
+        array_push( $buttons, self::FAQ_TINYMCE_ADD_BUTTON_ID );
48
+
49
+        return $buttons;
50
+    }
51 51
 
52 52
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,27 +24,27 @@
 block discarded – undo
24 24
 	 *
25 25
 	 * @return array
26 26
 	 */
27
-	public function register_custom_tags( $init_array ) {
28
-		$opts                                  = '~wl-faq-question,~wl-faq-answer';
29
-		$init_array['custom_elements']         .= ( empty( $init_array['custom_elements'] ) ? '' : ',' ) . $opts;
30
-		$init_array['extended_valid_elements'] .= ( empty( $init_array['extended_valid_elements'] ) ? '' : ',' ) . $opts;
27
+	public function register_custom_tags($init_array) {
28
+		$opts = '~wl-faq-question,~wl-faq-answer';
29
+		$init_array['custom_elements']         .= (empty($init_array['custom_elements']) ? '' : ',').$opts;
30
+		$init_array['extended_valid_elements'] .= (empty($init_array['extended_valid_elements']) ? '' : ',').$opts;
31 31
 
32 32
 		return $init_array;
33 33
 	}
34 34
 
35
-	public function register_faq_tinymce_plugin( $plugins ) {
35
+	public function register_faq_tinymce_plugin($plugins) {
36 36
 		/**
37 37
 		 * Registering the tinymce plugin for FAQ here.
38 38
 		 * @since 3.26.0
39 39
 		 */
40 40
 		$version                                  = Wordlift::get_instance()->get_version();
41
-		$plugins[ self::FAQ_TINYMCE_PLUGIN_NAME ] = plugin_dir_url( dirname( __DIR__ ) ) . 'js/dist/tinymce-faq-plugin.full.js?ver=' . $version;
41
+		$plugins[self::FAQ_TINYMCE_PLUGIN_NAME] = plugin_dir_url(dirname(__DIR__)).'js/dist/tinymce-faq-plugin.full.js?ver='.$version;
42 42
 
43 43
 		return $plugins;
44 44
 	}
45 45
 
46
-	public function register_faq_toolbar_button( $buttons ) {
47
-		array_push( $buttons, self::FAQ_TINYMCE_ADD_BUTTON_ID );
46
+	public function register_faq_toolbar_button($buttons) {
47
+		array_push($buttons, self::FAQ_TINYMCE_ADD_BUTTON_ID);
48 48
 
49 49
 		return $buttons;
50 50
 	}
Please login to merge, or discard this patch.
src/includes/linked-data/storage/class-wordlift-post-image-storage.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -18,45 +18,45 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Post_Image_Storage extends Wordlift_Storage {
20 20
 
21
-	/**
22
-	 * Get the property value.
23
-	 *
24
-	 * @param int $post_id The {@link WP_Post}'s id.
25
-	 *
26
-	 * @return array|string|null A single string, or an array of values or null
27
-	 *                           if the property isn't recognized.
28
-	 * @since 3.15.0
29
-	 *
30
-	 */
31
-	public function get( $post_id ) {
32
-
33
-		// Prepare the return array.
34
-		$image_urls = array();
35
-
36
-		// If there is a featured image it has the priority.
37
-		$featured_image_id = get_post_thumbnail_id( $post_id );
38
-		if ( is_numeric( $featured_image_id ) && 0 < $featured_image_id ) {
39
-			$image_url = wp_get_attachment_url( $featured_image_id );
40
-
41
-			$image_urls[] = $image_url;
42
-		}
43
-
44
-		$images = get_children( array(
45
-			'post_parent'    => $post_id,
46
-			'post_type'      => 'attachment',
47
-			'post_mime_type' => 'image',
48
-		) );
49
-
50
-		// Collect the URLs.
51
-		foreach ( $images as $attachment_id => $attachment ) {
52
-			$image_url = wp_get_attachment_url( $attachment_id );
53
-			// Ensure the URL isn't collected already.
54
-			if ( ! in_array( $image_url, $image_urls ) ) {
55
-				array_push( $image_urls, $image_url );
56
-			}
57
-		}
58
-
59
-		return $image_urls;
60
-	}
21
+    /**
22
+     * Get the property value.
23
+     *
24
+     * @param int $post_id The {@link WP_Post}'s id.
25
+     *
26
+     * @return array|string|null A single string, or an array of values or null
27
+     *                           if the property isn't recognized.
28
+     * @since 3.15.0
29
+     *
30
+     */
31
+    public function get( $post_id ) {
32
+
33
+        // Prepare the return array.
34
+        $image_urls = array();
35
+
36
+        // If there is a featured image it has the priority.
37
+        $featured_image_id = get_post_thumbnail_id( $post_id );
38
+        if ( is_numeric( $featured_image_id ) && 0 < $featured_image_id ) {
39
+            $image_url = wp_get_attachment_url( $featured_image_id );
40
+
41
+            $image_urls[] = $image_url;
42
+        }
43
+
44
+        $images = get_children( array(
45
+            'post_parent'    => $post_id,
46
+            'post_type'      => 'attachment',
47
+            'post_mime_type' => 'image',
48
+        ) );
49
+
50
+        // Collect the URLs.
51
+        foreach ( $images as $attachment_id => $attachment ) {
52
+            $image_url = wp_get_attachment_url( $attachment_id );
53
+            // Ensure the URL isn't collected already.
54
+            if ( ! in_array( $image_url, $image_urls ) ) {
55
+                array_push( $image_urls, $image_url );
56
+            }
57
+        }
58
+
59
+        return $image_urls;
60
+    }
61 61
 
62 62
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,31 +28,31 @@
 block discarded – undo
28 28
 	 * @since 3.15.0
29 29
 	 *
30 30
 	 */
31
-	public function get( $post_id ) {
31
+	public function get($post_id) {
32 32
 
33 33
 		// Prepare the return array.
34 34
 		$image_urls = array();
35 35
 
36 36
 		// If there is a featured image it has the priority.
37
-		$featured_image_id = get_post_thumbnail_id( $post_id );
38
-		if ( is_numeric( $featured_image_id ) && 0 < $featured_image_id ) {
39
-			$image_url = wp_get_attachment_url( $featured_image_id );
37
+		$featured_image_id = get_post_thumbnail_id($post_id);
38
+		if (is_numeric($featured_image_id) && 0 < $featured_image_id) {
39
+			$image_url = wp_get_attachment_url($featured_image_id);
40 40
 
41 41
 			$image_urls[] = $image_url;
42 42
 		}
43 43
 
44
-		$images = get_children( array(
44
+		$images = get_children(array(
45 45
 			'post_parent'    => $post_id,
46 46
 			'post_type'      => 'attachment',
47 47
 			'post_mime_type' => 'image',
48
-		) );
48
+		));
49 49
 
50 50
 		// Collect the URLs.
51
-		foreach ( $images as $attachment_id => $attachment ) {
52
-			$image_url = wp_get_attachment_url( $attachment_id );
51
+		foreach ($images as $attachment_id => $attachment) {
52
+			$image_url = wp_get_attachment_url($attachment_id);
53 53
 			// Ensure the URL isn't collected already.
54
-			if ( ! in_array( $image_url, $image_urls ) ) {
55
-				array_push( $image_urls, $image_url );
54
+			if ( ! in_array($image_url, $image_urls)) {
55
+				array_push($image_urls, $image_url);
56 56
 			}
57 57
 		}
58 58
 
Please login to merge, or discard this patch.
src/wordlift/jsonld/class-jsonld-response-helper.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@
 block discarded – undo
17 17
 
18 18
 class Jsonld_Response_Helper {
19 19
 
20
-	/**
21
-	 * Converts the provided data into a {@link WP_REST_Response} by adding the required caching and content-type
22
-	 * headers.
23
-	 *
24
-	 * @param mixed $data The output data.
25
-	 *
26
-	 * @return WP_REST_Response The {@link WP_REST_Response}.
27
-	 */
28
-	public static function to_response( $data ) {
29
-
30
-		$response = new WP_REST_Response( $data );
31
-
32
-		$cache_in_seconds = 86400;
33
-		$date_timezone    = new DateTimeZone( 'GMT' );
34
-		$date_now         = new DateTime( 'now', $date_timezone );
35
-		$date_interval    = new DateInterval( "PT{$cache_in_seconds}S" );
36
-		$expires          = $date_now->add( $date_interval )->format( 'D, j M Y H:i:s T' );
37
-
38
-		$response->set_headers( array(
39
-			'Content-Type'  => 'application/ld+json; charset=' . get_option( 'blog_charset' ),
40
-			'Cache-Control' => "max-age=$cache_in_seconds",
41
-			'Expires'       => $expires
42
-		) );
43
-
44
-		return $response;
45
-	}
20
+    /**
21
+     * Converts the provided data into a {@link WP_REST_Response} by adding the required caching and content-type
22
+     * headers.
23
+     *
24
+     * @param mixed $data The output data.
25
+     *
26
+     * @return WP_REST_Response The {@link WP_REST_Response}.
27
+     */
28
+    public static function to_response( $data ) {
29
+
30
+        $response = new WP_REST_Response( $data );
31
+
32
+        $cache_in_seconds = 86400;
33
+        $date_timezone    = new DateTimeZone( 'GMT' );
34
+        $date_now         = new DateTime( 'now', $date_timezone );
35
+        $date_interval    = new DateInterval( "PT{$cache_in_seconds}S" );
36
+        $expires          = $date_now->add( $date_interval )->format( 'D, j M Y H:i:s T' );
37
+
38
+        $response->set_headers( array(
39
+            'Content-Type'  => 'application/ld+json; charset=' . get_option( 'blog_charset' ),
40
+            'Cache-Control' => "max-age=$cache_in_seconds",
41
+            'Expires'       => $expires
42
+        ) );
43
+
44
+        return $response;
45
+    }
46 46
 
47 47
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,21 +25,21 @@
 block discarded – undo
25 25
 	 *
26 26
 	 * @return WP_REST_Response The {@link WP_REST_Response}.
27 27
 	 */
28
-	public static function to_response( $data ) {
28
+	public static function to_response($data) {
29 29
 
30
-		$response = new WP_REST_Response( $data );
30
+		$response = new WP_REST_Response($data);
31 31
 
32 32
 		$cache_in_seconds = 86400;
33
-		$date_timezone    = new DateTimeZone( 'GMT' );
34
-		$date_now         = new DateTime( 'now', $date_timezone );
35
-		$date_interval    = new DateInterval( "PT{$cache_in_seconds}S" );
36
-		$expires          = $date_now->add( $date_interval )->format( 'D, j M Y H:i:s T' );
33
+		$date_timezone    = new DateTimeZone('GMT');
34
+		$date_now         = new DateTime('now', $date_timezone);
35
+		$date_interval    = new DateInterval("PT{$cache_in_seconds}S");
36
+		$expires          = $date_now->add($date_interval)->format('D, j M Y H:i:s T');
37 37
 
38
-		$response->set_headers( array(
39
-			'Content-Type'  => 'application/ld+json; charset=' . get_option( 'blog_charset' ),
38
+		$response->set_headers(array(
39
+			'Content-Type'  => 'application/ld+json; charset='.get_option('blog_charset'),
40 40
 			'Cache-Control' => "max-age=$cache_in_seconds",
41 41
 			'Expires'       => $expires
42
-		) );
42
+		));
43 43
 
44 44
 		return $response;
45 45
 	}
Please login to merge, or discard this patch.