@@ -8,19 +8,19 @@ |
||
8 | 8 | */ |
9 | 9 | class Wordlift_Install_3_36_0 extends Wordlift_Install { |
10 | 10 | |
11 | - /** |
|
12 | - * {@inheritdoc} |
|
13 | - */ |
|
14 | - protected static $version = '3.36.1'; |
|
11 | + /** |
|
12 | + * {@inheritdoc} |
|
13 | + */ |
|
14 | + protected static $version = '3.36.1'; |
|
15 | 15 | |
16 | - public function install() { |
|
16 | + public function install() { |
|
17 | 17 | |
18 | - $is_woocommerce_extension_installed = defined( 'WL_WOO_VERSION' ); |
|
18 | + $is_woocommerce_extension_installed = defined( 'WL_WOO_VERSION' ); |
|
19 | 19 | |
20 | - if ( $is_woocommerce_extension_installed ) { |
|
21 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
22 | - do_action( 'wl_install_and_activate_advanced-custom-fields-for-schema-org' ); |
|
23 | - } |
|
24 | - } |
|
20 | + if ( $is_woocommerce_extension_installed ) { |
|
21 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
22 | + do_action( 'wl_install_and_activate_advanced-custom-fields-for-schema-org' ); |
|
23 | + } |
|
24 | + } |
|
25 | 25 | |
26 | 26 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
|
3 | +require_once ABSPATH.'wp-admin/includes/upgrade.php'; |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * @since 3.36.0 |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | |
16 | 16 | public function install() { |
17 | 17 | |
18 | - $is_woocommerce_extension_installed = defined( 'WL_WOO_VERSION' ); |
|
18 | + $is_woocommerce_extension_installed = defined('WL_WOO_VERSION'); |
|
19 | 19 | |
20 | - if ( $is_woocommerce_extension_installed ) { |
|
20 | + if ($is_woocommerce_extension_installed) { |
|
21 | 21 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
22 | - do_action( 'wl_install_and_activate_advanced-custom-fields-for-schema-org' ); |
|
22 | + do_action('wl_install_and_activate_advanced-custom-fields-for-schema-org'); |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 |
@@ -15,26 +15,26 @@ |
||
15 | 15 | * @subpackage Wordlift/install |
16 | 16 | */ |
17 | 17 | class Wordlift_Install_3_12_0 extends Wordlift_Install { |
18 | - /** |
|
19 | - * @inheritdoc |
|
20 | - */ |
|
21 | - protected static $version = '3.12.0'; |
|
18 | + /** |
|
19 | + * @inheritdoc |
|
20 | + */ |
|
21 | + protected static $version = '3.12.0'; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @inheritdoc |
|
25 | - */ |
|
26 | - public function install() { |
|
27 | - /* |
|
23 | + /** |
|
24 | + * @inheritdoc |
|
25 | + */ |
|
26 | + public function install() { |
|
27 | + /* |
|
28 | 28 | * As this upgrade functionality runs on the init hook, and the AMP plugin |
29 | 29 | * initialization does the same, avoid possible race conditions by |
30 | 30 | * deferring the actual flush to a later hook. |
31 | 31 | */ |
32 | - add_action( |
|
33 | - 'wp_loaded', |
|
34 | - function () { |
|
35 | - flush_rewrite_rules(); |
|
36 | - } |
|
37 | - ); |
|
38 | - } |
|
32 | + add_action( |
|
33 | + 'wp_loaded', |
|
34 | + function () { |
|
35 | + flush_rewrite_rules(); |
|
36 | + } |
|
37 | + ); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | */ |
32 | 32 | add_action( |
33 | 33 | 'wp_loaded', |
34 | - function () { |
|
34 | + function() { |
|
35 | 35 | flush_rewrite_rules(); |
36 | 36 | } |
37 | 37 | ); |
@@ -17,50 +17,50 @@ |
||
17 | 17 | */ |
18 | 18 | class Wordlift_Install_All_Entity_Types extends Wordlift_Install { |
19 | 19 | |
20 | - /** |
|
21 | - * The option name for the version of the Schema.org taxonomy. |
|
22 | - * |
|
23 | - * @since 3.20.0 |
|
24 | - */ |
|
25 | - const OPTION_NAME = 'wl_schemaorg_version'; |
|
20 | + /** |
|
21 | + * The option name for the version of the Schema.org taxonomy. |
|
22 | + * |
|
23 | + * @since 3.20.0 |
|
24 | + */ |
|
25 | + const OPTION_NAME = 'wl_schemaorg_version'; |
|
26 | 26 | |
27 | - /** |
|
28 | - * {@inheritdoc} |
|
29 | - */ |
|
30 | - protected static $version = '3.20.0'; |
|
27 | + /** |
|
28 | + * {@inheritdoc} |
|
29 | + */ |
|
30 | + protected static $version = '3.20.0'; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Perform the installation. |
|
34 | - * |
|
35 | - * @since 3.20.0 |
|
36 | - */ |
|
37 | - public function install() { |
|
32 | + /** |
|
33 | + * Perform the installation. |
|
34 | + * |
|
35 | + * @since 3.20.0 |
|
36 | + */ |
|
37 | + public function install() { |
|
38 | 38 | |
39 | - $this->log->info( 'Installing `All Entity Types` configuration...' ); |
|
39 | + $this->log->info( 'Installing `All Entity Types` configuration...' ); |
|
40 | 40 | |
41 | - // Get the Schema.org sync service instance. |
|
42 | - $schema_sync_service = Wordlift_Schemaorg_Sync_Service::get_instance(); |
|
41 | + // Get the Schema.org sync service instance. |
|
42 | + $schema_sync_service = Wordlift_Schemaorg_Sync_Service::get_instance(); |
|
43 | 43 | |
44 | - // Try to load the Schema.org taxonomy and, if successful, update the local Schema.org version. |
|
45 | - if ( $schema_sync_service->load_from_file() ) { |
|
46 | - $this->log->debug( 'Updating `All Entity Types` configuration to 1.0.0.' ); |
|
44 | + // Try to load the Schema.org taxonomy and, if successful, update the local Schema.org version. |
|
45 | + if ( $schema_sync_service->load_from_file() ) { |
|
46 | + $this->log->debug( 'Updating `All Entity Types` configuration to 1.0.0.' ); |
|
47 | 47 | |
48 | - update_option( self::OPTION_NAME, '1.0.0', true ); |
|
49 | - } |
|
48 | + update_option( self::OPTION_NAME, '1.0.0', true ); |
|
49 | + } |
|
50 | 50 | |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Whether the installation procedure must run. |
|
55 | - * |
|
56 | - * @since 3.20.0 |
|
57 | - * |
|
58 | - * @return bool True if the installation procedure must run otherwise false. |
|
59 | - */ |
|
60 | - public function must_install() { |
|
53 | + /** |
|
54 | + * Whether the installation procedure must run. |
|
55 | + * |
|
56 | + * @since 3.20.0 |
|
57 | + * |
|
58 | + * @return bool True if the installation procedure must run otherwise false. |
|
59 | + */ |
|
60 | + public function must_install() { |
|
61 | 61 | |
62 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
63 | - return apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) && version_compare( '1.0.0', get_option( self::OPTION_NAME, '0.0.0' ), '>' ); |
|
64 | - } |
|
62 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
63 | + return apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) && version_compare( '1.0.0', get_option( self::OPTION_NAME, '0.0.0' ), '>' ); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | } |
@@ -36,16 +36,16 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function install() { |
38 | 38 | |
39 | - $this->log->info( 'Installing `All Entity Types` configuration...' ); |
|
39 | + $this->log->info('Installing `All Entity Types` configuration...'); |
|
40 | 40 | |
41 | 41 | // Get the Schema.org sync service instance. |
42 | 42 | $schema_sync_service = Wordlift_Schemaorg_Sync_Service::get_instance(); |
43 | 43 | |
44 | 44 | // Try to load the Schema.org taxonomy and, if successful, update the local Schema.org version. |
45 | - if ( $schema_sync_service->load_from_file() ) { |
|
46 | - $this->log->debug( 'Updating `All Entity Types` configuration to 1.0.0.' ); |
|
45 | + if ($schema_sync_service->load_from_file()) { |
|
46 | + $this->log->debug('Updating `All Entity Types` configuration to 1.0.0.'); |
|
47 | 47 | |
48 | - update_option( self::OPTION_NAME, '1.0.0', true ); |
|
48 | + update_option(self::OPTION_NAME, '1.0.0', true); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public function must_install() { |
61 | 61 | |
62 | 62 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
63 | - return apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) && version_compare( '1.0.0', get_option( self::OPTION_NAME, '0.0.0' ), '>' ); |
|
63 | + return apply_filters('wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES) && version_compare('1.0.0', get_option(self::OPTION_NAME, '0.0.0'), '>'); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | } |
@@ -15,111 +15,111 @@ |
||
15 | 15 | * @subpackage Wordlift/install |
16 | 16 | */ |
17 | 17 | class Wordlift_Install_3_18_0 extends Wordlift_Install { |
18 | - /** |
|
19 | - * @inheritdoc |
|
20 | - */ |
|
21 | - protected static $version = '3.18.0'; |
|
22 | - |
|
23 | - /** |
|
24 | - * @inheritdoc |
|
25 | - */ |
|
26 | - public function __construct() { |
|
27 | - parent::__construct(); |
|
28 | - |
|
29 | - add_action( |
|
30 | - 'wl_async_wl_push_references', |
|
31 | - array( |
|
32 | - $this, |
|
33 | - 'push_references', |
|
34 | - ) |
|
35 | - ); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @inheritdoc |
|
40 | - */ |
|
41 | - public function install() { |
|
42 | - $this->add_offer_entity_type(); |
|
43 | - $this->add_editors_read_wordlift_entity_capability(); |
|
44 | - do_action( 'wl_push_references' ); |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Creates references for articles *referencing* entities |
|
49 | - * |
|
50 | - * @return void |
|
51 | - * @since 3.18.0 |
|
52 | - */ |
|
53 | - public function push_references() { |
|
54 | - // Get relations. |
|
55 | - $relations = Wordlift_Relation_Service::get_instance()->find_all_grouped_by_subject_id(); |
|
56 | - |
|
57 | - $entity_service = Wordlift_Entity_Service::get_instance(); |
|
58 | - |
|
59 | - // Loop through all relations and push the references. |
|
60 | - foreach ( $relations as $relation ) { |
|
61 | - |
|
62 | - $post = get_post( $relation->subject_id ); |
|
63 | - |
|
64 | - // Bail out if it's an entity: we're only interested in articles |
|
65 | - // *referencing* entities. |
|
66 | - if ( $entity_service->is_entity( $post->ID ) ) { |
|
67 | - continue; |
|
68 | - } |
|
69 | - } |
|
70 | - |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Adds the new `Offer` entity type. |
|
75 | - * |
|
76 | - * @return void |
|
77 | - * @since 3.18.0 |
|
78 | - */ |
|
79 | - public function add_offer_entity_type() { |
|
80 | - // Check whether the `offer` term exists. |
|
81 | - $offer = get_term_by( |
|
82 | - 'slug', |
|
83 | - 'offer', |
|
84 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME |
|
85 | - ); |
|
86 | - |
|
87 | - // The `offer` term doesn't exists, so create it. |
|
88 | - if ( empty( $offer ) ) { |
|
89 | - wp_insert_term( |
|
90 | - 'Offer', |
|
91 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
92 | - array( |
|
93 | - 'slug' => 'offer', |
|
94 | - 'description' => 'An Offer.', |
|
95 | - ) |
|
96 | - ); |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Add additional `read_wordlift_entity` capability to editors. |
|
102 | - * |
|
103 | - * @return void |
|
104 | - * @since 3.18.0 |
|
105 | - */ |
|
106 | - public function add_editors_read_wordlift_entity_capability() { |
|
107 | - // Get the editor roles. |
|
108 | - $admins = get_role( 'administrator' ); |
|
109 | - $admins->add_cap( 'read_wordlift_entity' ); |
|
110 | - |
|
111 | - /* |
|
18 | + /** |
|
19 | + * @inheritdoc |
|
20 | + */ |
|
21 | + protected static $version = '3.18.0'; |
|
22 | + |
|
23 | + /** |
|
24 | + * @inheritdoc |
|
25 | + */ |
|
26 | + public function __construct() { |
|
27 | + parent::__construct(); |
|
28 | + |
|
29 | + add_action( |
|
30 | + 'wl_async_wl_push_references', |
|
31 | + array( |
|
32 | + $this, |
|
33 | + 'push_references', |
|
34 | + ) |
|
35 | + ); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @inheritdoc |
|
40 | + */ |
|
41 | + public function install() { |
|
42 | + $this->add_offer_entity_type(); |
|
43 | + $this->add_editors_read_wordlift_entity_capability(); |
|
44 | + do_action( 'wl_push_references' ); |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Creates references for articles *referencing* entities |
|
49 | + * |
|
50 | + * @return void |
|
51 | + * @since 3.18.0 |
|
52 | + */ |
|
53 | + public function push_references() { |
|
54 | + // Get relations. |
|
55 | + $relations = Wordlift_Relation_Service::get_instance()->find_all_grouped_by_subject_id(); |
|
56 | + |
|
57 | + $entity_service = Wordlift_Entity_Service::get_instance(); |
|
58 | + |
|
59 | + // Loop through all relations and push the references. |
|
60 | + foreach ( $relations as $relation ) { |
|
61 | + |
|
62 | + $post = get_post( $relation->subject_id ); |
|
63 | + |
|
64 | + // Bail out if it's an entity: we're only interested in articles |
|
65 | + // *referencing* entities. |
|
66 | + if ( $entity_service->is_entity( $post->ID ) ) { |
|
67 | + continue; |
|
68 | + } |
|
69 | + } |
|
70 | + |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Adds the new `Offer` entity type. |
|
75 | + * |
|
76 | + * @return void |
|
77 | + * @since 3.18.0 |
|
78 | + */ |
|
79 | + public function add_offer_entity_type() { |
|
80 | + // Check whether the `offer` term exists. |
|
81 | + $offer = get_term_by( |
|
82 | + 'slug', |
|
83 | + 'offer', |
|
84 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME |
|
85 | + ); |
|
86 | + |
|
87 | + // The `offer` term doesn't exists, so create it. |
|
88 | + if ( empty( $offer ) ) { |
|
89 | + wp_insert_term( |
|
90 | + 'Offer', |
|
91 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
92 | + array( |
|
93 | + 'slug' => 'offer', |
|
94 | + 'description' => 'An Offer.', |
|
95 | + ) |
|
96 | + ); |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Add additional `read_wordlift_entity` capability to editors. |
|
102 | + * |
|
103 | + * @return void |
|
104 | + * @since 3.18.0 |
|
105 | + */ |
|
106 | + public function add_editors_read_wordlift_entity_capability() { |
|
107 | + // Get the editor roles. |
|
108 | + $admins = get_role( 'administrator' ); |
|
109 | + $admins->add_cap( 'read_wordlift_entity' ); |
|
110 | + |
|
111 | + /* |
|
112 | 112 | * Check that the `editor` role exists before using it. |
113 | 113 | * |
114 | 114 | * @since 3.19.6 |
115 | 115 | * |
116 | 116 | * @see https://github.com/insideout10/wordlift-plugin/issues/886 |
117 | 117 | */ |
118 | - $editors = get_role( 'editor' ); |
|
119 | - if ( isset( $editors ) ) { |
|
120 | - $editors->add_cap( 'read_wordlift_entity' ); |
|
121 | - } |
|
118 | + $editors = get_role( 'editor' ); |
|
119 | + if ( isset( $editors ) ) { |
|
120 | + $editors->add_cap( 'read_wordlift_entity' ); |
|
121 | + } |
|
122 | 122 | |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | 125 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function install() { |
42 | 42 | $this->add_offer_entity_type(); |
43 | 43 | $this->add_editors_read_wordlift_entity_capability(); |
44 | - do_action( 'wl_push_references' ); |
|
44 | + do_action('wl_push_references'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | $entity_service = Wordlift_Entity_Service::get_instance(); |
58 | 58 | |
59 | 59 | // Loop through all relations and push the references. |
60 | - foreach ( $relations as $relation ) { |
|
60 | + foreach ($relations as $relation) { |
|
61 | 61 | |
62 | - $post = get_post( $relation->subject_id ); |
|
62 | + $post = get_post($relation->subject_id); |
|
63 | 63 | |
64 | 64 | // Bail out if it's an entity: we're only interested in articles |
65 | 65 | // *referencing* entities. |
66 | - if ( $entity_service->is_entity( $post->ID ) ) { |
|
66 | + if ($entity_service->is_entity($post->ID)) { |
|
67 | 67 | continue; |
68 | 68 | } |
69 | 69 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | ); |
86 | 86 | |
87 | 87 | // The `offer` term doesn't exists, so create it. |
88 | - if ( empty( $offer ) ) { |
|
88 | + if (empty($offer)) { |
|
89 | 89 | wp_insert_term( |
90 | 90 | 'Offer', |
91 | 91 | Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function add_editors_read_wordlift_entity_capability() { |
107 | 107 | // Get the editor roles. |
108 | - $admins = get_role( 'administrator' ); |
|
109 | - $admins->add_cap( 'read_wordlift_entity' ); |
|
108 | + $admins = get_role('administrator'); |
|
109 | + $admins->add_cap('read_wordlift_entity'); |
|
110 | 110 | |
111 | 111 | /* |
112 | 112 | * Check that the `editor` role exists before using it. |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @see https://github.com/insideout10/wordlift-plugin/issues/886 |
117 | 117 | */ |
118 | - $editors = get_role( 'editor' ); |
|
119 | - if ( isset( $editors ) ) { |
|
120 | - $editors->add_cap( 'read_wordlift_entity' ); |
|
118 | + $editors = get_role('editor'); |
|
119 | + if (isset($editors)) { |
|
120 | + $editors->add_cap('read_wordlift_entity'); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | } |
@@ -14,32 +14,32 @@ |
||
14 | 14 | */ |
15 | 15 | class Wordlift_Install_3_23_4 extends Wordlift_Install { |
16 | 16 | |
17 | - /** |
|
18 | - * {@inheritdoc} |
|
19 | - */ |
|
20 | - protected static $version = '3.23.4'; |
|
17 | + /** |
|
18 | + * {@inheritdoc} |
|
19 | + */ |
|
20 | + protected static $version = '3.23.4'; |
|
21 | 21 | |
22 | - public function install() { |
|
22 | + public function install() { |
|
23 | 23 | |
24 | - $existing_term = get_term_by( 'slug', 'web-page', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
24 | + $existing_term = get_term_by( 'slug', 'web-page', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
25 | 25 | |
26 | - // Bail out if term exists. |
|
27 | - if ( false !== $existing_term ) { |
|
28 | - return; |
|
29 | - } |
|
26 | + // Bail out if term exists. |
|
27 | + if ( false !== $existing_term ) { |
|
28 | + return; |
|
29 | + } |
|
30 | 30 | |
31 | - $term = wp_insert_term( |
|
32 | - 'WebPage', |
|
33 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
34 | - array( |
|
35 | - 'slug' => 'web-page', |
|
36 | - 'description' => 'A Web Page.', |
|
37 | - ) |
|
38 | - ); |
|
31 | + $term = wp_insert_term( |
|
32 | + 'WebPage', |
|
33 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
34 | + array( |
|
35 | + 'slug' => 'web-page', |
|
36 | + 'description' => 'A Web Page.', |
|
37 | + ) |
|
38 | + ); |
|
39 | 39 | |
40 | - update_term_meta( $term['term_id'], '_wl_name', 'WebPage' ); |
|
41 | - update_term_meta( $term['term_id'], '_wl_uri', 'http://schema.org/WebPage' ); |
|
40 | + update_term_meta( $term['term_id'], '_wl_name', 'WebPage' ); |
|
41 | + update_term_meta( $term['term_id'], '_wl_uri', 'http://schema.org/WebPage' ); |
|
42 | 42 | |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | 45 | } |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | |
22 | 22 | public function install() { |
23 | 23 | |
24 | - $existing_term = get_term_by( 'slug', 'web-page', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
24 | + $existing_term = get_term_by('slug', 'web-page', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
25 | 25 | |
26 | 26 | // Bail out if term exists. |
27 | - if ( false !== $existing_term ) { |
|
27 | + if (false !== $existing_term) { |
|
28 | 28 | return; |
29 | 29 | } |
30 | 30 | |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | ) |
38 | 38 | ); |
39 | 39 | |
40 | - update_term_meta( $term['term_id'], '_wl_name', 'WebPage' ); |
|
41 | - update_term_meta( $term['term_id'], '_wl_uri', 'http://schema.org/WebPage' ); |
|
40 | + update_term_meta($term['term_id'], '_wl_name', 'WebPage'); |
|
41 | + update_term_meta($term['term_id'], '_wl_uri', 'http://schema.org/WebPage'); |
|
42 | 42 | |
43 | 43 | } |
44 | 44 |
@@ -42,67 +42,67 @@ |
||
42 | 42 | // Mapping options / validations rules used by wl_core_get_posts to perform validation on args |
43 | 43 | // The array is serialized because array constants are only from php 5.6 on. |
44 | 44 | define( |
45 | - 'WL_CORE_GET_POSTS_VALIDATION_RULES', |
|
46 | - // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize |
|
47 | - serialize( |
|
48 | - array( |
|
49 | - 'get' => array( 'posts', 'post_ids' ), |
|
50 | - 'as' => array( 'object', 'subject' ), |
|
51 | - 'post_type' => array( 'post', 'entity' ), |
|
52 | - 'post_status' => array( 'draft', 'trash', 'publish' ), |
|
53 | - 'with_predicate' => array( |
|
54 | - WL_WHAT_RELATION, |
|
55 | - WL_WHEN_RELATION, |
|
56 | - WL_WHERE_RELATION, |
|
57 | - WL_WHO_RELATION, |
|
58 | - ), |
|
59 | - ) |
|
60 | - ) |
|
45 | + 'WL_CORE_GET_POSTS_VALIDATION_RULES', |
|
46 | + // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize |
|
47 | + serialize( |
|
48 | + array( |
|
49 | + 'get' => array( 'posts', 'post_ids' ), |
|
50 | + 'as' => array( 'object', 'subject' ), |
|
51 | + 'post_type' => array( 'post', 'entity' ), |
|
52 | + 'post_status' => array( 'draft', 'trash', 'publish' ), |
|
53 | + 'with_predicate' => array( |
|
54 | + WL_WHAT_RELATION, |
|
55 | + WL_WHEN_RELATION, |
|
56 | + WL_WHERE_RELATION, |
|
57 | + WL_WHO_RELATION, |
|
58 | + ), |
|
59 | + ) |
|
60 | + ) |
|
61 | 61 | ); |
62 | 62 | |
63 | 63 | // Classification boxes configuration for angularjs edit-post widget |
64 | 64 | // The array is serialized because array constants are only from php 5.6 on. |
65 | 65 | |
66 | 66 | define( |
67 | - 'WL_CORE_POST_CLASSIFICATION_BOXES', |
|
68 | - // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize |
|
69 | - serialize( |
|
70 | - array( |
|
71 | - array( |
|
72 | - 'id' => WL_WHAT_RELATION, |
|
73 | - 'label' => 'What', |
|
74 | - 'registeredTypes' => array( |
|
75 | - 'thing', |
|
76 | - 'creative-work', |
|
77 | - 'recipe', |
|
78 | - ), |
|
79 | - 'selectedEntities' => array(), |
|
80 | - ), |
|
81 | - array( |
|
82 | - 'id' => WL_WHO_RELATION, |
|
83 | - 'label' => 'Who', |
|
84 | - 'registeredTypes' => array( |
|
85 | - 'organization', |
|
86 | - 'person', |
|
87 | - 'local-business', |
|
88 | - 'localbusiness', |
|
89 | - ), |
|
90 | - 'selectedEntities' => array(), |
|
91 | - ), |
|
92 | - array( |
|
93 | - 'id' => WL_WHERE_RELATION, |
|
94 | - 'label' => 'Where', |
|
95 | - 'registeredTypes' => array( 'place' ), |
|
96 | - 'selectedEntities' => array(), |
|
97 | - ), |
|
98 | - array( |
|
99 | - 'id' => WL_WHEN_RELATION, |
|
100 | - 'label' => 'When', |
|
101 | - 'registeredTypes' => array( 'event' ), |
|
102 | - 'selectedEntities' => array(), |
|
103 | - ), |
|
104 | - ) |
|
105 | - ) |
|
67 | + 'WL_CORE_POST_CLASSIFICATION_BOXES', |
|
68 | + // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize |
|
69 | + serialize( |
|
70 | + array( |
|
71 | + array( |
|
72 | + 'id' => WL_WHAT_RELATION, |
|
73 | + 'label' => 'What', |
|
74 | + 'registeredTypes' => array( |
|
75 | + 'thing', |
|
76 | + 'creative-work', |
|
77 | + 'recipe', |
|
78 | + ), |
|
79 | + 'selectedEntities' => array(), |
|
80 | + ), |
|
81 | + array( |
|
82 | + 'id' => WL_WHO_RELATION, |
|
83 | + 'label' => 'Who', |
|
84 | + 'registeredTypes' => array( |
|
85 | + 'organization', |
|
86 | + 'person', |
|
87 | + 'local-business', |
|
88 | + 'localbusiness', |
|
89 | + ), |
|
90 | + 'selectedEntities' => array(), |
|
91 | + ), |
|
92 | + array( |
|
93 | + 'id' => WL_WHERE_RELATION, |
|
94 | + 'label' => 'Where', |
|
95 | + 'registeredTypes' => array( 'place' ), |
|
96 | + 'selectedEntities' => array(), |
|
97 | + ), |
|
98 | + array( |
|
99 | + 'id' => WL_WHEN_RELATION, |
|
100 | + 'label' => 'When', |
|
101 | + 'registeredTypes' => array( 'event' ), |
|
102 | + 'selectedEntities' => array(), |
|
103 | + ), |
|
104 | + ) |
|
105 | + ) |
|
106 | 106 | ); |
107 | 107 | |
108 | 108 | // Default namespace for wp-json |
@@ -1,43 +1,43 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -define( 'WL_DEFAULT_THUMBNAIL_PATH', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/public/images/missing-image-150x150.png' ); |
|
4 | -define( 'WL_DEFAULT_PATH', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/' ); |
|
3 | +define('WL_DEFAULT_THUMBNAIL_PATH', dirname(dirname(plugin_dir_url(__FILE__))).'/public/images/missing-image-150x150.png'); |
|
4 | +define('WL_DEFAULT_PATH', dirname(dirname(plugin_dir_url(__FILE__))).'/'); |
|
5 | 5 | |
6 | 6 | // Custom table name |
7 | -define( 'WL_DB_RELATION_INSTANCES_TABLE_NAME', 'wl_relation_instances' ); |
|
7 | +define('WL_DB_RELATION_INSTANCES_TABLE_NAME', 'wl_relation_instances'); |
|
8 | 8 | |
9 | -define( 'WL_WHAT_RELATION', 'what' ); |
|
10 | -define( 'WL_WHO_RELATION', 'who' ); |
|
11 | -define( 'WL_WHERE_RELATION', 'where' ); |
|
12 | -define( 'WL_WHEN_RELATION', 'when' ); |
|
9 | +define('WL_WHAT_RELATION', 'what'); |
|
10 | +define('WL_WHO_RELATION', 'who'); |
|
11 | +define('WL_WHERE_RELATION', 'where'); |
|
12 | +define('WL_WHEN_RELATION', 'when'); |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Define wl_mapping_table_name |
16 | 16 | * |
17 | 17 | * @since 3.25.0 |
18 | 18 | */ |
19 | -define( 'WL_MAPPING_TABLE_NAME', 'wl_mapping' ); |
|
19 | +define('WL_MAPPING_TABLE_NAME', 'wl_mapping'); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Define wl_rule_group_table_name |
23 | 23 | * |
24 | 24 | * @since 3.25.0 |
25 | 25 | */ |
26 | -define( 'WL_RULE_GROUP_TABLE_NAME', 'wl_mapping_rule_group' ); |
|
26 | +define('WL_RULE_GROUP_TABLE_NAME', 'wl_mapping_rule_group'); |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Define wl_rule_table_name |
30 | 30 | * |
31 | 31 | * @since 3.25.0 |
32 | 32 | */ |
33 | -define( 'WL_RULE_TABLE_NAME', 'wl_mapping_rule' ); |
|
33 | +define('WL_RULE_TABLE_NAME', 'wl_mapping_rule'); |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Define wl_property_table_name |
37 | 37 | * |
38 | 38 | * @since 3.25.0 |
39 | 39 | */ |
40 | -define( 'WL_PROPERTY_TABLE_NAME', 'wl_mapping_property' ); |
|
40 | +define('WL_PROPERTY_TABLE_NAME', 'wl_mapping_property'); |
|
41 | 41 | |
42 | 42 | // Mapping options / validations rules used by wl_core_get_posts to perform validation on args |
43 | 43 | // The array is serialized because array constants are only from php 5.6 on. |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize |
47 | 47 | serialize( |
48 | 48 | array( |
49 | - 'get' => array( 'posts', 'post_ids' ), |
|
50 | - 'as' => array( 'object', 'subject' ), |
|
51 | - 'post_type' => array( 'post', 'entity' ), |
|
52 | - 'post_status' => array( 'draft', 'trash', 'publish' ), |
|
49 | + 'get' => array('posts', 'post_ids'), |
|
50 | + 'as' => array('object', 'subject'), |
|
51 | + 'post_type' => array('post', 'entity'), |
|
52 | + 'post_status' => array('draft', 'trash', 'publish'), |
|
53 | 53 | 'with_predicate' => array( |
54 | 54 | WL_WHAT_RELATION, |
55 | 55 | WL_WHEN_RELATION, |
@@ -92,13 +92,13 @@ discard block |
||
92 | 92 | array( |
93 | 93 | 'id' => WL_WHERE_RELATION, |
94 | 94 | 'label' => 'Where', |
95 | - 'registeredTypes' => array( 'place' ), |
|
95 | + 'registeredTypes' => array('place'), |
|
96 | 96 | 'selectedEntities' => array(), |
97 | 97 | ), |
98 | 98 | array( |
99 | 99 | 'id' => WL_WHEN_RELATION, |
100 | 100 | 'label' => 'When', |
101 | - 'registeredTypes' => array( 'event' ), |
|
101 | + 'registeredTypes' => array('event'), |
|
102 | 102 | 'selectedEntities' => array(), |
103 | 103 | ), |
104 | 104 | ) |
@@ -106,4 +106,4 @@ discard block |
||
106 | 106 | ); |
107 | 107 | |
108 | 108 | // Default namespace for wp-json |
109 | -define( 'WL_REST_ROUTE_DEFAULT_NAMESPACE', 'wordlift/v1' ); |
|
109 | +define('WL_REST_ROUTE_DEFAULT_NAMESPACE', 'wordlift/v1'); |
@@ -7,9 +7,9 @@ |
||
7 | 7 | * @param mixed $response The response to send to the client as JSON. |
8 | 8 | */ |
9 | 9 | function wl_core_send_json( $response ) { |
10 | - if ( ob_get_contents() ) { |
|
11 | - ob_clean(); |
|
12 | - } |
|
10 | + if ( ob_get_contents() ) { |
|
11 | + ob_clean(); |
|
12 | + } |
|
13 | 13 | |
14 | - wp_send_json( $response ); |
|
14 | + wp_send_json( $response ); |
|
15 | 15 | } |
@@ -6,10 +6,10 @@ |
||
6 | 6 | * |
7 | 7 | * @param mixed $response The response to send to the client as JSON. |
8 | 8 | */ |
9 | -function wl_core_send_json( $response ) { |
|
10 | - if ( ob_get_contents() ) { |
|
9 | +function wl_core_send_json($response) { |
|
10 | + if (ob_get_contents()) { |
|
11 | 11 | ob_clean(); |
12 | 12 | } |
13 | 13 | |
14 | - wp_send_json( $response ); |
|
14 | + wp_send_json($response); |
|
15 | 15 | } |
@@ -17,34 +17,34 @@ discard block |
||
17 | 17 | */ |
18 | 18 | function wl_schema_get_value( $post_id, $property_name ) { |
19 | 19 | |
20 | - // Property name must be defined. |
|
21 | - if ( ! isset( $property_name ) || $property_name === null ) { |
|
22 | - return null; |
|
23 | - } |
|
24 | - |
|
25 | - // store eventual schema name in different variable |
|
26 | - $property_schema_name = wl_build_full_schema_uri_from_schema_slug( $property_name ); |
|
27 | - |
|
28 | - // Establish entity id. |
|
29 | - if ( $post_id === null || ! is_numeric( $post_id ) ) { |
|
30 | - $post_id = get_the_ID(); |
|
31 | - if ( $post_id === null || ! is_numeric( $post_id ) ) { |
|
32 | - return null; |
|
33 | - } |
|
34 | - } |
|
35 | - |
|
36 | - // Get custom fields. |
|
37 | - $term_mapping = wl_entity_taxonomy_get_custom_fields( $post_id ); |
|
38 | - // Search for the required meta value (by constant name or schema name) |
|
39 | - foreach ( $term_mapping as $wl_constant => $property_info ) { |
|
40 | - $found_constant = ( $wl_constant === $property_name ); |
|
41 | - $found_predicate = ( isset( $property_info['predicate'] ) && $property_info['predicate'] === $property_schema_name ); |
|
42 | - if ( $found_constant || $found_predicate ) { |
|
43 | - return get_post_meta( $post_id, $wl_constant ); |
|
44 | - } |
|
45 | - } |
|
46 | - |
|
47 | - return null; |
|
20 | + // Property name must be defined. |
|
21 | + if ( ! isset( $property_name ) || $property_name === null ) { |
|
22 | + return null; |
|
23 | + } |
|
24 | + |
|
25 | + // store eventual schema name in different variable |
|
26 | + $property_schema_name = wl_build_full_schema_uri_from_schema_slug( $property_name ); |
|
27 | + |
|
28 | + // Establish entity id. |
|
29 | + if ( $post_id === null || ! is_numeric( $post_id ) ) { |
|
30 | + $post_id = get_the_ID(); |
|
31 | + if ( $post_id === null || ! is_numeric( $post_id ) ) { |
|
32 | + return null; |
|
33 | + } |
|
34 | + } |
|
35 | + |
|
36 | + // Get custom fields. |
|
37 | + $term_mapping = wl_entity_taxonomy_get_custom_fields( $post_id ); |
|
38 | + // Search for the required meta value (by constant name or schema name) |
|
39 | + foreach ( $term_mapping as $wl_constant => $property_info ) { |
|
40 | + $found_constant = ( $wl_constant === $property_name ); |
|
41 | + $found_predicate = ( isset( $property_info['predicate'] ) && $property_info['predicate'] === $property_schema_name ); |
|
42 | + if ( $found_constant || $found_predicate ) { |
|
43 | + return get_post_meta( $post_id, $wl_constant ); |
|
44 | + } |
|
45 | + } |
|
46 | + |
|
47 | + return null; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -58,38 +58,38 @@ discard block |
||
58 | 58 | */ |
59 | 59 | function wl_schema_set_value( $post_id, $property_name, $property_value ) { |
60 | 60 | |
61 | - // Some checks on the parameters |
|
62 | - if ( ! is_numeric( $post_id ) || $property_name === null || empty( $property_value ) || $property_value === null ) { |
|
63 | - return false; |
|
64 | - } |
|
61 | + // Some checks on the parameters |
|
62 | + if ( ! is_numeric( $post_id ) || $property_name === null || empty( $property_value ) || $property_value === null ) { |
|
63 | + return false; |
|
64 | + } |
|
65 | 65 | |
66 | - // Build full schema uri if necessary |
|
67 | - $property_name = wl_build_full_schema_uri_from_schema_slug( $property_name ); |
|
66 | + // Build full schema uri if necessary |
|
67 | + $property_name = wl_build_full_schema_uri_from_schema_slug( $property_name ); |
|
68 | 68 | |
69 | - // Get accepted properties |
|
70 | - $accepted_fields = wl_entity_taxonomy_get_custom_fields( $post_id ); |
|
69 | + // Get accepted properties |
|
70 | + $accepted_fields = wl_entity_taxonomy_get_custom_fields( $post_id ); |
|
71 | 71 | |
72 | - // Find the name of the custom-field managing the schema property |
|
73 | - foreach ( $accepted_fields as $wl_constant => $field ) { |
|
74 | - if ( $field['predicate'] === $property_name ) { |
|
72 | + // Find the name of the custom-field managing the schema property |
|
73 | + foreach ( $accepted_fields as $wl_constant => $field ) { |
|
74 | + if ( $field['predicate'] === $property_name ) { |
|
75 | 75 | |
76 | - // Deal with single values |
|
77 | - if ( ! is_array( $property_value ) ) { |
|
78 | - $property_value = array( $property_value ); |
|
79 | - } |
|
76 | + // Deal with single values |
|
77 | + if ( ! is_array( $property_value ) ) { |
|
78 | + $property_value = array( $property_value ); |
|
79 | + } |
|
80 | 80 | |
81 | - // Delete present meta |
|
82 | - delete_post_meta( $post_id, $wl_constant ); |
|
81 | + // Delete present meta |
|
82 | + delete_post_meta( $post_id, $wl_constant ); |
|
83 | 83 | |
84 | - foreach ( $property_value as $value ) { |
|
85 | - add_post_meta( $post_id, $wl_constant, $value ); |
|
86 | - } |
|
84 | + foreach ( $property_value as $value ) { |
|
85 | + add_post_meta( $post_id, $wl_constant, $value ); |
|
86 | + } |
|
87 | 87 | |
88 | - return true; |
|
89 | - } |
|
90 | - } |
|
88 | + return true; |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - return false; |
|
92 | + return false; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -102,18 +102,18 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function wl_schema_get_types( $post_id ) { |
104 | 104 | |
105 | - // Some checks on the parameters |
|
106 | - if ( ! is_numeric( $post_id ) ) { |
|
107 | - return null; |
|
108 | - } |
|
105 | + // Some checks on the parameters |
|
106 | + if ( ! is_numeric( $post_id ) ) { |
|
107 | + return null; |
|
108 | + } |
|
109 | 109 | |
110 | - $type = Wordlift_Entity_Type_Service::get_instance()->get( $post_id ); |
|
110 | + $type = Wordlift_Entity_Type_Service::get_instance()->get( $post_id ); |
|
111 | 111 | |
112 | - if ( isset( $type['uri'] ) ) { |
|
113 | - return array( $type['uri'] ); |
|
114 | - } |
|
112 | + if ( isset( $type['uri'] ) ) { |
|
113 | + return array( $type['uri'] ); |
|
114 | + } |
|
115 | 115 | |
116 | - return null; |
|
116 | + return null; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -126,21 +126,21 @@ discard block |
||
126 | 126 | */ |
127 | 127 | function wl_schema_set_types( $post_id, $type_names ) { |
128 | 128 | |
129 | - // Some checks on the parameters |
|
130 | - if ( ! is_numeric( $post_id ) || empty( $type_names ) || $type_names === null ) { |
|
131 | - return null; |
|
132 | - } |
|
129 | + // Some checks on the parameters |
|
130 | + if ( ! is_numeric( $post_id ) || empty( $type_names ) || $type_names === null ) { |
|
131 | + return null; |
|
132 | + } |
|
133 | 133 | |
134 | - // TODO: support more than one type. |
|
135 | - if ( is_array( $type_names ) ) { |
|
136 | - $type_names = $type_names[0]; |
|
137 | - } |
|
134 | + // TODO: support more than one type. |
|
135 | + if ( is_array( $type_names ) ) { |
|
136 | + $type_names = $type_names[0]; |
|
137 | + } |
|
138 | 138 | |
139 | - // Get the schema URI (e.g. http://schema.org/Thing) |
|
140 | - $type_names = wl_build_full_schema_uri_from_schema_slug( $type_names ); |
|
139 | + // Get the schema URI (e.g. http://schema.org/Thing) |
|
140 | + $type_names = wl_build_full_schema_uri_from_schema_slug( $type_names ); |
|
141 | 141 | |
142 | - // Actually sets the taxonomy type |
|
143 | - wl_set_entity_main_type( $post_id, $type_names ); |
|
142 | + // Actually sets the taxonomy type |
|
143 | + wl_set_entity_main_type( $post_id, $type_names ); |
|
144 | 144 | |
145 | 145 | } |
146 | 146 | |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | */ |
154 | 154 | function wl_build_full_schema_uri_from_schema_slug( $schema_name ) { |
155 | 155 | |
156 | - $schema_root_address = 'http://schema.org/'; |
|
156 | + $schema_root_address = 'http://schema.org/'; |
|
157 | 157 | |
158 | - if ( strpos( $schema_name, $schema_root_address ) === false ) { // === necessary |
|
159 | - $schema_name = $schema_root_address . $schema_name; |
|
160 | - } |
|
158 | + if ( strpos( $schema_name, $schema_root_address ) === false ) { // === necessary |
|
159 | + $schema_name = $schema_root_address . $schema_name; |
|
160 | + } |
|
161 | 161 | |
162 | - return $schema_name; |
|
162 | + return $schema_name; |
|
163 | 163 | } |
@@ -15,32 +15,32 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @return array|null An array of values or NULL in case of no values (or error). |
17 | 17 | */ |
18 | -function wl_schema_get_value( $post_id, $property_name ) { |
|
18 | +function wl_schema_get_value($post_id, $property_name) { |
|
19 | 19 | |
20 | 20 | // Property name must be defined. |
21 | - if ( ! isset( $property_name ) || $property_name === null ) { |
|
21 | + if ( ! isset($property_name) || $property_name === null) { |
|
22 | 22 | return null; |
23 | 23 | } |
24 | 24 | |
25 | 25 | // store eventual schema name in different variable |
26 | - $property_schema_name = wl_build_full_schema_uri_from_schema_slug( $property_name ); |
|
26 | + $property_schema_name = wl_build_full_schema_uri_from_schema_slug($property_name); |
|
27 | 27 | |
28 | 28 | // Establish entity id. |
29 | - if ( $post_id === null || ! is_numeric( $post_id ) ) { |
|
29 | + if ($post_id === null || ! is_numeric($post_id)) { |
|
30 | 30 | $post_id = get_the_ID(); |
31 | - if ( $post_id === null || ! is_numeric( $post_id ) ) { |
|
31 | + if ($post_id === null || ! is_numeric($post_id)) { |
|
32 | 32 | return null; |
33 | 33 | } |
34 | 34 | } |
35 | 35 | |
36 | 36 | // Get custom fields. |
37 | - $term_mapping = wl_entity_taxonomy_get_custom_fields( $post_id ); |
|
37 | + $term_mapping = wl_entity_taxonomy_get_custom_fields($post_id); |
|
38 | 38 | // Search for the required meta value (by constant name or schema name) |
39 | - foreach ( $term_mapping as $wl_constant => $property_info ) { |
|
40 | - $found_constant = ( $wl_constant === $property_name ); |
|
41 | - $found_predicate = ( isset( $property_info['predicate'] ) && $property_info['predicate'] === $property_schema_name ); |
|
42 | - if ( $found_constant || $found_predicate ) { |
|
43 | - return get_post_meta( $post_id, $wl_constant ); |
|
39 | + foreach ($term_mapping as $wl_constant => $property_info) { |
|
40 | + $found_constant = ($wl_constant === $property_name); |
|
41 | + $found_predicate = (isset($property_info['predicate']) && $property_info['predicate'] === $property_schema_name); |
|
42 | + if ($found_constant || $found_predicate) { |
|
43 | + return get_post_meta($post_id, $wl_constant); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
@@ -56,33 +56,33 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return boolean The method returns true if everything went ok, an error string otherwise. |
58 | 58 | */ |
59 | -function wl_schema_set_value( $post_id, $property_name, $property_value ) { |
|
59 | +function wl_schema_set_value($post_id, $property_name, $property_value) { |
|
60 | 60 | |
61 | 61 | // Some checks on the parameters |
62 | - if ( ! is_numeric( $post_id ) || $property_name === null || empty( $property_value ) || $property_value === null ) { |
|
62 | + if ( ! is_numeric($post_id) || $property_name === null || empty($property_value) || $property_value === null) { |
|
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | |
66 | 66 | // Build full schema uri if necessary |
67 | - $property_name = wl_build_full_schema_uri_from_schema_slug( $property_name ); |
|
67 | + $property_name = wl_build_full_schema_uri_from_schema_slug($property_name); |
|
68 | 68 | |
69 | 69 | // Get accepted properties |
70 | - $accepted_fields = wl_entity_taxonomy_get_custom_fields( $post_id ); |
|
70 | + $accepted_fields = wl_entity_taxonomy_get_custom_fields($post_id); |
|
71 | 71 | |
72 | 72 | // Find the name of the custom-field managing the schema property |
73 | - foreach ( $accepted_fields as $wl_constant => $field ) { |
|
74 | - if ( $field['predicate'] === $property_name ) { |
|
73 | + foreach ($accepted_fields as $wl_constant => $field) { |
|
74 | + if ($field['predicate'] === $property_name) { |
|
75 | 75 | |
76 | 76 | // Deal with single values |
77 | - if ( ! is_array( $property_value ) ) { |
|
78 | - $property_value = array( $property_value ); |
|
77 | + if ( ! is_array($property_value)) { |
|
78 | + $property_value = array($property_value); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | // Delete present meta |
82 | - delete_post_meta( $post_id, $wl_constant ); |
|
82 | + delete_post_meta($post_id, $wl_constant); |
|
83 | 83 | |
84 | - foreach ( $property_value as $value ) { |
|
85 | - add_post_meta( $post_id, $wl_constant, $value ); |
|
84 | + foreach ($property_value as $value) { |
|
85 | + add_post_meta($post_id, $wl_constant, $value); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | return true; |
@@ -100,17 +100,17 @@ discard block |
||
100 | 100 | * @return array Array of type(s) (e.g. Type, for the http://schema.org/Type) |
101 | 101 | * or NULL in case of no values (or error). |
102 | 102 | */ |
103 | -function wl_schema_get_types( $post_id ) { |
|
103 | +function wl_schema_get_types($post_id) { |
|
104 | 104 | |
105 | 105 | // Some checks on the parameters |
106 | - if ( ! is_numeric( $post_id ) ) { |
|
106 | + if ( ! is_numeric($post_id)) { |
|
107 | 107 | return null; |
108 | 108 | } |
109 | 109 | |
110 | - $type = Wordlift_Entity_Type_Service::get_instance()->get( $post_id ); |
|
110 | + $type = Wordlift_Entity_Type_Service::get_instance()->get($post_id); |
|
111 | 111 | |
112 | - if ( isset( $type['uri'] ) ) { |
|
113 | - return array( $type['uri'] ); |
|
112 | + if (isset($type['uri'])) { |
|
113 | + return array($type['uri']); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return null; |
@@ -124,23 +124,23 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return boolean True if everything went ok, an error string otherwise. |
126 | 126 | */ |
127 | -function wl_schema_set_types( $post_id, $type_names ) { |
|
127 | +function wl_schema_set_types($post_id, $type_names) { |
|
128 | 128 | |
129 | 129 | // Some checks on the parameters |
130 | - if ( ! is_numeric( $post_id ) || empty( $type_names ) || $type_names === null ) { |
|
130 | + if ( ! is_numeric($post_id) || empty($type_names) || $type_names === null) { |
|
131 | 131 | return null; |
132 | 132 | } |
133 | 133 | |
134 | 134 | // TODO: support more than one type. |
135 | - if ( is_array( $type_names ) ) { |
|
135 | + if (is_array($type_names)) { |
|
136 | 136 | $type_names = $type_names[0]; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // Get the schema URI (e.g. http://schema.org/Thing) |
140 | - $type_names = wl_build_full_schema_uri_from_schema_slug( $type_names ); |
|
140 | + $type_names = wl_build_full_schema_uri_from_schema_slug($type_names); |
|
141 | 141 | |
142 | 142 | // Actually sets the taxonomy type |
143 | - wl_set_entity_main_type( $post_id, $type_names ); |
|
143 | + wl_set_entity_main_type($post_id, $type_names); |
|
144 | 144 | |
145 | 145 | } |
146 | 146 | |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return string The full schema uri (es. 'latitude' returns 'http://schema.org/latitude') |
153 | 153 | */ |
154 | -function wl_build_full_schema_uri_from_schema_slug( $schema_name ) { |
|
154 | +function wl_build_full_schema_uri_from_schema_slug($schema_name) { |
|
155 | 155 | |
156 | 156 | $schema_root_address = 'http://schema.org/'; |
157 | 157 | |
158 | - if ( strpos( $schema_name, $schema_root_address ) === false ) { // === necessary |
|
159 | - $schema_name = $schema_root_address . $schema_name; |
|
158 | + if (strpos($schema_name, $schema_root_address) === false) { // === necessary |
|
159 | + $schema_name = $schema_root_address.$schema_name; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | return $schema_name; |
@@ -12,6 +12,6 @@ |
||
12 | 12 | */ |
13 | 13 | function wl_configuration_get_redlink_dataset_uri() { |
14 | 14 | |
15 | - return Wordlift_Configuration_Service::get_instance()->get_dataset_uri(); |
|
15 | + return Wordlift_Configuration_Service::get_instance()->get_dataset_uri(); |
|
16 | 16 | } |
17 | 17 |