@@ -11,95 +11,95 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | function wl_core_install_entity_type_data() { |
| 13 | 13 | |
| 14 | - // Ensure the custom type and the taxonomy are registered. |
|
| 15 | - Wordlift_Entity_Post_Type_Service::get_instance()->register(); |
|
| 16 | - |
|
| 17 | - wl_entity_type_taxonomy_register(); |
|
| 18 | - |
|
| 19 | - // Ensure the custom taxonomy for dbpedia topics is registered |
|
| 20 | - Wordlift_Topic_Taxonomy_Service::get_instance()->init(); |
|
| 21 | - |
|
| 22 | - // Set the taxonomy data. |
|
| 23 | - // Note: parent types must be defined before child types. |
|
| 24 | - $terms = array( |
|
| 25 | - 'thing' => array( |
|
| 26 | - 'label' => 'Thing', |
|
| 27 | - 'description' => 'A generic thing (something that doesn\'t fit in the previous definitions.', |
|
| 28 | - ), |
|
| 29 | - 'creative-work' => array( |
|
| 30 | - 'label' => 'CreativeWork', |
|
| 31 | - 'description' => 'A creative work (or a Music Album).', |
|
| 32 | - ), |
|
| 33 | - 'event' => array( |
|
| 34 | - 'label' => 'Event', |
|
| 35 | - 'description' => 'An event.', |
|
| 36 | - ), |
|
| 37 | - 'organization' => array( |
|
| 38 | - 'label' => 'Organization', |
|
| 39 | - 'description' => 'An organization, including a government or a newspaper.', |
|
| 40 | - ), |
|
| 41 | - 'person' => array( |
|
| 42 | - 'label' => 'Person', |
|
| 43 | - 'description' => 'A person (or a music artist).', |
|
| 44 | - ), |
|
| 45 | - 'place' => array( |
|
| 46 | - 'label' => 'Place', |
|
| 47 | - 'description' => 'A place.', |
|
| 48 | - ), |
|
| 49 | - 'localbusiness' => array( |
|
| 50 | - 'label' => 'LocalBusiness', |
|
| 51 | - 'description' => 'A local business.', |
|
| 52 | - ), |
|
| 53 | - ); |
|
| 54 | - |
|
| 55 | - foreach ( $terms as $slug => $term ) { |
|
| 56 | - |
|
| 57 | - // Create the term if it does not exist, then get its ID |
|
| 58 | - $term_id = term_exists( $slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 59 | - |
|
| 60 | - if ( 0 == $term_id || is_null( $term_id ) ) { |
|
| 61 | - $result = wp_insert_term( $slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 62 | - } else { |
|
| 63 | - $term_id = $term_id['term_id']; |
|
| 64 | - $result = get_term( $term_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, ARRAY_A ); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - // Check for errors. |
|
| 68 | - if ( is_wp_error( $result ) ) { |
|
| 69 | - wl_write_log( 'wl_install_entity_type_data [ ' . $result->get_error_message() . ' ]' ); |
|
| 70 | - continue; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - // Check if 'parent' corresponds to an actual term and get its ID. |
|
| 74 | - if ( ! isset( $term['parents'] ) ) { |
|
| 75 | - $term['parents'] = array(); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $parent_ids = array(); |
|
| 79 | - foreach ( $term['parents'] as $parent_slug ) { |
|
| 80 | - $parent_id = get_term_by( 'slug', $parent_slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 81 | - $parent_ids[] = intval( $parent_id->term_id ); // Note: int casting is suggested by Codex: http://codex.wordpress.org/Function_Reference/get_term_by |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - // Define a parent in the WP taxonomy style (not important for WL) |
|
| 85 | - if ( empty( $parent_ids ) ) { |
|
| 86 | - // No parent |
|
| 87 | - $parent_id = 0; |
|
| 88 | - } else { |
|
| 89 | - // Get first parent |
|
| 90 | - $parent_id = $parent_ids[0]; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // Update term with description, slug and parent |
|
| 94 | - wp_update_term( $result['term_id'], Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array( |
|
| 95 | - 'name' => $term['label'], |
|
| 96 | - 'slug' => $slug, |
|
| 97 | - 'description' => $term['description'], |
|
| 98 | - // We give to WP taxonomy just one parent. TODO: see if can give more than one |
|
| 99 | - 'parent' => $parent_id, |
|
| 100 | - ) ); |
|
| 101 | - |
|
| 102 | - } |
|
| 14 | + // Ensure the custom type and the taxonomy are registered. |
|
| 15 | + Wordlift_Entity_Post_Type_Service::get_instance()->register(); |
|
| 16 | + |
|
| 17 | + wl_entity_type_taxonomy_register(); |
|
| 18 | + |
|
| 19 | + // Ensure the custom taxonomy for dbpedia topics is registered |
|
| 20 | + Wordlift_Topic_Taxonomy_Service::get_instance()->init(); |
|
| 21 | + |
|
| 22 | + // Set the taxonomy data. |
|
| 23 | + // Note: parent types must be defined before child types. |
|
| 24 | + $terms = array( |
|
| 25 | + 'thing' => array( |
|
| 26 | + 'label' => 'Thing', |
|
| 27 | + 'description' => 'A generic thing (something that doesn\'t fit in the previous definitions.', |
|
| 28 | + ), |
|
| 29 | + 'creative-work' => array( |
|
| 30 | + 'label' => 'CreativeWork', |
|
| 31 | + 'description' => 'A creative work (or a Music Album).', |
|
| 32 | + ), |
|
| 33 | + 'event' => array( |
|
| 34 | + 'label' => 'Event', |
|
| 35 | + 'description' => 'An event.', |
|
| 36 | + ), |
|
| 37 | + 'organization' => array( |
|
| 38 | + 'label' => 'Organization', |
|
| 39 | + 'description' => 'An organization, including a government or a newspaper.', |
|
| 40 | + ), |
|
| 41 | + 'person' => array( |
|
| 42 | + 'label' => 'Person', |
|
| 43 | + 'description' => 'A person (or a music artist).', |
|
| 44 | + ), |
|
| 45 | + 'place' => array( |
|
| 46 | + 'label' => 'Place', |
|
| 47 | + 'description' => 'A place.', |
|
| 48 | + ), |
|
| 49 | + 'localbusiness' => array( |
|
| 50 | + 'label' => 'LocalBusiness', |
|
| 51 | + 'description' => 'A local business.', |
|
| 52 | + ), |
|
| 53 | + ); |
|
| 54 | + |
|
| 55 | + foreach ( $terms as $slug => $term ) { |
|
| 56 | + |
|
| 57 | + // Create the term if it does not exist, then get its ID |
|
| 58 | + $term_id = term_exists( $slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 59 | + |
|
| 60 | + if ( 0 == $term_id || is_null( $term_id ) ) { |
|
| 61 | + $result = wp_insert_term( $slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 62 | + } else { |
|
| 63 | + $term_id = $term_id['term_id']; |
|
| 64 | + $result = get_term( $term_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, ARRAY_A ); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + // Check for errors. |
|
| 68 | + if ( is_wp_error( $result ) ) { |
|
| 69 | + wl_write_log( 'wl_install_entity_type_data [ ' . $result->get_error_message() . ' ]' ); |
|
| 70 | + continue; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + // Check if 'parent' corresponds to an actual term and get its ID. |
|
| 74 | + if ( ! isset( $term['parents'] ) ) { |
|
| 75 | + $term['parents'] = array(); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $parent_ids = array(); |
|
| 79 | + foreach ( $term['parents'] as $parent_slug ) { |
|
| 80 | + $parent_id = get_term_by( 'slug', $parent_slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 81 | + $parent_ids[] = intval( $parent_id->term_id ); // Note: int casting is suggested by Codex: http://codex.wordpress.org/Function_Reference/get_term_by |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + // Define a parent in the WP taxonomy style (not important for WL) |
|
| 85 | + if ( empty( $parent_ids ) ) { |
|
| 86 | + // No parent |
|
| 87 | + $parent_id = 0; |
|
| 88 | + } else { |
|
| 89 | + // Get first parent |
|
| 90 | + $parent_id = $parent_ids[0]; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // Update term with description, slug and parent |
|
| 94 | + wp_update_term( $result['term_id'], Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array( |
|
| 95 | + 'name' => $term['label'], |
|
| 96 | + 'slug' => $slug, |
|
| 97 | + 'description' => $term['description'], |
|
| 98 | + // We give to WP taxonomy just one parent. TODO: see if can give more than one |
|
| 99 | + 'parent' => $parent_id, |
|
| 100 | + ) ); |
|
| 101 | + |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | } |
| 105 | 105 | |
@@ -108,16 +108,16 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | function wl_core_install_create_relation_instance_table() { |
| 110 | 110 | |
| 111 | - global $wpdb; |
|
| 112 | - // global $wl_db_version; |
|
| 113 | - $installed_version = get_option( 'wl_db_version' ); |
|
| 111 | + global $wpdb; |
|
| 112 | + // global $wl_db_version; |
|
| 113 | + $installed_version = get_option( 'wl_db_version' ); |
|
| 114 | 114 | |
| 115 | - if ( WL_DB_VERSION != $installed_version ) { |
|
| 116 | - $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
| 117 | - $charset_collate = $wpdb->get_charset_collate(); |
|
| 115 | + if ( WL_DB_VERSION != $installed_version ) { |
|
| 116 | + $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
| 117 | + $charset_collate = $wpdb->get_charset_collate(); |
|
| 118 | 118 | |
| 119 | - // Sql statement for the relation instances custom table |
|
| 120 | - $sql = <<<EOF |
|
| 119 | + // Sql statement for the relation instances custom table |
|
| 120 | + $sql = <<<EOF |
|
| 121 | 121 | CREATE TABLE $table_name ( |
| 122 | 122 | id int(11) NOT NULL AUTO_INCREMENT, |
| 123 | 123 | subject_id int(11) NOT NULL, |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | ) $charset_collate; |
| 130 | 130 | EOF; |
| 131 | 131 | |
| 132 | - // @see: https://codex.wordpress.org/Creating_Tables_with_Plugins |
|
| 133 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 134 | - $results = dbDelta( $sql ); |
|
| 132 | + // @see: https://codex.wordpress.org/Creating_Tables_with_Plugins |
|
| 133 | + require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 134 | + $results = dbDelta( $sql ); |
|
| 135 | 135 | |
| 136 | - wl_write_log( $results ); |
|
| 136 | + wl_write_log( $results ); |
|
| 137 | 137 | |
| 138 | - update_option( 'wl_db_version', WL_DB_VERSION ); |
|
| 139 | - } |
|
| 138 | + update_option( 'wl_db_version', WL_DB_VERSION ); |
|
| 139 | + } |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | function wl_core_upgrade_db_to_1_0() { |
| 149 | 149 | |
| 150 | - if ( ! get_site_option( 'wl_db_version' ) ) { |
|
| 151 | - wl_core_install_create_relation_instance_table(); |
|
| 152 | - } |
|
| 150 | + if ( ! get_site_option( 'wl_db_version' ) ) { |
|
| 151 | + wl_core_install_create_relation_instance_table(); |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | 154 | } |
| 155 | 155 | |
@@ -162,44 +162,44 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | function wl_core_upgrade_db_1_0_to_3_10() { |
| 164 | 164 | |
| 165 | - // If the DB version is less than 3.10, than flatten the txonomy. |
|
| 166 | - if ( version_compare( get_site_option( 'wl_db_version' ), '3.9', '<=' ) ) { |
|
| 165 | + // If the DB version is less than 3.10, than flatten the txonomy. |
|
| 166 | + if ( version_compare( get_site_option( 'wl_db_version' ), '3.9', '<=' ) ) { |
|
| 167 | 167 | |
| 168 | - $term_slugs = array( |
|
| 169 | - 'thing', |
|
| 170 | - 'creative-work', |
|
| 171 | - 'event', |
|
| 172 | - 'organization', |
|
| 173 | - 'person', |
|
| 174 | - 'place', |
|
| 175 | - 'localbusiness', |
|
| 176 | - ); |
|
| 168 | + $term_slugs = array( |
|
| 169 | + 'thing', |
|
| 170 | + 'creative-work', |
|
| 171 | + 'event', |
|
| 172 | + 'organization', |
|
| 173 | + 'person', |
|
| 174 | + 'place', |
|
| 175 | + 'localbusiness', |
|
| 176 | + ); |
|
| 177 | 177 | |
| 178 | - foreach ( $term_slugs as $slug ) { |
|
| 178 | + foreach ( $term_slugs as $slug ) { |
|
| 179 | 179 | |
| 180 | - $term = get_term_by( 'slug', $slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 180 | + $term = get_term_by( 'slug', $slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 181 | 181 | |
| 182 | - // Set the term's parent to 0. |
|
| 183 | - if ( $term ) { |
|
| 184 | - wp_update_term( $term->term_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array( |
|
| 185 | - 'parent' => 0, |
|
| 186 | - ) ); |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - } |
|
| 182 | + // Set the term's parent to 0. |
|
| 183 | + if ( $term ) { |
|
| 184 | + wp_update_term( $term->term_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array( |
|
| 185 | + 'parent' => 0, |
|
| 186 | + ) ); |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | // Check db status on automated plugins updates |
| 194 | 194 | function wl_core_update_db_check() { |
| 195 | 195 | |
| 196 | - if ( get_site_option( 'wl_db_version' ) != WL_DB_VERSION ) { |
|
| 196 | + if ( get_site_option( 'wl_db_version' ) != WL_DB_VERSION ) { |
|
| 197 | 197 | |
| 198 | - wl_core_upgrade_db_to_1_0(); |
|
| 199 | - wl_core_upgrade_db_1_0_to_3_10(); |
|
| 200 | - update_site_option( 'wl_db_version', WL_DB_VERSION ); |
|
| 198 | + wl_core_upgrade_db_to_1_0(); |
|
| 199 | + wl_core_upgrade_db_1_0_to_3_10(); |
|
| 200 | + update_site_option( 'wl_db_version', WL_DB_VERSION ); |
|
| 201 | 201 | |
| 202 | - } |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | } |
| 205 | 205 | |
@@ -52,37 +52,37 @@ discard block |
||
| 52 | 52 | ), |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | - foreach ( $terms as $slug => $term ) { |
|
| 55 | + foreach ($terms as $slug => $term) { |
|
| 56 | 56 | |
| 57 | 57 | // Create the term if it does not exist, then get its ID |
| 58 | - $term_id = term_exists( $slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 58 | + $term_id = term_exists($slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME); |
|
| 59 | 59 | |
| 60 | - if ( 0 == $term_id || is_null( $term_id ) ) { |
|
| 61 | - $result = wp_insert_term( $slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 60 | + if (0 == $term_id || is_null($term_id)) { |
|
| 61 | + $result = wp_insert_term($slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME); |
|
| 62 | 62 | } else { |
| 63 | 63 | $term_id = $term_id['term_id']; |
| 64 | - $result = get_term( $term_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, ARRAY_A ); |
|
| 64 | + $result = get_term($term_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, ARRAY_A); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // Check for errors. |
| 68 | - if ( is_wp_error( $result ) ) { |
|
| 69 | - wl_write_log( 'wl_install_entity_type_data [ ' . $result->get_error_message() . ' ]' ); |
|
| 68 | + if (is_wp_error($result)) { |
|
| 69 | + wl_write_log('wl_install_entity_type_data [ '.$result->get_error_message().' ]'); |
|
| 70 | 70 | continue; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // Check if 'parent' corresponds to an actual term and get its ID. |
| 74 | - if ( ! isset( $term['parents'] ) ) { |
|
| 74 | + if ( ! isset($term['parents'])) { |
|
| 75 | 75 | $term['parents'] = array(); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $parent_ids = array(); |
| 79 | - foreach ( $term['parents'] as $parent_slug ) { |
|
| 80 | - $parent_id = get_term_by( 'slug', $parent_slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 81 | - $parent_ids[] = intval( $parent_id->term_id ); // Note: int casting is suggested by Codex: http://codex.wordpress.org/Function_Reference/get_term_by |
|
| 79 | + foreach ($term['parents'] as $parent_slug) { |
|
| 80 | + $parent_id = get_term_by('slug', $parent_slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME); |
|
| 81 | + $parent_ids[] = intval($parent_id->term_id); // Note: int casting is suggested by Codex: http://codex.wordpress.org/Function_Reference/get_term_by |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // Define a parent in the WP taxonomy style (not important for WL) |
| 85 | - if ( empty( $parent_ids ) ) { |
|
| 85 | + if (empty($parent_ids)) { |
|
| 86 | 86 | // No parent |
| 87 | 87 | $parent_id = 0; |
| 88 | 88 | } else { |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // Update term with description, slug and parent |
| 94 | - wp_update_term( $result['term_id'], Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array( |
|
| 94 | + wp_update_term($result['term_id'], Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array( |
|
| 95 | 95 | 'name' => $term['label'], |
| 96 | 96 | 'slug' => $slug, |
| 97 | 97 | 'description' => $term['description'], |
| 98 | 98 | // We give to WP taxonomy just one parent. TODO: see if can give more than one |
| 99 | 99 | 'parent' => $parent_id, |
| 100 | - ) ); |
|
| 100 | + )); |
|
| 101 | 101 | |
| 102 | 102 | } |
| 103 | 103 | |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | global $wpdb; |
| 112 | 112 | // global $wl_db_version; |
| 113 | - $installed_version = get_option( 'wl_db_version' ); |
|
| 113 | + $installed_version = get_option('wl_db_version'); |
|
| 114 | 114 | |
| 115 | - if ( WL_DB_VERSION != $installed_version ) { |
|
| 116 | - $table_name = $wpdb->prefix . WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
| 115 | + if (WL_DB_VERSION != $installed_version) { |
|
| 116 | + $table_name = $wpdb->prefix.WL_DB_RELATION_INSTANCES_TABLE_NAME; |
|
| 117 | 117 | $charset_collate = $wpdb->get_charset_collate(); |
| 118 | 118 | |
| 119 | 119 | // Sql statement for the relation instances custom table |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | EOF; |
| 131 | 131 | |
| 132 | 132 | // @see: https://codex.wordpress.org/Creating_Tables_with_Plugins |
| 133 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 134 | - $results = dbDelta( $sql ); |
|
| 133 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 134 | + $results = dbDelta($sql); |
|
| 135 | 135 | |
| 136 | - wl_write_log( $results ); |
|
| 136 | + wl_write_log($results); |
|
| 137 | 137 | |
| 138 | - update_option( 'wl_db_version', WL_DB_VERSION ); |
|
| 138 | + update_option('wl_db_version', WL_DB_VERSION); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | function wl_core_upgrade_db_to_1_0() { |
| 149 | 149 | |
| 150 | - if ( ! get_site_option( 'wl_db_version' ) ) { |
|
| 150 | + if ( ! get_site_option('wl_db_version')) { |
|
| 151 | 151 | wl_core_install_create_relation_instance_table(); |
| 152 | 152 | } |
| 153 | 153 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | function wl_core_upgrade_db_1_0_to_3_10() { |
| 164 | 164 | |
| 165 | 165 | // If the DB version is less than 3.10, than flatten the txonomy. |
| 166 | - if ( version_compare( get_site_option( 'wl_db_version' ), '3.9', '<=' ) ) { |
|
| 166 | + if (version_compare(get_site_option('wl_db_version'), '3.9', '<=')) { |
|
| 167 | 167 | |
| 168 | 168 | $term_slugs = array( |
| 169 | 169 | 'thing', |
@@ -175,15 +175,15 @@ discard block |
||
| 175 | 175 | 'localbusiness', |
| 176 | 176 | ); |
| 177 | 177 | |
| 178 | - foreach ( $term_slugs as $slug ) { |
|
| 178 | + foreach ($term_slugs as $slug) { |
|
| 179 | 179 | |
| 180 | - $term = get_term_by( 'slug', $slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 180 | + $term = get_term_by('slug', $slug, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME); |
|
| 181 | 181 | |
| 182 | 182 | // Set the term's parent to 0. |
| 183 | - if ( $term ) { |
|
| 184 | - wp_update_term( $term->term_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array( |
|
| 183 | + if ($term) { |
|
| 184 | + wp_update_term($term->term_id, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME, array( |
|
| 185 | 185 | 'parent' => 0, |
| 186 | - ) ); |
|
| 186 | + )); |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | } |
@@ -193,14 +193,14 @@ discard block |
||
| 193 | 193 | // Check db status on automated plugins updates |
| 194 | 194 | function wl_core_update_db_check() { |
| 195 | 195 | |
| 196 | - if ( get_site_option( 'wl_db_version' ) != WL_DB_VERSION ) { |
|
| 196 | + if (get_site_option('wl_db_version') != WL_DB_VERSION) { |
|
| 197 | 197 | |
| 198 | 198 | wl_core_upgrade_db_to_1_0(); |
| 199 | 199 | wl_core_upgrade_db_1_0_to_3_10(); |
| 200 | - update_site_option( 'wl_db_version', WL_DB_VERSION ); |
|
| 200 | + update_site_option('wl_db_version', WL_DB_VERSION); |
|
| 201 | 201 | |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | -add_action( 'init', 'wl_core_update_db_check', 11 ); // need taxonomies and post type to be defined first |
|
| 206 | +add_action('init', 'wl_core_update_db_check', 11); // need taxonomies and post type to be defined first |
|
@@ -22,33 +22,33 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class Wordlift_Activator { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Short Description. (use period) |
|
| 27 | - * |
|
| 28 | - * Long Description. |
|
| 29 | - * |
|
| 30 | - * @since 1.0.0 |
|
| 31 | - */ |
|
| 32 | - public static function activate() { |
|
| 33 | - |
|
| 34 | - $configuration_service = Wordlift_Configuration_Service::get_instance(); |
|
| 35 | - |
|
| 36 | - // Create a blank application key if there is none |
|
| 37 | - $key = $configuration_service->get_key(); |
|
| 38 | - if ( empty( $key ) ) { |
|
| 39 | - $configuration_service->set_key( '' ); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - wl_core_install_entity_type_data(); |
|
| 43 | - wl_core_install_create_relation_instance_table(); |
|
| 44 | - flush_rewrite_rules(); |
|
| 45 | - |
|
| 46 | - // If WordLift's key is not configured, set `_wl_activation_redirect` transient. We won't redirect here, because we can't give |
|
| 47 | - // for granted that we're in a browser admin session. |
|
| 48 | - if ( '' === $configuration_service->get_key() ) { |
|
| 49 | - set_transient( '_wl_activation_redirect', true, 30 ); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - } |
|
| 25 | + /** |
|
| 26 | + * Short Description. (use period) |
|
| 27 | + * |
|
| 28 | + * Long Description. |
|
| 29 | + * |
|
| 30 | + * @since 1.0.0 |
|
| 31 | + */ |
|
| 32 | + public static function activate() { |
|
| 33 | + |
|
| 34 | + $configuration_service = Wordlift_Configuration_Service::get_instance(); |
|
| 35 | + |
|
| 36 | + // Create a blank application key if there is none |
|
| 37 | + $key = $configuration_service->get_key(); |
|
| 38 | + if ( empty( $key ) ) { |
|
| 39 | + $configuration_service->set_key( '' ); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + wl_core_install_entity_type_data(); |
|
| 43 | + wl_core_install_create_relation_instance_table(); |
|
| 44 | + flush_rewrite_rules(); |
|
| 45 | + |
|
| 46 | + // If WordLift's key is not configured, set `_wl_activation_redirect` transient. We won't redirect here, because we can't give |
|
| 47 | + // for granted that we're in a browser admin session. |
|
| 48 | + if ( '' === $configuration_service->get_key() ) { |
|
| 49 | + set_transient( '_wl_activation_redirect', true, 30 ); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | } |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | // Create a blank application key if there is none |
| 37 | 37 | $key = $configuration_service->get_key(); |
| 38 | - if ( empty( $key ) ) { |
|
| 39 | - $configuration_service->set_key( '' ); |
|
| 38 | + if (empty($key)) { |
|
| 39 | + $configuration_service->set_key(''); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | wl_core_install_entity_type_data(); |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | // If WordLift's key is not configured, set `_wl_activation_redirect` transient. We won't redirect here, because we can't give |
| 47 | 47 | // for granted that we're in a browser admin session. |
| 48 | - if ( '' === $configuration_service->get_key() ) { |
|
| 49 | - set_transient( '_wl_activation_redirect', true, 30 ); |
|
| 48 | + if ('' === $configuration_service->get_key()) { |
|
| 49 | + set_transient('_wl_activation_redirect', true, 30); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | } |