@@ -11,40 +11,40 @@ |
||
11 | 11 | |
12 | 12 | class Wordlift_Install_3_24_2 extends Wordlift_Install { |
13 | 13 | |
14 | - /** |
|
15 | - * {@inheritdoc} |
|
16 | - */ |
|
17 | - protected static $version = '3.24.2'; |
|
14 | + /** |
|
15 | + * {@inheritdoc} |
|
16 | + */ |
|
17 | + protected static $version = '3.24.2'; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @inheritDoc |
|
21 | - */ |
|
22 | - public function install() { |
|
19 | + /** |
|
20 | + * @inheritDoc |
|
21 | + */ |
|
22 | + public function install() { |
|
23 | 23 | |
24 | - global $wpdb; |
|
24 | + global $wpdb; |
|
25 | 25 | |
26 | - if ( false === get_option( 'wl_mappings' ) ) { |
|
27 | - add_option( 'wl_mappings', array(), '', true ); |
|
28 | - } |
|
26 | + if ( false === get_option( 'wl_mappings' ) ) { |
|
27 | + add_option( 'wl_mappings', array(), '', true ); |
|
28 | + } |
|
29 | 29 | |
30 | - if ( false === get_option( 'wl_analytics_settings' ) ) { |
|
31 | - add_option( 'wl_analytics_settings', false, '', true ); |
|
32 | - } |
|
30 | + if ( false === get_option( 'wl_analytics_settings' ) ) { |
|
31 | + add_option( 'wl_analytics_settings', false, '', true ); |
|
32 | + } |
|
33 | 33 | |
34 | - if ( false === get_option( 'wl_entity_type_settings' ) ) { |
|
35 | - add_option( 'wl_entity_type_settings', array(), '', true ); |
|
36 | - } |
|
34 | + if ( false === get_option( 'wl_entity_type_settings' ) ) { |
|
35 | + add_option( 'wl_entity_type_settings', array(), '', true ); |
|
36 | + } |
|
37 | 37 | |
38 | - // Added for feature request 1496 (Webhooks) |
|
39 | - if ( false === get_option( 'wl_webhooks_settings' ) ) { |
|
40 | - add_option( 'wl_webhooks_settings', array(), '', false ); |
|
41 | - } |
|
38 | + // Added for feature request 1496 (Webhooks) |
|
39 | + if ( false === get_option( 'wl_webhooks_settings' ) ) { |
|
40 | + add_option( 'wl_webhooks_settings', array(), '', false ); |
|
41 | + } |
|
42 | 42 | |
43 | - $wpdb->query( |
|
44 | - "UPDATE {$wpdb->options} SET autoload = 'yes'" |
|
45 | - . " WHERE option_name IN ( 'wl_mappings', 'wl_analytics_settings', 'wl_entity_type_settings', 'WPLANG' )" |
|
46 | - ); |
|
43 | + $wpdb->query( |
|
44 | + "UPDATE {$wpdb->options} SET autoload = 'yes'" |
|
45 | + . " WHERE option_name IN ( 'wl_mappings', 'wl_analytics_settings', 'wl_entity_type_settings', 'WPLANG' )" |
|
46 | + ); |
|
47 | 47 | |
48 | - } |
|
48 | + } |
|
49 | 49 | |
50 | 50 | } |
@@ -23,21 +23,21 @@ |
||
23 | 23 | |
24 | 24 | global $wpdb; |
25 | 25 | |
26 | - if ( false === get_option( 'wl_mappings' ) ) { |
|
27 | - add_option( 'wl_mappings', array(), '', true ); |
|
26 | + if (false === get_option('wl_mappings')) { |
|
27 | + add_option('wl_mappings', array(), '', true); |
|
28 | 28 | } |
29 | 29 | |
30 | - if ( false === get_option( 'wl_analytics_settings' ) ) { |
|
31 | - add_option( 'wl_analytics_settings', false, '', true ); |
|
30 | + if (false === get_option('wl_analytics_settings')) { |
|
31 | + add_option('wl_analytics_settings', false, '', true); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( false === get_option( 'wl_entity_type_settings' ) ) { |
|
35 | - add_option( 'wl_entity_type_settings', array(), '', true ); |
|
34 | + if (false === get_option('wl_entity_type_settings')) { |
|
35 | + add_option('wl_entity_type_settings', array(), '', true); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // Added for feature request 1496 (Webhooks) |
39 | - if ( false === get_option( 'wl_webhooks_settings' ) ) { |
|
40 | - add_option( 'wl_webhooks_settings', array(), '', false ); |
|
39 | + if (false === get_option('wl_webhooks_settings')) { |
|
40 | + add_option('wl_webhooks_settings', array(), '', false); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | $wpdb->query( |
@@ -15,47 +15,47 @@ discard block |
||
15 | 15 | * @subpackage Wordlift/install |
16 | 16 | */ |
17 | 17 | class Wordlift_Install_3_18_3 extends Wordlift_Install { |
18 | - /** |
|
19 | - * @inheritdoc |
|
20 | - */ |
|
21 | - protected static $version = '3.18.3'; |
|
18 | + /** |
|
19 | + * @inheritdoc |
|
20 | + */ |
|
21 | + protected static $version = '3.18.3'; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @inheritdoc |
|
25 | - */ |
|
26 | - public function install() { |
|
27 | - $this->set_article_term_to_posts(); |
|
28 | - } |
|
23 | + /** |
|
24 | + * @inheritdoc |
|
25 | + */ |
|
26 | + public function install() { |
|
27 | + $this->set_article_term_to_posts(); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Set default article term to posts |
|
32 | - * that exists in `wl_relation_instances` table. |
|
33 | - * |
|
34 | - * @since 3.18.3 |
|
35 | - * |
|
36 | - * @return mixed False if the `article` doesn't exists. |
|
37 | - */ |
|
38 | - public function set_article_term_to_posts() { |
|
39 | - // Load the global $wpdb; |
|
40 | - global $wpdb; |
|
30 | + /** |
|
31 | + * Set default article term to posts |
|
32 | + * that exists in `wl_relation_instances` table. |
|
33 | + * |
|
34 | + * @since 3.18.3 |
|
35 | + * |
|
36 | + * @return mixed False if the `article` doesn't exists. |
|
37 | + */ |
|
38 | + public function set_article_term_to_posts() { |
|
39 | + // Load the global $wpdb; |
|
40 | + global $wpdb; |
|
41 | 41 | |
42 | - // Get the article term. |
|
43 | - $term = get_term_by( |
|
44 | - 'slug', |
|
45 | - 'article', |
|
46 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME |
|
47 | - ); |
|
42 | + // Get the article term. |
|
43 | + $term = get_term_by( |
|
44 | + 'slug', |
|
45 | + 'article', |
|
46 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME |
|
47 | + ); |
|
48 | 48 | |
49 | - // Bail if term doesn't exist. |
|
50 | - if ( empty( $term ) ) { |
|
51 | - return false; |
|
52 | - } |
|
49 | + // Bail if term doesn't exist. |
|
50 | + if ( empty( $term ) ) { |
|
51 | + return false; |
|
52 | + } |
|
53 | 53 | |
54 | - // Set `article` term to all posts that exists in |
|
55 | - // `wl_relation_instances` table and don't have `article` term set. |
|
56 | - $post_ids = $wpdb->get_results( |
|
57 | - $wpdb->prepare( |
|
58 | - " |
|
54 | + // Set `article` term to all posts that exists in |
|
55 | + // `wl_relation_instances` table and don't have `article` term set. |
|
56 | + $post_ids = $wpdb->get_results( |
|
57 | + $wpdb->prepare( |
|
58 | + " |
|
59 | 59 | SELECT DISTINCT p.ID |
60 | 60 | FROM $wpdb->posts AS p |
61 | 61 | INNER JOIN {$wpdb->prefix}wl_relation_instances AS ri |
@@ -70,18 +70,18 @@ discard block |
||
70 | 70 | ) |
71 | 71 | ) |
72 | 72 | ", |
73 | - $term->term_id |
|
74 | - ) |
|
75 | - ); |
|
73 | + $term->term_id |
|
74 | + ) |
|
75 | + ); |
|
76 | 76 | |
77 | - // Loop through all posts and set `article` term for each one. |
|
78 | - foreach ( $post_ids as $p ) { |
|
79 | - wp_set_object_terms( |
|
80 | - (int) $p->ID, |
|
81 | - $term->term_id, |
|
82 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME |
|
83 | - ); |
|
84 | - } |
|
85 | - } |
|
77 | + // Loop through all posts and set `article` term for each one. |
|
78 | + foreach ( $post_ids as $p ) { |
|
79 | + wp_set_object_terms( |
|
80 | + (int) $p->ID, |
|
81 | + $term->term_id, |
|
82 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME |
|
83 | + ); |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | 87 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | ); |
48 | 48 | |
49 | 49 | // Bail if term doesn't exist. |
50 | - if ( empty( $term ) ) { |
|
50 | + if (empty($term)) { |
|
51 | 51 | return false; |
52 | 52 | } |
53 | 53 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | ); |
76 | 76 | |
77 | 77 | // Loop through all posts and set `article` term for each one. |
78 | - foreach ( $post_ids as $p ) { |
|
78 | + foreach ($post_ids as $p) { |
|
79 | 79 | wp_set_object_terms( |
80 | 80 | (int) $p->ID, |
81 | 81 | $term->term_id, |
@@ -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 | } |