@@ -3,82 +3,82 @@ |
||
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 | - 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 | + public function admin_menu() { |
|
60 | 60 | |
61 | - // Add the sub-menu page. |
|
62 | - // |
|
63 | - // See http://codex.wordpress.org/Function_Reference/add_submenu_page |
|
64 | - $page = add_submenu_page( |
|
65 | - $this->parent_slug, |
|
66 | - $this->page_title, |
|
67 | - $this->menu_title, |
|
68 | - $this->capability, |
|
69 | - $this->menu_slug, |
|
70 | - array( $this, 'render' ) |
|
71 | - ); |
|
61 | + // Add the sub-menu page. |
|
62 | + // |
|
63 | + // See http://codex.wordpress.org/Function_Reference/add_submenu_page |
|
64 | + $page = add_submenu_page( |
|
65 | + $this->parent_slug, |
|
66 | + $this->page_title, |
|
67 | + $this->menu_title, |
|
68 | + $this->capability, |
|
69 | + $this->menu_slug, |
|
70 | + array( $this, 'render' ) |
|
71 | + ); |
|
72 | 72 | |
73 | - // Set a hook to enqueue scripts only when the settings page is displayed. |
|
74 | - add_action( 'admin_print_scripts-' . $page, array( $this, 'enqueue_scripts' ) ); |
|
73 | + // Set a hook to enqueue scripts only when the settings page is displayed. |
|
74 | + add_action( 'admin_print_scripts-' . $page, array( $this, 'enqueue_scripts' ) ); |
|
75 | 75 | |
76 | - // Finally return the page hook_suffix. |
|
77 | - return $page; |
|
78 | - } |
|
76 | + // Finally return the page hook_suffix. |
|
77 | + return $page; |
|
78 | + } |
|
79 | 79 | |
80 | - abstract public function enqueue_scripts(); |
|
80 | + abstract public function enqueue_scripts(); |
|
81 | 81 | |
82 | - abstract public function render(); |
|
82 | + abstract public function render(); |
|
83 | 83 | |
84 | 84 | } |
@@ -33,15 +33,15 @@ discard block |
||
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() { |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | $this->menu_title, |
68 | 68 | $this->capability, |
69 | 69 | $this->menu_slug, |
70 | - array( $this, 'render' ) |
|
70 | + array($this, 'render') |
|
71 | 71 | ); |
72 | 72 | |
73 | 73 | // Set a hook to enqueue scripts only when the settings page is displayed. |
74 | - add_action( 'admin_print_scripts-' . $page, array( $this, 'enqueue_scripts' ) ); |
|
74 | + add_action('admin_print_scripts-'.$page, array($this, 'enqueue_scripts')); |
|
75 | 75 | |
76 | 76 | // Finally return the page hook_suffix. |
77 | 77 | return $page; |
@@ -8,78 +8,78 @@ |
||
8 | 8 | */ |
9 | 9 | class Async_Template_Decorator { |
10 | 10 | |
11 | - /** |
|
12 | - * @var $rest_url_name string |
|
13 | - */ |
|
14 | - private $rest_url_name; |
|
11 | + /** |
|
12 | + * @var $rest_url_name string |
|
13 | + */ |
|
14 | + private $rest_url_name; |
|
15 | 15 | |
16 | - /** |
|
17 | - * @var $filter_name string |
|
18 | - */ |
|
19 | - private $filter_name; |
|
16 | + /** |
|
17 | + * @var $filter_name string |
|
18 | + */ |
|
19 | + private $filter_name; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Async_Template_Decorator constructor. |
|
23 | - * |
|
24 | - * @param $shortcode_instance \Wordlift_Shortcode |
|
25 | - */ |
|
26 | - public function __construct( $shortcode_instance ) { |
|
27 | - $this->rest_url_name = $this->get_widget_name( $shortcode_instance ); |
|
28 | - $this->filter_name = str_replace( '-', '_', $this->rest_url_name ); |
|
29 | - add_action( 'rest_api_init', array( $this, 'register_template_route' ) ); |
|
30 | - } |
|
21 | + /** |
|
22 | + * Async_Template_Decorator constructor. |
|
23 | + * |
|
24 | + * @param $shortcode_instance \Wordlift_Shortcode |
|
25 | + */ |
|
26 | + public function __construct( $shortcode_instance ) { |
|
27 | + $this->rest_url_name = $this->get_widget_name( $shortcode_instance ); |
|
28 | + $this->filter_name = str_replace( '-', '_', $this->rest_url_name ); |
|
29 | + add_action( 'rest_api_init', array( $this, 'register_template_route' ) ); |
|
30 | + } |
|
31 | 31 | |
32 | - public function register_template_route() { |
|
32 | + public function register_template_route() { |
|
33 | 33 | |
34 | - register_rest_route( |
|
35 | - WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
36 | - "/{$this->rest_url_name}/template/", |
|
37 | - array( |
|
38 | - 'methods' => \WP_REST_Server::CREATABLE, |
|
39 | - 'callback' => array( $this, 'get_template' ), |
|
40 | - /** |
|
41 | - * We want this endpoint to be publicly accessible |
|
42 | - */ |
|
43 | - 'permission_callback' => '__return_true', |
|
44 | - 'args' => array( |
|
45 | - 'template_id' => array( |
|
46 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
47 | - 'validate_callback' => function ( $param, $request, $key ) { |
|
48 | - return is_string( $param ) && $param; |
|
49 | - }, |
|
50 | - ), |
|
51 | - ), |
|
52 | - ) |
|
53 | - ); |
|
54 | - } |
|
34 | + register_rest_route( |
|
35 | + WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
36 | + "/{$this->rest_url_name}/template/", |
|
37 | + array( |
|
38 | + 'methods' => \WP_REST_Server::CREATABLE, |
|
39 | + 'callback' => array( $this, 'get_template' ), |
|
40 | + /** |
|
41 | + * We want this endpoint to be publicly accessible |
|
42 | + */ |
|
43 | + 'permission_callback' => '__return_true', |
|
44 | + 'args' => array( |
|
45 | + 'template_id' => array( |
|
46 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
47 | + 'validate_callback' => function ( $param, $request, $key ) { |
|
48 | + return is_string( $param ) && $param; |
|
49 | + }, |
|
50 | + ), |
|
51 | + ), |
|
52 | + ) |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Shortcode widget makes call to this endpoint to get the template. |
|
58 | - * Takes the request, checks if template id is registered via filter, |
|
59 | - * if not it returns empty. |
|
60 | - * |
|
61 | - * @param $request \WP_REST_Request |
|
62 | - * |
|
63 | - * @return string Returns the template string. |
|
64 | - */ |
|
65 | - public function get_template( $request ) { |
|
66 | - $data = $request->get_params(); |
|
67 | - $template_id = (string) $data['template_id']; |
|
68 | - $templates = apply_filters( "wordlift_{$this->filter_name}_templates", array() ); |
|
69 | - $template = array_key_exists( $template_id, $templates ) ? $templates[ $template_id ] : ''; |
|
56 | + /** |
|
57 | + * Shortcode widget makes call to this endpoint to get the template. |
|
58 | + * Takes the request, checks if template id is registered via filter, |
|
59 | + * if not it returns empty. |
|
60 | + * |
|
61 | + * @param $request \WP_REST_Request |
|
62 | + * |
|
63 | + * @return string Returns the template string. |
|
64 | + */ |
|
65 | + public function get_template( $request ) { |
|
66 | + $data = $request->get_params(); |
|
67 | + $template_id = (string) $data['template_id']; |
|
68 | + $templates = apply_filters( "wordlift_{$this->filter_name}_templates", array() ); |
|
69 | + $template = array_key_exists( $template_id, $templates ) ? $templates[ $template_id ] : ''; |
|
70 | 70 | |
71 | - return array( 'template' => $template ); |
|
72 | - } |
|
71 | + return array( 'template' => $template ); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @param $shortcode_instance \Wordlift_Shortcode |
|
76 | - * |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - private static function get_widget_name( $shortcode_instance ) { |
|
80 | - $name = str_replace( 'wl_', '', $shortcode_instance::SHORTCODE ); |
|
74 | + /** |
|
75 | + * @param $shortcode_instance \Wordlift_Shortcode |
|
76 | + * |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + private static function get_widget_name( $shortcode_instance ) { |
|
80 | + $name = str_replace( 'wl_', '', $shortcode_instance::SHORTCODE ); |
|
81 | 81 | |
82 | - return str_replace( '_', '-', $name ); |
|
83 | - } |
|
82 | + return str_replace( '_', '-', $name ); |
|
83 | + } |
|
84 | 84 | |
85 | 85 | } |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param $shortcode_instance \Wordlift_Shortcode |
25 | 25 | */ |
26 | - public function __construct( $shortcode_instance ) { |
|
27 | - $this->rest_url_name = $this->get_widget_name( $shortcode_instance ); |
|
28 | - $this->filter_name = str_replace( '-', '_', $this->rest_url_name ); |
|
29 | - add_action( 'rest_api_init', array( $this, 'register_template_route' ) ); |
|
26 | + public function __construct($shortcode_instance) { |
|
27 | + $this->rest_url_name = $this->get_widget_name($shortcode_instance); |
|
28 | + $this->filter_name = str_replace('-', '_', $this->rest_url_name); |
|
29 | + add_action('rest_api_init', array($this, 'register_template_route')); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function register_template_route() { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | "/{$this->rest_url_name}/template/", |
37 | 37 | array( |
38 | 38 | 'methods' => \WP_REST_Server::CREATABLE, |
39 | - 'callback' => array( $this, 'get_template' ), |
|
39 | + 'callback' => array($this, 'get_template'), |
|
40 | 40 | /** |
41 | 41 | * We want this endpoint to be publicly accessible |
42 | 42 | */ |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | 'args' => array( |
45 | 45 | 'template_id' => array( |
46 | 46 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
47 | - 'validate_callback' => function ( $param, $request, $key ) { |
|
48 | - return is_string( $param ) && $param; |
|
47 | + 'validate_callback' => function($param, $request, $key) { |
|
48 | + return is_string($param) && $param; |
|
49 | 49 | }, |
50 | 50 | ), |
51 | 51 | ), |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return string Returns the template string. |
64 | 64 | */ |
65 | - public function get_template( $request ) { |
|
65 | + public function get_template($request) { |
|
66 | 66 | $data = $request->get_params(); |
67 | 67 | $template_id = (string) $data['template_id']; |
68 | - $templates = apply_filters( "wordlift_{$this->filter_name}_templates", array() ); |
|
69 | - $template = array_key_exists( $template_id, $templates ) ? $templates[ $template_id ] : ''; |
|
68 | + $templates = apply_filters("wordlift_{$this->filter_name}_templates", array()); |
|
69 | + $template = array_key_exists($template_id, $templates) ? $templates[$template_id] : ''; |
|
70 | 70 | |
71 | - return array( 'template' => $template ); |
|
71 | + return array('template' => $template); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return string |
78 | 78 | */ |
79 | - private static function get_widget_name( $shortcode_instance ) { |
|
80 | - $name = str_replace( 'wl_', '', $shortcode_instance::SHORTCODE ); |
|
79 | + private static function get_widget_name($shortcode_instance) { |
|
80 | + $name = str_replace('wl_', '', $shortcode_instance::SHORTCODE); |
|
81 | 81 | |
82 | - return str_replace( '_', '-', $name ); |
|
82 | + return str_replace('_', '-', $name); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | } |
@@ -8,53 +8,53 @@ |
||
8 | 8 | */ |
9 | 9 | class Srcset_Util { |
10 | 10 | |
11 | - const NAVIGATOR_WIDGET = 'navigator'; |
|
12 | - |
|
13 | - const FACETED_SEARCH_WIDGET = 'faceted_search'; |
|
14 | - |
|
15 | - public static function get_srcset( $post_id, $widget_name ) { |
|
16 | - |
|
17 | - $srcset = array(); |
|
18 | - $medium = get_the_post_thumbnail_url( $post_id, 'medium' ); |
|
19 | - $large = get_the_post_thumbnail_url( $post_id, 'large' ); |
|
20 | - |
|
21 | - $width = self::get_image_width( $post_id, 'medium' ); |
|
22 | - if ( $medium && $width ) { |
|
23 | - $srcset[] = $medium . ' ' . $width . 'w'; |
|
24 | - } |
|
25 | - |
|
26 | - $width = self::get_image_width( $post_id, 'large' ); |
|
27 | - if ( $large && $width ) { |
|
28 | - $srcset[] = $large . ' ' . $width . 'w'; |
|
29 | - } |
|
30 | - |
|
31 | - $srcset_string = join( ',', $srcset ); |
|
32 | - |
|
33 | - /** |
|
34 | - * Filter name: wordlift_${widget_name}_thumbnail_srcset |
|
35 | - * Filters the srcset string supplied to widgets for each post. |
|
36 | - * |
|
37 | - * @param $srcset_string string The srcset string |
|
38 | - * |
|
39 | - * @since 3.28.0 |
|
40 | - */ |
|
41 | - $srcset_string = apply_filters( "wordlift_${widget_name}_thumbnail_srcset", $srcset_string ); |
|
42 | - |
|
43 | - return $srcset_string; |
|
44 | - |
|
45 | - } |
|
46 | - |
|
47 | - private static function get_image_width( $post_id, $size ) { |
|
48 | - $thumbnail_id = get_post_thumbnail_id( $post_id ); |
|
49 | - if ( ! $thumbnail_id ) { |
|
50 | - return false; |
|
51 | - } |
|
52 | - $data = wp_get_attachment_image_src( $thumbnail_id, $size ); |
|
53 | - if ( ! $data ) { |
|
54 | - return false; |
|
55 | - } |
|
56 | - |
|
57 | - return array_key_exists( 2, $data ) ? $data[2] : false; |
|
58 | - } |
|
11 | + const NAVIGATOR_WIDGET = 'navigator'; |
|
12 | + |
|
13 | + const FACETED_SEARCH_WIDGET = 'faceted_search'; |
|
14 | + |
|
15 | + public static function get_srcset( $post_id, $widget_name ) { |
|
16 | + |
|
17 | + $srcset = array(); |
|
18 | + $medium = get_the_post_thumbnail_url( $post_id, 'medium' ); |
|
19 | + $large = get_the_post_thumbnail_url( $post_id, 'large' ); |
|
20 | + |
|
21 | + $width = self::get_image_width( $post_id, 'medium' ); |
|
22 | + if ( $medium && $width ) { |
|
23 | + $srcset[] = $medium . ' ' . $width . 'w'; |
|
24 | + } |
|
25 | + |
|
26 | + $width = self::get_image_width( $post_id, 'large' ); |
|
27 | + if ( $large && $width ) { |
|
28 | + $srcset[] = $large . ' ' . $width . 'w'; |
|
29 | + } |
|
30 | + |
|
31 | + $srcset_string = join( ',', $srcset ); |
|
32 | + |
|
33 | + /** |
|
34 | + * Filter name: wordlift_${widget_name}_thumbnail_srcset |
|
35 | + * Filters the srcset string supplied to widgets for each post. |
|
36 | + * |
|
37 | + * @param $srcset_string string The srcset string |
|
38 | + * |
|
39 | + * @since 3.28.0 |
|
40 | + */ |
|
41 | + $srcset_string = apply_filters( "wordlift_${widget_name}_thumbnail_srcset", $srcset_string ); |
|
42 | + |
|
43 | + return $srcset_string; |
|
44 | + |
|
45 | + } |
|
46 | + |
|
47 | + private static function get_image_width( $post_id, $size ) { |
|
48 | + $thumbnail_id = get_post_thumbnail_id( $post_id ); |
|
49 | + if ( ! $thumbnail_id ) { |
|
50 | + return false; |
|
51 | + } |
|
52 | + $data = wp_get_attachment_image_src( $thumbnail_id, $size ); |
|
53 | + if ( ! $data ) { |
|
54 | + return false; |
|
55 | + } |
|
56 | + |
|
57 | + return array_key_exists( 2, $data ) ? $data[2] : false; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | } |
@@ -12,23 +12,23 @@ discard block |
||
12 | 12 | |
13 | 13 | const FACETED_SEARCH_WIDGET = 'faceted_search'; |
14 | 14 | |
15 | - public static function get_srcset( $post_id, $widget_name ) { |
|
15 | + public static function get_srcset($post_id, $widget_name) { |
|
16 | 16 | |
17 | 17 | $srcset = array(); |
18 | - $medium = get_the_post_thumbnail_url( $post_id, 'medium' ); |
|
19 | - $large = get_the_post_thumbnail_url( $post_id, 'large' ); |
|
18 | + $medium = get_the_post_thumbnail_url($post_id, 'medium'); |
|
19 | + $large = get_the_post_thumbnail_url($post_id, 'large'); |
|
20 | 20 | |
21 | - $width = self::get_image_width( $post_id, 'medium' ); |
|
22 | - if ( $medium && $width ) { |
|
23 | - $srcset[] = $medium . ' ' . $width . 'w'; |
|
21 | + $width = self::get_image_width($post_id, 'medium'); |
|
22 | + if ($medium && $width) { |
|
23 | + $srcset[] = $medium.' '.$width.'w'; |
|
24 | 24 | } |
25 | 25 | |
26 | - $width = self::get_image_width( $post_id, 'large' ); |
|
27 | - if ( $large && $width ) { |
|
28 | - $srcset[] = $large . ' ' . $width . 'w'; |
|
26 | + $width = self::get_image_width($post_id, 'large'); |
|
27 | + if ($large && $width) { |
|
28 | + $srcset[] = $large.' '.$width.'w'; |
|
29 | 29 | } |
30 | 30 | |
31 | - $srcset_string = join( ',', $srcset ); |
|
31 | + $srcset_string = join(',', $srcset); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Filter name: wordlift_${widget_name}_thumbnail_srcset |
@@ -38,23 +38,23 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @since 3.28.0 |
40 | 40 | */ |
41 | - $srcset_string = apply_filters( "wordlift_${widget_name}_thumbnail_srcset", $srcset_string ); |
|
41 | + $srcset_string = apply_filters("wordlift_${widget_name}_thumbnail_srcset", $srcset_string); |
|
42 | 42 | |
43 | 43 | return $srcset_string; |
44 | 44 | |
45 | 45 | } |
46 | 46 | |
47 | - private static function get_image_width( $post_id, $size ) { |
|
48 | - $thumbnail_id = get_post_thumbnail_id( $post_id ); |
|
49 | - if ( ! $thumbnail_id ) { |
|
47 | + private static function get_image_width($post_id, $size) { |
|
48 | + $thumbnail_id = get_post_thumbnail_id($post_id); |
|
49 | + if ( ! $thumbnail_id) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | - $data = wp_get_attachment_image_src( $thumbnail_id, $size ); |
|
53 | - if ( ! $data ) { |
|
52 | + $data = wp_get_attachment_image_src($thumbnail_id, $size); |
|
53 | + if ( ! $data) { |
|
54 | 54 | return false; |
55 | 55 | } |
56 | 56 | |
57 | - return array_key_exists( 2, $data ) ? $data[2] : false; |
|
57 | + return array_key_exists(2, $data) ? $data[2] : false; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | } |
@@ -8,54 +8,54 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class Navigator_Data { |
10 | 10 | |
11 | - public static function get_post_types_as_string( $post_types ) { |
|
12 | - if ( array() === $post_types ) { |
|
13 | - $post_types = get_post_types(); |
|
14 | - } |
|
15 | - $post_types = array_map( |
|
16 | - function ( $post_type ) { |
|
17 | - return "'" . esc_sql( $post_type ) . "'"; |
|
18 | - }, |
|
19 | - $post_types |
|
20 | - ); |
|
11 | + public static function get_post_types_as_string( $post_types ) { |
|
12 | + if ( array() === $post_types ) { |
|
13 | + $post_types = get_post_types(); |
|
14 | + } |
|
15 | + $post_types = array_map( |
|
16 | + function ( $post_type ) { |
|
17 | + return "'" . esc_sql( $post_type ) . "'"; |
|
18 | + }, |
|
19 | + $post_types |
|
20 | + ); |
|
21 | 21 | |
22 | - return implode( ',', $post_types ); |
|
23 | - } |
|
22 | + return implode( ',', $post_types ); |
|
23 | + } |
|
24 | 24 | |
25 | - public static function post_navigator_get_results( |
|
26 | - $post_id, $fields = array( |
|
27 | - 'ID', |
|
28 | - 'post_title', |
|
29 | - ), $order_by = 'ID DESC', $limit = 10, $offset = 0, $post_types = array() |
|
30 | - ) { |
|
25 | + public static function post_navigator_get_results( |
|
26 | + $post_id, $fields = array( |
|
27 | + 'ID', |
|
28 | + 'post_title', |
|
29 | + ), $order_by = 'ID DESC', $limit = 10, $offset = 0, $post_types = array() |
|
30 | + ) { |
|
31 | 31 | |
32 | - $post_types = self::get_post_types_as_string( $post_types ); |
|
33 | - global $wpdb; |
|
32 | + $post_types = self::get_post_types_as_string( $post_types ); |
|
33 | + global $wpdb; |
|
34 | 34 | |
35 | - $select = implode( |
|
36 | - ', ', |
|
37 | - array_map( |
|
38 | - function ( $item ) { |
|
39 | - return "p.$item AS $item"; |
|
40 | - }, |
|
41 | - (array) $fields |
|
42 | - ) |
|
43 | - ); |
|
35 | + $select = implode( |
|
36 | + ', ', |
|
37 | + array_map( |
|
38 | + function ( $item ) { |
|
39 | + return "p.$item AS $item"; |
|
40 | + }, |
|
41 | + (array) $fields |
|
42 | + ) |
|
43 | + ); |
|
44 | 44 | |
45 | - $order_by = implode( |
|
46 | - ', ', |
|
47 | - array_map( |
|
48 | - function ( $item ) { |
|
49 | - return "p.$item"; |
|
50 | - }, |
|
51 | - (array) $order_by |
|
52 | - ) |
|
53 | - ); |
|
45 | + $order_by = implode( |
|
46 | + ', ', |
|
47 | + array_map( |
|
48 | + function ( $item ) { |
|
49 | + return "p.$item"; |
|
50 | + }, |
|
51 | + (array) $order_by |
|
52 | + ) |
|
53 | + ); |
|
54 | 54 | // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder |
55 | - /** @noinspection SqlNoDataSourceInspection */ |
|
56 | - return $wpdb->get_results( |
|
57 | - $wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber |
|
58 | - " |
|
55 | + /** @noinspection SqlNoDataSourceInspection */ |
|
56 | + return $wpdb->get_results( |
|
57 | + $wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber |
|
58 | + " |
|
59 | 59 | SELECT %4\$s, p2.ID as entity_id |
60 | 60 | FROM {$wpdb->prefix}wl_relation_instances r1 |
61 | 61 | INNER JOIN {$wpdb->prefix}wl_relation_instances r2 |
@@ -89,50 +89,50 @@ discard block |
||
89 | 89 | LIMIT %2\$d |
90 | 90 | OFFSET %3\$d |
91 | 91 | ", |
92 | - $post_id, |
|
93 | - $limit, |
|
94 | - $offset, |
|
95 | - $select, |
|
96 | - $order_by |
|
97 | - ) |
|
98 | - ); |
|
92 | + $post_id, |
|
93 | + $limit, |
|
94 | + $offset, |
|
95 | + $select, |
|
96 | + $order_by |
|
97 | + ) |
|
98 | + ); |
|
99 | 99 | // phpcs:enable |
100 | - } |
|
100 | + } |
|
101 | 101 | |
102 | - public static function entity_navigator_get_results( |
|
103 | - $post_id, $fields = array( |
|
104 | - 'ID', |
|
105 | - 'post_title', |
|
106 | - ), $order_by = 'ID DESC', $limit = 10, $offset = 0, $post_types = array() |
|
107 | - ) { |
|
108 | - global $wpdb; |
|
102 | + public static function entity_navigator_get_results( |
|
103 | + $post_id, $fields = array( |
|
104 | + 'ID', |
|
105 | + 'post_title', |
|
106 | + ), $order_by = 'ID DESC', $limit = 10, $offset = 0, $post_types = array() |
|
107 | + ) { |
|
108 | + global $wpdb; |
|
109 | 109 | |
110 | - $select = implode( |
|
111 | - ', ', |
|
112 | - array_map( |
|
113 | - function ( $item ) { |
|
114 | - return "p.$item AS $item"; |
|
115 | - }, |
|
116 | - (array) $fields |
|
117 | - ) |
|
118 | - ); |
|
110 | + $select = implode( |
|
111 | + ', ', |
|
112 | + array_map( |
|
113 | + function ( $item ) { |
|
114 | + return "p.$item AS $item"; |
|
115 | + }, |
|
116 | + (array) $fields |
|
117 | + ) |
|
118 | + ); |
|
119 | 119 | |
120 | - $order_by = implode( |
|
121 | - ', ', |
|
122 | - array_map( |
|
123 | - function ( $item ) { |
|
124 | - return "p.$item"; |
|
125 | - }, |
|
126 | - (array) $order_by |
|
127 | - ) |
|
128 | - ); |
|
120 | + $order_by = implode( |
|
121 | + ', ', |
|
122 | + array_map( |
|
123 | + function ( $item ) { |
|
124 | + return "p.$item"; |
|
125 | + }, |
|
126 | + (array) $order_by |
|
127 | + ) |
|
128 | + ); |
|
129 | 129 | |
130 | - $post_types = self::get_post_types_as_string( $post_types ); |
|
130 | + $post_types = self::get_post_types_as_string( $post_types ); |
|
131 | 131 | // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder |
132 | - /** @noinspection SqlNoDataSourceInspection */ |
|
133 | - return $wpdb->get_results( |
|
134 | - $wpdb->prepare( |
|
135 | - " |
|
132 | + /** @noinspection SqlNoDataSourceInspection */ |
|
133 | + return $wpdb->get_results( |
|
134 | + $wpdb->prepare( |
|
135 | + " |
|
136 | 136 | SELECT %4\$s, p2.ID as entity_id |
137 | 137 | FROM {$wpdb->prefix}wl_relation_instances r1 |
138 | 138 | -- get the ID of the post entity in common between the object and the subject 2. |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | LIMIT %2\$d |
164 | 164 | OFFSET %3\$d |
165 | 165 | ", |
166 | - $post_id, |
|
167 | - $limit, |
|
168 | - $offset, |
|
169 | - $select, |
|
170 | - $order_by |
|
171 | - ) |
|
172 | - ); |
|
173 | - } |
|
166 | + $post_id, |
|
167 | + $limit, |
|
168 | + $offset, |
|
169 | + $select, |
|
170 | + $order_by |
|
171 | + ) |
|
172 | + ); |
|
173 | + } |
|
174 | 174 | // phpcs:enable |
175 | 175 | } |
176 | 176 |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class Navigator_Data { |
10 | 10 | |
11 | - public static function get_post_types_as_string( $post_types ) { |
|
12 | - if ( array() === $post_types ) { |
|
11 | + public static function get_post_types_as_string($post_types) { |
|
12 | + if (array() === $post_types) { |
|
13 | 13 | $post_types = get_post_types(); |
14 | 14 | } |
15 | 15 | $post_types = array_map( |
16 | - function ( $post_type ) { |
|
17 | - return "'" . esc_sql( $post_type ) . "'"; |
|
16 | + function($post_type) { |
|
17 | + return "'".esc_sql($post_type)."'"; |
|
18 | 18 | }, |
19 | 19 | $post_types |
20 | 20 | ); |
21 | 21 | |
22 | - return implode( ',', $post_types ); |
|
22 | + return implode(',', $post_types); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public static function post_navigator_get_results( |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | ), $order_by = 'ID DESC', $limit = 10, $offset = 0, $post_types = array() |
30 | 30 | ) { |
31 | 31 | |
32 | - $post_types = self::get_post_types_as_string( $post_types ); |
|
32 | + $post_types = self::get_post_types_as_string($post_types); |
|
33 | 33 | global $wpdb; |
34 | 34 | |
35 | 35 | $select = implode( |
36 | 36 | ', ', |
37 | 37 | array_map( |
38 | - function ( $item ) { |
|
38 | + function($item) { |
|
39 | 39 | return "p.$item AS $item"; |
40 | 40 | }, |
41 | 41 | (array) $fields |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $order_by = implode( |
46 | 46 | ', ', |
47 | 47 | array_map( |
48 | - function ( $item ) { |
|
48 | + function($item) { |
|
49 | 49 | return "p.$item"; |
50 | 50 | }, |
51 | 51 | (array) $order_by |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $select = implode( |
111 | 111 | ', ', |
112 | 112 | array_map( |
113 | - function ( $item ) { |
|
113 | + function($item) { |
|
114 | 114 | return "p.$item AS $item"; |
115 | 115 | }, |
116 | 116 | (array) $fields |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | $order_by = implode( |
121 | 121 | ', ', |
122 | 122 | array_map( |
123 | - function ( $item ) { |
|
123 | + function($item) { |
|
124 | 124 | return "p.$item"; |
125 | 125 | }, |
126 | 126 | (array) $order_by |
127 | 127 | ) |
128 | 128 | ); |
129 | 129 | |
130 | - $post_types = self::get_post_types_as_string( $post_types ); |
|
130 | + $post_types = self::get_post_types_as_string($post_types); |
|
131 | 131 | // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder |
132 | 132 | /** @noinspection SqlNoDataSourceInspection */ |
133 | 133 | return $wpdb->get_results( |
@@ -16,17 +16,17 @@ |
||
16 | 16 | */ |
17 | 17 | class Same_Category_Filler_Posts extends Filler_Posts { |
18 | 18 | |
19 | - public function get_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
19 | + public function get_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
20 | 20 | |
21 | - $current_post_categories = wp_get_post_categories( $this->post_id ); |
|
22 | - $post_type = $this->alternate_post_type ? $this->alternate_post_type : get_post_types(); |
|
21 | + $current_post_categories = wp_get_post_categories( $this->post_id ); |
|
22 | + $post_type = $this->alternate_post_type ? $this->alternate_post_type : get_post_types(); |
|
23 | 23 | |
24 | - return get_posts( |
|
25 | - array( |
|
26 | - 'category__in' => $current_post_categories, |
|
27 | - 'post_type' => $post_type, |
|
28 | - ) |
|
29 | - + $this->get_posts_config( $filler_count, $post_ids_to_be_excluded ) |
|
30 | - ); |
|
31 | - } |
|
24 | + return get_posts( |
|
25 | + array( |
|
26 | + 'category__in' => $current_post_categories, |
|
27 | + 'post_type' => $post_type, |
|
28 | + ) |
|
29 | + + $this->get_posts_config( $filler_count, $post_ids_to_be_excluded ) |
|
30 | + ); |
|
31 | + } |
|
32 | 32 | } |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class Same_Category_Filler_Posts extends Filler_Posts { |
18 | 18 | |
19 | - public function get_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
19 | + public function get_posts($filler_count, $post_ids_to_be_excluded) { |
|
20 | 20 | |
21 | - $current_post_categories = wp_get_post_categories( $this->post_id ); |
|
21 | + $current_post_categories = wp_get_post_categories($this->post_id); |
|
22 | 22 | $post_type = $this->alternate_post_type ? $this->alternate_post_type : get_post_types(); |
23 | 23 | |
24 | 24 | return get_posts( |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | 'category__in' => $current_post_categories, |
27 | 27 | 'post_type' => $post_type, |
28 | 28 | ) |
29 | - + $this->get_posts_config( $filler_count, $post_ids_to_be_excluded ) |
|
29 | + + $this->get_posts_config($filler_count, $post_ids_to_be_excluded) |
|
30 | 30 | ); |
31 | 31 | } |
32 | 32 | } |
@@ -8,16 +8,16 @@ |
||
8 | 8 | */ |
9 | 9 | class Same_Post_Type_Same_Category_Posts extends Filler_Posts { |
10 | 10 | |
11 | - public function get_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
12 | - $current_post_categories = wp_get_post_categories( $this->post_id ); |
|
13 | - $post_type = $this->alternate_post_type ? $this->alternate_post_type : get_post_type( $this->post_id ); |
|
11 | + public function get_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
12 | + $current_post_categories = wp_get_post_categories( $this->post_id ); |
|
13 | + $post_type = $this->alternate_post_type ? $this->alternate_post_type : get_post_type( $this->post_id ); |
|
14 | 14 | |
15 | - return get_posts( |
|
16 | - array( |
|
17 | - 'category__in' => $current_post_categories, |
|
18 | - 'post_type' => $post_type, |
|
19 | - ) |
|
20 | - + $this->get_posts_config( $filler_count, $post_ids_to_be_excluded ) |
|
21 | - ); |
|
22 | - } |
|
15 | + return get_posts( |
|
16 | + array( |
|
17 | + 'category__in' => $current_post_categories, |
|
18 | + 'post_type' => $post_type, |
|
19 | + ) |
|
20 | + + $this->get_posts_config( $filler_count, $post_ids_to_be_excluded ) |
|
21 | + ); |
|
22 | + } |
|
23 | 23 | } |
@@ -8,16 +8,16 @@ |
||
8 | 8 | */ |
9 | 9 | class Same_Post_Type_Same_Category_Posts extends Filler_Posts { |
10 | 10 | |
11 | - public function get_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
12 | - $current_post_categories = wp_get_post_categories( $this->post_id ); |
|
13 | - $post_type = $this->alternate_post_type ? $this->alternate_post_type : get_post_type( $this->post_id ); |
|
11 | + public function get_posts($filler_count, $post_ids_to_be_excluded) { |
|
12 | + $current_post_categories = wp_get_post_categories($this->post_id); |
|
13 | + $post_type = $this->alternate_post_type ? $this->alternate_post_type : get_post_type($this->post_id); |
|
14 | 14 | |
15 | 15 | return get_posts( |
16 | 16 | array( |
17 | 17 | 'category__in' => $current_post_categories, |
18 | 18 | 'post_type' => $post_type, |
19 | 19 | ) |
20 | - + $this->get_posts_config( $filler_count, $post_ids_to_be_excluded ) |
|
20 | + + $this->get_posts_config($filler_count, $post_ids_to_be_excluded) |
|
21 | 21 | ); |
22 | 22 | } |
23 | 23 | } |
@@ -8,54 +8,54 @@ |
||
8 | 8 | */ |
9 | 9 | abstract class Filler_Posts { |
10 | 10 | |
11 | - /** |
|
12 | - * @var int |
|
13 | - */ |
|
14 | - public $filler_count; |
|
15 | - |
|
16 | - /** |
|
17 | - * @var array<int> |
|
18 | - */ |
|
19 | - public $post_ids_to_be_excluded; |
|
20 | - |
|
21 | - /** |
|
22 | - * @var $post_id int |
|
23 | - */ |
|
24 | - protected $post_id; |
|
25 | - |
|
26 | - /** |
|
27 | - * Filler_Posts constructor. |
|
28 | - * |
|
29 | - * @param $post_id |
|
30 | - */ |
|
31 | - public function __construct( $post_id, $alternate_post_type = null ) { |
|
32 | - |
|
33 | - $this->post_id = $post_id; |
|
34 | - $this->alternate_post_type = $alternate_post_type; |
|
35 | - |
|
36 | - } |
|
37 | - |
|
38 | - protected function get_posts_config( $filler_count, $post_ids_to_be_excluded ) { |
|
39 | - |
|
40 | - return array( |
|
41 | - 'meta_query' => array( |
|
42 | - array( |
|
43 | - 'key' => '_thumbnail_id', |
|
44 | - ), |
|
45 | - ), |
|
46 | - 'numberposts' => $filler_count, |
|
47 | - 'post__not_in' => $post_ids_to_be_excluded, |
|
48 | - 'ignore_sticky_posts' => 1, |
|
49 | - ); |
|
50 | - |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * @param $filler_count |
|
55 | - * @param $post_ids_to_be_excluded |
|
56 | - * |
|
57 | - * @return array<\WP_Post> |
|
58 | - */ |
|
59 | - abstract public function get_posts( $filler_count, $post_ids_to_be_excluded ); |
|
11 | + /** |
|
12 | + * @var int |
|
13 | + */ |
|
14 | + public $filler_count; |
|
15 | + |
|
16 | + /** |
|
17 | + * @var array<int> |
|
18 | + */ |
|
19 | + public $post_ids_to_be_excluded; |
|
20 | + |
|
21 | + /** |
|
22 | + * @var $post_id int |
|
23 | + */ |
|
24 | + protected $post_id; |
|
25 | + |
|
26 | + /** |
|
27 | + * Filler_Posts constructor. |
|
28 | + * |
|
29 | + * @param $post_id |
|
30 | + */ |
|
31 | + public function __construct( $post_id, $alternate_post_type = null ) { |
|
32 | + |
|
33 | + $this->post_id = $post_id; |
|
34 | + $this->alternate_post_type = $alternate_post_type; |
|
35 | + |
|
36 | + } |
|
37 | + |
|
38 | + protected function get_posts_config( $filler_count, $post_ids_to_be_excluded ) { |
|
39 | + |
|
40 | + return array( |
|
41 | + 'meta_query' => array( |
|
42 | + array( |
|
43 | + 'key' => '_thumbnail_id', |
|
44 | + ), |
|
45 | + ), |
|
46 | + 'numberposts' => $filler_count, |
|
47 | + 'post__not_in' => $post_ids_to_be_excluded, |
|
48 | + 'ignore_sticky_posts' => 1, |
|
49 | + ); |
|
50 | + |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * @param $filler_count |
|
55 | + * @param $post_ids_to_be_excluded |
|
56 | + * |
|
57 | + * @return array<\WP_Post> |
|
58 | + */ |
|
59 | + abstract public function get_posts( $filler_count, $post_ids_to_be_excluded ); |
|
60 | 60 | |
61 | 61 | } |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param $post_id |
30 | 30 | */ |
31 | - public function __construct( $post_id, $alternate_post_type = null ) { |
|
31 | + public function __construct($post_id, $alternate_post_type = null) { |
|
32 | 32 | |
33 | 33 | $this->post_id = $post_id; |
34 | 34 | $this->alternate_post_type = $alternate_post_type; |
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | - protected function get_posts_config( $filler_count, $post_ids_to_be_excluded ) { |
|
38 | + protected function get_posts_config($filler_count, $post_ids_to_be_excluded) { |
|
39 | 39 | |
40 | 40 | return array( |
41 | 41 | 'meta_query' => array( |
@@ -56,6 +56,6 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return array<\WP_Post> |
58 | 58 | */ |
59 | - abstract public function get_posts( $filler_count, $post_ids_to_be_excluded ); |
|
59 | + abstract public function get_posts($filler_count, $post_ids_to_be_excluded); |
|
60 | 60 | |
61 | 61 | } |
@@ -10,161 +10,161 @@ |
||
10 | 10 | */ |
11 | 11 | class Filler_Posts_Util { |
12 | 12 | |
13 | - /** |
|
14 | - * @var array<Filler_Posts> |
|
15 | - */ |
|
16 | - private $sources = array(); |
|
17 | - |
|
18 | - public function __construct( $post_id, $alternate_post_type = null ) { |
|
19 | - |
|
20 | - $post_type = $alternate_post_type ? $alternate_post_type : get_post_type( $post_id ); |
|
21 | - |
|
22 | - if ( 'post' === $post_type || ( is_array( $post_type ) && in_array( 'post', $post_type, true ) ) ) { |
|
23 | - $this->sources = array( |
|
24 | - new Same_Category_Filler_Posts( $post_id ), |
|
25 | - new Same_Post_Type_Filler_Posts( $post_id ), |
|
26 | - ); |
|
27 | - } elseif ( 'product' === $post_type || ( is_array( $post_type ) && in_array( 'product', $post_type, true ) ) ) { |
|
28 | - $this->sources = array( |
|
29 | - new Same_Post_Type_Same_Category_Posts( $post_id, 'product' ), |
|
30 | - new Same_Post_Type_Filler_Posts( $post_id, 'product' ), |
|
31 | - ); |
|
32 | - } else { |
|
33 | - $this->sources = array( |
|
34 | - new Same_Post_Type_Filler_Posts( $post_id ), |
|
35 | - ); |
|
36 | - } |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * @param $posts array<\WP_Post> |
|
41 | - * |
|
42 | - * @return array<int> |
|
43 | - */ |
|
44 | - private function extract_post_ids( $posts ) { |
|
45 | - return array_map( |
|
46 | - function ( $post ) { |
|
47 | - /** |
|
48 | - * @var $post \WP_Post |
|
49 | - */ |
|
50 | - return $post->ID; |
|
51 | - }, |
|
52 | - $posts |
|
53 | - ); |
|
54 | - } |
|
55 | - |
|
56 | - public function get_filler_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
57 | - |
|
58 | - $filler_posts = array(); |
|
59 | - |
|
60 | - foreach ( $this->sources as $source ) { |
|
61 | - |
|
62 | - if ( $filler_count <= 0 ) { |
|
63 | - break; |
|
64 | - } |
|
65 | - /** |
|
66 | - * @var Filler_Posts $source |
|
67 | - */ |
|
68 | - $source->post_ids_to_be_excluded = $post_ids_to_be_excluded; |
|
69 | - $source->filler_count = $filler_count; |
|
70 | - |
|
71 | - $posts = $source->get_posts( $filler_count, $post_ids_to_be_excluded ); |
|
72 | - $post_ids = $this->extract_post_ids( $posts ); |
|
73 | - |
|
74 | - // Update the post ids, filler posts and filler count |
|
75 | - $post_ids_to_be_excluded = array_merge( $post_ids_to_be_excluded, $post_ids ); |
|
76 | - $filler_count = $filler_count - count( $posts ); |
|
77 | - $filler_posts = array_merge( $filler_posts, $posts ); |
|
78 | - } |
|
79 | - $filler_posts = $this->add_additional_properties_to_filler_posts( $filler_posts ); |
|
80 | - |
|
81 | - return $filler_posts; |
|
82 | - |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @param $posts array<\WP_Post> |
|
87 | - * |
|
88 | - * @return array $posts array<\WP_Post> |
|
89 | - */ |
|
90 | - private function add_additional_properties_to_filler_posts( $posts ) { |
|
91 | - return array_map( |
|
92 | - function ( $post ) { |
|
93 | - $post->thumbnail = get_the_post_thumbnail_url( $post->ID, 'medium' ); |
|
94 | - $post->permalink = get_permalink( $post->ID ); |
|
95 | - $post->post_title = html_entity_decode( $post->post_title, ENT_QUOTES, 'UTF-8' ); |
|
96 | - |
|
97 | - return $post; |
|
98 | - }, |
|
99 | - $posts |
|
100 | - ); |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Called by wordlift navigator, converts all the posts to response format. |
|
105 | - * |
|
106 | - * @param $filler_count |
|
107 | - * @param $post_ids_to_be_excluded |
|
108 | - * |
|
109 | - * @return array |
|
110 | - */ |
|
111 | - public function get_filler_response( $filler_count, $post_ids_to_be_excluded ) { |
|
112 | - $filler_posts = $this->get_filler_posts( $filler_count, $post_ids_to_be_excluded ); |
|
113 | - // Add thumbnail and permalink to filler posts |
|
114 | - $filler_response = array(); |
|
115 | - foreach ( $filler_posts as $post_obj ) { |
|
116 | - $thumbnail = get_the_post_thumbnail_url( $post_obj, 'medium' ); |
|
117 | - $filler_response[] = array( |
|
118 | - 'post' => array( |
|
119 | - 'id' => $post_obj->ID, |
|
120 | - 'permalink' => get_permalink( $post_obj->ID ), |
|
121 | - 'thumbnail' => ( $thumbnail ) ? $thumbnail : WL_DEFAULT_THUMBNAIL_PATH, |
|
122 | - 'title' => $post_obj->post_title, |
|
123 | - 'srcset' => Srcset_Util::get_srcset( $post_obj->ID, Srcset_Util::NAVIGATOR_WIDGET ), |
|
124 | - ), |
|
125 | - 'entity' => array( |
|
126 | - 'id' => 0, |
|
127 | - ), |
|
128 | - ); |
|
129 | - } |
|
130 | - |
|
131 | - return $filler_response; |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * Called by wordlift navigator, converts all the posts to response format. |
|
136 | - * |
|
137 | - * @param $filler_count |
|
138 | - * @param $post_ids_to_be_excluded |
|
139 | - * |
|
140 | - * @return array |
|
141 | - */ |
|
142 | - public function get_product_navigator_response( $filler_count, $post_ids_to_be_excluded ) { |
|
143 | - $filler_posts = $this->get_filler_posts( $filler_count, $post_ids_to_be_excluded ); |
|
144 | - // Add thumbnail and permalink to filler posts |
|
145 | - $filler_response = array(); |
|
146 | - foreach ( $filler_posts as $post_obj ) { |
|
147 | - $product = wc_get_product( $post_obj->ID ); |
|
148 | - $filler_response[] = array( |
|
149 | - 'product' => array( |
|
150 | - 'id' => $post_obj->ID, |
|
151 | - 'permalink' => get_permalink( $post_obj->ID ), |
|
152 | - 'title' => $post_obj->post_title, |
|
153 | - 'thumbnail' => get_the_post_thumbnail_url( $post_obj->ID, 'medium' ), |
|
154 | - 'regular_price' => $product->get_regular_price(), |
|
155 | - 'sale_price' => $product->get_sale_price(), |
|
156 | - 'price' => $product->get_price(), |
|
157 | - 'currency_symbol' => get_woocommerce_currency_symbol(), |
|
158 | - 'discount_pc' => ( $product->get_sale_price() && ( $product->get_regular_price() > 0 ) ) ? round( 1 - ( $product->get_sale_price() / $product->get_regular_price() ), 2 ) * 100 : 0, |
|
159 | - 'average_rating' => $product->get_average_rating(), |
|
160 | - 'rating_count' => $product->get_rating_count(), |
|
161 | - 'rating_html' => wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ), |
|
162 | - ), |
|
163 | - 'entity' => array(), |
|
164 | - ); |
|
165 | - } |
|
166 | - |
|
167 | - return $filler_response; |
|
168 | - } |
|
13 | + /** |
|
14 | + * @var array<Filler_Posts> |
|
15 | + */ |
|
16 | + private $sources = array(); |
|
17 | + |
|
18 | + public function __construct( $post_id, $alternate_post_type = null ) { |
|
19 | + |
|
20 | + $post_type = $alternate_post_type ? $alternate_post_type : get_post_type( $post_id ); |
|
21 | + |
|
22 | + if ( 'post' === $post_type || ( is_array( $post_type ) && in_array( 'post', $post_type, true ) ) ) { |
|
23 | + $this->sources = array( |
|
24 | + new Same_Category_Filler_Posts( $post_id ), |
|
25 | + new Same_Post_Type_Filler_Posts( $post_id ), |
|
26 | + ); |
|
27 | + } elseif ( 'product' === $post_type || ( is_array( $post_type ) && in_array( 'product', $post_type, true ) ) ) { |
|
28 | + $this->sources = array( |
|
29 | + new Same_Post_Type_Same_Category_Posts( $post_id, 'product' ), |
|
30 | + new Same_Post_Type_Filler_Posts( $post_id, 'product' ), |
|
31 | + ); |
|
32 | + } else { |
|
33 | + $this->sources = array( |
|
34 | + new Same_Post_Type_Filler_Posts( $post_id ), |
|
35 | + ); |
|
36 | + } |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * @param $posts array<\WP_Post> |
|
41 | + * |
|
42 | + * @return array<int> |
|
43 | + */ |
|
44 | + private function extract_post_ids( $posts ) { |
|
45 | + return array_map( |
|
46 | + function ( $post ) { |
|
47 | + /** |
|
48 | + * @var $post \WP_Post |
|
49 | + */ |
|
50 | + return $post->ID; |
|
51 | + }, |
|
52 | + $posts |
|
53 | + ); |
|
54 | + } |
|
55 | + |
|
56 | + public function get_filler_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
57 | + |
|
58 | + $filler_posts = array(); |
|
59 | + |
|
60 | + foreach ( $this->sources as $source ) { |
|
61 | + |
|
62 | + if ( $filler_count <= 0 ) { |
|
63 | + break; |
|
64 | + } |
|
65 | + /** |
|
66 | + * @var Filler_Posts $source |
|
67 | + */ |
|
68 | + $source->post_ids_to_be_excluded = $post_ids_to_be_excluded; |
|
69 | + $source->filler_count = $filler_count; |
|
70 | + |
|
71 | + $posts = $source->get_posts( $filler_count, $post_ids_to_be_excluded ); |
|
72 | + $post_ids = $this->extract_post_ids( $posts ); |
|
73 | + |
|
74 | + // Update the post ids, filler posts and filler count |
|
75 | + $post_ids_to_be_excluded = array_merge( $post_ids_to_be_excluded, $post_ids ); |
|
76 | + $filler_count = $filler_count - count( $posts ); |
|
77 | + $filler_posts = array_merge( $filler_posts, $posts ); |
|
78 | + } |
|
79 | + $filler_posts = $this->add_additional_properties_to_filler_posts( $filler_posts ); |
|
80 | + |
|
81 | + return $filler_posts; |
|
82 | + |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * @param $posts array<\WP_Post> |
|
87 | + * |
|
88 | + * @return array $posts array<\WP_Post> |
|
89 | + */ |
|
90 | + private function add_additional_properties_to_filler_posts( $posts ) { |
|
91 | + return array_map( |
|
92 | + function ( $post ) { |
|
93 | + $post->thumbnail = get_the_post_thumbnail_url( $post->ID, 'medium' ); |
|
94 | + $post->permalink = get_permalink( $post->ID ); |
|
95 | + $post->post_title = html_entity_decode( $post->post_title, ENT_QUOTES, 'UTF-8' ); |
|
96 | + |
|
97 | + return $post; |
|
98 | + }, |
|
99 | + $posts |
|
100 | + ); |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Called by wordlift navigator, converts all the posts to response format. |
|
105 | + * |
|
106 | + * @param $filler_count |
|
107 | + * @param $post_ids_to_be_excluded |
|
108 | + * |
|
109 | + * @return array |
|
110 | + */ |
|
111 | + public function get_filler_response( $filler_count, $post_ids_to_be_excluded ) { |
|
112 | + $filler_posts = $this->get_filler_posts( $filler_count, $post_ids_to_be_excluded ); |
|
113 | + // Add thumbnail and permalink to filler posts |
|
114 | + $filler_response = array(); |
|
115 | + foreach ( $filler_posts as $post_obj ) { |
|
116 | + $thumbnail = get_the_post_thumbnail_url( $post_obj, 'medium' ); |
|
117 | + $filler_response[] = array( |
|
118 | + 'post' => array( |
|
119 | + 'id' => $post_obj->ID, |
|
120 | + 'permalink' => get_permalink( $post_obj->ID ), |
|
121 | + 'thumbnail' => ( $thumbnail ) ? $thumbnail : WL_DEFAULT_THUMBNAIL_PATH, |
|
122 | + 'title' => $post_obj->post_title, |
|
123 | + 'srcset' => Srcset_Util::get_srcset( $post_obj->ID, Srcset_Util::NAVIGATOR_WIDGET ), |
|
124 | + ), |
|
125 | + 'entity' => array( |
|
126 | + 'id' => 0, |
|
127 | + ), |
|
128 | + ); |
|
129 | + } |
|
130 | + |
|
131 | + return $filler_response; |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * Called by wordlift navigator, converts all the posts to response format. |
|
136 | + * |
|
137 | + * @param $filler_count |
|
138 | + * @param $post_ids_to_be_excluded |
|
139 | + * |
|
140 | + * @return array |
|
141 | + */ |
|
142 | + public function get_product_navigator_response( $filler_count, $post_ids_to_be_excluded ) { |
|
143 | + $filler_posts = $this->get_filler_posts( $filler_count, $post_ids_to_be_excluded ); |
|
144 | + // Add thumbnail and permalink to filler posts |
|
145 | + $filler_response = array(); |
|
146 | + foreach ( $filler_posts as $post_obj ) { |
|
147 | + $product = wc_get_product( $post_obj->ID ); |
|
148 | + $filler_response[] = array( |
|
149 | + 'product' => array( |
|
150 | + 'id' => $post_obj->ID, |
|
151 | + 'permalink' => get_permalink( $post_obj->ID ), |
|
152 | + 'title' => $post_obj->post_title, |
|
153 | + 'thumbnail' => get_the_post_thumbnail_url( $post_obj->ID, 'medium' ), |
|
154 | + 'regular_price' => $product->get_regular_price(), |
|
155 | + 'sale_price' => $product->get_sale_price(), |
|
156 | + 'price' => $product->get_price(), |
|
157 | + 'currency_symbol' => get_woocommerce_currency_symbol(), |
|
158 | + 'discount_pc' => ( $product->get_sale_price() && ( $product->get_regular_price() > 0 ) ) ? round( 1 - ( $product->get_sale_price() / $product->get_regular_price() ), 2 ) * 100 : 0, |
|
159 | + 'average_rating' => $product->get_average_rating(), |
|
160 | + 'rating_count' => $product->get_rating_count(), |
|
161 | + 'rating_html' => wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ), |
|
162 | + ), |
|
163 | + 'entity' => array(), |
|
164 | + ); |
|
165 | + } |
|
166 | + |
|
167 | + return $filler_response; |
|
168 | + } |
|
169 | 169 | |
170 | 170 | } |
@@ -15,23 +15,23 @@ discard block |
||
15 | 15 | */ |
16 | 16 | private $sources = array(); |
17 | 17 | |
18 | - public function __construct( $post_id, $alternate_post_type = null ) { |
|
18 | + public function __construct($post_id, $alternate_post_type = null) { |
|
19 | 19 | |
20 | - $post_type = $alternate_post_type ? $alternate_post_type : get_post_type( $post_id ); |
|
20 | + $post_type = $alternate_post_type ? $alternate_post_type : get_post_type($post_id); |
|
21 | 21 | |
22 | - if ( 'post' === $post_type || ( is_array( $post_type ) && in_array( 'post', $post_type, true ) ) ) { |
|
22 | + if ('post' === $post_type || (is_array($post_type) && in_array('post', $post_type, true))) { |
|
23 | 23 | $this->sources = array( |
24 | - new Same_Category_Filler_Posts( $post_id ), |
|
25 | - new Same_Post_Type_Filler_Posts( $post_id ), |
|
24 | + new Same_Category_Filler_Posts($post_id), |
|
25 | + new Same_Post_Type_Filler_Posts($post_id), |
|
26 | 26 | ); |
27 | - } elseif ( 'product' === $post_type || ( is_array( $post_type ) && in_array( 'product', $post_type, true ) ) ) { |
|
27 | + } elseif ('product' === $post_type || (is_array($post_type) && in_array('product', $post_type, true))) { |
|
28 | 28 | $this->sources = array( |
29 | - new Same_Post_Type_Same_Category_Posts( $post_id, 'product' ), |
|
30 | - new Same_Post_Type_Filler_Posts( $post_id, 'product' ), |
|
29 | + new Same_Post_Type_Same_Category_Posts($post_id, 'product'), |
|
30 | + new Same_Post_Type_Filler_Posts($post_id, 'product'), |
|
31 | 31 | ); |
32 | 32 | } else { |
33 | 33 | $this->sources = array( |
34 | - new Same_Post_Type_Filler_Posts( $post_id ), |
|
34 | + new Same_Post_Type_Filler_Posts($post_id), |
|
35 | 35 | ); |
36 | 36 | } |
37 | 37 | } |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return array<int> |
43 | 43 | */ |
44 | - private function extract_post_ids( $posts ) { |
|
44 | + private function extract_post_ids($posts) { |
|
45 | 45 | return array_map( |
46 | - function ( $post ) { |
|
46 | + function($post) { |
|
47 | 47 | /** |
48 | 48 | * @var $post \WP_Post |
49 | 49 | */ |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | ); |
54 | 54 | } |
55 | 55 | |
56 | - public function get_filler_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
56 | + public function get_filler_posts($filler_count, $post_ids_to_be_excluded) { |
|
57 | 57 | |
58 | 58 | $filler_posts = array(); |
59 | 59 | |
60 | - foreach ( $this->sources as $source ) { |
|
60 | + foreach ($this->sources as $source) { |
|
61 | 61 | |
62 | - if ( $filler_count <= 0 ) { |
|
62 | + if ($filler_count <= 0) { |
|
63 | 63 | break; |
64 | 64 | } |
65 | 65 | /** |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | $source->post_ids_to_be_excluded = $post_ids_to_be_excluded; |
69 | 69 | $source->filler_count = $filler_count; |
70 | 70 | |
71 | - $posts = $source->get_posts( $filler_count, $post_ids_to_be_excluded ); |
|
72 | - $post_ids = $this->extract_post_ids( $posts ); |
|
71 | + $posts = $source->get_posts($filler_count, $post_ids_to_be_excluded); |
|
72 | + $post_ids = $this->extract_post_ids($posts); |
|
73 | 73 | |
74 | 74 | // Update the post ids, filler posts and filler count |
75 | - $post_ids_to_be_excluded = array_merge( $post_ids_to_be_excluded, $post_ids ); |
|
76 | - $filler_count = $filler_count - count( $posts ); |
|
77 | - $filler_posts = array_merge( $filler_posts, $posts ); |
|
75 | + $post_ids_to_be_excluded = array_merge($post_ids_to_be_excluded, $post_ids); |
|
76 | + $filler_count = $filler_count - count($posts); |
|
77 | + $filler_posts = array_merge($filler_posts, $posts); |
|
78 | 78 | } |
79 | - $filler_posts = $this->add_additional_properties_to_filler_posts( $filler_posts ); |
|
79 | + $filler_posts = $this->add_additional_properties_to_filler_posts($filler_posts); |
|
80 | 80 | |
81 | 81 | return $filler_posts; |
82 | 82 | |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return array $posts array<\WP_Post> |
89 | 89 | */ |
90 | - private function add_additional_properties_to_filler_posts( $posts ) { |
|
90 | + private function add_additional_properties_to_filler_posts($posts) { |
|
91 | 91 | return array_map( |
92 | - function ( $post ) { |
|
93 | - $post->thumbnail = get_the_post_thumbnail_url( $post->ID, 'medium' ); |
|
94 | - $post->permalink = get_permalink( $post->ID ); |
|
95 | - $post->post_title = html_entity_decode( $post->post_title, ENT_QUOTES, 'UTF-8' ); |
|
92 | + function($post) { |
|
93 | + $post->thumbnail = get_the_post_thumbnail_url($post->ID, 'medium'); |
|
94 | + $post->permalink = get_permalink($post->ID); |
|
95 | + $post->post_title = html_entity_decode($post->post_title, ENT_QUOTES, 'UTF-8'); |
|
96 | 96 | |
97 | 97 | return $post; |
98 | 98 | }, |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return array |
110 | 110 | */ |
111 | - public function get_filler_response( $filler_count, $post_ids_to_be_excluded ) { |
|
112 | - $filler_posts = $this->get_filler_posts( $filler_count, $post_ids_to_be_excluded ); |
|
111 | + public function get_filler_response($filler_count, $post_ids_to_be_excluded) { |
|
112 | + $filler_posts = $this->get_filler_posts($filler_count, $post_ids_to_be_excluded); |
|
113 | 113 | // Add thumbnail and permalink to filler posts |
114 | 114 | $filler_response = array(); |
115 | - foreach ( $filler_posts as $post_obj ) { |
|
116 | - $thumbnail = get_the_post_thumbnail_url( $post_obj, 'medium' ); |
|
115 | + foreach ($filler_posts as $post_obj) { |
|
116 | + $thumbnail = get_the_post_thumbnail_url($post_obj, 'medium'); |
|
117 | 117 | $filler_response[] = array( |
118 | 118 | 'post' => array( |
119 | 119 | 'id' => $post_obj->ID, |
120 | - 'permalink' => get_permalink( $post_obj->ID ), |
|
121 | - 'thumbnail' => ( $thumbnail ) ? $thumbnail : WL_DEFAULT_THUMBNAIL_PATH, |
|
120 | + 'permalink' => get_permalink($post_obj->ID), |
|
121 | + 'thumbnail' => ($thumbnail) ? $thumbnail : WL_DEFAULT_THUMBNAIL_PATH, |
|
122 | 122 | 'title' => $post_obj->post_title, |
123 | - 'srcset' => Srcset_Util::get_srcset( $post_obj->ID, Srcset_Util::NAVIGATOR_WIDGET ), |
|
123 | + 'srcset' => Srcset_Util::get_srcset($post_obj->ID, Srcset_Util::NAVIGATOR_WIDGET), |
|
124 | 124 | ), |
125 | 125 | 'entity' => array( |
126 | 126 | 'id' => 0, |
@@ -139,26 +139,26 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return array |
141 | 141 | */ |
142 | - public function get_product_navigator_response( $filler_count, $post_ids_to_be_excluded ) { |
|
143 | - $filler_posts = $this->get_filler_posts( $filler_count, $post_ids_to_be_excluded ); |
|
142 | + public function get_product_navigator_response($filler_count, $post_ids_to_be_excluded) { |
|
143 | + $filler_posts = $this->get_filler_posts($filler_count, $post_ids_to_be_excluded); |
|
144 | 144 | // Add thumbnail and permalink to filler posts |
145 | 145 | $filler_response = array(); |
146 | - foreach ( $filler_posts as $post_obj ) { |
|
147 | - $product = wc_get_product( $post_obj->ID ); |
|
146 | + foreach ($filler_posts as $post_obj) { |
|
147 | + $product = wc_get_product($post_obj->ID); |
|
148 | 148 | $filler_response[] = array( |
149 | 149 | 'product' => array( |
150 | 150 | 'id' => $post_obj->ID, |
151 | - 'permalink' => get_permalink( $post_obj->ID ), |
|
151 | + 'permalink' => get_permalink($post_obj->ID), |
|
152 | 152 | 'title' => $post_obj->post_title, |
153 | - 'thumbnail' => get_the_post_thumbnail_url( $post_obj->ID, 'medium' ), |
|
153 | + 'thumbnail' => get_the_post_thumbnail_url($post_obj->ID, 'medium'), |
|
154 | 154 | 'regular_price' => $product->get_regular_price(), |
155 | 155 | 'sale_price' => $product->get_sale_price(), |
156 | 156 | 'price' => $product->get_price(), |
157 | 157 | 'currency_symbol' => get_woocommerce_currency_symbol(), |
158 | - 'discount_pc' => ( $product->get_sale_price() && ( $product->get_regular_price() > 0 ) ) ? round( 1 - ( $product->get_sale_price() / $product->get_regular_price() ), 2 ) * 100 : 0, |
|
158 | + 'discount_pc' => ($product->get_sale_price() && ($product->get_regular_price() > 0)) ? round(1 - ($product->get_sale_price() / $product->get_regular_price()), 2) * 100 : 0, |
|
159 | 159 | 'average_rating' => $product->get_average_rating(), |
160 | 160 | 'rating_count' => $product->get_rating_count(), |
161 | - 'rating_html' => wc_get_rating_html( $product->get_average_rating(), $product->get_rating_count() ), |
|
161 | + 'rating_html' => wc_get_rating_html($product->get_average_rating(), $product->get_rating_count()), |
|
162 | 162 | ), |
163 | 163 | 'entity' => array(), |
164 | 164 | ); |
@@ -8,17 +8,17 @@ |
||
8 | 8 | */ |
9 | 9 | class Same_Post_Type_Filler_Posts extends Filler_Posts { |
10 | 10 | |
11 | - public function get_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
11 | + public function get_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
12 | 12 | |
13 | - $post_type = $this->alternate_post_type ? $this->alternate_post_type : get_post_type( $this->post_id ); |
|
13 | + $post_type = $this->alternate_post_type ? $this->alternate_post_type : get_post_type( $this->post_id ); |
|
14 | 14 | |
15 | - if ( 'entity' === $post_type ) { |
|
16 | - $post_type = 'post'; |
|
17 | - } |
|
15 | + if ( 'entity' === $post_type ) { |
|
16 | + $post_type = 'post'; |
|
17 | + } |
|
18 | 18 | |
19 | - return get_posts( |
|
20 | - array( 'post_type' => $post_type ) |
|
21 | - + $this->get_posts_config( $filler_count, $post_ids_to_be_excluded ) |
|
22 | - ); |
|
23 | - } |
|
19 | + return get_posts( |
|
20 | + array( 'post_type' => $post_type ) |
|
21 | + + $this->get_posts_config( $filler_count, $post_ids_to_be_excluded ) |
|
22 | + ); |
|
23 | + } |
|
24 | 24 | } |
@@ -8,17 +8,17 @@ |
||
8 | 8 | */ |
9 | 9 | class Same_Post_Type_Filler_Posts extends Filler_Posts { |
10 | 10 | |
11 | - public function get_posts( $filler_count, $post_ids_to_be_excluded ) { |
|
11 | + public function get_posts($filler_count, $post_ids_to_be_excluded) { |
|
12 | 12 | |
13 | - $post_type = $this->alternate_post_type ? $this->alternate_post_type : get_post_type( $this->post_id ); |
|
13 | + $post_type = $this->alternate_post_type ? $this->alternate_post_type : get_post_type($this->post_id); |
|
14 | 14 | |
15 | - if ( 'entity' === $post_type ) { |
|
15 | + if ('entity' === $post_type) { |
|
16 | 16 | $post_type = 'post'; |
17 | 17 | } |
18 | 18 | |
19 | 19 | return get_posts( |
20 | - array( 'post_type' => $post_type ) |
|
21 | - + $this->get_posts_config( $filler_count, $post_ids_to_be_excluded ) |
|
20 | + array('post_type' => $post_type) |
|
21 | + + $this->get_posts_config($filler_count, $post_ids_to_be_excluded) |
|
22 | 22 | ); |
23 | 23 | } |
24 | 24 | } |