@@ -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( |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | protected static $version = '3.32.0'; |
13 | 13 | |
14 | - public static function is_column_exists( $column_name ) { |
|
14 | + public static function is_column_exists($column_name) { |
|
15 | 15 | global $wpdb; |
16 | 16 | |
17 | 17 | return $wpdb->get_results( |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | // const USER = 3; |
35 | 35 | // we add 0 as default since we want to add compat between old and new values. |
36 | 36 | |
37 | - if ( ! self::is_column_exists( 'object_type' ) ) { |
|
37 | + if ( ! self::is_column_exists('object_type')) { |
|
38 | 38 | // Add object_type column |
39 | 39 | $wpdb->query( |
40 | 40 | "ALTER TABLE {$wpdb->prefix}wl_relation_instances |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | ); |
43 | 43 | } |
44 | 44 | |
45 | - if ( ! self::is_column_exists( 'subject_type' ) ) { |
|
45 | + if ( ! self::is_column_exists('subject_type')) { |
|
46 | 46 | // Add subject_type column. |
47 | 47 | $wpdb->query( |
48 | 48 | "ALTER TABLE {$wpdb->prefix}wl_relation_instances |
@@ -6,49 +6,49 @@ |
||
6 | 6 | */ |
7 | 7 | class Wordlift_Install_3_32_0 extends Wordlift_Install { |
8 | 8 | |
9 | - /** |
|
10 | - * {@inheritdoc} |
|
11 | - */ |
|
12 | - protected static $version = '3.32.0'; |
|
13 | - |
|
14 | - public static function is_column_exists( $column_name ) { |
|
15 | - global $wpdb; |
|
16 | - |
|
17 | - return $wpdb->get_results( |
|
18 | - $wpdb->prepare( |
|
19 | - "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name ='{$wpdb->prefix}wl_relation_instances' AND column_name = %s", |
|
20 | - $column_name |
|
21 | - ) |
|
22 | - ); |
|
23 | - |
|
24 | - } |
|
25 | - |
|
26 | - public function install() { |
|
27 | - global $wpdb; |
|
28 | - // Allocate only 8 bytes, represent 2 ^ 8 values in signed form ( -128 to 127 ) |
|
29 | - // we default to 0 here, because we are going to represent Object_Type_Enum in |
|
30 | - // this field |
|
31 | - // const POST = 0; |
|
32 | - // const TERM = 1; |
|
33 | - // const HOMEPAGE = 2; |
|
34 | - // const USER = 3; |
|
35 | - // we add 0 as default since we want to add compat between old and new values. |
|
36 | - |
|
37 | - if ( ! self::is_column_exists( 'object_type' ) ) { |
|
38 | - // Add object_type column |
|
39 | - $wpdb->query( |
|
40 | - "ALTER TABLE {$wpdb->prefix}wl_relation_instances |
|
9 | + /** |
|
10 | + * {@inheritdoc} |
|
11 | + */ |
|
12 | + protected static $version = '3.32.0'; |
|
13 | + |
|
14 | + public static function is_column_exists( $column_name ) { |
|
15 | + global $wpdb; |
|
16 | + |
|
17 | + return $wpdb->get_results( |
|
18 | + $wpdb->prepare( |
|
19 | + "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name ='{$wpdb->prefix}wl_relation_instances' AND column_name = %s", |
|
20 | + $column_name |
|
21 | + ) |
|
22 | + ); |
|
23 | + |
|
24 | + } |
|
25 | + |
|
26 | + public function install() { |
|
27 | + global $wpdb; |
|
28 | + // Allocate only 8 bytes, represent 2 ^ 8 values in signed form ( -128 to 127 ) |
|
29 | + // we default to 0 here, because we are going to represent Object_Type_Enum in |
|
30 | + // this field |
|
31 | + // const POST = 0; |
|
32 | + // const TERM = 1; |
|
33 | + // const HOMEPAGE = 2; |
|
34 | + // const USER = 3; |
|
35 | + // we add 0 as default since we want to add compat between old and new values. |
|
36 | + |
|
37 | + if ( ! self::is_column_exists( 'object_type' ) ) { |
|
38 | + // Add object_type column |
|
39 | + $wpdb->query( |
|
40 | + "ALTER TABLE {$wpdb->prefix}wl_relation_instances |
|
41 | 41 | ADD object_type TINYINT DEFAULT 0;" |
42 | - ); |
|
43 | - } |
|
42 | + ); |
|
43 | + } |
|
44 | 44 | |
45 | - if ( ! self::is_column_exists( 'subject_type' ) ) { |
|
46 | - // Add subject_type column. |
|
47 | - $wpdb->query( |
|
48 | - "ALTER TABLE {$wpdb->prefix}wl_relation_instances |
|
45 | + if ( ! self::is_column_exists( 'subject_type' ) ) { |
|
46 | + // Add subject_type column. |
|
47 | + $wpdb->query( |
|
48 | + "ALTER TABLE {$wpdb->prefix}wl_relation_instances |
|
49 | 49 | ADD subject_type TINYINT DEFAULT 0;" |
50 | - ); |
|
51 | - } |
|
52 | - } |
|
50 | + ); |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | 54 | } |
@@ -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, |