@@ -26,38 +26,38 @@ |
||
26 | 26 | */ |
27 | 27 | class Wordlift_i18n { |
28 | 28 | |
29 | - /** |
|
30 | - * The domain specified for this plugin. |
|
31 | - * |
|
32 | - * @since 1.0.0 |
|
33 | - * @access private |
|
34 | - * @var string $domain The domain identifier for this plugin. |
|
35 | - */ |
|
36 | - private $domain; |
|
37 | - |
|
38 | - /** |
|
39 | - * Load the plugin text domain for translation. |
|
40 | - * |
|
41 | - * @since 1.0.0 |
|
42 | - */ |
|
43 | - public function load_plugin_textdomain() { |
|
44 | - |
|
45 | - load_plugin_textdomain( |
|
46 | - $this->domain, |
|
47 | - false, |
|
48 | - dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' |
|
49 | - ); |
|
50 | - |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Set the domain equal to that of the specified domain. |
|
55 | - * |
|
56 | - * @since 1.0.0 |
|
57 | - * @param string $domain The domain that represents the locale of this plugin. |
|
58 | - */ |
|
59 | - public function set_domain( $domain ) { |
|
60 | - $this->domain = $domain; |
|
61 | - } |
|
29 | + /** |
|
30 | + * The domain specified for this plugin. |
|
31 | + * |
|
32 | + * @since 1.0.0 |
|
33 | + * @access private |
|
34 | + * @var string $domain The domain identifier for this plugin. |
|
35 | + */ |
|
36 | + private $domain; |
|
37 | + |
|
38 | + /** |
|
39 | + * Load the plugin text domain for translation. |
|
40 | + * |
|
41 | + * @since 1.0.0 |
|
42 | + */ |
|
43 | + public function load_plugin_textdomain() { |
|
44 | + |
|
45 | + load_plugin_textdomain( |
|
46 | + $this->domain, |
|
47 | + false, |
|
48 | + dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' |
|
49 | + ); |
|
50 | + |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Set the domain equal to that of the specified domain. |
|
55 | + * |
|
56 | + * @since 1.0.0 |
|
57 | + * @param string $domain The domain that represents the locale of this plugin. |
|
58 | + */ |
|
59 | + public function set_domain( $domain ) { |
|
60 | + $this->domain = $domain; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | } |
@@ -7,33 +7,33 @@ |
||
7 | 7 | */ |
8 | 8 | class Wordlift_PrimaShop_Adapter { |
9 | 9 | |
10 | - /** |
|
11 | - * Create a Wordlift_PrimaShop_Adapter instance. |
|
12 | - * |
|
13 | - * @since 3.2.3 |
|
14 | - */ |
|
15 | - public function __construct() { |
|
10 | + /** |
|
11 | + * Create a Wordlift_PrimaShop_Adapter instance. |
|
12 | + * |
|
13 | + * @since 3.2.3 |
|
14 | + */ |
|
15 | + public function __construct() { |
|
16 | 16 | |
17 | - // Tell WP (and PrimaShop) that we support the *prima-layout-settings*. This will display the Content Settings |
|
18 | - // in the entity edit page. |
|
19 | - add_post_type_support( Wordlift_Entity_Service::TYPE_NAME, 'prima-layout-settings' ); |
|
17 | + // Tell WP (and PrimaShop) that we support the *prima-layout-settings*. This will display the Content Settings |
|
18 | + // in the entity edit page. |
|
19 | + add_post_type_support( Wordlift_Entity_Service::TYPE_NAME, 'prima-layout-settings' ); |
|
20 | 20 | |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Intercept the <em>prima_metabox_entity_header_args</em> filter and return what a call to the related <em>post</em> |
|
25 | - * would have returned. |
|
26 | - * |
|
27 | - * @since 3.2.3 |
|
28 | - * |
|
29 | - * @param array $meta The meta array. |
|
30 | - * @param string $ype The post type. |
|
31 | - * |
|
32 | - * @return array A meta array. |
|
33 | - */ |
|
34 | - function prima_metabox_entity_header_args( $meta, $ype ) { |
|
23 | + /** |
|
24 | + * Intercept the <em>prima_metabox_entity_header_args</em> filter and return what a call to the related <em>post</em> |
|
25 | + * would have returned. |
|
26 | + * |
|
27 | + * @since 3.2.3 |
|
28 | + * |
|
29 | + * @param array $meta The meta array. |
|
30 | + * @param string $ype The post type. |
|
31 | + * |
|
32 | + * @return array A meta array. |
|
33 | + */ |
|
34 | + function prima_metabox_entity_header_args( $meta, $ype ) { |
|
35 | 35 | |
36 | - return apply_filters( "prima_metabox_post_header_args", $meta, 'post' ); |
|
37 | - } |
|
36 | + return apply_filters( "prima_metabox_post_header_args", $meta, 'post' ); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | } |
@@ -8,50 +8,50 @@ |
||
8 | 8 | */ |
9 | 9 | abstract class Wordlift_Shortcode { |
10 | 10 | |
11 | - /** |
|
12 | - * The shortcode, set by extending classes. |
|
13 | - */ |
|
14 | - const SHORTCODE = NULL; |
|
15 | - |
|
16 | - /** |
|
17 | - * Create a shortcode instance by registering the shortcode with the render |
|
18 | - * function. |
|
19 | - * |
|
20 | - * @since 3.5.4 |
|
21 | - */ |
|
22 | - public function __construct() { |
|
23 | - |
|
24 | - add_shortcode( static::SHORTCODE, array( $this, 'render' ) ); |
|
25 | - |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * Render the shortcode. |
|
30 | - * |
|
31 | - * @since 3.5.4 |
|
32 | - * |
|
33 | - * @param array $atts An array of shortcode attributes as set by the editor. |
|
34 | - * |
|
35 | - * @return string The output html code. |
|
36 | - */ |
|
37 | - public abstract function render( $atts ); |
|
38 | - |
|
39 | - /** |
|
40 | - * Enqueue scripts. Called by the shortcode implementations in their render |
|
41 | - * method. |
|
42 | - * |
|
43 | - * @since 3.5.4 |
|
44 | - */ |
|
45 | - protected function enqueue_scripts() { |
|
46 | - |
|
47 | - wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
48 | - wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js', array( 'angularjs' ) ); |
|
49 | - wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.js', array( |
|
50 | - 'jquery', |
|
51 | - 'angularjs', |
|
52 | - 'angularjs-touch' |
|
53 | - ) ); |
|
54 | - |
|
55 | - } |
|
11 | + /** |
|
12 | + * The shortcode, set by extending classes. |
|
13 | + */ |
|
14 | + const SHORTCODE = NULL; |
|
15 | + |
|
16 | + /** |
|
17 | + * Create a shortcode instance by registering the shortcode with the render |
|
18 | + * function. |
|
19 | + * |
|
20 | + * @since 3.5.4 |
|
21 | + */ |
|
22 | + public function __construct() { |
|
23 | + |
|
24 | + add_shortcode( static::SHORTCODE, array( $this, 'render' ) ); |
|
25 | + |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * Render the shortcode. |
|
30 | + * |
|
31 | + * @since 3.5.4 |
|
32 | + * |
|
33 | + * @param array $atts An array of shortcode attributes as set by the editor. |
|
34 | + * |
|
35 | + * @return string The output html code. |
|
36 | + */ |
|
37 | + public abstract function render( $atts ); |
|
38 | + |
|
39 | + /** |
|
40 | + * Enqueue scripts. Called by the shortcode implementations in their render |
|
41 | + * method. |
|
42 | + * |
|
43 | + * @since 3.5.4 |
|
44 | + */ |
|
45 | + protected function enqueue_scripts() { |
|
46 | + |
|
47 | + wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' ); |
|
48 | + wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js', array( 'angularjs' ) ); |
|
49 | + wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.js', array( |
|
50 | + 'jquery', |
|
51 | + 'angularjs', |
|
52 | + 'angularjs-touch' |
|
53 | + ) ); |
|
54 | + |
|
55 | + } |
|
56 | 56 | |
57 | 57 | } |
@@ -11,56 +11,56 @@ |
||
11 | 11 | */ |
12 | 12 | class Wordlift_Property_Factory { |
13 | 13 | |
14 | - /** |
|
15 | - * The default {@link Wordlift_Property_Service}. |
|
16 | - * |
|
17 | - * @since 3.7.0 |
|
18 | - * @access private |
|
19 | - * @var \Wordlift_Property_Service $default_property_service The default {@link Wordlift_Property_Service}. |
|
20 | - */ |
|
21 | - private $default_property_service; |
|
14 | + /** |
|
15 | + * The default {@link Wordlift_Property_Service}. |
|
16 | + * |
|
17 | + * @since 3.7.0 |
|
18 | + * @access private |
|
19 | + * @var \Wordlift_Property_Service $default_property_service The default {@link Wordlift_Property_Service}. |
|
20 | + */ |
|
21 | + private $default_property_service; |
|
22 | 22 | |
23 | - private $property_services = array(); |
|
23 | + private $property_services = array(); |
|
24 | 24 | |
25 | - /** |
|
26 | - * Wordlift_Property_Factory constructor. |
|
27 | - * |
|
28 | - * @since 3.7.0 |
|
29 | - * |
|
30 | - * @param \Wordlift_Property_Service $default_property_service |
|
31 | - */ |
|
32 | - public function __construct( $default_property_service ) { |
|
25 | + /** |
|
26 | + * Wordlift_Property_Factory constructor. |
|
27 | + * |
|
28 | + * @since 3.7.0 |
|
29 | + * |
|
30 | + * @param \Wordlift_Property_Service $default_property_service |
|
31 | + */ |
|
32 | + public function __construct( $default_property_service ) { |
|
33 | 33 | |
34 | - $this->default_property_service = $default_property_service; |
|
34 | + $this->default_property_service = $default_property_service; |
|
35 | 35 | |
36 | - } |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Set the {@link Wordlift_Property_Service} which handles that meta key. |
|
40 | - * |
|
41 | - * @since 3.7.0 |
|
42 | - * |
|
43 | - * @param string $meta_key WordPress' meta key. |
|
44 | - * @param \Wordlift_Property_Service $property_service A {@link Wordlift_Property_Service} instance. |
|
45 | - */ |
|
46 | - public function register( $meta_key, $property_service ) { |
|
38 | + /** |
|
39 | + * Set the {@link Wordlift_Property_Service} which handles that meta key. |
|
40 | + * |
|
41 | + * @since 3.7.0 |
|
42 | + * |
|
43 | + * @param string $meta_key WordPress' meta key. |
|
44 | + * @param \Wordlift_Property_Service $property_service A {@link Wordlift_Property_Service} instance. |
|
45 | + */ |
|
46 | + public function register( $meta_key, $property_service ) { |
|
47 | 47 | |
48 | - $this->property_services[ $meta_key ] = $property_service; |
|
48 | + $this->property_services[ $meta_key ] = $property_service; |
|
49 | 49 | |
50 | - } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get the {@link Wordlift_Property_Service} which handles the specified meta key. |
|
54 | - * |
|
55 | - * @since 3.7.0 |
|
56 | - * |
|
57 | - * @param $meta_key |
|
58 | - * |
|
59 | - * @return \Wordlift_Property_Service The {@link Wordlift_Property_Service} which handles the specified meta key. |
|
60 | - */ |
|
61 | - public function get( $meta_key ) { |
|
52 | + /** |
|
53 | + * Get the {@link Wordlift_Property_Service} which handles the specified meta key. |
|
54 | + * |
|
55 | + * @since 3.7.0 |
|
56 | + * |
|
57 | + * @param $meta_key |
|
58 | + * |
|
59 | + * @return \Wordlift_Property_Service The {@link Wordlift_Property_Service} which handles the specified meta key. |
|
60 | + */ |
|
61 | + public function get( $meta_key ) { |
|
62 | 62 | |
63 | - return $this->property_services[ $meta_key ] ?: $this->default_property_service; |
|
64 | - } |
|
63 | + return $this->property_services[ $meta_key ] ?: $this->default_property_service; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | \ No newline at end of file |
@@ -21,66 +21,66 @@ |
||
21 | 21 | */ |
22 | 22 | class Wordlift_Seo_Service { |
23 | 23 | |
24 | - /** |
|
25 | - * @inheritdoc |
|
26 | - */ |
|
27 | - function __construct() { |
|
24 | + /** |
|
25 | + * @inheritdoc |
|
26 | + */ |
|
27 | + function __construct() { |
|
28 | 28 | |
29 | - // If we are not on the admin, run the get_term filter for entity type terms. |
|
30 | - add_filter( 'get_wl_entity_type', array( |
|
31 | - $this, |
|
32 | - 'get_wl_entity_type', |
|
33 | - ), 10, 2 ); |
|
29 | + // If we are not on the admin, run the get_term filter for entity type terms. |
|
30 | + add_filter( 'get_wl_entity_type', array( |
|
31 | + $this, |
|
32 | + 'get_wl_entity_type', |
|
33 | + ), 10, 2 ); |
|
34 | 34 | |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Filter the entity term object, and when not in admin context replace title |
|
39 | - * and description with whatever was set in the entity settings page. |
|
40 | - * |
|
41 | - * @since 3.11 |
|
42 | - * |
|
43 | - * @param WP_Term $term The term to filters. |
|
44 | - * @param string $taxonomy The taxonomy name. |
|
45 | - * |
|
46 | - * @return WP_Term The {@link WP_Term} with fields changed. |
|
47 | - */ |
|
48 | - function get_wl_entity_type( $term, $taxonomy ) { |
|
37 | + /** |
|
38 | + * Filter the entity term object, and when not in admin context replace title |
|
39 | + * and description with whatever was set in the entity settings page. |
|
40 | + * |
|
41 | + * @since 3.11 |
|
42 | + * |
|
43 | + * @param WP_Term $term The term to filters. |
|
44 | + * @param string $taxonomy The taxonomy name. |
|
45 | + * |
|
46 | + * @return WP_Term The {@link WP_Term} with fields changed. |
|
47 | + */ |
|
48 | + function get_wl_entity_type( $term, $taxonomy ) { |
|
49 | 49 | |
50 | - // Do nothing when in admin. |
|
51 | - if ( is_admin() ) { |
|
52 | - return $term; |
|
53 | - } |
|
50 | + // Do nothing when in admin. |
|
51 | + if ( is_admin() ) { |
|
52 | + return $term; |
|
53 | + } |
|
54 | 54 | |
55 | - // Get the terms' settings. |
|
56 | - $entity_settings = get_option( 'wl_entity_type_settings', array() ); |
|
55 | + // Get the terms' settings. |
|
56 | + $entity_settings = get_option( 'wl_entity_type_settings', array() ); |
|
57 | 57 | |
58 | - // If we have no settings for the specified term, then return the original |
|
59 | - // term. |
|
60 | - if ( ! isset( $entity_settings[ $term->term_id ] ) ) { |
|
58 | + // If we have no settings for the specified term, then return the original |
|
59 | + // term. |
|
60 | + if ( ! isset( $entity_settings[ $term->term_id ] ) ) { |
|
61 | 61 | |
62 | - return $term; |
|
63 | - } |
|
62 | + return $term; |
|
63 | + } |
|
64 | 64 | |
65 | - // Get the settings for the specified term. |
|
66 | - $settings = $entity_settings[ $term->term_id ]; |
|
65 | + // Get the settings for the specified term. |
|
66 | + $settings = $entity_settings[ $term->term_id ]; |
|
67 | 67 | |
68 | - // Update the name. |
|
69 | - if ( ! empty( $settings['title'] ) ) { |
|
68 | + // Update the name. |
|
69 | + if ( ! empty( $settings['title'] ) ) { |
|
70 | 70 | |
71 | - $term->name = $settings['title']; |
|
71 | + $term->name = $settings['title']; |
|
72 | 72 | |
73 | - } |
|
73 | + } |
|
74 | 74 | |
75 | - // Update the description. |
|
76 | - if ( ! empty( $settings['description'] ) ) { |
|
75 | + // Update the description. |
|
76 | + if ( ! empty( $settings['description'] ) ) { |
|
77 | 77 | |
78 | - $term->description = $settings['description']; |
|
78 | + $term->description = $settings['description']; |
|
79 | 79 | |
80 | - } |
|
80 | + } |
|
81 | 81 | |
82 | - // Return the updated term. |
|
83 | - return $term; |
|
84 | - } |
|
82 | + // Return the updated term. |
|
83 | + return $term; |
|
84 | + } |
|
85 | 85 | |
86 | 86 | } |
@@ -16,26 +16,26 @@ |
||
16 | 16 | */ |
17 | 17 | abstract class Wordlift_Widget extends WP_Widget { |
18 | 18 | |
19 | - /** |
|
20 | - * @inheritdoc |
|
21 | - */ |
|
22 | - public function __construct( $id_base, $name, array $widget_options = array(), array $control_options = array() ) { |
|
23 | - parent::__construct( $id_base, $name, $widget_options, $control_options ); |
|
19 | + /** |
|
20 | + * @inheritdoc |
|
21 | + */ |
|
22 | + public function __construct( $id_base, $name, array $widget_options = array(), array $control_options = array() ) { |
|
23 | + parent::__construct( $id_base, $name, $widget_options, $control_options ); |
|
24 | 24 | |
25 | - // Initialize the Related Entities Cloud Widget. |
|
26 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
25 | + // Initialize the Related Entities Cloud Widget. |
|
26 | + add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
27 | 27 | |
28 | - } |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Register the related entities cloud widget |
|
32 | - * |
|
33 | - * @since 3.11.0 |
|
34 | - */ |
|
35 | - public function widget_init() { |
|
30 | + /** |
|
31 | + * Register the related entities cloud widget |
|
32 | + * |
|
33 | + * @since 3.11.0 |
|
34 | + */ |
|
35 | + public function widget_init() { |
|
36 | 36 | |
37 | - register_widget( get_class( $this ) ); |
|
37 | + register_widget( get_class( $this ) ); |
|
38 | 38 | |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | 41 | } |
@@ -18,74 +18,74 @@ |
||
18 | 18 | */ |
19 | 19 | class Wordlift_Category_Taxonomy_Service { |
20 | 20 | |
21 | - /** |
|
22 | - * The {@link Wordlift_Entity_Post_Type_Service} instance. |
|
23 | - * |
|
24 | - * @since 3.11.0 |
|
25 | - * @access private |
|
26 | - * @var \Wordlift_Entity_Post_Type_Service $entity_post_type_service The {@link Wordlift_Entity_Post_Type_Service} instance. |
|
27 | - */ |
|
28 | - private $entity_post_type_service; |
|
21 | + /** |
|
22 | + * The {@link Wordlift_Entity_Post_Type_Service} instance. |
|
23 | + * |
|
24 | + * @since 3.11.0 |
|
25 | + * @access private |
|
26 | + * @var \Wordlift_Entity_Post_Type_Service $entity_post_type_service The {@link Wordlift_Entity_Post_Type_Service} instance. |
|
27 | + */ |
|
28 | + private $entity_post_type_service; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Create a {@link Wordlift_Category_Taxonomy_Service} instance. |
|
32 | - * |
|
33 | - * @since 3.11.0 |
|
34 | - * |
|
35 | - * @param \Wordlift_Entity_Post_Type_Service $entity_post_type_service The {@link Wordlift_Entity_Post_Type_Service} instance. |
|
36 | - */ |
|
37 | - function __construct( $entity_post_type_service ) { |
|
30 | + /** |
|
31 | + * Create a {@link Wordlift_Category_Taxonomy_Service} instance. |
|
32 | + * |
|
33 | + * @since 3.11.0 |
|
34 | + * |
|
35 | + * @param \Wordlift_Entity_Post_Type_Service $entity_post_type_service The {@link Wordlift_Entity_Post_Type_Service} instance. |
|
36 | + */ |
|
37 | + function __construct( $entity_post_type_service ) { |
|
38 | 38 | |
39 | - $this->entity_post_type_service = $entity_post_type_service; |
|
39 | + $this->entity_post_type_service = $entity_post_type_service; |
|
40 | 40 | |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Set the entity post types as one to be included in archive pages. |
|
45 | - * |
|
46 | - * In order to have entities show up in standard WP categories (Posts categories) |
|
47 | - * we configure the `entity` post type, but we also need to alter the main |
|
48 | - * WP query (which by default queries posts only) to include the `entities`. |
|
49 | - * |
|
50 | - * @since 3.11.0 |
|
51 | - * |
|
52 | - * @param WP_Query $query WP's {@link WP_Query} instance. |
|
53 | - */ |
|
54 | - public function pre_get_posts( $query ) { |
|
43 | + /** |
|
44 | + * Set the entity post types as one to be included in archive pages. |
|
45 | + * |
|
46 | + * In order to have entities show up in standard WP categories (Posts categories) |
|
47 | + * we configure the `entity` post type, but we also need to alter the main |
|
48 | + * WP query (which by default queries posts only) to include the `entities`. |
|
49 | + * |
|
50 | + * @since 3.11.0 |
|
51 | + * |
|
52 | + * @param WP_Query $query WP's {@link WP_Query} instance. |
|
53 | + */ |
|
54 | + public function pre_get_posts( $query ) { |
|
55 | 55 | |
56 | - // Only for the main query, avoid problems with widgets and what not. |
|
57 | - if ( ! $query->is_main_query() ) { |
|
58 | - return; |
|
59 | - } |
|
56 | + // Only for the main query, avoid problems with widgets and what not. |
|
57 | + if ( ! $query->is_main_query() ) { |
|
58 | + return; |
|
59 | + } |
|
60 | 60 | |
61 | - // We don't want to alter the query if we're in the admin UI, if this is |
|
62 | - // not a category query, or if the `suppress_filters` is set. |
|
63 | - // |
|
64 | - // Note that it is unlikely for `suppress_filter` to be set on the front |
|
65 | - // end, but let's be safe if it is set the calling code assumes no |
|
66 | - // modifications of queries. |
|
67 | - // |
|
68 | - // is_admin is needed, otherwise category based post filters will show |
|
69 | - // both types and at the current release (4.7) it causes PHP errors. |
|
70 | - if ( is_admin() || ! is_category() || ! empty( $query->query_vars['suppress_filters'] ) ) { |
|
71 | - return; |
|
72 | - } |
|
61 | + // We don't want to alter the query if we're in the admin UI, if this is |
|
62 | + // not a category query, or if the `suppress_filters` is set. |
|
63 | + // |
|
64 | + // Note that it is unlikely for `suppress_filter` to be set on the front |
|
65 | + // end, but let's be safe if it is set the calling code assumes no |
|
66 | + // modifications of queries. |
|
67 | + // |
|
68 | + // is_admin is needed, otherwise category based post filters will show |
|
69 | + // both types and at the current release (4.7) it causes PHP errors. |
|
70 | + if ( is_admin() || ! is_category() || ! empty( $query->query_vars['suppress_filters'] ) ) { |
|
71 | + return; |
|
72 | + } |
|
73 | 73 | |
74 | - // Check the current post types, maybe the category archive pages |
|
75 | - // are already associated with other post types. |
|
76 | - // |
|
77 | - // If `post_type` isn't set, WP assumes `post` by default. |
|
78 | - $post_types = (array) ( $query->get( 'post_type' ) ?: 'post' ); |
|
74 | + // Check the current post types, maybe the category archive pages |
|
75 | + // are already associated with other post types. |
|
76 | + // |
|
77 | + // If `post_type` isn't set, WP assumes `post` by default. |
|
78 | + $post_types = (array) ( $query->get( 'post_type' ) ?: 'post' ); |
|
79 | 79 | |
80 | - // Add the entities post type only if the post post type is used in the query |
|
81 | - // since we only want `entities` to appear alongside posts. |
|
82 | - if ( in_array( 'post', $post_types ) ) { |
|
83 | - $post_types[] = $this->entity_post_type_service->get_post_type(); |
|
84 | - } |
|
80 | + // Add the entities post type only if the post post type is used in the query |
|
81 | + // since we only want `entities` to appear alongside posts. |
|
82 | + if ( in_array( 'post', $post_types ) ) { |
|
83 | + $post_types[] = $this->entity_post_type_service->get_post_type(); |
|
84 | + } |
|
85 | 85 | |
86 | - // Update the query post types. |
|
87 | - $query->set( 'post_type', $post_types ); |
|
86 | + // Update the query post types. |
|
87 | + $query->set( 'post_type', $post_types ); |
|
88 | 88 | |
89 | - } |
|
89 | + } |
|
90 | 90 | |
91 | 91 | } |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | if ( ! defined( 'ABSPATH' ) ) { |
15 | - exit; |
|
15 | + exit; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | $term = get_term( $term_id, 'wl_entity_type' ); |
19 | 19 | |
20 | 20 | $term_settings = ! is_null( $settings ) ? $settings : array( |
21 | - 'title' => '', |
|
22 | - 'description' => '', |
|
21 | + 'title' => '', |
|
22 | + 'description' => '', |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | ?> |
@@ -37,32 +37,32 @@ discard block |
||
37 | 37 | <tr class="form-field form-required term-name-wrap"> |
38 | 38 | <th scope="row"> |
39 | 39 | <label><?php |
40 | - esc_html_e( 'Name', 'wordlift' ); ?></label> |
|
40 | + esc_html_e( 'Name', 'wordlift' ); ?></label> |
|
41 | 41 | </th> |
42 | 42 | <td><?php |
43 | - echo esc_html( $term->name ) ?></td> |
|
43 | + echo esc_html( $term->name ) ?></td> |
|
44 | 44 | </tr> |
45 | 45 | <tr class="form-field form-required term-name-wrap"> |
46 | 46 | <th scope="row"> |
47 | 47 | <label for="title"><?php |
48 | - esc_html_e( 'Title', 'wordlift' ); ?></label> |
|
48 | + esc_html_e( 'Title', 'wordlift' ); ?></label> |
|
49 | 49 | </th> |
50 | 50 | <td><input name="title" id="title" type="text" |
51 | 51 | value="<?php echo esc_attr( $term_settings['title'] ) ?>" |
52 | 52 | size="40" /> |
53 | 53 | <p class="description"><?php |
54 | - esc_html_e( 'The HTML title to be used in the entity type archive page.', 'wordlift' ); ?></p> |
|
54 | + esc_html_e( 'The HTML title to be used in the entity type archive page.', 'wordlift' ); ?></p> |
|
55 | 55 | </td> |
56 | 56 | </tr> |
57 | 57 | <tr class="form-field term-description-wrap"> |
58 | 58 | <th scope="row"><label for="description"><?php |
59 | - esc_html_e( 'Description', 'wordlift' ); ?></label> |
|
59 | + esc_html_e( 'Description', 'wordlift' ); ?></label> |
|
60 | 60 | </th> |
61 | 61 | <td><textarea name="description" id="description" rows="5" |
62 | 62 | cols="50" class="large-text"><?php |
63 | - echo esc_html( $term_settings['description'] ) ?></textarea> |
|
63 | + echo esc_html( $term_settings['description'] ) ?></textarea> |
|
64 | 64 | <p class="description"><?php |
65 | - esc_html_e( 'The description to be used in the entity type archive page.', 'wordlift' ); ?></p> |
|
65 | + esc_html_e( 'The description to be used in the entity type archive page.', 'wordlift' ); ?></p> |
|
66 | 66 | </td> |
67 | 67 | </tr> |
68 | 68 | </table> |
@@ -16,33 +16,33 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class Wordlift_Related_Entities_Cloud_Widget extends Wordlift_Widget { |
18 | 18 | |
19 | - /** |
|
20 | - * Create an {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
21 | - * |
|
22 | - * @since 3.11.0 |
|
23 | - */ |
|
24 | - public function __construct() { |
|
25 | - parent::__construct( |
|
26 | - 'wl_related_entities_cloud', |
|
27 | - __( 'WordLift Entities Cloud', 'wordlift' ), |
|
28 | - array( |
|
29 | - 'classname' => 'wl_related_entities_cloud', |
|
30 | - 'description' => __( 'Display entities related to the current post/entity in a tag cloud.', 'wordlift' ), |
|
31 | - ) |
|
32 | - ); |
|
33 | - |
|
34 | - } |
|
35 | - |
|
36 | - /** |
|
37 | - * @inheritdoc |
|
38 | - */ |
|
39 | - public function form( $instance ) { |
|
40 | - $title_id = $this->get_field_id( 'title' ); |
|
41 | - $instance['title'] = ! empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; |
|
42 | - ?> |
|
19 | + /** |
|
20 | + * Create an {@link Wordlift_Related_Entities_Cloud_Widget} instance. |
|
21 | + * |
|
22 | + * @since 3.11.0 |
|
23 | + */ |
|
24 | + public function __construct() { |
|
25 | + parent::__construct( |
|
26 | + 'wl_related_entities_cloud', |
|
27 | + __( 'WordLift Entities Cloud', 'wordlift' ), |
|
28 | + array( |
|
29 | + 'classname' => 'wl_related_entities_cloud', |
|
30 | + 'description' => __( 'Display entities related to the current post/entity in a tag cloud.', 'wordlift' ), |
|
31 | + ) |
|
32 | + ); |
|
33 | + |
|
34 | + } |
|
35 | + |
|
36 | + /** |
|
37 | + * @inheritdoc |
|
38 | + */ |
|
39 | + public function form( $instance ) { |
|
40 | + $title_id = $this->get_field_id( 'title' ); |
|
41 | + $instance['title'] = ! empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; |
|
42 | + ?> |
|
43 | 43 | |
44 | 44 | <p><label for="<?php echo esc_attr( $title_id ); ?>"><?php |
45 | - esc_html_e( 'Title:' ); ?></label> |
|
45 | + esc_html_e( 'Title:' ); ?></label> |
|
46 | 46 | <input type="text" class="widefat" |
47 | 47 | id="<?php echo esc_attr( $title_id ); ?>" |
48 | 48 | name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" |
@@ -51,46 +51,46 @@ discard block |
||
51 | 51 | |
52 | 52 | <?php |
53 | 53 | |
54 | - return 'wl_related_entities_cloud_form'; |
|
55 | - } |
|
54 | + return 'wl_related_entities_cloud_form'; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @inheritdoc |
|
59 | - */ |
|
60 | - public function update( $new_instance, $old_instance ) { |
|
57 | + /** |
|
58 | + * @inheritdoc |
|
59 | + */ |
|
60 | + public function update( $new_instance, $old_instance ) { |
|
61 | 61 | |
62 | - return array( 'title' => sanitize_text_field( $new_instance['title'] ) ); |
|
63 | - } |
|
62 | + return array( 'title' => sanitize_text_field( $new_instance['title'] ) ); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @inheritdoc |
|
67 | - */ |
|
68 | - public function widget( $args, $instance ) { |
|
65 | + /** |
|
66 | + * @inheritdoc |
|
67 | + */ |
|
68 | + public function widget( $args, $instance ) { |
|
69 | 69 | |
70 | - /* |
|
70 | + /* |
|
71 | 71 | * Use the shortcode to calculate the HTML required to show the cloud |
72 | 72 | * if there is no such html do not render the widget at all. |
73 | 73 | */ |
74 | - $cloud_html = do_shortcode( '[wl_cloud]' ); |
|
75 | - if ( empty( $cloud_html ) ) { |
|
76 | - return false; |
|
77 | - } |
|
74 | + $cloud_html = do_shortcode( '[wl_cloud]' ); |
|
75 | + if ( empty( $cloud_html ) ) { |
|
76 | + return false; |
|
77 | + } |
|
78 | 78 | |
79 | - // The widget title. |
|
80 | - $title = empty( $instance['title'] ) ? __( 'Related Entities', 'wordlift' ) : $instance['title']; |
|
79 | + // The widget title. |
|
80 | + $title = empty( $instance['title'] ) ? __( 'Related Entities', 'wordlift' ) : $instance['title']; |
|
81 | 81 | |
82 | - // Standard filter all widgets should apply |
|
83 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
82 | + // Standard filter all widgets should apply |
|
83 | + $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
84 | 84 | |
85 | - echo $args['before_widget']; |
|
85 | + echo $args['before_widget']; |
|
86 | 86 | |
87 | - if ( $title ) { |
|
88 | - echo $args['before_title'] . $title . $args['after_title']; |
|
89 | - } |
|
87 | + if ( $title ) { |
|
88 | + echo $args['before_title'] . $title . $args['after_title']; |
|
89 | + } |
|
90 | 90 | |
91 | - echo $cloud_html; |
|
92 | - echo $args['after_widget']; |
|
91 | + echo $cloud_html; |
|
92 | + echo $args['after_widget']; |
|
93 | 93 | |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | 96 | } |