@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | // If uninstall not called from WordPress, then exit. |
29 | 29 | if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
30 | - exit; |
|
30 | + exit; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | // Get a reference to WP and the Wordlift plugin |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | |
41 | 41 | // Do a db search for posts of type entity |
42 | 42 | $args = array( |
43 | - 'posts_per_page' => - 1, |
|
44 | - 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
45 | - 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ), |
|
46 | - 'fields' => 'ids', |
|
43 | + 'posts_per_page' => - 1, |
|
44 | + 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
45 | + 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ), |
|
46 | + 'fields' => 'ids', |
|
47 | 47 | ); |
48 | 48 | $entities_array = get_posts( $args ); |
49 | 49 | |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | wl_write_log( 'Deleting entities and their meta... ' ); |
53 | 53 | wl_write_log( $entities_array ); |
54 | 54 | foreach ( $entities_array as $entity_id ) { |
55 | - // Delete the whole entity and its metas. |
|
56 | - wp_delete_post( $entity_id, true ); |
|
55 | + // Delete the whole entity and its metas. |
|
56 | + wp_delete_post( $entity_id, true ); |
|
57 | 57 | } |
58 | 58 | wl_write_log( 'Done.' ); |
59 | 59 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | // We loop over terms in this rude way because in the uninstall script |
74 | 74 | // is not possible to call WP custom taxonomy functions. |
75 | 75 | foreach ( range( 0, 100 ) as $index ) { |
76 | - delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_' . $index ); |
|
77 | - wp_delete_term( $index, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
76 | + delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_' . $index ); |
|
77 | + wp_delete_term( $index, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
78 | 78 | } |
79 | 79 | delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_children' ); // it's a hierarchical taxonomy |
80 | 80 | wl_write_log( 'Done.' ); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | |
28 | 28 | // If uninstall not called from WordPress, then exit. |
29 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
29 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
30 | 30 | exit; |
31 | 31 | } |
32 | 32 | |
@@ -39,52 +39,52 @@ discard block |
||
39 | 39 | */ |
40 | 40 | |
41 | 41 | // Do a db search for posts of type entity |
42 | -$args = array( |
|
43 | - 'posts_per_page' => - 1, |
|
42 | +$args = array( |
|
43 | + 'posts_per_page' => -1, |
|
44 | 44 | 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
45 | - 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ), |
|
45 | + 'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash'), |
|
46 | 46 | 'fields' => 'ids', |
47 | 47 | ); |
48 | -$entities_array = get_posts( $args ); |
|
48 | +$entities_array = get_posts($args); |
|
49 | 49 | |
50 | 50 | // Loop over entities and delete them. |
51 | 51 | // TODO: thumbnails? |
52 | -wl_write_log( 'Deleting entities and their meta... ' ); |
|
53 | -wl_write_log( $entities_array ); |
|
54 | -foreach ( $entities_array as $entity_id ) { |
|
52 | +wl_write_log('Deleting entities and their meta... '); |
|
53 | +wl_write_log($entities_array); |
|
54 | +foreach ($entities_array as $entity_id) { |
|
55 | 55 | // Delete the whole entity and its metas. |
56 | - wp_delete_post( $entity_id, true ); |
|
56 | + wp_delete_post($entity_id, true); |
|
57 | 57 | } |
58 | -wl_write_log( 'Done.' ); |
|
58 | +wl_write_log('Done.'); |
|
59 | 59 | |
60 | 60 | /* |
61 | 61 | * Delete post-entity relationships |
62 | 62 | */ |
63 | -wl_write_log( 'Deleting post-entity relationships... ' ); |
|
64 | -$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wl_relation_instances" ); |
|
65 | -delete_option( 'wl_db_version' ); |
|
66 | -wl_write_log( 'Done.' ); |
|
63 | +wl_write_log('Deleting post-entity relationships... '); |
|
64 | +$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}wl_relation_instances"); |
|
65 | +delete_option('wl_db_version'); |
|
66 | +wl_write_log('Done.'); |
|
67 | 67 | |
68 | 68 | /* |
69 | 69 | * Delete taxonomy |
70 | 70 | */ |
71 | -wl_write_log( 'Cleaning entities taxonomy... ' ); |
|
71 | +wl_write_log('Cleaning entities taxonomy... '); |
|
72 | 72 | // Delte custom taxonomy terms. |
73 | 73 | // We loop over terms in this rude way because in the uninstall script |
74 | 74 | // is not possible to call WP custom taxonomy functions. |
75 | -foreach ( range( 0, 100 ) as $index ) { |
|
76 | - delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_' . $index ); |
|
77 | - wp_delete_term( $index, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
75 | +foreach (range(0, 100) as $index) { |
|
76 | + delete_option(Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME.'_'.$index); |
|
77 | + wp_delete_term($index, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
78 | 78 | } |
79 | -delete_option( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '_children' ); // it's a hierarchical taxonomy |
|
80 | -wl_write_log( 'Done.' ); |
|
79 | +delete_option(Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME.'_children'); // it's a hierarchical taxonomy |
|
80 | +wl_write_log('Done.'); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Delete options |
84 | 84 | */ |
85 | -wl_write_log( 'Cleaning WordLift options... ' ); |
|
85 | +wl_write_log('Cleaning WordLift options... '); |
|
86 | 86 | // delete_option( WL_OPTIONS_NAME ); |
87 | -delete_option( 'wl_option_prefixes' ); |
|
88 | -delete_option( 'wl_general_settings' ); |
|
89 | -delete_option( 'wl_advanced_settings' ); |
|
90 | -wl_write_log( 'Done. WordLift successfully uninstalled.' ); |
|
87 | +delete_option('wl_option_prefixes'); |
|
88 | +delete_option('wl_general_settings'); |
|
89 | +delete_option('wl_advanced_settings'); |
|
90 | +wl_write_log('Done. WordLift successfully uninstalled.'); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | function wl_get_entity_uri( $post_id ) { |
17 | 17 | |
18 | - return Wordlift_Entity_Service::get_instance()->get_uri( $post_id ); |
|
18 | + return Wordlift_Entity_Service::get_instance()->get_uri( $post_id ); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | function wl_get_entity_rdf_types( $post_id ) { |
30 | 30 | |
31 | - return get_post_meta( $post_id, Wordlift_Schema_Service::FIELD_ENTITY_TYPE ); |
|
31 | + return get_post_meta( $post_id, Wordlift_Schema_Service::FIELD_ENTITY_TYPE ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,21 +39,21 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function wl_set_entity_rdf_types( $post_id, $type_uris = array() ) { |
41 | 41 | |
42 | - // Avoid errors because of null values. |
|
43 | - if ( $type_uris === null ) { |
|
44 | - $type_uris = array(); |
|
45 | - } |
|
46 | - |
|
47 | - // Ensure there are no duplicates. |
|
48 | - $type_uris = array_unique( $type_uris ); |
|
49 | - |
|
50 | - delete_post_meta( $post_id, Wordlift_Schema_Service::FIELD_ENTITY_TYPE ); |
|
51 | - foreach ( $type_uris as $type_uri ) { |
|
52 | - if ( empty( $type_uri ) ) { |
|
53 | - continue; |
|
54 | - } |
|
55 | - add_post_meta( $post_id, Wordlift_Schema_Service::FIELD_ENTITY_TYPE, $type_uri ); |
|
56 | - } |
|
42 | + // Avoid errors because of null values. |
|
43 | + if ( $type_uris === null ) { |
|
44 | + $type_uris = array(); |
|
45 | + } |
|
46 | + |
|
47 | + // Ensure there are no duplicates. |
|
48 | + $type_uris = array_unique( $type_uris ); |
|
49 | + |
|
50 | + delete_post_meta( $post_id, Wordlift_Schema_Service::FIELD_ENTITY_TYPE ); |
|
51 | + foreach ( $type_uris as $type_uri ) { |
|
52 | + if ( empty( $type_uri ) ) { |
|
53 | + continue; |
|
54 | + } |
|
55 | + add_post_meta( $post_id, Wordlift_Schema_Service::FIELD_ENTITY_TYPE, $type_uri ); |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // ** |
@@ -102,38 +102,38 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function wl_entity_taxonomy_get_custom_fields( $entity_id = null ) { |
104 | 104 | |
105 | - if ( $entity_id === null ) { |
|
105 | + if ( $entity_id === null ) { |
|
106 | 106 | |
107 | - // Return all custom fields. |
|
108 | - // Get taxonomy terms |
|
109 | - $terms = get_terms( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'get' => 'all' ) ); |
|
107 | + // Return all custom fields. |
|
108 | + // Get taxonomy terms |
|
109 | + $terms = get_terms( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'get' => 'all' ) ); |
|
110 | 110 | |
111 | - if ( is_wp_error( $terms ) ) { |
|
112 | - return null; |
|
113 | - } |
|
111 | + if ( is_wp_error( $terms ) ) { |
|
112 | + return null; |
|
113 | + } |
|
114 | 114 | |
115 | - $custom_fields = array(); |
|
116 | - foreach ( $terms as $term ) { |
|
117 | - // Get custom_fields |
|
118 | - $term_options = Wordlift_Schema_Service::get_instance() |
|
119 | - ->get_schema( $term->slug ); |
|
115 | + $custom_fields = array(); |
|
116 | + foreach ( $terms as $term ) { |
|
117 | + // Get custom_fields |
|
118 | + $term_options = Wordlift_Schema_Service::get_instance() |
|
119 | + ->get_schema( $term->slug ); |
|
120 | 120 | |
121 | - if ( ! isset( $term_options['uri'] ) || ! isset( $term_options['custom_fields'] ) ) { |
|
122 | - continue; |
|
123 | - } |
|
121 | + if ( ! isset( $term_options['uri'] ) || ! isset( $term_options['custom_fields'] ) ) { |
|
122 | + continue; |
|
123 | + } |
|
124 | 124 | |
125 | - $custom_fields[ $term_options['uri'] ] = $term_options['custom_fields']; |
|
126 | - } |
|
125 | + $custom_fields[ $term_options['uri'] ] = $term_options['custom_fields']; |
|
126 | + } |
|
127 | 127 | |
128 | - return $custom_fields; |
|
128 | + return $custom_fields; |
|
129 | 129 | |
130 | - } |
|
130 | + } |
|
131 | 131 | |
132 | - // Return custom fields for this specific entity's type. |
|
133 | - $types = Wordlift_Entity_Type_Service::get_instance()->get_ids( $entity_id ); |
|
132 | + // Return custom fields for this specific entity's type. |
|
133 | + $types = Wordlift_Entity_Type_Service::get_instance()->get_ids( $entity_id ); |
|
134 | 134 | |
135 | - /** @var WP_Term[] $terms */ |
|
136 | - return wl_get_custom_fields_by_entity_type( $types ); |
|
135 | + /** @var WP_Term[] $terms */ |
|
136 | + return wl_get_custom_fields_by_entity_type( $types ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -142,41 +142,41 @@ discard block |
||
142 | 142 | * @return array |
143 | 143 | */ |
144 | 144 | function wl_get_custom_fields_by_entity_type( $types ) { |
145 | - $terms = array_filter( |
|
146 | - array_map( |
|
147 | - function ( $item ) { |
|
148 | - return get_term( $item ); |
|
149 | - }, |
|
150 | - $types |
|
151 | - ), |
|
152 | - function ( $item ) { |
|
153 | - return isset( $item ) && is_a( $item, 'WP_Term' ); |
|
154 | - } |
|
155 | - ); |
|
156 | - |
|
157 | - $term_slugs = array_map( |
|
158 | - function ( $item ) { |
|
159 | - return $item->slug; |
|
160 | - }, |
|
161 | - $terms |
|
162 | - ); |
|
163 | - |
|
164 | - $term_slugs[] = 'thing'; |
|
165 | - |
|
166 | - $schema_service = Wordlift_Schema_Service::get_instance(); |
|
167 | - |
|
168 | - return array_reduce( |
|
169 | - $term_slugs, |
|
170 | - function ( $carry, $item ) use ( $schema_service ) { |
|
171 | - |
|
172 | - $schema = $schema_service->get_schema( $item ); |
|
173 | - |
|
174 | - if ( ! isset( $schema['custom_fields'] ) ) { |
|
175 | - return $carry; |
|
176 | - } |
|
177 | - |
|
178 | - return $carry + $schema['custom_fields']; |
|
179 | - }, |
|
180 | - array() |
|
181 | - ); |
|
145 | + $terms = array_filter( |
|
146 | + array_map( |
|
147 | + function ( $item ) { |
|
148 | + return get_term( $item ); |
|
149 | + }, |
|
150 | + $types |
|
151 | + ), |
|
152 | + function ( $item ) { |
|
153 | + return isset( $item ) && is_a( $item, 'WP_Term' ); |
|
154 | + } |
|
155 | + ); |
|
156 | + |
|
157 | + $term_slugs = array_map( |
|
158 | + function ( $item ) { |
|
159 | + return $item->slug; |
|
160 | + }, |
|
161 | + $terms |
|
162 | + ); |
|
163 | + |
|
164 | + $term_slugs[] = 'thing'; |
|
165 | + |
|
166 | + $schema_service = Wordlift_Schema_Service::get_instance(); |
|
167 | + |
|
168 | + return array_reduce( |
|
169 | + $term_slugs, |
|
170 | + function ( $carry, $item ) use ( $schema_service ) { |
|
171 | + |
|
172 | + $schema = $schema_service->get_schema( $item ); |
|
173 | + |
|
174 | + if ( ! isset( $schema['custom_fields'] ) ) { |
|
175 | + return $carry; |
|
176 | + } |
|
177 | + |
|
178 | + return $carry + $schema['custom_fields']; |
|
179 | + }, |
|
180 | + array() |
|
181 | + ); |
|
182 | 182 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @deprecated use Wordlift_Entity_Service::get_instance()->get_uri( $post_id ) |
15 | 15 | */ |
16 | -function wl_get_entity_uri( $post_id ) { |
|
16 | +function wl_get_entity_uri($post_id) { |
|
17 | 17 | |
18 | - return Wordlift_Entity_Service::get_instance()->get_uri( $post_id ); |
|
18 | + return Wordlift_Entity_Service::get_instance()->get_uri($post_id); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | * @return array An array of terms. |
27 | 27 | * @since 3.0.0 |
28 | 28 | */ |
29 | -function wl_get_entity_rdf_types( $post_id ) { |
|
29 | +function wl_get_entity_rdf_types($post_id) { |
|
30 | 30 | |
31 | - return get_post_meta( $post_id, Wordlift_Schema_Service::FIELD_ENTITY_TYPE ); |
|
31 | + return get_post_meta($post_id, Wordlift_Schema_Service::FIELD_ENTITY_TYPE); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -37,22 +37,22 @@ discard block |
||
37 | 37 | * @param int $post_id The entity post ID. |
38 | 38 | * @param array $type_uris An array of type URIs. |
39 | 39 | */ |
40 | -function wl_set_entity_rdf_types( $post_id, $type_uris = array() ) { |
|
40 | +function wl_set_entity_rdf_types($post_id, $type_uris = array()) { |
|
41 | 41 | |
42 | 42 | // Avoid errors because of null values. |
43 | - if ( $type_uris === null ) { |
|
43 | + if ($type_uris === null) { |
|
44 | 44 | $type_uris = array(); |
45 | 45 | } |
46 | 46 | |
47 | 47 | // Ensure there are no duplicates. |
48 | - $type_uris = array_unique( $type_uris ); |
|
48 | + $type_uris = array_unique($type_uris); |
|
49 | 49 | |
50 | - delete_post_meta( $post_id, Wordlift_Schema_Service::FIELD_ENTITY_TYPE ); |
|
51 | - foreach ( $type_uris as $type_uri ) { |
|
52 | - if ( empty( $type_uri ) ) { |
|
50 | + delete_post_meta($post_id, Wordlift_Schema_Service::FIELD_ENTITY_TYPE); |
|
51 | + foreach ($type_uris as $type_uri) { |
|
52 | + if (empty($type_uri)) { |
|
53 | 53 | continue; |
54 | 54 | } |
55 | - add_post_meta( $post_id, Wordlift_Schema_Service::FIELD_ENTITY_TYPE, $type_uri ); |
|
55 | + add_post_meta($post_id, Wordlift_Schema_Service::FIELD_ENTITY_TYPE, $type_uri); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -100,29 +100,29 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return array|null if $entity_id was specified, return custom_fields for that entity's type. Otherwise returns all custom_fields |
102 | 102 | */ |
103 | -function wl_entity_taxonomy_get_custom_fields( $entity_id = null ) { |
|
103 | +function wl_entity_taxonomy_get_custom_fields($entity_id = null) { |
|
104 | 104 | |
105 | - if ( $entity_id === null ) { |
|
105 | + if ($entity_id === null) { |
|
106 | 106 | |
107 | 107 | // Return all custom fields. |
108 | 108 | // Get taxonomy terms |
109 | - $terms = get_terms( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'get' => 'all' ) ); |
|
109 | + $terms = get_terms(Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array('get' => 'all')); |
|
110 | 110 | |
111 | - if ( is_wp_error( $terms ) ) { |
|
111 | + if (is_wp_error($terms)) { |
|
112 | 112 | return null; |
113 | 113 | } |
114 | 114 | |
115 | 115 | $custom_fields = array(); |
116 | - foreach ( $terms as $term ) { |
|
116 | + foreach ($terms as $term) { |
|
117 | 117 | // Get custom_fields |
118 | 118 | $term_options = Wordlift_Schema_Service::get_instance() |
119 | - ->get_schema( $term->slug ); |
|
119 | + ->get_schema($term->slug); |
|
120 | 120 | |
121 | - if ( ! isset( $term_options['uri'] ) || ! isset( $term_options['custom_fields'] ) ) { |
|
121 | + if ( ! isset($term_options['uri']) || ! isset($term_options['custom_fields'])) { |
|
122 | 122 | continue; |
123 | 123 | } |
124 | 124 | |
125 | - $custom_fields[ $term_options['uri'] ] = $term_options['custom_fields']; |
|
125 | + $custom_fields[$term_options['uri']] = $term_options['custom_fields']; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | return $custom_fields; |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | // Return custom fields for this specific entity's type. |
133 | - $types = Wordlift_Entity_Type_Service::get_instance()->get_ids( $entity_id ); |
|
133 | + $types = Wordlift_Entity_Type_Service::get_instance()->get_ids($entity_id); |
|
134 | 134 | |
135 | 135 | /** @var WP_Term[] $terms */ |
136 | - return wl_get_custom_fields_by_entity_type( $types ); |
|
136 | + return wl_get_custom_fields_by_entity_type($types); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -141,21 +141,21 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return array |
143 | 143 | */ |
144 | -function wl_get_custom_fields_by_entity_type( $types ) { |
|
144 | +function wl_get_custom_fields_by_entity_type($types) { |
|
145 | 145 | $terms = array_filter( |
146 | 146 | array_map( |
147 | - function ( $item ) { |
|
148 | - return get_term( $item ); |
|
147 | + function($item) { |
|
148 | + return get_term($item); |
|
149 | 149 | }, |
150 | 150 | $types |
151 | 151 | ), |
152 | - function ( $item ) { |
|
153 | - return isset( $item ) && is_a( $item, 'WP_Term' ); |
|
152 | + function($item) { |
|
153 | + return isset($item) && is_a($item, 'WP_Term'); |
|
154 | 154 | } |
155 | 155 | ); |
156 | 156 | |
157 | 157 | $term_slugs = array_map( |
158 | - function ( $item ) { |
|
158 | + function($item) { |
|
159 | 159 | return $item->slug; |
160 | 160 | }, |
161 | 161 | $terms |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | |
168 | 168 | return array_reduce( |
169 | 169 | $term_slugs, |
170 | - function ( $carry, $item ) use ( $schema_service ) { |
|
170 | + function($carry, $item) use ($schema_service) { |
|
171 | 171 | |
172 | - $schema = $schema_service->get_schema( $item ); |
|
172 | + $schema = $schema_service->get_schema($item); |
|
173 | 173 | |
174 | - if ( ! isset( $schema['custom_fields'] ) ) { |
|
174 | + if ( ! isset($schema['custom_fields'])) { |
|
175 | 175 | return $carry; |
176 | 176 | } |
177 | 177 |
@@ -1,6 +1,6 @@ |
||
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.33.9 |
@@ -8,24 +8,24 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class Wordlift_Install_3_33_9 extends Wordlift_Install { |
10 | 10 | |
11 | - /** |
|
12 | - * {@inheritdoc} |
|
13 | - */ |
|
14 | - protected static $version = '3.33.9'; |
|
11 | + /** |
|
12 | + * {@inheritdoc} |
|
13 | + */ |
|
14 | + protected static $version = '3.33.9'; |
|
15 | 15 | |
16 | - public function install() { |
|
17 | - $this->create_entities_table(); |
|
18 | - $this->delete_legacy_fields_from_postmeta(); |
|
19 | - } |
|
16 | + public function install() { |
|
17 | + $this->create_entities_table(); |
|
18 | + $this->delete_legacy_fields_from_postmeta(); |
|
19 | + } |
|
20 | 20 | |
21 | - private function create_entities_table() { |
|
22 | - global $wpdb; |
|
21 | + private function create_entities_table() { |
|
22 | + global $wpdb; |
|
23 | 23 | |
24 | - $charset_collate = $wpdb->get_charset_collate(); |
|
24 | + $charset_collate = $wpdb->get_charset_collate(); |
|
25 | 25 | |
26 | - $wpdb->query( |
|
27 | - $wpdb->prepare( |
|
28 | - "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wl_entities ( |
|
26 | + $wpdb->query( |
|
27 | + $wpdb->prepare( |
|
28 | + "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wl_entities ( |
|
29 | 29 | id bigint(20) unsigned NOT NULL auto_increment, |
30 | 30 | content_id bigint(20) unsigned NOT NULL, |
31 | 31 | content_type tinyint(1) unsigned NOT NULL, |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | UNIQUE KEY uq__content_id__content_type (content_id,content_type), |
38 | 38 | UNIQUE KEY uq__rel_uri_hash (rel_uri_hash) |
39 | 39 | ) %1s;", // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder |
40 | - $charset_collate |
|
41 | - ) |
|
42 | - ); |
|
40 | + $charset_collate |
|
41 | + ) |
|
42 | + ); |
|
43 | 43 | |
44 | - dbDelta( |
|
45 | - $wpdb->prepare( |
|
46 | - "CREATE TABLE {$wpdb->prefix}wl_entities ( |
|
44 | + dbDelta( |
|
45 | + $wpdb->prepare( |
|
46 | + "CREATE TABLE {$wpdb->prefix}wl_entities ( |
|
47 | 47 | id bigint(20) unsigned NOT NULL auto_increment, |
48 | 48 | content_id bigint(20) unsigned NOT NULL, |
49 | 49 | content_type tinyint(1) unsigned NOT NULL, |
@@ -55,36 +55,36 @@ discard block |
||
55 | 55 | UNIQUE KEY uq__content_id__content_type (content_id,content_type), |
56 | 56 | UNIQUE KEY uq__rel_uri_hash (rel_uri_hash) |
57 | 57 | ) %1s;", // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder |
58 | - $charset_collate |
|
59 | - ) |
|
60 | - ); |
|
58 | + $charset_collate |
|
59 | + ) |
|
60 | + ); |
|
61 | 61 | |
62 | - } |
|
62 | + } |
|
63 | 63 | |
64 | - private function delete_legacy_fields_from_postmeta() { |
|
65 | - global $wpdb; |
|
64 | + private function delete_legacy_fields_from_postmeta() { |
|
65 | + global $wpdb; |
|
66 | 66 | |
67 | - $wpdb->query( |
|
68 | - "DELETE |
|
67 | + $wpdb->query( |
|
68 | + "DELETE |
|
69 | 69 | FROM $wpdb->postmeta |
70 | 70 | WHERE meta_key IN ( '_wl_jsonld_hash', '_synced_gmt' );" |
71 | - ); |
|
71 | + ); |
|
72 | 72 | |
73 | - } |
|
73 | + } |
|
74 | 74 | |
75 | - private function migrate_entity_url() { |
|
76 | - global $wpdb; |
|
75 | + private function migrate_entity_url() { |
|
76 | + global $wpdb; |
|
77 | 77 | |
78 | - $wpdb->query( |
|
79 | - "INSERT INTO {$wpdb->prefix}wl_entities( content_id, content_type, rel_uri, rel_uri_hash ) |
|
78 | + $wpdb->query( |
|
79 | + "INSERT INTO {$wpdb->prefix}wl_entities( content_id, content_type, rel_uri, rel_uri_hash ) |
|
80 | 80 | SELECT post_id AS content_id, 0 AS content_type, |
81 | 81 | SUBSTR( meta_value, LENGTH( SUBSTRING_INDEX( meta_value, '/', 4 ) ) + 2 ) AS rel_uri, |
82 | 82 | SHA1( SUBSTR( meta_value, LENGTH( SUBSTRING_INDEX( meta_value, '/', 4 ) ) + 2 ) ) AS rel_uri_hash |
83 | 83 | FROM $wpdb->postmeta |
84 | 84 | WHERE meta_key = 'entity_url' AND post_id IN (SELECT ID FROM $wpdb->posts) |
85 | 85 | ON DUPLICATE KEY UPDATE rel_uri = VALUES( rel_uri ), rel_uri_hash = VALUES( rel_uri_hash );" |
86 | - ); |
|
86 | + ); |
|
87 | 87 | |
88 | - } |
|
88 | + } |
|
89 | 89 | |
90 | 90 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | |
51 | 51 | // @see: https://codex.wordpress.org/Creating_Tables_with_Plugins |
52 | -require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
|
52 | +require_once ABSPATH.'wp-admin/includes/upgrade.php'; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Define the {@link Wordlift_Install_3_25_0} interface. |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @since 3.25.0 |
103 | 103 | */ |
104 | 104 | public function create_mappings_table() { |
105 | - $table_name = $this->wpdb->prefix . WL_MAPPING_TABLE_NAME; |
|
105 | + $table_name = $this->wpdb->prefix.WL_MAPPING_TABLE_NAME; |
|
106 | 106 | $charset_collate = $this->wpdb->get_charset_collate(); |
107 | 107 | // @@todo: is necessary to prefix the column names with `mapping_` ? we're the mappings table already. |
108 | 108 | $sql = " |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | ) $charset_collate; |
115 | 115 | "; |
116 | 116 | // Execute the query for mappings table. |
117 | - dbDelta( $sql ); |
|
117 | + dbDelta($sql); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | public static function drop_tables() { |
238 | 238 | global $wpdb; |
239 | 239 | |
240 | - $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping_property" ); |
|
241 | - $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping_rule" ); |
|
242 | - $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping_rule_group" ); |
|
243 | - $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping" ); |
|
240 | + $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping_property"); |
|
241 | + $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping_rule"); |
|
242 | + $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping_rule_group"); |
|
243 | + $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping"); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | } |
@@ -59,53 +59,53 @@ discard block |
||
59 | 59 | * @subpackage Wordlift/install |
60 | 60 | */ |
61 | 61 | class Wordlift_Install_3_25_0 extends Wordlift_Install { |
62 | - /** |
|
63 | - * @inheritdoc |
|
64 | - */ |
|
65 | - protected static $version = '3.25.3'; |
|
66 | - |
|
67 | - /** |
|
68 | - * Reference to global $wpdb instance. |
|
69 | - * |
|
70 | - * @var $wpdb |
|
71 | - * */ |
|
72 | - private $wpdb; |
|
73 | - |
|
74 | - /** Constructor for 3_25_0 installer. */ |
|
75 | - public function __construct() { |
|
76 | - global $wpdb; |
|
77 | - $this->wpdb = $wpdb; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * @inheritdoc |
|
82 | - */ |
|
83 | - public function install() { |
|
84 | - $this->create_mappings_table(); |
|
85 | - $this->create_rule_group_table(); |
|
86 | - $this->create_rule_table(); |
|
87 | - $this->create_property_table(); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Install mappings table. |
|
92 | - * |
|
93 | - * +----------------+--------------+------+-----+---------+----------------+ |
|
94 | - * | Field | Type | Null | Key | Default | Extra | |
|
95 | - * +----------------+--------------+------+-----+---------+----------------+ |
|
96 | - * | mapping_id | int(11) | NO | PRI | NULL | auto_increment | |
|
97 | - * | mapping_title | varchar(255) | NO | | NULL | | |
|
98 | - * | mapping_status | varchar(255) | NO | | active | | |
|
99 | - * +----------------+--------------+------+-----+---------+----------------+ |
|
100 | - * |
|
101 | - * @return void |
|
102 | - * @since 3.25.0 |
|
103 | - */ |
|
104 | - public function create_mappings_table() { |
|
105 | - $table_name = $this->wpdb->prefix . WL_MAPPING_TABLE_NAME; |
|
106 | - $charset_collate = $this->wpdb->get_charset_collate(); |
|
107 | - // @@todo: is necessary to prefix the column names with `mapping_` ? we're the mappings table already. |
|
108 | - $sql = " |
|
62 | + /** |
|
63 | + * @inheritdoc |
|
64 | + */ |
|
65 | + protected static $version = '3.25.3'; |
|
66 | + |
|
67 | + /** |
|
68 | + * Reference to global $wpdb instance. |
|
69 | + * |
|
70 | + * @var $wpdb |
|
71 | + * */ |
|
72 | + private $wpdb; |
|
73 | + |
|
74 | + /** Constructor for 3_25_0 installer. */ |
|
75 | + public function __construct() { |
|
76 | + global $wpdb; |
|
77 | + $this->wpdb = $wpdb; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * @inheritdoc |
|
82 | + */ |
|
83 | + public function install() { |
|
84 | + $this->create_mappings_table(); |
|
85 | + $this->create_rule_group_table(); |
|
86 | + $this->create_rule_table(); |
|
87 | + $this->create_property_table(); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Install mappings table. |
|
92 | + * |
|
93 | + * +----------------+--------------+------+-----+---------+----------------+ |
|
94 | + * | Field | Type | Null | Key | Default | Extra | |
|
95 | + * +----------------+--------------+------+-----+---------+----------------+ |
|
96 | + * | mapping_id | int(11) | NO | PRI | NULL | auto_increment | |
|
97 | + * | mapping_title | varchar(255) | NO | | NULL | | |
|
98 | + * | mapping_status | varchar(255) | NO | | active | | |
|
99 | + * +----------------+--------------+------+-----+---------+----------------+ |
|
100 | + * |
|
101 | + * @return void |
|
102 | + * @since 3.25.0 |
|
103 | + */ |
|
104 | + public function create_mappings_table() { |
|
105 | + $table_name = $this->wpdb->prefix . WL_MAPPING_TABLE_NAME; |
|
106 | + $charset_collate = $this->wpdb->get_charset_collate(); |
|
107 | + // @@todo: is necessary to prefix the column names with `mapping_` ? we're the mappings table already. |
|
108 | + $sql = " |
|
109 | 109 | CREATE TABLE $table_name ( |
110 | 110 | mapping_id INT(11) NOT NULL AUTO_INCREMENT, |
111 | 111 | mapping_title VARCHAR(255) NOT NULL, |
@@ -113,36 +113,36 @@ discard block |
||
113 | 113 | PRIMARY KEY (mapping_id) |
114 | 114 | ) $charset_collate; |
115 | 115 | "; |
116 | - // Execute the query for mappings table. |
|
117 | - dbDelta( $sql ); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Install rule table |
|
122 | - * |
|
123 | - * +------------------+--------------+------+-----+---------+----------------+ |
|
124 | - * | Field | Type | Null | Key | Default | Extra | |
|
125 | - * +------------------+--------------+------+-----+---------+----------------+ |
|
126 | - * | rule_id | int(11) | NO | PRI | NULL | auto_increment | |
|
127 | - * | rule_field_one | varchar(255) | NO | | NULL | | |
|
128 | - * | rule_logic_field | varchar(255) | NO | | NULL | | |
|
129 | - * | rule_field_two | varchar(255) | NO | | NULL | | |
|
130 | - * | rule_group_id | int(11) | NO | MUL | NULL | | |
|
131 | - * +------------------+--------------+------+-----+---------+----------------+ |
|
132 | - * |
|
133 | - * @return void |
|
134 | - * @since 3.25.0 |
|
135 | - */ |
|
136 | - public function create_rule_table() { |
|
137 | - global $wpdb; |
|
138 | - |
|
139 | - $charset_collate = $this->wpdb->get_charset_collate(); |
|
140 | - // @@todo: is necessary to prefix the column names with `rule_` ? we're the rules table already. |
|
141 | - |
|
142 | - // Execute the query for mappings table. |
|
143 | - $wpdb->query( |
|
144 | - $wpdb->prepare( |
|
145 | - "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wl_mapping_rule ( |
|
116 | + // Execute the query for mappings table. |
|
117 | + dbDelta( $sql ); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Install rule table |
|
122 | + * |
|
123 | + * +------------------+--------------+------+-----+---------+----------------+ |
|
124 | + * | Field | Type | Null | Key | Default | Extra | |
|
125 | + * +------------------+--------------+------+-----+---------+----------------+ |
|
126 | + * | rule_id | int(11) | NO | PRI | NULL | auto_increment | |
|
127 | + * | rule_field_one | varchar(255) | NO | | NULL | | |
|
128 | + * | rule_logic_field | varchar(255) | NO | | NULL | | |
|
129 | + * | rule_field_two | varchar(255) | NO | | NULL | | |
|
130 | + * | rule_group_id | int(11) | NO | MUL | NULL | | |
|
131 | + * +------------------+--------------+------+-----+---------+----------------+ |
|
132 | + * |
|
133 | + * @return void |
|
134 | + * @since 3.25.0 |
|
135 | + */ |
|
136 | + public function create_rule_table() { |
|
137 | + global $wpdb; |
|
138 | + |
|
139 | + $charset_collate = $this->wpdb->get_charset_collate(); |
|
140 | + // @@todo: is necessary to prefix the column names with `rule_` ? we're the rules table already. |
|
141 | + |
|
142 | + // Execute the query for mappings table. |
|
143 | + $wpdb->query( |
|
144 | + $wpdb->prepare( |
|
145 | + "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wl_mapping_rule ( |
|
146 | 146 | rule_id INT(11) NOT NULL AUTO_INCREMENT, |
147 | 147 | rule_field_one VARCHAR(255) NOT NULL, |
148 | 148 | rule_logic_field VARCHAR(255) NOT NULL, |
@@ -152,72 +152,72 @@ discard block |
||
152 | 152 | ON DELETE CASCADE, |
153 | 153 | PRIMARY KEY (rule_id) |
154 | 154 | ) %1s;", // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder |
155 | - $charset_collate |
|
156 | - ) |
|
157 | - ); |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Install rule group table, should run after creating mapping and |
|
162 | - * rule table due to foreign key reference. |
|
163 | - * |
|
164 | - * +---------------+---------+------+-----+---------+----------------+ |
|
165 | - * | Field | Type | Null | Key | Default | Extra | |
|
166 | - * +---------------+---------+------+-----+---------+----------------+ |
|
167 | - * | rule_group_id | int(11) | NO | PRI | NULL | auto_increment | |
|
168 | - * | mapping_id | int(11) | NO | MUL | NULL | | |
|
169 | - * +---------------+---------+------+-----+---------+----------------+ |
|
170 | - * |
|
171 | - * @return void |
|
172 | - * @since 3.25.0 |
|
173 | - */ |
|
174 | - public function create_rule_group_table() { |
|
175 | - global $wpdb; |
|
176 | - $charset_collate = $wpdb->get_charset_collate(); |
|
177 | - |
|
178 | - // Execute the query for rule group table, we cant use db delta |
|
179 | - // due to lack of support for foreign keys. |
|
180 | - $wpdb->query( |
|
181 | - $wpdb->prepare( |
|
182 | - "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wl_mapping_rule_group ( |
|
155 | + $charset_collate |
|
156 | + ) |
|
157 | + ); |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Install rule group table, should run after creating mapping and |
|
162 | + * rule table due to foreign key reference. |
|
163 | + * |
|
164 | + * +---------------+---------+------+-----+---------+----------------+ |
|
165 | + * | Field | Type | Null | Key | Default | Extra | |
|
166 | + * +---------------+---------+------+-----+---------+----------------+ |
|
167 | + * | rule_group_id | int(11) | NO | PRI | NULL | auto_increment | |
|
168 | + * | mapping_id | int(11) | NO | MUL | NULL | | |
|
169 | + * +---------------+---------+------+-----+---------+----------------+ |
|
170 | + * |
|
171 | + * @return void |
|
172 | + * @since 3.25.0 |
|
173 | + */ |
|
174 | + public function create_rule_group_table() { |
|
175 | + global $wpdb; |
|
176 | + $charset_collate = $wpdb->get_charset_collate(); |
|
177 | + |
|
178 | + // Execute the query for rule group table, we cant use db delta |
|
179 | + // due to lack of support for foreign keys. |
|
180 | + $wpdb->query( |
|
181 | + $wpdb->prepare( |
|
182 | + "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wl_mapping_rule_group ( |
|
183 | 183 | rule_group_id INT(11) NOT NULL AUTO_INCREMENT, |
184 | 184 | mapping_id INT(11) NOT NULL, |
185 | 185 | PRIMARY KEY (rule_group_id), |
186 | 186 | FOREIGN KEY (mapping_id) REFERENCES {$wpdb->prefix}wl_mapping(mapping_id) |
187 | 187 | ON DELETE CASCADE |
188 | 188 | ) %1s;", // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder |
189 | - $charset_collate |
|
190 | - ) |
|
191 | - ); |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Install property table, should run after mapping table due to |
|
196 | - * foreign key reference. |
|
197 | - * |
|
198 | - * +--------------------+--------------+------+-----+---------+----------------+ |
|
199 | - * | Field | Type | Null | Key | Default | Extra | |
|
200 | - * +--------------------+--------------+------+-----+---------+----------------+ |
|
201 | - * | property_id | int(11) | NO | PRI | NULL | auto_increment | |
|
202 | - * | mapping_id | int(11) | NO | MUL | NULL | | |
|
203 | - * | property_name | varchar(255) | NO | | NULL | | |
|
204 | - * | field_type | varchar(255) | NO | | NULL | | |
|
205 | - * | field_name | varchar(255) | NO | | NULL | | |
|
206 | - * | transform_function | varchar(255) | NO | | NULL | | |
|
207 | - * | property_status | varchar(255) | NO | | active | | |
|
208 | - * +--------------------+--------------+------+-----+---------+----------------+ |
|
209 | - * |
|
210 | - * @return void |
|
211 | - * @since 3.25.0 |
|
212 | - */ |
|
213 | - public function create_property_table() { |
|
214 | - global $wpdb; |
|
215 | - |
|
216 | - // Execute the query for property table, we cant use db delta |
|
217 | - // due to lack of support for foreign keys. |
|
218 | - $wpdb->query( |
|
219 | - $wpdb->prepare( |
|
220 | - "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wl_mapping_property ( |
|
189 | + $charset_collate |
|
190 | + ) |
|
191 | + ); |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Install property table, should run after mapping table due to |
|
196 | + * foreign key reference. |
|
197 | + * |
|
198 | + * +--------------------+--------------+------+-----+---------+----------------+ |
|
199 | + * | Field | Type | Null | Key | Default | Extra | |
|
200 | + * +--------------------+--------------+------+-----+---------+----------------+ |
|
201 | + * | property_id | int(11) | NO | PRI | NULL | auto_increment | |
|
202 | + * | mapping_id | int(11) | NO | MUL | NULL | | |
|
203 | + * | property_name | varchar(255) | NO | | NULL | | |
|
204 | + * | field_type | varchar(255) | NO | | NULL | | |
|
205 | + * | field_name | varchar(255) | NO | | NULL | | |
|
206 | + * | transform_function | varchar(255) | NO | | NULL | | |
|
207 | + * | property_status | varchar(255) | NO | | active | | |
|
208 | + * +--------------------+--------------+------+-----+---------+----------------+ |
|
209 | + * |
|
210 | + * @return void |
|
211 | + * @since 3.25.0 |
|
212 | + */ |
|
213 | + public function create_property_table() { |
|
214 | + global $wpdb; |
|
215 | + |
|
216 | + // Execute the query for property table, we cant use db delta |
|
217 | + // due to lack of support for foreign keys. |
|
218 | + $wpdb->query( |
|
219 | + $wpdb->prepare( |
|
220 | + "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wl_mapping_property ( |
|
221 | 221 | property_id INT(11) NOT NULL AUTO_INCREMENT, |
222 | 222 | mapping_id INT(11) NOT NULL, |
223 | 223 | property_name VARCHAR(255) NOT NULL, |
@@ -229,18 +229,18 @@ discard block |
||
229 | 229 | FOREIGN KEY (mapping_id) REFERENCES {$wpdb->prefix}wl_mapping(mapping_id) |
230 | 230 | ON DELETE CASCADE |
231 | 231 | ) %1s;", // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder |
232 | - $wpdb->get_charset_collate() |
|
233 | - ) |
|
234 | - ); |
|
235 | - } |
|
236 | - |
|
237 | - public static function drop_tables() { |
|
238 | - global $wpdb; |
|
239 | - |
|
240 | - $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping_property" ); |
|
241 | - $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping_rule" ); |
|
242 | - $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping_rule_group" ); |
|
243 | - $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping" ); |
|
244 | - } |
|
232 | + $wpdb->get_charset_collate() |
|
233 | + ) |
|
234 | + ); |
|
235 | + } |
|
236 | + |
|
237 | + public static function drop_tables() { |
|
238 | + global $wpdb; |
|
239 | + |
|
240 | + $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping_property" ); |
|
241 | + $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping_rule" ); |
|
242 | + $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping_rule_group" ); |
|
243 | + $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wl_mapping" ); |
|
244 | + } |
|
245 | 245 | |
246 | 246 | } |
@@ -15,66 +15,66 @@ |
||
15 | 15 | * @subpackage Wordlift/install |
16 | 16 | */ |
17 | 17 | class Wordlift_Install_3_14_0 extends Wordlift_Install { |
18 | - /** |
|
19 | - * @inheritdoc |
|
20 | - */ |
|
21 | - protected static $version = '3.14.0'; |
|
18 | + /** |
|
19 | + * @inheritdoc |
|
20 | + */ |
|
21 | + protected static $version = '3.14.0'; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @inheritdoc |
|
25 | - */ |
|
26 | - public function install() { |
|
27 | - // Check whether the `recipe` term exists. |
|
28 | - $recipe = get_term_by( 'slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
23 | + /** |
|
24 | + * @inheritdoc |
|
25 | + */ |
|
26 | + public function install() { |
|
27 | + // Check whether the `recipe` term exists. |
|
28 | + $recipe = get_term_by( 'slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
29 | 29 | |
30 | - // The recipe term doesn't exists, so create it. |
|
31 | - if ( empty( $recipe ) ) { |
|
32 | - wp_insert_term( |
|
33 | - 'Recipe', |
|
34 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
35 | - array( |
|
36 | - 'slug' => 'recipe', |
|
37 | - 'description' => 'A Recipe.', |
|
38 | - ) |
|
39 | - ); |
|
40 | - } |
|
30 | + // The recipe term doesn't exists, so create it. |
|
31 | + if ( empty( $recipe ) ) { |
|
32 | + wp_insert_term( |
|
33 | + 'Recipe', |
|
34 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
35 | + array( |
|
36 | + 'slug' => 'recipe', |
|
37 | + 'description' => 'A Recipe.', |
|
38 | + ) |
|
39 | + ); |
|
40 | + } |
|
41 | 41 | |
42 | - // Assign capabilities to manipulate entities to admins. |
|
43 | - $admins = get_role( 'administrator' ); |
|
42 | + // Assign capabilities to manipulate entities to admins. |
|
43 | + $admins = get_role( 'administrator' ); |
|
44 | 44 | |
45 | - $admins->add_cap( 'edit_wordlift_entity' ); |
|
46 | - $admins->add_cap( 'edit_wordlift_entities' ); |
|
47 | - $admins->add_cap( 'edit_others_wordlift_entities' ); |
|
48 | - $admins->add_cap( 'publish_wordlift_entities' ); |
|
49 | - $admins->add_cap( 'read_private_wordlift_entities' ); |
|
50 | - $admins->add_cap( 'delete_wordlift_entity' ); |
|
51 | - $admins->add_cap( 'delete_wordlift_entities' ); |
|
52 | - $admins->add_cap( 'delete_others_wordlift_entities' ); |
|
53 | - $admins->add_cap( 'delete_published_wordlift_entities' ); |
|
54 | - $admins->add_cap( 'delete_private_wordlift_entities' ); |
|
45 | + $admins->add_cap( 'edit_wordlift_entity' ); |
|
46 | + $admins->add_cap( 'edit_wordlift_entities' ); |
|
47 | + $admins->add_cap( 'edit_others_wordlift_entities' ); |
|
48 | + $admins->add_cap( 'publish_wordlift_entities' ); |
|
49 | + $admins->add_cap( 'read_private_wordlift_entities' ); |
|
50 | + $admins->add_cap( 'delete_wordlift_entity' ); |
|
51 | + $admins->add_cap( 'delete_wordlift_entities' ); |
|
52 | + $admins->add_cap( 'delete_others_wordlift_entities' ); |
|
53 | + $admins->add_cap( 'delete_published_wordlift_entities' ); |
|
54 | + $admins->add_cap( 'delete_private_wordlift_entities' ); |
|
55 | 55 | |
56 | - /* |
|
56 | + /* |
|
57 | 57 | * Check that the `editor` role exists before using it. |
58 | 58 | * |
59 | 59 | * @since 3.19.6 |
60 | 60 | * |
61 | 61 | * @see https://github.com/insideout10/wordlift-plugin/issues/886 |
62 | 62 | */ |
63 | - $editors = get_role( 'editor' ); |
|
63 | + $editors = get_role( 'editor' ); |
|
64 | 64 | |
65 | - if ( isset( $editors ) ) { |
|
66 | - $editors->add_cap( 'edit_wordlift_entity' ); |
|
67 | - $editors->add_cap( 'edit_wordlift_entities' ); |
|
68 | - $editors->add_cap( 'edit_others_wordlift_entities' ); |
|
69 | - $editors->add_cap( 'publish_wordlift_entities' ); |
|
70 | - $editors->add_cap( 'read_private_wordlift_entities' ); |
|
71 | - $editors->add_cap( 'delete_wordlift_entity' ); |
|
72 | - $editors->add_cap( 'delete_wordlift_entities' ); |
|
73 | - $editors->add_cap( 'delete_others_wordlift_entities' ); |
|
74 | - $editors->add_cap( 'delete_published_wordlift_entities' ); |
|
75 | - $editors->add_cap( 'delete_private_wordlift_entities' ); |
|
76 | - } |
|
65 | + if ( isset( $editors ) ) { |
|
66 | + $editors->add_cap( 'edit_wordlift_entity' ); |
|
67 | + $editors->add_cap( 'edit_wordlift_entities' ); |
|
68 | + $editors->add_cap( 'edit_others_wordlift_entities' ); |
|
69 | + $editors->add_cap( 'publish_wordlift_entities' ); |
|
70 | + $editors->add_cap( 'read_private_wordlift_entities' ); |
|
71 | + $editors->add_cap( 'delete_wordlift_entity' ); |
|
72 | + $editors->add_cap( 'delete_wordlift_entities' ); |
|
73 | + $editors->add_cap( 'delete_others_wordlift_entities' ); |
|
74 | + $editors->add_cap( 'delete_published_wordlift_entities' ); |
|
75 | + $editors->add_cap( 'delete_private_wordlift_entities' ); |
|
76 | + } |
|
77 | 77 | |
78 | - } |
|
78 | + } |
|
79 | 79 | |
80 | 80 | } |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function install() { |
27 | 27 | // Check whether the `recipe` term exists. |
28 | - $recipe = get_term_by( 'slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
28 | + $recipe = get_term_by('slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
29 | 29 | |
30 | 30 | // The recipe term doesn't exists, so create it. |
31 | - if ( empty( $recipe ) ) { |
|
31 | + if (empty($recipe)) { |
|
32 | 32 | wp_insert_term( |
33 | 33 | 'Recipe', |
34 | 34 | Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
@@ -40,18 +40,18 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | // Assign capabilities to manipulate entities to admins. |
43 | - $admins = get_role( 'administrator' ); |
|
43 | + $admins = get_role('administrator'); |
|
44 | 44 | |
45 | - $admins->add_cap( 'edit_wordlift_entity' ); |
|
46 | - $admins->add_cap( 'edit_wordlift_entities' ); |
|
47 | - $admins->add_cap( 'edit_others_wordlift_entities' ); |
|
48 | - $admins->add_cap( 'publish_wordlift_entities' ); |
|
49 | - $admins->add_cap( 'read_private_wordlift_entities' ); |
|
50 | - $admins->add_cap( 'delete_wordlift_entity' ); |
|
51 | - $admins->add_cap( 'delete_wordlift_entities' ); |
|
52 | - $admins->add_cap( 'delete_others_wordlift_entities' ); |
|
53 | - $admins->add_cap( 'delete_published_wordlift_entities' ); |
|
54 | - $admins->add_cap( 'delete_private_wordlift_entities' ); |
|
45 | + $admins->add_cap('edit_wordlift_entity'); |
|
46 | + $admins->add_cap('edit_wordlift_entities'); |
|
47 | + $admins->add_cap('edit_others_wordlift_entities'); |
|
48 | + $admins->add_cap('publish_wordlift_entities'); |
|
49 | + $admins->add_cap('read_private_wordlift_entities'); |
|
50 | + $admins->add_cap('delete_wordlift_entity'); |
|
51 | + $admins->add_cap('delete_wordlift_entities'); |
|
52 | + $admins->add_cap('delete_others_wordlift_entities'); |
|
53 | + $admins->add_cap('delete_published_wordlift_entities'); |
|
54 | + $admins->add_cap('delete_private_wordlift_entities'); |
|
55 | 55 | |
56 | 56 | /* |
57 | 57 | * Check that the `editor` role exists before using it. |
@@ -60,19 +60,19 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @see https://github.com/insideout10/wordlift-plugin/issues/886 |
62 | 62 | */ |
63 | - $editors = get_role( 'editor' ); |
|
63 | + $editors = get_role('editor'); |
|
64 | 64 | |
65 | - if ( isset( $editors ) ) { |
|
66 | - $editors->add_cap( 'edit_wordlift_entity' ); |
|
67 | - $editors->add_cap( 'edit_wordlift_entities' ); |
|
68 | - $editors->add_cap( 'edit_others_wordlift_entities' ); |
|
69 | - $editors->add_cap( 'publish_wordlift_entities' ); |
|
70 | - $editors->add_cap( 'read_private_wordlift_entities' ); |
|
71 | - $editors->add_cap( 'delete_wordlift_entity' ); |
|
72 | - $editors->add_cap( 'delete_wordlift_entities' ); |
|
73 | - $editors->add_cap( 'delete_others_wordlift_entities' ); |
|
74 | - $editors->add_cap( 'delete_published_wordlift_entities' ); |
|
75 | - $editors->add_cap( 'delete_private_wordlift_entities' ); |
|
65 | + if (isset($editors)) { |
|
66 | + $editors->add_cap('edit_wordlift_entity'); |
|
67 | + $editors->add_cap('edit_wordlift_entities'); |
|
68 | + $editors->add_cap('edit_others_wordlift_entities'); |
|
69 | + $editors->add_cap('publish_wordlift_entities'); |
|
70 | + $editors->add_cap('read_private_wordlift_entities'); |
|
71 | + $editors->add_cap('delete_wordlift_entity'); |
|
72 | + $editors->add_cap('delete_wordlift_entities'); |
|
73 | + $editors->add_cap('delete_others_wordlift_entities'); |
|
74 | + $editors->add_cap('delete_published_wordlift_entities'); |
|
75 | + $editors->add_cap('delete_private_wordlift_entities'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | } |
@@ -14,34 +14,34 @@ |
||
14 | 14 | |
15 | 15 | class Wordlift_Install_3_27_0 extends Wordlift_Install { |
16 | 16 | |
17 | - /** |
|
18 | - * {@inheritdoc} |
|
19 | - */ |
|
20 | - protected static $version = '3.27.0'; |
|
17 | + /** |
|
18 | + * {@inheritdoc} |
|
19 | + */ |
|
20 | + protected static $version = '3.27.0'; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @inheritDoc |
|
24 | - */ |
|
25 | - public function install() { |
|
26 | - global $wpdb; |
|
22 | + /** |
|
23 | + * @inheritDoc |
|
24 | + */ |
|
25 | + public function install() { |
|
26 | + global $wpdb; |
|
27 | 27 | |
28 | - $posts_with_empty_post_name = $wpdb->get_results( |
|
29 | - " SELECT ID, post_title |
|
28 | + $posts_with_empty_post_name = $wpdb->get_results( |
|
29 | + " SELECT ID, post_title |
|
30 | 30 | FROM $wpdb->posts |
31 | 31 | WHERE post_type = 'entity' |
32 | 32 | AND post_status = 'publish' |
33 | 33 | AND post_name = ''" |
34 | - ); |
|
34 | + ); |
|
35 | 35 | |
36 | - foreach ( $posts_with_empty_post_name as $post ) { |
|
37 | - wp_update_post( |
|
38 | - array( |
|
39 | - 'ID' => $post->ID, |
|
40 | - 'post_name' => sanitize_title( $post->post_title ), |
|
41 | - ) |
|
42 | - ); |
|
43 | - } |
|
36 | + foreach ( $posts_with_empty_post_name as $post ) { |
|
37 | + wp_update_post( |
|
38 | + array( |
|
39 | + 'ID' => $post->ID, |
|
40 | + 'post_name' => sanitize_title( $post->post_title ), |
|
41 | + ) |
|
42 | + ); |
|
43 | + } |
|
44 | 44 | |
45 | - } |
|
45 | + } |
|
46 | 46 | |
47 | 47 | } |
@@ -33,11 +33,11 @@ |
||
33 | 33 | AND post_name = ''" |
34 | 34 | ); |
35 | 35 | |
36 | - foreach ( $posts_with_empty_post_name as $post ) { |
|
36 | + foreach ($posts_with_empty_post_name as $post) { |
|
37 | 37 | wp_update_post( |
38 | 38 | array( |
39 | 39 | 'ID' => $post->ID, |
40 | - 'post_name' => sanitize_title( $post->post_title ), |
|
40 | + 'post_name' => sanitize_title($post->post_title), |
|
41 | 41 | ) |
42 | 42 | ); |
43 | 43 | } |
@@ -15,120 +15,120 @@ discard block |
||
15 | 15 | * @subpackage Wordlift/install |
16 | 16 | */ |
17 | 17 | class Wordlift_Install_1_0_0 extends Wordlift_Install { |
18 | - /** |
|
19 | - * @inheritdoc |
|
20 | - */ |
|
21 | - protected static $version = '1.0.0'; |
|
22 | - |
|
23 | - /** |
|
24 | - * The WordLift entity type terms. |
|
25 | - * |
|
26 | - * @since 3.18.0 |
|
27 | - * @access private |
|
28 | - * @var array $terms The entity type terms. |
|
29 | - */ |
|
30 | - private static $terms = array( |
|
31 | - 'thing' => array( |
|
32 | - 'label' => 'Thing', |
|
33 | - 'description' => 'A generic thing (something that doesn\'t fit in the previous definitions.', |
|
34 | - ), |
|
35 | - 'creative-work' => array( |
|
36 | - 'label' => 'CreativeWork', |
|
37 | - 'description' => 'A creative work (or a Music Album).', |
|
38 | - ), |
|
39 | - 'event' => array( |
|
40 | - 'label' => 'Event', |
|
41 | - 'description' => 'An event.', |
|
42 | - ), |
|
43 | - 'organization' => array( |
|
44 | - 'label' => 'Organization', |
|
45 | - 'description' => 'An organization, including a government or a newspaper.', |
|
46 | - ), |
|
47 | - 'person' => array( |
|
48 | - 'label' => 'Person', |
|
49 | - 'description' => 'A person (or a music artist).', |
|
50 | - ), |
|
51 | - 'place' => array( |
|
52 | - 'label' => 'Place', |
|
53 | - 'description' => 'A place.', |
|
54 | - ), |
|
55 | - 'localbusiness' => array( |
|
56 | - 'label' => 'LocalBusiness', |
|
57 | - 'description' => 'A local business.', |
|
58 | - ), |
|
59 | - ); |
|
60 | - |
|
61 | - /** |
|
62 | - * @inheritdoc |
|
63 | - */ |
|
64 | - public function install() { |
|
65 | - // Set the dataset uri. |
|
66 | - $this->set_dataset_uri(); |
|
67 | - |
|
68 | - // Create entity type terms. |
|
69 | - $this->create_entity_type_terms(); |
|
70 | - |
|
71 | - // Create relations table. |
|
72 | - $this->create_relation_instance_table(); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Create required entity type terms |
|
77 | - * |
|
78 | - * @since 3.18.0 |
|
79 | - * |
|
80 | - * @return void |
|
81 | - */ |
|
82 | - private function create_entity_type_terms() { |
|
83 | - $this->log->debug( 'Installing Entity Type data...' ); |
|
84 | - |
|
85 | - // Set the taxonomy data. |
|
86 | - // Note: parent types must be defined before child types. |
|
87 | - foreach ( self::$terms as $slug => $term ) { |
|
88 | - |
|
89 | - // Check whether the term exists and create it if it doesn't. |
|
90 | - $term_id = $this->get_term_or_create_if_not_exists( $slug ); |
|
91 | - |
|
92 | - // Bail if the term doesn't exists or it's not created. |
|
93 | - if ( empty( $term_id ) ) { |
|
94 | - continue; |
|
95 | - } |
|
96 | - |
|
97 | - // Update term with description, slug and parent. |
|
98 | - $term = wp_update_term( |
|
99 | - $term_id, |
|
100 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
101 | - array( |
|
102 | - 'name' => $term['label'], |
|
103 | - 'slug' => $slug, |
|
104 | - 'description' => $term['description'], |
|
105 | - // We give to WP taxonomy just one parent. |
|
106 | - 'parent' => 0, |
|
107 | - ) |
|
108 | - ); |
|
109 | - |
|
110 | - $this->log->trace( "Entity Type $slug installed with ID {$term['term_id']}." ); |
|
111 | - |
|
112 | - } |
|
113 | - |
|
114 | - $this->log->debug( 'Entity Type data installed.' ); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * Install custom relations table. |
|
119 | - * |
|
120 | - * @since 3.8.0 |
|
121 | - * |
|
122 | - * @return void |
|
123 | - */ |
|
124 | - private function create_relation_instance_table() { |
|
125 | - global $wpdb; |
|
126 | - |
|
127 | - $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
128 | - $charset_collate = $wpdb->get_charset_collate(); |
|
129 | - |
|
130 | - // Sql statement for the relation instances custom table. |
|
131 | - $sql = " |
|
18 | + /** |
|
19 | + * @inheritdoc |
|
20 | + */ |
|
21 | + protected static $version = '1.0.0'; |
|
22 | + |
|
23 | + /** |
|
24 | + * The WordLift entity type terms. |
|
25 | + * |
|
26 | + * @since 3.18.0 |
|
27 | + * @access private |
|
28 | + * @var array $terms The entity type terms. |
|
29 | + */ |
|
30 | + private static $terms = array( |
|
31 | + 'thing' => array( |
|
32 | + 'label' => 'Thing', |
|
33 | + 'description' => 'A generic thing (something that doesn\'t fit in the previous definitions.', |
|
34 | + ), |
|
35 | + 'creative-work' => array( |
|
36 | + 'label' => 'CreativeWork', |
|
37 | + 'description' => 'A creative work (or a Music Album).', |
|
38 | + ), |
|
39 | + 'event' => array( |
|
40 | + 'label' => 'Event', |
|
41 | + 'description' => 'An event.', |
|
42 | + ), |
|
43 | + 'organization' => array( |
|
44 | + 'label' => 'Organization', |
|
45 | + 'description' => 'An organization, including a government or a newspaper.', |
|
46 | + ), |
|
47 | + 'person' => array( |
|
48 | + 'label' => 'Person', |
|
49 | + 'description' => 'A person (or a music artist).', |
|
50 | + ), |
|
51 | + 'place' => array( |
|
52 | + 'label' => 'Place', |
|
53 | + 'description' => 'A place.', |
|
54 | + ), |
|
55 | + 'localbusiness' => array( |
|
56 | + 'label' => 'LocalBusiness', |
|
57 | + 'description' => 'A local business.', |
|
58 | + ), |
|
59 | + ); |
|
60 | + |
|
61 | + /** |
|
62 | + * @inheritdoc |
|
63 | + */ |
|
64 | + public function install() { |
|
65 | + // Set the dataset uri. |
|
66 | + $this->set_dataset_uri(); |
|
67 | + |
|
68 | + // Create entity type terms. |
|
69 | + $this->create_entity_type_terms(); |
|
70 | + |
|
71 | + // Create relations table. |
|
72 | + $this->create_relation_instance_table(); |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Create required entity type terms |
|
77 | + * |
|
78 | + * @since 3.18.0 |
|
79 | + * |
|
80 | + * @return void |
|
81 | + */ |
|
82 | + private function create_entity_type_terms() { |
|
83 | + $this->log->debug( 'Installing Entity Type data...' ); |
|
84 | + |
|
85 | + // Set the taxonomy data. |
|
86 | + // Note: parent types must be defined before child types. |
|
87 | + foreach ( self::$terms as $slug => $term ) { |
|
88 | + |
|
89 | + // Check whether the term exists and create it if it doesn't. |
|
90 | + $term_id = $this->get_term_or_create_if_not_exists( $slug ); |
|
91 | + |
|
92 | + // Bail if the term doesn't exists or it's not created. |
|
93 | + if ( empty( $term_id ) ) { |
|
94 | + continue; |
|
95 | + } |
|
96 | + |
|
97 | + // Update term with description, slug and parent. |
|
98 | + $term = wp_update_term( |
|
99 | + $term_id, |
|
100 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
101 | + array( |
|
102 | + 'name' => $term['label'], |
|
103 | + 'slug' => $slug, |
|
104 | + 'description' => $term['description'], |
|
105 | + // We give to WP taxonomy just one parent. |
|
106 | + 'parent' => 0, |
|
107 | + ) |
|
108 | + ); |
|
109 | + |
|
110 | + $this->log->trace( "Entity Type $slug installed with ID {$term['term_id']}." ); |
|
111 | + |
|
112 | + } |
|
113 | + |
|
114 | + $this->log->debug( 'Entity Type data installed.' ); |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * Install custom relations table. |
|
119 | + * |
|
120 | + * @since 3.8.0 |
|
121 | + * |
|
122 | + * @return void |
|
123 | + */ |
|
124 | + private function create_relation_instance_table() { |
|
125 | + global $wpdb; |
|
126 | + |
|
127 | + $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
128 | + $charset_collate = $wpdb->get_charset_collate(); |
|
129 | + |
|
130 | + // Sql statement for the relation instances custom table. |
|
131 | + $sql = " |
|
132 | 132 | CREATE TABLE $table_name ( |
133 | 133 | id int(11) NOT NULL AUTO_INCREMENT, |
134 | 134 | subject_id int(11) NOT NULL, |
@@ -140,64 +140,64 @@ discard block |
||
140 | 140 | ) $charset_collate; |
141 | 141 | "; |
142 | 142 | |
143 | - // @see: https://codex.wordpress.org/Creating_Tables_with_Plugins |
|
144 | - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
|
145 | - dbDelta( $sql ); |
|
146 | - |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * Configure the dataset uri. |
|
151 | - * |
|
152 | - * @since 3.18.0 |
|
153 | - * |
|
154 | - * @return void |
|
155 | - */ |
|
156 | - private function set_dataset_uri() { |
|
157 | - // Get the configuration service and load the key. |
|
158 | - $configuration_service = Wordlift_Configuration_Service::get_instance(); |
|
159 | - $key = $configuration_service->get_key(); |
|
160 | - |
|
161 | - // If the key is not empty then set the dataset URI while sending |
|
162 | - // the site URL. |
|
163 | - if ( ! empty( $key ) ) { |
|
164 | - $this->log->info( 'Updating the remote dataset URI...' ); |
|
165 | - |
|
166 | - $configuration_service->get_remote_dataset_uri( $key ); |
|
167 | - } |
|
168 | - |
|
169 | - } |
|
170 | - |
|
171 | - /** |
|
172 | - * Checks whether the term exists and create it if it doesn't. |
|
173 | - * |
|
174 | - * @since 3.18.0 |
|
175 | - * |
|
176 | - * @param string $slug Term slug. |
|
177 | - * |
|
178 | - * @return mixed Term id if the term exists or if it's created. False on failure |
|
179 | - */ |
|
180 | - private function get_term_or_create_if_not_exists( $slug ) { |
|
181 | - // Create the term if it does not exist, then get its ID. |
|
182 | - $term_id = term_exists( $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
183 | - |
|
184 | - if ( empty( $term_id ) ) { |
|
185 | - // The term doesn't exists, so create it. |
|
186 | - $maybe_term = wp_insert_term( $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
187 | - } else { |
|
188 | - // Get the term. |
|
189 | - $maybe_term = get_term( $term_id['term_id'], Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, ARRAY_A ); |
|
190 | - } |
|
191 | - |
|
192 | - // Check for errors. |
|
193 | - if ( is_wp_error( $maybe_term ) ) { |
|
194 | - $this->log->info( 'wl_install_entity_type_data [ ' . $maybe_term->get_error_message() . ' ]' ); |
|
195 | - |
|
196 | - return false; |
|
197 | - } |
|
198 | - |
|
199 | - // Finally return the term id. |
|
200 | - return $maybe_term['term_id']; |
|
201 | - } |
|
143 | + // @see: https://codex.wordpress.org/Creating_Tables_with_Plugins |
|
144 | + require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
|
145 | + dbDelta( $sql ); |
|
146 | + |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * Configure the dataset uri. |
|
151 | + * |
|
152 | + * @since 3.18.0 |
|
153 | + * |
|
154 | + * @return void |
|
155 | + */ |
|
156 | + private function set_dataset_uri() { |
|
157 | + // Get the configuration service and load the key. |
|
158 | + $configuration_service = Wordlift_Configuration_Service::get_instance(); |
|
159 | + $key = $configuration_service->get_key(); |
|
160 | + |
|
161 | + // If the key is not empty then set the dataset URI while sending |
|
162 | + // the site URL. |
|
163 | + if ( ! empty( $key ) ) { |
|
164 | + $this->log->info( 'Updating the remote dataset URI...' ); |
|
165 | + |
|
166 | + $configuration_service->get_remote_dataset_uri( $key ); |
|
167 | + } |
|
168 | + |
|
169 | + } |
|
170 | + |
|
171 | + /** |
|
172 | + * Checks whether the term exists and create it if it doesn't. |
|
173 | + * |
|
174 | + * @since 3.18.0 |
|
175 | + * |
|
176 | + * @param string $slug Term slug. |
|
177 | + * |
|
178 | + * @return mixed Term id if the term exists or if it's created. False on failure |
|
179 | + */ |
|
180 | + private function get_term_or_create_if_not_exists( $slug ) { |
|
181 | + // Create the term if it does not exist, then get its ID. |
|
182 | + $term_id = term_exists( $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
183 | + |
|
184 | + if ( empty( $term_id ) ) { |
|
185 | + // The term doesn't exists, so create it. |
|
186 | + $maybe_term = wp_insert_term( $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
187 | + } else { |
|
188 | + // Get the term. |
|
189 | + $maybe_term = get_term( $term_id['term_id'], Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, ARRAY_A ); |
|
190 | + } |
|
191 | + |
|
192 | + // Check for errors. |
|
193 | + if ( is_wp_error( $maybe_term ) ) { |
|
194 | + $this->log->info( 'wl_install_entity_type_data [ ' . $maybe_term->get_error_message() . ' ]' ); |
|
195 | + |
|
196 | + return false; |
|
197 | + } |
|
198 | + |
|
199 | + // Finally return the term id. |
|
200 | + return $maybe_term['term_id']; |
|
201 | + } |
|
202 | 202 | |
203 | 203 | } |
@@ -80,17 +80,17 @@ discard block |
||
80 | 80 | * @return void |
81 | 81 | */ |
82 | 82 | private function create_entity_type_terms() { |
83 | - $this->log->debug( 'Installing Entity Type data...' ); |
|
83 | + $this->log->debug('Installing Entity Type data...'); |
|
84 | 84 | |
85 | 85 | // Set the taxonomy data. |
86 | 86 | // Note: parent types must be defined before child types. |
87 | - foreach ( self::$terms as $slug => $term ) { |
|
87 | + foreach (self::$terms as $slug => $term) { |
|
88 | 88 | |
89 | 89 | // Check whether the term exists and create it if it doesn't. |
90 | - $term_id = $this->get_term_or_create_if_not_exists( $slug ); |
|
90 | + $term_id = $this->get_term_or_create_if_not_exists($slug); |
|
91 | 91 | |
92 | 92 | // Bail if the term doesn't exists or it's not created. |
93 | - if ( empty( $term_id ) ) { |
|
93 | + if (empty($term_id)) { |
|
94 | 94 | continue; |
95 | 95 | } |
96 | 96 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | ) |
108 | 108 | ); |
109 | 109 | |
110 | - $this->log->trace( "Entity Type $slug installed with ID {$term['term_id']}." ); |
|
110 | + $this->log->trace("Entity Type $slug installed with ID {$term['term_id']}."); |
|
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | - $this->log->debug( 'Entity Type data installed.' ); |
|
114 | + $this->log->debug('Entity Type data installed.'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | private function create_relation_instance_table() { |
125 | 125 | global $wpdb; |
126 | 126 | |
127 | - $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
127 | + $table_name = $wpdb->prefix.WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
128 | 128 | $charset_collate = $wpdb->get_charset_collate(); |
129 | 129 | |
130 | 130 | // Sql statement for the relation instances custom table. |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | "; |
142 | 142 | |
143 | 143 | // @see: https://codex.wordpress.org/Creating_Tables_with_Plugins |
144 | - require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
|
145 | - dbDelta( $sql ); |
|
144 | + require_once ABSPATH.'wp-admin/includes/upgrade.php'; |
|
145 | + dbDelta($sql); |
|
146 | 146 | |
147 | 147 | } |
148 | 148 | |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | |
161 | 161 | // If the key is not empty then set the dataset URI while sending |
162 | 162 | // the site URL. |
163 | - if ( ! empty( $key ) ) { |
|
164 | - $this->log->info( 'Updating the remote dataset URI...' ); |
|
163 | + if ( ! empty($key)) { |
|
164 | + $this->log->info('Updating the remote dataset URI...'); |
|
165 | 165 | |
166 | - $configuration_service->get_remote_dataset_uri( $key ); |
|
166 | + $configuration_service->get_remote_dataset_uri($key); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | } |
@@ -177,21 +177,21 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return mixed Term id if the term exists or if it's created. False on failure |
179 | 179 | */ |
180 | - private function get_term_or_create_if_not_exists( $slug ) { |
|
180 | + private function get_term_or_create_if_not_exists($slug) { |
|
181 | 181 | // Create the term if it does not exist, then get its ID. |
182 | - $term_id = term_exists( $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
182 | + $term_id = term_exists($slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
183 | 183 | |
184 | - if ( empty( $term_id ) ) { |
|
184 | + if (empty($term_id)) { |
|
185 | 185 | // The term doesn't exists, so create it. |
186 | - $maybe_term = wp_insert_term( $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
186 | + $maybe_term = wp_insert_term($slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
187 | 187 | } else { |
188 | 188 | // Get the term. |
189 | - $maybe_term = get_term( $term_id['term_id'], Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, ARRAY_A ); |
|
189 | + $maybe_term = get_term($term_id['term_id'], Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, ARRAY_A); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | // Check for errors. |
193 | - if ( is_wp_error( $maybe_term ) ) { |
|
194 | - $this->log->info( 'wl_install_entity_type_data [ ' . $maybe_term->get_error_message() . ' ]' ); |
|
193 | + if (is_wp_error($maybe_term)) { |
|
194 | + $this->log->info('wl_install_entity_type_data [ '.$maybe_term->get_error_message().' ]'); |
|
195 | 195 | |
196 | 196 | return false; |
197 | 197 | } |
@@ -12,68 +12,68 @@ |
||
12 | 12 | */ |
13 | 13 | class Wordlift_Install_3_20_0 extends Wordlift_Install { |
14 | 14 | |
15 | - /** |
|
16 | - * {@inheritdoc} |
|
17 | - */ |
|
18 | - protected static $version = '3.20.0'; |
|
15 | + /** |
|
16 | + * {@inheritdoc} |
|
17 | + */ |
|
18 | + protected static $version = '3.20.0'; |
|
19 | 19 | |
20 | - public function install() { |
|
20 | + public function install() { |
|
21 | 21 | |
22 | - $this->add_names_to_existing_terms(); |
|
23 | - $this->rename_localbusiness_to_local_business(); |
|
22 | + $this->add_names_to_existing_terms(); |
|
23 | + $this->rename_localbusiness_to_local_business(); |
|
24 | 24 | |
25 | - } |
|
25 | + } |
|
26 | 26 | |
27 | - private function add_names_to_existing_terms() { |
|
27 | + private function add_names_to_existing_terms() { |
|
28 | 28 | |
29 | - $this->log->debug( 'Adding names and URIs to existing terms...' ); |
|
29 | + $this->log->debug( 'Adding names and URIs to existing terms...' ); |
|
30 | 30 | |
31 | - $schema_names = array( |
|
32 | - 'article' => 'Article', |
|
33 | - 'thing' => 'Thing', |
|
34 | - 'creative-work' => 'CreativeWork', |
|
35 | - 'event' => 'Event', |
|
36 | - 'organization' => 'Organization', |
|
37 | - 'person' => 'Person', |
|
38 | - 'place' => 'Place', |
|
39 | - 'localbusiness' => 'LocalBusiness', |
|
40 | - 'recipe' => 'Recipe', |
|
41 | - 'web-page' => 'WebPage', |
|
42 | - 'offer' => 'Offer', |
|
43 | - ); |
|
31 | + $schema_names = array( |
|
32 | + 'article' => 'Article', |
|
33 | + 'thing' => 'Thing', |
|
34 | + 'creative-work' => 'CreativeWork', |
|
35 | + 'event' => 'Event', |
|
36 | + 'organization' => 'Organization', |
|
37 | + 'person' => 'Person', |
|
38 | + 'place' => 'Place', |
|
39 | + 'localbusiness' => 'LocalBusiness', |
|
40 | + 'recipe' => 'Recipe', |
|
41 | + 'web-page' => 'WebPage', |
|
42 | + 'offer' => 'Offer', |
|
43 | + ); |
|
44 | 44 | |
45 | - foreach ( $schema_names as $slug => $name ) { |
|
46 | - $term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
45 | + foreach ( $schema_names as $slug => $name ) { |
|
46 | + $term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
47 | 47 | |
48 | - if ( false === $term ) { |
|
49 | - $this->log->warn( "Term `$slug` not found." ); |
|
48 | + if ( false === $term ) { |
|
49 | + $this->log->warn( "Term `$slug` not found." ); |
|
50 | 50 | |
51 | - continue; |
|
52 | - } |
|
51 | + continue; |
|
52 | + } |
|
53 | 53 | |
54 | - // $this->log->debug( "Adding $name and http://schema.org/$name as name and URI of term `$slug` ({$term->term_id})." ); |
|
54 | + // $this->log->debug( "Adding $name and http://schema.org/$name as name and URI of term `$slug` ({$term->term_id})." ); |
|
55 | 55 | |
56 | - // We don't use the references to the Wordlift_Schemaorg_Class_Service because it might not be |
|
57 | - // loaded if the `WL_ALL_ENTITY_TYPES` constant isn't set. |
|
58 | - update_term_meta( $term->term_id, '_wl_name', $name ); |
|
59 | - update_term_meta( $term->term_id, '_wl_uri', "http://schema.org/$name" ); |
|
56 | + // We don't use the references to the Wordlift_Schemaorg_Class_Service because it might not be |
|
57 | + // loaded if the `WL_ALL_ENTITY_TYPES` constant isn't set. |
|
58 | + update_term_meta( $term->term_id, '_wl_name', $name ); |
|
59 | + update_term_meta( $term->term_id, '_wl_uri', "http://schema.org/$name" ); |
|
60 | 60 | |
61 | - // $this->log->debug( 'name :: ' . var_export( $result_1, true ) . ' URI :: ' . var_export( $result_2, true ) ); |
|
61 | + // $this->log->debug( 'name :: ' . var_export( $result_1, true ) . ' URI :: ' . var_export( $result_2, true ) ); |
|
62 | 62 | |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | - } |
|
65 | + } |
|
66 | 66 | |
67 | - private function rename_localbusiness_to_local_business() { |
|
67 | + private function rename_localbusiness_to_local_business() { |
|
68 | 68 | |
69 | - $term = get_term_by( 'slug', 'localbusiness', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
69 | + $term = get_term_by( 'slug', 'localbusiness', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
70 | 70 | |
71 | - if ( false === $term ) { |
|
72 | - return; |
|
73 | - } |
|
71 | + if ( false === $term ) { |
|
72 | + return; |
|
73 | + } |
|
74 | 74 | |
75 | - wp_update_term( $term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'slug' => 'local-business' ) ); |
|
75 | + wp_update_term( $term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'slug' => 'local-business' ) ); |
|
76 | 76 | |
77 | - } |
|
77 | + } |
|
78 | 78 | |
79 | 79 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | private function add_names_to_existing_terms() { |
28 | 28 | |
29 | - $this->log->debug( 'Adding names and URIs to existing terms...' ); |
|
29 | + $this->log->debug('Adding names and URIs to existing terms...'); |
|
30 | 30 | |
31 | 31 | $schema_names = array( |
32 | 32 | 'article' => 'Article', |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | 'offer' => 'Offer', |
43 | 43 | ); |
44 | 44 | |
45 | - foreach ( $schema_names as $slug => $name ) { |
|
46 | - $term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
45 | + foreach ($schema_names as $slug => $name) { |
|
46 | + $term = get_term_by('slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
47 | 47 | |
48 | - if ( false === $term ) { |
|
49 | - $this->log->warn( "Term `$slug` not found." ); |
|
48 | + if (false === $term) { |
|
49 | + $this->log->warn("Term `$slug` not found."); |
|
50 | 50 | |
51 | 51 | continue; |
52 | 52 | } |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | |
56 | 56 | // We don't use the references to the Wordlift_Schemaorg_Class_Service because it might not be |
57 | 57 | // loaded if the `WL_ALL_ENTITY_TYPES` constant isn't set. |
58 | - update_term_meta( $term->term_id, '_wl_name', $name ); |
|
59 | - update_term_meta( $term->term_id, '_wl_uri', "http://schema.org/$name" ); |
|
58 | + update_term_meta($term->term_id, '_wl_name', $name); |
|
59 | + update_term_meta($term->term_id, '_wl_uri', "http://schema.org/$name"); |
|
60 | 60 | |
61 | 61 | // $this->log->debug( 'name :: ' . var_export( $result_1, true ) . ' URI :: ' . var_export( $result_2, true ) ); |
62 | 62 | |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | |
67 | 67 | private function rename_localbusiness_to_local_business() { |
68 | 68 | |
69 | - $term = get_term_by( 'slug', 'localbusiness', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
69 | + $term = get_term_by('slug', 'localbusiness', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME); |
|
70 | 70 | |
71 | - if ( false === $term ) { |
|
71 | + if (false === $term) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | - wp_update_term( $term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array( 'slug' => 'local-business' ) ); |
|
75 | + wp_update_term($term->term_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, array('slug' => 'local-business')); |
|
76 | 76 | |
77 | 77 | } |
78 | 78 |
@@ -6,38 +6,38 @@ |
||
6 | 6 | */ |
7 | 7 | class Wordlift_Install_3_28_0 extends Wordlift_Install { |
8 | 8 | |
9 | - /** |
|
10 | - * {@inheritdoc} |
|
11 | - */ |
|
12 | - protected static $version = '3.28.0'; |
|
9 | + /** |
|
10 | + * {@inheritdoc} |
|
11 | + */ |
|
12 | + protected static $version = '3.28.0'; |
|
13 | 13 | |
14 | - public function install() { |
|
14 | + public function install() { |
|
15 | 15 | |
16 | - global $wpdb; |
|
16 | + global $wpdb; |
|
17 | 17 | |
18 | - $dataset_uri = Wordlift_Configuration_Service::get_instance()->get_dataset_uri(); |
|
18 | + $dataset_uri = Wordlift_Configuration_Service::get_instance()->get_dataset_uri(); |
|
19 | 19 | |
20 | - if ( ! $dataset_uri ) { |
|
21 | - // Don't run the query, running it would delete all the values. |
|
22 | - return; |
|
23 | - } |
|
20 | + if ( ! $dataset_uri ) { |
|
21 | + // Don't run the query, running it would delete all the values. |
|
22 | + return; |
|
23 | + } |
|
24 | 24 | |
25 | - $http = $wpdb->esc_like( 'http://' ) . '%'; |
|
26 | - $https = $wpdb->esc_like( 'https://' ) . '%'; |
|
27 | - $dataset_uri = $wpdb->esc_like( $dataset_uri ) . '%'; |
|
25 | + $http = $wpdb->esc_like( 'http://' ) . '%'; |
|
26 | + $https = $wpdb->esc_like( 'https://' ) . '%'; |
|
27 | + $dataset_uri = $wpdb->esc_like( $dataset_uri ) . '%'; |
|
28 | 28 | |
29 | - $wpdb->query( |
|
30 | - $wpdb->prepare( |
|
31 | - "DELETE FROM {$wpdb->postmeta} WHERE meta_key=%s |
|
29 | + $wpdb->query( |
|
30 | + $wpdb->prepare( |
|
31 | + "DELETE FROM {$wpdb->postmeta} WHERE meta_key=%s |
|
32 | 32 | AND ( ( meta_value NOT LIKE %s AND meta_value NOT LIKE %s ) |
33 | 33 | OR meta_value LIKE %s )", |
34 | - Wordlift_Schema_Service::FIELD_SAME_AS, |
|
35 | - $http, |
|
36 | - $https, |
|
37 | - $dataset_uri |
|
38 | - ) |
|
39 | - ); |
|
40 | - |
|
41 | - } |
|
34 | + Wordlift_Schema_Service::FIELD_SAME_AS, |
|
35 | + $http, |
|
36 | + $https, |
|
37 | + $dataset_uri |
|
38 | + ) |
|
39 | + ); |
|
40 | + |
|
41 | + } |
|
42 | 42 | |
43 | 43 | } |
@@ -17,14 +17,14 @@ |
||
17 | 17 | |
18 | 18 | $dataset_uri = Wordlift_Configuration_Service::get_instance()->get_dataset_uri(); |
19 | 19 | |
20 | - if ( ! $dataset_uri ) { |
|
20 | + if ( ! $dataset_uri) { |
|
21 | 21 | // Don't run the query, running it would delete all the values. |
22 | 22 | return; |
23 | 23 | } |
24 | 24 | |
25 | - $http = $wpdb->esc_like( 'http://' ) . '%'; |
|
26 | - $https = $wpdb->esc_like( 'https://' ) . '%'; |
|
27 | - $dataset_uri = $wpdb->esc_like( $dataset_uri ) . '%'; |
|
25 | + $http = $wpdb->esc_like('http://').'%'; |
|
26 | + $https = $wpdb->esc_like('https://').'%'; |
|
27 | + $dataset_uri = $wpdb->esc_like($dataset_uri).'%'; |
|
28 | 28 | |
29 | 29 | $wpdb->query( |
30 | 30 | $wpdb->prepare( |