@@ -14,262 +14,262 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class WL_Metabox { |
| 16 | 16 | |
| 17 | - public $fields; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * The Log service. |
|
| 21 | - * |
|
| 22 | - * @since 3.1.0 |
|
| 23 | - * @access private |
|
| 24 | - * @var Wordlift_Log_Service $log_service The Log service. |
|
| 25 | - */ |
|
| 26 | - private $log_service; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * WL_Metabox constructor. |
|
| 30 | - * |
|
| 31 | - * @since 3.1.0 |
|
| 32 | - */ |
|
| 33 | - public function __construct() { |
|
| 34 | - |
|
| 35 | - // Create a logger instance. |
|
| 36 | - $this->log_service = Wordlift_Log_Service::get_logger( 'WL_Metabox' ); |
|
| 37 | - |
|
| 38 | - // Add hooks to print metaboxes and save submitted data. |
|
| 39 | - add_action( 'add_meta_boxes', array( &$this, 'add_main_metabox' ) ); |
|
| 40 | - add_action( 'wl_linked_data_save_post', array( |
|
| 41 | - &$this, |
|
| 42 | - 'save_form_data' |
|
| 43 | - ) ); |
|
| 44 | - |
|
| 45 | - // Enqueue js and css |
|
| 46 | - $this->enqueue_scripts_and_styles(); |
|
| 47 | - |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Add a callback to print the metabox in page. |
|
| 52 | - * Wordpress will fire the $this->html() callback at the right time. |
|
| 53 | - */ |
|
| 54 | - public function add_main_metabox() { |
|
| 55 | - |
|
| 56 | - // Add main metabox (will print also the inner fields) |
|
| 57 | - $id = uniqid( 'wl-metabox-' ); |
|
| 58 | - $title = get_the_title() . ' ' . __( 'properties', 'wordlift' ); |
|
| 59 | - add_meta_box( $id, $title, array( |
|
| 60 | - $this, |
|
| 61 | - 'html' |
|
| 62 | - ), Wordlift_Entity_Service::TYPE_NAME, 'normal', 'high' ); |
|
| 63 | - |
|
| 64 | - // Add filter to change the metabox CSS class |
|
| 65 | - add_filter( "postbox_classes_entity_$id", 'wl_admin_metaboxes_add_css_class' ); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Called from WP to print the metabox content in page. |
|
| 70 | - * |
|
| 71 | - * @since 3.1.0 |
|
| 72 | - * |
|
| 73 | - * @param WP_Post $post The post. |
|
| 74 | - */ |
|
| 75 | - public function html( $post ) { |
|
| 76 | - |
|
| 77 | - // Build the fields we need to print. |
|
| 78 | - $this->instantiate_fields( $post->ID ); |
|
| 79 | - |
|
| 80 | - // Loop over the fields |
|
| 81 | - foreach ( $this->fields as $field ) { |
|
| 82 | - |
|
| 83 | - // load data from DB (values will be available in $field->data) |
|
| 84 | - $field->get_data(); |
|
| 85 | - |
|
| 86 | - // print field HTML (nonce included) |
|
| 87 | - echo $field->html(); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Read the WL <-> Schema mapping and build the Fields for the entity being edited. |
|
| 94 | - * |
|
| 95 | - * Note: the first function that calls this method will instantiate the fields. |
|
| 96 | - * Why it isn't called from the constructor? Because we need to hook this process as late as possible. |
|
| 97 | - * |
|
| 98 | - * @since 3.1.0 |
|
| 99 | - * |
|
| 100 | - * @param int $post_id The post id. |
|
| 101 | - */ |
|
| 102 | - public function instantiate_fields( $post_id ) { |
|
| 103 | - |
|
| 104 | - // This function must be called only once. Not called from the constructor because WP hooks have a rococo ordering |
|
| 105 | - if ( isset( $this->fields ) ) { |
|
| 106 | - return; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - $entity_type = wl_entity_taxonomy_get_custom_fields( $post_id ); |
|
| 110 | - |
|
| 111 | - if ( isset( $entity_type ) ) { |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * In some special case, properties must be grouped in one field (e.g. coordinates) or dealed with custom methods. |
|
| 115 | - * We must divide fields in two groups: |
|
| 116 | - * - simple: accept values for one property |
|
| 117 | - * - grouped: accept values for more properties, or for one property that needs a specific metabox. |
|
| 118 | - */ |
|
| 119 | - $metaboxes = $this->group_properties_by_input_field( $entity_type ); |
|
| 120 | - $simple_metaboxes = $metaboxes[0]; |
|
| 121 | - $grouped_metaboxes = $metaboxes[1]; |
|
| 122 | - |
|
| 123 | - // Loop over simple entity properties |
|
| 124 | - foreach ( $simple_metaboxes as $key => $property ) { |
|
| 125 | - |
|
| 126 | - // Info passed to the metabox |
|
| 127 | - $info = array(); |
|
| 128 | - $info[ $key ] = $property; |
|
| 129 | - |
|
| 130 | - // Build the requested field as WL_Metabox_Field_ object |
|
| 131 | - $this->add_field( $info ); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - // Loop over grouped properties |
|
| 135 | - foreach ( $grouped_metaboxes as $key => $property ) { |
|
| 136 | - |
|
| 137 | - // Info passed to the metabox |
|
| 138 | - $info = array(); |
|
| 139 | - $info[ $key ] = $property; |
|
| 140 | - |
|
| 141 | - // Build the requested field group as WL_Metabox_Field_ object |
|
| 142 | - $this->add_field( $info, TRUE ); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * Separes metaboxes in simple and grouped. |
|
| 150 | - * |
|
| 151 | - * @param array $custom_fields Information on the entity type. |
|
| 152 | - */ |
|
| 153 | - public function group_properties_by_input_field( $custom_fields ) { |
|
| 154 | - |
|
| 155 | - $simple_properties = array(); |
|
| 156 | - $grouped_properties = array(); |
|
| 157 | - |
|
| 158 | - // Loop over possible entity properties |
|
| 159 | - foreach ( $custom_fields as $key => $property ) { |
|
| 160 | - |
|
| 161 | - // Check presence of predicate and type |
|
| 162 | - if ( isset( $property['predicate'] ) && isset( $property['type'] ) ) { |
|
| 163 | - |
|
| 164 | - // Check if input_field is defined |
|
| 165 | - if ( isset( $property['input_field'] ) && $property['input_field'] !== '' ) { |
|
| 166 | - |
|
| 167 | - $grouped_key = $property['input_field']; |
|
| 168 | - |
|
| 169 | - // Update list of grouped properties |
|
| 170 | - $grouped_properties[ $grouped_key ][ $key ] = $property; |
|
| 171 | - |
|
| 172 | - } else { |
|
| 173 | - |
|
| 174 | - // input_field not defined, add simple metabox |
|
| 175 | - $simple_properties[ $key ] = $property; |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - return array( $simple_properties, $grouped_properties ); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * Add a Field to the current Metabox, based on the description of the Field. |
|
| 185 | - * This method is a rude factory for Field objects. |
|
| 186 | - * |
|
| 187 | - * @param type $args |
|
| 188 | - * @param type $grouped Flag to distinguish between simple and grouped Fields |
|
| 189 | - */ |
|
| 190 | - public function add_field( $args, $grouped = FALSE ) { |
|
| 191 | - |
|
| 192 | - if ( $grouped ) { |
|
| 193 | - // Special fields (sameas, coordinates, etc.) |
|
| 194 | - |
|
| 195 | - // Build Field with a custom class (e.g. WL_Metabox_Field_date) |
|
| 196 | - $field_class = 'WL_Metabox_Field_' . key( $args ); |
|
| 197 | - |
|
| 198 | - } else { |
|
| 199 | - // Simple fields (string, uri, boolean, etc.) |
|
| 200 | - |
|
| 201 | - // Which field? We want to use the class that is specific for the field. |
|
| 202 | - $meta = key( $args ); |
|
| 203 | - if ( ! isset( $args[ $meta ]['type'] ) || ( $args[ $meta ]['type'] == Wordlift_Schema_Service::DATA_TYPE_STRING ) ) { |
|
| 204 | - // Use default WL_Metabox_Field (manages strings) |
|
| 205 | - $field_class = 'WL_Metabox_Field'; |
|
| 206 | - } else { |
|
| 207 | - // Build Field with a custom class (e.g. WL_Metabox_Field_date) |
|
| 208 | - $field_class = 'WL_Metabox_Field_' . $args[ $meta ]['type']; |
|
| 209 | - } |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - // Call apropriate constructor (e.g. WL_Metabox_Field_... ) |
|
| 213 | - $this->fields[] = new $field_class( $args ); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - public function save_form_data( $entity_id ) { |
|
| 217 | - |
|
| 218 | - // Build Field objects |
|
| 219 | - $this->instantiate_fields( $entity_id ); |
|
| 17 | + public $fields; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * The Log service. |
|
| 21 | + * |
|
| 22 | + * @since 3.1.0 |
|
| 23 | + * @access private |
|
| 24 | + * @var Wordlift_Log_Service $log_service The Log service. |
|
| 25 | + */ |
|
| 26 | + private $log_service; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * WL_Metabox constructor. |
|
| 30 | + * |
|
| 31 | + * @since 3.1.0 |
|
| 32 | + */ |
|
| 33 | + public function __construct() { |
|
| 34 | + |
|
| 35 | + // Create a logger instance. |
|
| 36 | + $this->log_service = Wordlift_Log_Service::get_logger( 'WL_Metabox' ); |
|
| 37 | + |
|
| 38 | + // Add hooks to print metaboxes and save submitted data. |
|
| 39 | + add_action( 'add_meta_boxes', array( &$this, 'add_main_metabox' ) ); |
|
| 40 | + add_action( 'wl_linked_data_save_post', array( |
|
| 41 | + &$this, |
|
| 42 | + 'save_form_data' |
|
| 43 | + ) ); |
|
| 44 | + |
|
| 45 | + // Enqueue js and css |
|
| 46 | + $this->enqueue_scripts_and_styles(); |
|
| 47 | + |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Add a callback to print the metabox in page. |
|
| 52 | + * Wordpress will fire the $this->html() callback at the right time. |
|
| 53 | + */ |
|
| 54 | + public function add_main_metabox() { |
|
| 55 | + |
|
| 56 | + // Add main metabox (will print also the inner fields) |
|
| 57 | + $id = uniqid( 'wl-metabox-' ); |
|
| 58 | + $title = get_the_title() . ' ' . __( 'properties', 'wordlift' ); |
|
| 59 | + add_meta_box( $id, $title, array( |
|
| 60 | + $this, |
|
| 61 | + 'html' |
|
| 62 | + ), Wordlift_Entity_Service::TYPE_NAME, 'normal', 'high' ); |
|
| 63 | + |
|
| 64 | + // Add filter to change the metabox CSS class |
|
| 65 | + add_filter( "postbox_classes_entity_$id", 'wl_admin_metaboxes_add_css_class' ); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Called from WP to print the metabox content in page. |
|
| 70 | + * |
|
| 71 | + * @since 3.1.0 |
|
| 72 | + * |
|
| 73 | + * @param WP_Post $post The post. |
|
| 74 | + */ |
|
| 75 | + public function html( $post ) { |
|
| 76 | + |
|
| 77 | + // Build the fields we need to print. |
|
| 78 | + $this->instantiate_fields( $post->ID ); |
|
| 79 | + |
|
| 80 | + // Loop over the fields |
|
| 81 | + foreach ( $this->fields as $field ) { |
|
| 82 | + |
|
| 83 | + // load data from DB (values will be available in $field->data) |
|
| 84 | + $field->get_data(); |
|
| 85 | + |
|
| 86 | + // print field HTML (nonce included) |
|
| 87 | + echo $field->html(); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Read the WL <-> Schema mapping and build the Fields for the entity being edited. |
|
| 94 | + * |
|
| 95 | + * Note: the first function that calls this method will instantiate the fields. |
|
| 96 | + * Why it isn't called from the constructor? Because we need to hook this process as late as possible. |
|
| 97 | + * |
|
| 98 | + * @since 3.1.0 |
|
| 99 | + * |
|
| 100 | + * @param int $post_id The post id. |
|
| 101 | + */ |
|
| 102 | + public function instantiate_fields( $post_id ) { |
|
| 103 | + |
|
| 104 | + // This function must be called only once. Not called from the constructor because WP hooks have a rococo ordering |
|
| 105 | + if ( isset( $this->fields ) ) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + $entity_type = wl_entity_taxonomy_get_custom_fields( $post_id ); |
|
| 110 | + |
|
| 111 | + if ( isset( $entity_type ) ) { |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * In some special case, properties must be grouped in one field (e.g. coordinates) or dealed with custom methods. |
|
| 115 | + * We must divide fields in two groups: |
|
| 116 | + * - simple: accept values for one property |
|
| 117 | + * - grouped: accept values for more properties, or for one property that needs a specific metabox. |
|
| 118 | + */ |
|
| 119 | + $metaboxes = $this->group_properties_by_input_field( $entity_type ); |
|
| 120 | + $simple_metaboxes = $metaboxes[0]; |
|
| 121 | + $grouped_metaboxes = $metaboxes[1]; |
|
| 122 | + |
|
| 123 | + // Loop over simple entity properties |
|
| 124 | + foreach ( $simple_metaboxes as $key => $property ) { |
|
| 125 | + |
|
| 126 | + // Info passed to the metabox |
|
| 127 | + $info = array(); |
|
| 128 | + $info[ $key ] = $property; |
|
| 129 | + |
|
| 130 | + // Build the requested field as WL_Metabox_Field_ object |
|
| 131 | + $this->add_field( $info ); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + // Loop over grouped properties |
|
| 135 | + foreach ( $grouped_metaboxes as $key => $property ) { |
|
| 136 | + |
|
| 137 | + // Info passed to the metabox |
|
| 138 | + $info = array(); |
|
| 139 | + $info[ $key ] = $property; |
|
| 140 | + |
|
| 141 | + // Build the requested field group as WL_Metabox_Field_ object |
|
| 142 | + $this->add_field( $info, TRUE ); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * Separes metaboxes in simple and grouped. |
|
| 150 | + * |
|
| 151 | + * @param array $custom_fields Information on the entity type. |
|
| 152 | + */ |
|
| 153 | + public function group_properties_by_input_field( $custom_fields ) { |
|
| 154 | + |
|
| 155 | + $simple_properties = array(); |
|
| 156 | + $grouped_properties = array(); |
|
| 157 | + |
|
| 158 | + // Loop over possible entity properties |
|
| 159 | + foreach ( $custom_fields as $key => $property ) { |
|
| 160 | + |
|
| 161 | + // Check presence of predicate and type |
|
| 162 | + if ( isset( $property['predicate'] ) && isset( $property['type'] ) ) { |
|
| 163 | + |
|
| 164 | + // Check if input_field is defined |
|
| 165 | + if ( isset( $property['input_field'] ) && $property['input_field'] !== '' ) { |
|
| 166 | + |
|
| 167 | + $grouped_key = $property['input_field']; |
|
| 168 | + |
|
| 169 | + // Update list of grouped properties |
|
| 170 | + $grouped_properties[ $grouped_key ][ $key ] = $property; |
|
| 171 | + |
|
| 172 | + } else { |
|
| 173 | + |
|
| 174 | + // input_field not defined, add simple metabox |
|
| 175 | + $simple_properties[ $key ] = $property; |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + return array( $simple_properties, $grouped_properties ); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * Add a Field to the current Metabox, based on the description of the Field. |
|
| 185 | + * This method is a rude factory for Field objects. |
|
| 186 | + * |
|
| 187 | + * @param type $args |
|
| 188 | + * @param type $grouped Flag to distinguish between simple and grouped Fields |
|
| 189 | + */ |
|
| 190 | + public function add_field( $args, $grouped = FALSE ) { |
|
| 191 | + |
|
| 192 | + if ( $grouped ) { |
|
| 193 | + // Special fields (sameas, coordinates, etc.) |
|
| 194 | + |
|
| 195 | + // Build Field with a custom class (e.g. WL_Metabox_Field_date) |
|
| 196 | + $field_class = 'WL_Metabox_Field_' . key( $args ); |
|
| 197 | + |
|
| 198 | + } else { |
|
| 199 | + // Simple fields (string, uri, boolean, etc.) |
|
| 200 | + |
|
| 201 | + // Which field? We want to use the class that is specific for the field. |
|
| 202 | + $meta = key( $args ); |
|
| 203 | + if ( ! isset( $args[ $meta ]['type'] ) || ( $args[ $meta ]['type'] == Wordlift_Schema_Service::DATA_TYPE_STRING ) ) { |
|
| 204 | + // Use default WL_Metabox_Field (manages strings) |
|
| 205 | + $field_class = 'WL_Metabox_Field'; |
|
| 206 | + } else { |
|
| 207 | + // Build Field with a custom class (e.g. WL_Metabox_Field_date) |
|
| 208 | + $field_class = 'WL_Metabox_Field_' . $args[ $meta ]['type']; |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + // Call apropriate constructor (e.g. WL_Metabox_Field_... ) |
|
| 213 | + $this->fields[] = new $field_class( $args ); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + public function save_form_data( $entity_id ) { |
|
| 217 | + |
|
| 218 | + // Build Field objects |
|
| 219 | + $this->instantiate_fields( $entity_id ); |
|
| 220 | 220 | |
| 221 | - // Check if WL metabox form was posted |
|
| 222 | - if ( ! isset( $_POST['wl_metaboxes'] ) ) { |
|
| 223 | - return; |
|
| 224 | - } |
|
| 221 | + // Check if WL metabox form was posted |
|
| 222 | + if ( ! isset( $_POST['wl_metaboxes'] ) ) { |
|
| 223 | + return; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - foreach ( $this->fields as $field ) { |
|
| 227 | - |
|
| 228 | - // Verify nonce |
|
| 229 | - $valid_nonce = $field->verify_nonce(); |
|
| 230 | - if ( $valid_nonce ) { |
|
| 231 | - |
|
| 232 | - $posted_data = $_POST['wl_metaboxes']; |
|
| 233 | - $field_name = $field->meta_name; |
|
| 234 | - |
|
| 235 | - // Each Filed only deals with its values. |
|
| 236 | - if ( isset( $posted_data[ $field_name ] ) ) { |
|
| 237 | - |
|
| 238 | - $values = $posted_data[ $field_name ]; |
|
| 239 | - if ( ! is_array( $values ) ) { |
|
| 240 | - $values = array( $values ); |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - // Save data permanently |
|
| 244 | - $field->save_data( $values ); |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - wl_linked_data_push_to_redlink( $entity_id ); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - // print on page all the js and css the fields will need |
|
| 253 | - public function enqueue_scripts_and_styles() { |
|
| 226 | + foreach ( $this->fields as $field ) { |
|
| 227 | + |
|
| 228 | + // Verify nonce |
|
| 229 | + $valid_nonce = $field->verify_nonce(); |
|
| 230 | + if ( $valid_nonce ) { |
|
| 231 | + |
|
| 232 | + $posted_data = $_POST['wl_metaboxes']; |
|
| 233 | + $field_name = $field->meta_name; |
|
| 234 | + |
|
| 235 | + // Each Filed only deals with its values. |
|
| 236 | + if ( isset( $posted_data[ $field_name ] ) ) { |
|
| 237 | + |
|
| 238 | + $values = $posted_data[ $field_name ]; |
|
| 239 | + if ( ! is_array( $values ) ) { |
|
| 240 | + $values = array( $values ); |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + // Save data permanently |
|
| 244 | + $field->save_data( $values ); |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + wl_linked_data_push_to_redlink( $entity_id ); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + // print on page all the js and css the fields will need |
|
| 253 | + public function enqueue_scripts_and_styles() { |
|
| 254 | 254 | |
| 255 | - // dateTimePicker |
|
| 256 | - wp_enqueue_style( 'jquery-ui-timepicker', dirname( plugin_dir_url( __FILE__ ) ) . '/css/jquery.datetimepicker.css' ); |
|
| 257 | - wp_enqueue_script( 'jquery-ui-timepicker', dirname( plugin_dir_url( __FILE__ ) ) . '/js/jquery.datetimepicker.full.min.js', array( 'jquery' ) ); |
|
| 258 | - |
|
| 259 | - // We rename the xdsoft datetimepicker function name to avoid conflicts to the jQuery UI derived datetimepicker library. |
|
| 260 | - // see https://github.com/insideout10/wordlift-plugin/issues/340 |
|
| 261 | - wp_enqueue_script( 'jquery-ui-timepicker-no-conflict', dirname( plugin_dir_url( __FILE__ ) ) . '/js/jquery.datetimepicker.no-conflict.js', array( 'jquery-ui-timepicker' ) ); |
|
| 262 | - |
|
| 263 | - // Leaflet. |
|
| 264 | - wp_enqueue_style( 'leaflet', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.css' ); |
|
| 265 | - wp_enqueue_script( 'leaflet', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.js', __FILE__ ); |
|
| 266 | - |
|
| 267 | - // Add AJAX autocomplete to facilitate metabox editing |
|
| 268 | - wp_enqueue_script( 'wl-entity-metabox-utility', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wl_entity_metabox_utilities.js' ); |
|
| 269 | - wp_localize_script( 'wl-entity-metabox-utility', 'wlEntityMetaboxParams', array( |
|
| 270 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 271 | - 'action' => 'entity_by_title' |
|
| 272 | - ) |
|
| 273 | - ); |
|
| 274 | - } |
|
| 255 | + // dateTimePicker |
|
| 256 | + wp_enqueue_style( 'jquery-ui-timepicker', dirname( plugin_dir_url( __FILE__ ) ) . '/css/jquery.datetimepicker.css' ); |
|
| 257 | + wp_enqueue_script( 'jquery-ui-timepicker', dirname( plugin_dir_url( __FILE__ ) ) . '/js/jquery.datetimepicker.full.min.js', array( 'jquery' ) ); |
|
| 258 | + |
|
| 259 | + // We rename the xdsoft datetimepicker function name to avoid conflicts to the jQuery UI derived datetimepicker library. |
|
| 260 | + // see https://github.com/insideout10/wordlift-plugin/issues/340 |
|
| 261 | + wp_enqueue_script( 'jquery-ui-timepicker-no-conflict', dirname( plugin_dir_url( __FILE__ ) ) . '/js/jquery.datetimepicker.no-conflict.js', array( 'jquery-ui-timepicker' ) ); |
|
| 262 | + |
|
| 263 | + // Leaflet. |
|
| 264 | + wp_enqueue_style( 'leaflet', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.css' ); |
|
| 265 | + wp_enqueue_script( 'leaflet', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.js', __FILE__ ); |
|
| 266 | + |
|
| 267 | + // Add AJAX autocomplete to facilitate metabox editing |
|
| 268 | + wp_enqueue_script( 'wl-entity-metabox-utility', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wl_entity_metabox_utilities.js' ); |
|
| 269 | + wp_localize_script( 'wl-entity-metabox-utility', 'wlEntityMetaboxParams', array( |
|
| 270 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 271 | + 'action' => 'entity_by_title' |
|
| 272 | + ) |
|
| 273 | + ); |
|
| 274 | + } |
|
| 275 | 275 | } |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once( 'WL_Metabox_Field.php' ); |
|
| 4 | -require_once( 'WL_Metabox_Field_date.php' ); |
|
| 5 | -require_once( 'WL_Metabox_Field_uri.php' ); |
|
| 6 | -require_once( 'WL_Metabox_Field_coordinates.php' ); |
|
| 7 | -require_once( 'WL_Metabox_Field_sameas.php' ); |
|
| 8 | -require_once( 'WL_Metabox_Field_address.php' ); |
|
| 3 | +require_once('WL_Metabox_Field.php'); |
|
| 4 | +require_once('WL_Metabox_Field_date.php'); |
|
| 5 | +require_once('WL_Metabox_Field_uri.php'); |
|
| 6 | +require_once('WL_Metabox_Field_coordinates.php'); |
|
| 7 | +require_once('WL_Metabox_Field_sameas.php'); |
|
| 8 | +require_once('WL_Metabox_Field_address.php'); |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Class WL_Metabox |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | public function __construct() { |
| 34 | 34 | |
| 35 | 35 | // Create a logger instance. |
| 36 | - $this->log_service = Wordlift_Log_Service::get_logger( 'WL_Metabox' ); |
|
| 36 | + $this->log_service = Wordlift_Log_Service::get_logger('WL_Metabox'); |
|
| 37 | 37 | |
| 38 | 38 | // Add hooks to print metaboxes and save submitted data. |
| 39 | - add_action( 'add_meta_boxes', array( &$this, 'add_main_metabox' ) ); |
|
| 40 | - add_action( 'wl_linked_data_save_post', array( |
|
| 39 | + add_action('add_meta_boxes', array(&$this, 'add_main_metabox')); |
|
| 40 | + add_action('wl_linked_data_save_post', array( |
|
| 41 | 41 | &$this, |
| 42 | 42 | 'save_form_data' |
| 43 | - ) ); |
|
| 43 | + )); |
|
| 44 | 44 | |
| 45 | 45 | // Enqueue js and css |
| 46 | 46 | $this->enqueue_scripts_and_styles(); |
@@ -54,15 +54,15 @@ discard block |
||
| 54 | 54 | public function add_main_metabox() { |
| 55 | 55 | |
| 56 | 56 | // Add main metabox (will print also the inner fields) |
| 57 | - $id = uniqid( 'wl-metabox-' ); |
|
| 58 | - $title = get_the_title() . ' ' . __( 'properties', 'wordlift' ); |
|
| 59 | - add_meta_box( $id, $title, array( |
|
| 57 | + $id = uniqid('wl-metabox-'); |
|
| 58 | + $title = get_the_title().' '.__('properties', 'wordlift'); |
|
| 59 | + add_meta_box($id, $title, array( |
|
| 60 | 60 | $this, |
| 61 | 61 | 'html' |
| 62 | - ), Wordlift_Entity_Service::TYPE_NAME, 'normal', 'high' ); |
|
| 62 | + ), Wordlift_Entity_Service::TYPE_NAME, 'normal', 'high'); |
|
| 63 | 63 | |
| 64 | 64 | // Add filter to change the metabox CSS class |
| 65 | - add_filter( "postbox_classes_entity_$id", 'wl_admin_metaboxes_add_css_class' ); |
|
| 65 | + add_filter("postbox_classes_entity_$id", 'wl_admin_metaboxes_add_css_class'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -72,13 +72,13 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param WP_Post $post The post. |
| 74 | 74 | */ |
| 75 | - public function html( $post ) { |
|
| 75 | + public function html($post) { |
|
| 76 | 76 | |
| 77 | 77 | // Build the fields we need to print. |
| 78 | - $this->instantiate_fields( $post->ID ); |
|
| 78 | + $this->instantiate_fields($post->ID); |
|
| 79 | 79 | |
| 80 | 80 | // Loop over the fields |
| 81 | - foreach ( $this->fields as $field ) { |
|
| 81 | + foreach ($this->fields as $field) { |
|
| 82 | 82 | |
| 83 | 83 | // load data from DB (values will be available in $field->data) |
| 84 | 84 | $field->get_data(); |
@@ -99,16 +99,16 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @param int $post_id The post id. |
| 101 | 101 | */ |
| 102 | - public function instantiate_fields( $post_id ) { |
|
| 102 | + public function instantiate_fields($post_id) { |
|
| 103 | 103 | |
| 104 | 104 | // This function must be called only once. Not called from the constructor because WP hooks have a rococo ordering |
| 105 | - if ( isset( $this->fields ) ) { |
|
| 105 | + if (isset($this->fields)) { |
|
| 106 | 106 | return; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $entity_type = wl_entity_taxonomy_get_custom_fields( $post_id ); |
|
| 109 | + $entity_type = wl_entity_taxonomy_get_custom_fields($post_id); |
|
| 110 | 110 | |
| 111 | - if ( isset( $entity_type ) ) { |
|
| 111 | + if (isset($entity_type)) { |
|
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | 114 | * In some special case, properties must be grouped in one field (e.g. coordinates) or dealed with custom methods. |
@@ -116,30 +116,30 @@ discard block |
||
| 116 | 116 | * - simple: accept values for one property |
| 117 | 117 | * - grouped: accept values for more properties, or for one property that needs a specific metabox. |
| 118 | 118 | */ |
| 119 | - $metaboxes = $this->group_properties_by_input_field( $entity_type ); |
|
| 119 | + $metaboxes = $this->group_properties_by_input_field($entity_type); |
|
| 120 | 120 | $simple_metaboxes = $metaboxes[0]; |
| 121 | 121 | $grouped_metaboxes = $metaboxes[1]; |
| 122 | 122 | |
| 123 | 123 | // Loop over simple entity properties |
| 124 | - foreach ( $simple_metaboxes as $key => $property ) { |
|
| 124 | + foreach ($simple_metaboxes as $key => $property) { |
|
| 125 | 125 | |
| 126 | 126 | // Info passed to the metabox |
| 127 | 127 | $info = array(); |
| 128 | - $info[ $key ] = $property; |
|
| 128 | + $info[$key] = $property; |
|
| 129 | 129 | |
| 130 | 130 | // Build the requested field as WL_Metabox_Field_ object |
| 131 | - $this->add_field( $info ); |
|
| 131 | + $this->add_field($info); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // Loop over grouped properties |
| 135 | - foreach ( $grouped_metaboxes as $key => $property ) { |
|
| 135 | + foreach ($grouped_metaboxes as $key => $property) { |
|
| 136 | 136 | |
| 137 | 137 | // Info passed to the metabox |
| 138 | 138 | $info = array(); |
| 139 | - $info[ $key ] = $property; |
|
| 139 | + $info[$key] = $property; |
|
| 140 | 140 | |
| 141 | 141 | // Build the requested field group as WL_Metabox_Field_ object |
| 142 | - $this->add_field( $info, TRUE ); |
|
| 142 | + $this->add_field($info, TRUE); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | } |
@@ -150,34 +150,34 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @param array $custom_fields Information on the entity type. |
| 152 | 152 | */ |
| 153 | - public function group_properties_by_input_field( $custom_fields ) { |
|
| 153 | + public function group_properties_by_input_field($custom_fields) { |
|
| 154 | 154 | |
| 155 | 155 | $simple_properties = array(); |
| 156 | 156 | $grouped_properties = array(); |
| 157 | 157 | |
| 158 | 158 | // Loop over possible entity properties |
| 159 | - foreach ( $custom_fields as $key => $property ) { |
|
| 159 | + foreach ($custom_fields as $key => $property) { |
|
| 160 | 160 | |
| 161 | 161 | // Check presence of predicate and type |
| 162 | - if ( isset( $property['predicate'] ) && isset( $property['type'] ) ) { |
|
| 162 | + if (isset($property['predicate']) && isset($property['type'])) { |
|
| 163 | 163 | |
| 164 | 164 | // Check if input_field is defined |
| 165 | - if ( isset( $property['input_field'] ) && $property['input_field'] !== '' ) { |
|
| 165 | + if (isset($property['input_field']) && $property['input_field'] !== '') { |
|
| 166 | 166 | |
| 167 | 167 | $grouped_key = $property['input_field']; |
| 168 | 168 | |
| 169 | 169 | // Update list of grouped properties |
| 170 | - $grouped_properties[ $grouped_key ][ $key ] = $property; |
|
| 170 | + $grouped_properties[$grouped_key][$key] = $property; |
|
| 171 | 171 | |
| 172 | 172 | } else { |
| 173 | 173 | |
| 174 | 174 | // input_field not defined, add simple metabox |
| 175 | - $simple_properties[ $key ] = $property; |
|
| 175 | + $simple_properties[$key] = $property; |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - return array( $simple_properties, $grouped_properties ); |
|
| 180 | + return array($simple_properties, $grouped_properties); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -187,87 +187,87 @@ discard block |
||
| 187 | 187 | * @param type $args |
| 188 | 188 | * @param type $grouped Flag to distinguish between simple and grouped Fields |
| 189 | 189 | */ |
| 190 | - public function add_field( $args, $grouped = FALSE ) { |
|
| 190 | + public function add_field($args, $grouped = FALSE) { |
|
| 191 | 191 | |
| 192 | - if ( $grouped ) { |
|
| 192 | + if ($grouped) { |
|
| 193 | 193 | // Special fields (sameas, coordinates, etc.) |
| 194 | 194 | |
| 195 | 195 | // Build Field with a custom class (e.g. WL_Metabox_Field_date) |
| 196 | - $field_class = 'WL_Metabox_Field_' . key( $args ); |
|
| 196 | + $field_class = 'WL_Metabox_Field_'.key($args); |
|
| 197 | 197 | |
| 198 | 198 | } else { |
| 199 | 199 | // Simple fields (string, uri, boolean, etc.) |
| 200 | 200 | |
| 201 | 201 | // Which field? We want to use the class that is specific for the field. |
| 202 | - $meta = key( $args ); |
|
| 203 | - if ( ! isset( $args[ $meta ]['type'] ) || ( $args[ $meta ]['type'] == Wordlift_Schema_Service::DATA_TYPE_STRING ) ) { |
|
| 202 | + $meta = key($args); |
|
| 203 | + if ( ! isset($args[$meta]['type']) || ($args[$meta]['type'] == Wordlift_Schema_Service::DATA_TYPE_STRING)) { |
|
| 204 | 204 | // Use default WL_Metabox_Field (manages strings) |
| 205 | 205 | $field_class = 'WL_Metabox_Field'; |
| 206 | 206 | } else { |
| 207 | 207 | // Build Field with a custom class (e.g. WL_Metabox_Field_date) |
| 208 | - $field_class = 'WL_Metabox_Field_' . $args[ $meta ]['type']; |
|
| 208 | + $field_class = 'WL_Metabox_Field_'.$args[$meta]['type']; |
|
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // Call apropriate constructor (e.g. WL_Metabox_Field_... ) |
| 213 | - $this->fields[] = new $field_class( $args ); |
|
| 213 | + $this->fields[] = new $field_class($args); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - public function save_form_data( $entity_id ) { |
|
| 216 | + public function save_form_data($entity_id) { |
|
| 217 | 217 | |
| 218 | 218 | // Build Field objects |
| 219 | - $this->instantiate_fields( $entity_id ); |
|
| 219 | + $this->instantiate_fields($entity_id); |
|
| 220 | 220 | |
| 221 | 221 | // Check if WL metabox form was posted |
| 222 | - if ( ! isset( $_POST['wl_metaboxes'] ) ) { |
|
| 222 | + if ( ! isset($_POST['wl_metaboxes'])) { |
|
| 223 | 223 | return; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - foreach ( $this->fields as $field ) { |
|
| 226 | + foreach ($this->fields as $field) { |
|
| 227 | 227 | |
| 228 | 228 | // Verify nonce |
| 229 | 229 | $valid_nonce = $field->verify_nonce(); |
| 230 | - if ( $valid_nonce ) { |
|
| 230 | + if ($valid_nonce) { |
|
| 231 | 231 | |
| 232 | 232 | $posted_data = $_POST['wl_metaboxes']; |
| 233 | 233 | $field_name = $field->meta_name; |
| 234 | 234 | |
| 235 | 235 | // Each Filed only deals with its values. |
| 236 | - if ( isset( $posted_data[ $field_name ] ) ) { |
|
| 236 | + if (isset($posted_data[$field_name])) { |
|
| 237 | 237 | |
| 238 | - $values = $posted_data[ $field_name ]; |
|
| 239 | - if ( ! is_array( $values ) ) { |
|
| 240 | - $values = array( $values ); |
|
| 238 | + $values = $posted_data[$field_name]; |
|
| 239 | + if ( ! is_array($values)) { |
|
| 240 | + $values = array($values); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | // Save data permanently |
| 244 | - $field->save_data( $values ); |
|
| 244 | + $field->save_data($values); |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - wl_linked_data_push_to_redlink( $entity_id ); |
|
| 249 | + wl_linked_data_push_to_redlink($entity_id); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | // print on page all the js and css the fields will need |
| 253 | 253 | public function enqueue_scripts_and_styles() { |
| 254 | 254 | |
| 255 | 255 | // dateTimePicker |
| 256 | - wp_enqueue_style( 'jquery-ui-timepicker', dirname( plugin_dir_url( __FILE__ ) ) . '/css/jquery.datetimepicker.css' ); |
|
| 257 | - wp_enqueue_script( 'jquery-ui-timepicker', dirname( plugin_dir_url( __FILE__ ) ) . '/js/jquery.datetimepicker.full.min.js', array( 'jquery' ) ); |
|
| 256 | + wp_enqueue_style('jquery-ui-timepicker', dirname(plugin_dir_url(__FILE__)).'/css/jquery.datetimepicker.css'); |
|
| 257 | + wp_enqueue_script('jquery-ui-timepicker', dirname(plugin_dir_url(__FILE__)).'/js/jquery.datetimepicker.full.min.js', array('jquery')); |
|
| 258 | 258 | |
| 259 | 259 | // We rename the xdsoft datetimepicker function name to avoid conflicts to the jQuery UI derived datetimepicker library. |
| 260 | 260 | // see https://github.com/insideout10/wordlift-plugin/issues/340 |
| 261 | - wp_enqueue_script( 'jquery-ui-timepicker-no-conflict', dirname( plugin_dir_url( __FILE__ ) ) . '/js/jquery.datetimepicker.no-conflict.js', array( 'jquery-ui-timepicker' ) ); |
|
| 261 | + wp_enqueue_script('jquery-ui-timepicker-no-conflict', dirname(plugin_dir_url(__FILE__)).'/js/jquery.datetimepicker.no-conflict.js', array('jquery-ui-timepicker')); |
|
| 262 | 262 | |
| 263 | 263 | // Leaflet. |
| 264 | - wp_enqueue_style( 'leaflet', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.css' ); |
|
| 265 | - wp_enqueue_script( 'leaflet', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.js', __FILE__ ); |
|
| 264 | + wp_enqueue_style('leaflet', dirname(dirname(plugin_dir_url(__FILE__))).'/bower_components/leaflet/dist/leaflet.css'); |
|
| 265 | + wp_enqueue_script('leaflet', dirname(dirname(plugin_dir_url(__FILE__))).'/bower_components/leaflet/dist/leaflet.js', __FILE__); |
|
| 266 | 266 | |
| 267 | 267 | // Add AJAX autocomplete to facilitate metabox editing |
| 268 | - wp_enqueue_script( 'wl-entity-metabox-utility', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wl_entity_metabox_utilities.js' ); |
|
| 269 | - wp_localize_script( 'wl-entity-metabox-utility', 'wlEntityMetaboxParams', array( |
|
| 270 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 268 | + wp_enqueue_script('wl-entity-metabox-utility', dirname(plugin_dir_url(__FILE__)).'/js/wl_entity_metabox_utilities.js'); |
|
| 269 | + wp_localize_script('wl-entity-metabox-utility', 'wlEntityMetaboxParams', array( |
|
| 270 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 271 | 271 | 'action' => 'entity_by_title' |
| 272 | 272 | ) |
| 273 | 273 | ); |
@@ -13,60 +13,60 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | class WL_Metabox_Field_date extends WL_Metabox_Field { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Attribute to distinguish between date formats, inferred from the schema property export type |
|
| 18 | - * |
|
| 19 | - * @access private |
|
| 20 | - * @var string $date_format The date format. |
|
| 21 | - * @since 3.2.0 |
|
| 22 | - */ |
|
| 23 | - private $date_format; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Boolean flag to decide if the calendar should include time or not |
|
| 27 | - * |
|
| 28 | - * @access private |
|
| 29 | - * @var boolean $timepicker A boolean flag. |
|
| 30 | - * @since 3.2.0 |
|
| 31 | - */ |
|
| 32 | - private $timepicker; |
|
| 33 | - |
|
| 34 | - public function __construct( $args ) { |
|
| 35 | - parent::__construct( $args ); |
|
| 36 | - |
|
| 37 | - // Distinguish between date and datetime |
|
| 38 | - if ( isset( $this->raw_custom_field['export_type'] ) && 'xsd:datetime' === $this->raw_custom_field['export_type'] ) { |
|
| 39 | - $this->date_format = 'Y/m/d H:i'; |
|
| 40 | - $this->timepicker = TRUE; |
|
| 41 | - } else { |
|
| 42 | - $this->date_format = 'Y/m/d'; |
|
| 43 | - $this->timepicker = FALSE; |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - public function html_input( $date ) { |
|
| 48 | - |
|
| 49 | - $picker_date = ( empty( $date ) ? '' : esc_attr( date( $this->date_format, strtotime( $date ) ) ) ); |
|
| 50 | - |
|
| 51 | - return <<<EOF |
|
| 16 | + /** |
|
| 17 | + * Attribute to distinguish between date formats, inferred from the schema property export type |
|
| 18 | + * |
|
| 19 | + * @access private |
|
| 20 | + * @var string $date_format The date format. |
|
| 21 | + * @since 3.2.0 |
|
| 22 | + */ |
|
| 23 | + private $date_format; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Boolean flag to decide if the calendar should include time or not |
|
| 27 | + * |
|
| 28 | + * @access private |
|
| 29 | + * @var boolean $timepicker A boolean flag. |
|
| 30 | + * @since 3.2.0 |
|
| 31 | + */ |
|
| 32 | + private $timepicker; |
|
| 33 | + |
|
| 34 | + public function __construct( $args ) { |
|
| 35 | + parent::__construct( $args ); |
|
| 36 | + |
|
| 37 | + // Distinguish between date and datetime |
|
| 38 | + if ( isset( $this->raw_custom_field['export_type'] ) && 'xsd:datetime' === $this->raw_custom_field['export_type'] ) { |
|
| 39 | + $this->date_format = 'Y/m/d H:i'; |
|
| 40 | + $this->timepicker = TRUE; |
|
| 41 | + } else { |
|
| 42 | + $this->date_format = 'Y/m/d'; |
|
| 43 | + $this->timepicker = FALSE; |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + public function html_input( $date ) { |
|
| 48 | + |
|
| 49 | + $picker_date = ( empty( $date ) ? '' : esc_attr( date( $this->date_format, strtotime( $date ) ) ) ); |
|
| 50 | + |
|
| 51 | + return <<<EOF |
|
| 52 | 52 | <div class="wl-input-wrapper"> |
| 53 | 53 | <input type="text" class="$this->meta_name" value="$picker_date" style="width:88%" /> |
| 54 | 54 | <input type="hidden" class="$this->meta_name" name="wl_metaboxes[$this->meta_name][]" value="$date" /> |
| 55 | 55 | <button class="button wl-remove-input wl-button" type="button" style="width:10%">Remove</button> |
| 56 | 56 | </div> |
| 57 | 57 | EOF; |
| 58 | - } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - public function html_wrapper_close() { |
|
| 60 | + public function html_wrapper_close() { |
|
| 61 | 61 | |
| 62 | - // Should the widget include time picker? |
|
| 63 | - $timepicker = json_encode( $this->timepicker ); |
|
| 62 | + // Should the widget include time picker? |
|
| 63 | + $timepicker = json_encode( $this->timepicker ); |
|
| 64 | 64 | |
| 65 | - // The wlDateTimePicker is actually the xdsoft datetimepicker function |
|
| 66 | - // which we renamed to avoid conflicts with datetime libraries installed |
|
| 67 | - // by other WP plugins (such as the media-from-ftp plugin). |
|
| 68 | - // see https://github.com/insideout10/wordlift-plugin/issues/340 |
|
| 69 | - $html = <<<EOF |
|
| 65 | + // The wlDateTimePicker is actually the xdsoft datetimepicker function |
|
| 66 | + // which we renamed to avoid conflicts with datetime libraries installed |
|
| 67 | + // by other WP plugins (such as the media-from-ftp plugin). |
|
| 68 | + // see https://github.com/insideout10/wordlift-plugin/issues/340 |
|
| 69 | + $html = <<<EOF |
|
| 70 | 70 | <script type='text/javascript'> |
| 71 | 71 | ( function( $ ) { |
| 72 | 72 | |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | </script> |
| 93 | 93 | EOF; |
| 94 | 94 | |
| 95 | - $html .= parent::html_wrapper_close(); |
|
| 95 | + $html .= parent::html_wrapper_close(); |
|
| 96 | 96 | |
| 97 | - return $html; |
|
| 98 | - } |
|
| 97 | + return $html; |
|
| 98 | + } |
|
| 99 | 99 | } |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | private $timepicker; |
| 33 | 33 | |
| 34 | - public function __construct( $args ) { |
|
| 35 | - parent::__construct( $args ); |
|
| 34 | + public function __construct($args) { |
|
| 35 | + parent::__construct($args); |
|
| 36 | 36 | |
| 37 | 37 | // Distinguish between date and datetime |
| 38 | - if ( isset( $this->raw_custom_field['export_type'] ) && 'xsd:datetime' === $this->raw_custom_field['export_type'] ) { |
|
| 38 | + if (isset($this->raw_custom_field['export_type']) && 'xsd:datetime' === $this->raw_custom_field['export_type']) { |
|
| 39 | 39 | $this->date_format = 'Y/m/d H:i'; |
| 40 | 40 | $this->timepicker = TRUE; |
| 41 | 41 | } else { |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function html_input( $date ) { |
|
| 47 | + public function html_input($date) { |
|
| 48 | 48 | |
| 49 | - $picker_date = ( empty( $date ) ? '' : esc_attr( date( $this->date_format, strtotime( $date ) ) ) ); |
|
| 49 | + $picker_date = (empty($date) ? '' : esc_attr(date($this->date_format, strtotime($date)))); |
|
| 50 | 50 | |
| 51 | 51 | return <<<EOF |
| 52 | 52 | <div class="wl-input-wrapper"> |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | public function html_wrapper_close() { |
| 61 | 61 | |
| 62 | 62 | // Should the widget include time picker? |
| 63 | - $timepicker = json_encode( $this->timepicker ); |
|
| 63 | + $timepicker = json_encode($this->timepicker); |
|
| 64 | 64 | |
| 65 | 65 | // The wlDateTimePicker is actually the xdsoft datetimepicker function |
| 66 | 66 | // which we renamed to avoid conflicts with datetime libraries installed |
@@ -8,52 +8,52 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class Wordlift_Uri_Service { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * A {@link Wordlift_Log_Service} instance. |
|
| 13 | - * |
|
| 14 | - * @since 3.6.0 |
|
| 15 | - * @access private |
|
| 16 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 17 | - */ |
|
| 18 | - private $log; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * The global WordPress database connection. |
|
| 22 | - * |
|
| 23 | - * @since 3.6.0 |
|
| 24 | - * @access private |
|
| 25 | - * @var \wpdb $wpdb The global WordPress database connection. |
|
| 26 | - */ |
|
| 27 | - private $wpdb; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Create an instance of Wordlift_Uri_Service. |
|
| 31 | - * |
|
| 32 | - * @since 3.6.0 |
|
| 33 | - * |
|
| 34 | - * @param wpdb $wpdb The global WordPress database connection. |
|
| 35 | - */ |
|
| 36 | - public function __construct( $wpdb ) { |
|
| 37 | - |
|
| 38 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Uri_Service' ); |
|
| 39 | - |
|
| 40 | - $this->wpdb = $wpdb; |
|
| 41 | - |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Delete all generated URIs from the database. |
|
| 46 | - * |
|
| 47 | - * @since 3.6.0 |
|
| 48 | - */ |
|
| 49 | - public function delete_all() { |
|
| 50 | - |
|
| 51 | - // Delete URIs associated with posts/entities. |
|
| 52 | - $this->wpdb->delete( $this->wpdb->postmeta, array( 'meta_key' => 'entity_url' ) ); |
|
| 53 | - |
|
| 54 | - // Delete URIs associated with authors. |
|
| 55 | - $this->wpdb->delete( $this->wpdb->usermeta, array( 'meta_key' => '_wl_uri' ) ); |
|
| 56 | - |
|
| 57 | - } |
|
| 11 | + /** |
|
| 12 | + * A {@link Wordlift_Log_Service} instance. |
|
| 13 | + * |
|
| 14 | + * @since 3.6.0 |
|
| 15 | + * @access private |
|
| 16 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 17 | + */ |
|
| 18 | + private $log; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * The global WordPress database connection. |
|
| 22 | + * |
|
| 23 | + * @since 3.6.0 |
|
| 24 | + * @access private |
|
| 25 | + * @var \wpdb $wpdb The global WordPress database connection. |
|
| 26 | + */ |
|
| 27 | + private $wpdb; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Create an instance of Wordlift_Uri_Service. |
|
| 31 | + * |
|
| 32 | + * @since 3.6.0 |
|
| 33 | + * |
|
| 34 | + * @param wpdb $wpdb The global WordPress database connection. |
|
| 35 | + */ |
|
| 36 | + public function __construct( $wpdb ) { |
|
| 37 | + |
|
| 38 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Uri_Service' ); |
|
| 39 | + |
|
| 40 | + $this->wpdb = $wpdb; |
|
| 41 | + |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Delete all generated URIs from the database. |
|
| 46 | + * |
|
| 47 | + * @since 3.6.0 |
|
| 48 | + */ |
|
| 49 | + public function delete_all() { |
|
| 50 | + |
|
| 51 | + // Delete URIs associated with posts/entities. |
|
| 52 | + $this->wpdb->delete( $this->wpdb->postmeta, array( 'meta_key' => 'entity_url' ) ); |
|
| 53 | + |
|
| 54 | + // Delete URIs associated with authors. |
|
| 55 | + $this->wpdb->delete( $this->wpdb->usermeta, array( 'meta_key' => '_wl_uri' ) ); |
|
| 56 | + |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | } |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @param wpdb $wpdb The global WordPress database connection. |
| 35 | 35 | */ |
| 36 | - public function __construct( $wpdb ) { |
|
| 36 | + public function __construct($wpdb) { |
|
| 37 | 37 | |
| 38 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Uri_Service' ); |
|
| 38 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Uri_Service'); |
|
| 39 | 39 | |
| 40 | 40 | $this->wpdb = $wpdb; |
| 41 | 41 | |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | public function delete_all() { |
| 50 | 50 | |
| 51 | 51 | // Delete URIs associated with posts/entities. |
| 52 | - $this->wpdb->delete( $this->wpdb->postmeta, array( 'meta_key' => 'entity_url' ) ); |
|
| 52 | + $this->wpdb->delete($this->wpdb->postmeta, array('meta_key' => 'entity_url')); |
|
| 53 | 53 | |
| 54 | 54 | // Delete URIs associated with authors. |
| 55 | - $this->wpdb->delete( $this->wpdb->usermeta, array( 'meta_key' => '_wl_uri' ) ); |
|
| 55 | + $this->wpdb->delete($this->wpdb->usermeta, array('meta_key' => '_wl_uri')); |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
@@ -4,44 +4,44 @@ |
||
| 4 | 4 | */ |
| 5 | 5 | abstract class Wordlift_Listable { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * List the items starting at the specified offset and up to the specified limit. |
|
| 9 | - * |
|
| 10 | - * @param int $offset The start offset. |
|
| 11 | - * @param int $limit The maximum number of items to return. |
|
| 12 | - * @param array $args Additional arguments. |
|
| 13 | - * |
|
| 14 | - * @return array A array of items (or an empty array if no items are found). |
|
| 15 | - */ |
|
| 16 | - abstract function find( $offset = 0, $limit = 10, $args = array() ); |
|
| 7 | + /** |
|
| 8 | + * List the items starting at the specified offset and up to the specified limit. |
|
| 9 | + * |
|
| 10 | + * @param int $offset The start offset. |
|
| 11 | + * @param int $limit The maximum number of items to return. |
|
| 12 | + * @param array $args Additional arguments. |
|
| 13 | + * |
|
| 14 | + * @return array A array of items (or an empty array if no items are found). |
|
| 15 | + */ |
|
| 16 | + abstract function find( $offset = 0, $limit = 10, $args = array() ); |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @param callable $callback |
|
| 20 | - * @param array $args |
|
| 21 | - */ |
|
| 22 | - public function process( $callback, $args = array() ) { |
|
| 18 | + /** |
|
| 19 | + * @param callable $callback |
|
| 20 | + * @param array $args |
|
| 21 | + */ |
|
| 22 | + public function process( $callback, $args = array() ) { |
|
| 23 | 23 | |
| 24 | - // We process users in chunks in order to avoid using too much memory, |
|
| 25 | - // starting at offset 0, 10 users at a time. |
|
| 26 | - $offset = 0; |
|
| 27 | - $limit = 10; |
|
| 24 | + // We process users in chunks in order to avoid using too much memory, |
|
| 25 | + // starting at offset 0, 10 users at a time. |
|
| 26 | + $offset = 0; |
|
| 27 | + $limit = 10; |
|
| 28 | 28 | |
| 29 | - while ( 0 < sizeof( $items = $this->find( $offset, $limit, $args ) ) ) { |
|
| 29 | + while ( 0 < sizeof( $items = $this->find( $offset, $limit, $args ) ) ) { |
|
| 30 | 30 | |
| 31 | - // Cycle through items and call the callback function. |
|
| 32 | - foreach ( $items as $item ) { |
|
| 33 | - call_user_func_array( $callback, array( $item ) ); |
|
| 34 | - } |
|
| 31 | + // Cycle through items and call the callback function. |
|
| 32 | + foreach ( $items as $item ) { |
|
| 33 | + call_user_func_array( $callback, array( $item ) ); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - // Clean the cache to avoid memory errors. |
|
| 37 | - wp_cache_flush(); |
|
| 36 | + // Clean the cache to avoid memory errors. |
|
| 37 | + wp_cache_flush(); |
|
| 38 | 38 | |
| 39 | - // Move to the next offset. |
|
| 40 | - $offset += $limit; |
|
| 39 | + // Move to the next offset. |
|
| 40 | + $offset += $limit; |
|
| 41 | 41 | |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | - } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | } |
@@ -13,24 +13,24 @@ |
||
| 13 | 13 | * |
| 14 | 14 | * @return array A array of items (or an empty array if no items are found). |
| 15 | 15 | */ |
| 16 | - abstract function find( $offset = 0, $limit = 10, $args = array() ); |
|
| 16 | + abstract function find($offset = 0, $limit = 10, $args = array()); |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * @param callable $callback |
| 20 | 20 | * @param array $args |
| 21 | 21 | */ |
| 22 | - public function process( $callback, $args = array() ) { |
|
| 22 | + public function process($callback, $args = array()) { |
|
| 23 | 23 | |
| 24 | 24 | // We process users in chunks in order to avoid using too much memory, |
| 25 | 25 | // starting at offset 0, 10 users at a time. |
| 26 | 26 | $offset = 0; |
| 27 | 27 | $limit = 10; |
| 28 | 28 | |
| 29 | - while ( 0 < sizeof( $items = $this->find( $offset, $limit, $args ) ) ) { |
|
| 29 | + while (0 < sizeof($items = $this->find($offset, $limit, $args))) { |
|
| 30 | 30 | |
| 31 | 31 | // Cycle through items and call the callback function. |
| 32 | - foreach ( $items as $item ) { |
|
| 33 | - call_user_func_array( $callback, array( $item ) ); |
|
| 32 | + foreach ($items as $item) { |
|
| 33 | + call_user_func_array($callback, array($item)); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | // Clean the cache to avoid memory errors. |
@@ -13,103 +13,103 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class Wordlift_Rebuild_Service extends Wordlift_Listable { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * A {@link Wordlift_Log_Service} instance. |
|
| 18 | - * |
|
| 19 | - * @since 3.6.0 |
|
| 20 | - * @access private |
|
| 21 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 22 | - */ |
|
| 23 | - private $log; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * A {@link Wordlift_Sparql_Service} instance. |
|
| 27 | - * @since 3.6.0 |
|
| 28 | - * @access private |
|
| 29 | - * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 30 | - */ |
|
| 31 | - private $sparql_service; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var \Wordlift_Uri_Service |
|
| 35 | - */ |
|
| 36 | - private $uri_service; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Create an instance of Wordlift_Rebuild_Service. |
|
| 40 | - * |
|
| 41 | - * @since 3.6.0 |
|
| 42 | - * |
|
| 43 | - * @param \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance used to query the remote dataset. |
|
| 44 | - * @param \Wordlift_Uri_Service $uri_service |
|
| 45 | - */ |
|
| 46 | - public function __construct( $sparql_service, $uri_service ) { |
|
| 47 | - |
|
| 48 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Rebuild_Service' ); |
|
| 49 | - |
|
| 50 | - $this->sparql_service = $sparql_service; |
|
| 51 | - $this->uri_service = $uri_service; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Rebuild the Linked Data remote dataset by clearing it out and repopulating |
|
| 56 | - * it with local data. |
|
| 57 | - * |
|
| 58 | - * @since 3.6.0 |
|
| 59 | - */ |
|
| 60 | - public function rebuild() { |
|
| 61 | - |
|
| 62 | - // Give ourselves some time to process the data. |
|
| 63 | - set_time_limit( 21600 ); // 6 hours |
|
| 64 | - |
|
| 65 | - // Clear out all generated URIs, since the dataset URI might have changed |
|
| 66 | - // in the process. |
|
| 67 | - $this->uri_service->delete_all(); |
|
| 68 | - |
|
| 69 | - // Delete all the triples in the remote dataset. |
|
| 70 | - $this->sparql_service->queue( 'DELETE { ?s ?p ?o } WHERE { ?s ?p ?o };' ); |
|
| 71 | - |
|
| 72 | - // Go through the list of published entities and posts and call the (legacy) |
|
| 73 | - // `wl_linked_data_save_post` function for each one. We're using the `process` |
|
| 74 | - // function which is provided by the parent `Wordlift_Listable` abstract class |
|
| 75 | - // and will cycle through all the posts w/ a very small memory footprint |
|
| 76 | - // in order to avoid memory errors. |
|
| 77 | - $this->process( function ( $post ) { |
|
| 78 | - wl_linked_data_save_post( $post->ID ); |
|
| 79 | - }, array( |
|
| 80 | - 'post_status' => 'publish', |
|
| 81 | - 'post_type' => array( 'entity', 'post' ) |
|
| 82 | - ) ); |
|
| 83 | - |
|
| 84 | - // If we're being called as AJAX, die here. |
|
| 85 | - if ( DOING_AJAX ) { |
|
| 86 | - wp_die(); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * List the items starting at the specified offset and up to the specified limit. |
|
| 93 | - * |
|
| 94 | - * @since 3.6.0 |
|
| 95 | - * |
|
| 96 | - * @param int $offset The start offset. |
|
| 97 | - * @param int $limit The maximum number of items to return. |
|
| 98 | - * @param array $args Additional arguments. |
|
| 99 | - * |
|
| 100 | - * @return array A array of items (or an empty array if no items are found). |
|
| 101 | - */ |
|
| 102 | - function find( $offset = 0, $limit = 10, $args = array() ) { |
|
| 103 | - |
|
| 104 | - return get_posts( wp_parse_args( $args, array( |
|
| 105 | - 'offset' => $offset, |
|
| 106 | - 'numberposts' => $limit, |
|
| 107 | - 'fields' => 'all', |
|
| 108 | - 'orderby' => 'ID', |
|
| 109 | - 'order' => 'ASC', |
|
| 110 | - 'post_status' => 'any', |
|
| 111 | - 'post_type' => 'post' |
|
| 112 | - ) ) ); |
|
| 113 | - } |
|
| 16 | + /** |
|
| 17 | + * A {@link Wordlift_Log_Service} instance. |
|
| 18 | + * |
|
| 19 | + * @since 3.6.0 |
|
| 20 | + * @access private |
|
| 21 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
| 22 | + */ |
|
| 23 | + private $log; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * A {@link Wordlift_Sparql_Service} instance. |
|
| 27 | + * @since 3.6.0 |
|
| 28 | + * @access private |
|
| 29 | + * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 30 | + */ |
|
| 31 | + private $sparql_service; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var \Wordlift_Uri_Service |
|
| 35 | + */ |
|
| 36 | + private $uri_service; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Create an instance of Wordlift_Rebuild_Service. |
|
| 40 | + * |
|
| 41 | + * @since 3.6.0 |
|
| 42 | + * |
|
| 43 | + * @param \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance used to query the remote dataset. |
|
| 44 | + * @param \Wordlift_Uri_Service $uri_service |
|
| 45 | + */ |
|
| 46 | + public function __construct( $sparql_service, $uri_service ) { |
|
| 47 | + |
|
| 48 | + $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Rebuild_Service' ); |
|
| 49 | + |
|
| 50 | + $this->sparql_service = $sparql_service; |
|
| 51 | + $this->uri_service = $uri_service; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Rebuild the Linked Data remote dataset by clearing it out and repopulating |
|
| 56 | + * it with local data. |
|
| 57 | + * |
|
| 58 | + * @since 3.6.0 |
|
| 59 | + */ |
|
| 60 | + public function rebuild() { |
|
| 61 | + |
|
| 62 | + // Give ourselves some time to process the data. |
|
| 63 | + set_time_limit( 21600 ); // 6 hours |
|
| 64 | + |
|
| 65 | + // Clear out all generated URIs, since the dataset URI might have changed |
|
| 66 | + // in the process. |
|
| 67 | + $this->uri_service->delete_all(); |
|
| 68 | + |
|
| 69 | + // Delete all the triples in the remote dataset. |
|
| 70 | + $this->sparql_service->queue( 'DELETE { ?s ?p ?o } WHERE { ?s ?p ?o };' ); |
|
| 71 | + |
|
| 72 | + // Go through the list of published entities and posts and call the (legacy) |
|
| 73 | + // `wl_linked_data_save_post` function for each one. We're using the `process` |
|
| 74 | + // function which is provided by the parent `Wordlift_Listable` abstract class |
|
| 75 | + // and will cycle through all the posts w/ a very small memory footprint |
|
| 76 | + // in order to avoid memory errors. |
|
| 77 | + $this->process( function ( $post ) { |
|
| 78 | + wl_linked_data_save_post( $post->ID ); |
|
| 79 | + }, array( |
|
| 80 | + 'post_status' => 'publish', |
|
| 81 | + 'post_type' => array( 'entity', 'post' ) |
|
| 82 | + ) ); |
|
| 83 | + |
|
| 84 | + // If we're being called as AJAX, die here. |
|
| 85 | + if ( DOING_AJAX ) { |
|
| 86 | + wp_die(); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * List the items starting at the specified offset and up to the specified limit. |
|
| 93 | + * |
|
| 94 | + * @since 3.6.0 |
|
| 95 | + * |
|
| 96 | + * @param int $offset The start offset. |
|
| 97 | + * @param int $limit The maximum number of items to return. |
|
| 98 | + * @param array $args Additional arguments. |
|
| 99 | + * |
|
| 100 | + * @return array A array of items (or an empty array if no items are found). |
|
| 101 | + */ |
|
| 102 | + function find( $offset = 0, $limit = 10, $args = array() ) { |
|
| 103 | + |
|
| 104 | + return get_posts( wp_parse_args( $args, array( |
|
| 105 | + 'offset' => $offset, |
|
| 106 | + 'numberposts' => $limit, |
|
| 107 | + 'fields' => 'all', |
|
| 108 | + 'orderby' => 'ID', |
|
| 109 | + 'order' => 'ASC', |
|
| 110 | + 'post_status' => 'any', |
|
| 111 | + 'post_type' => 'post' |
|
| 112 | + ) ) ); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | 115 | } |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | * @param \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance used to query the remote dataset. |
| 44 | 44 | * @param \Wordlift_Uri_Service $uri_service |
| 45 | 45 | */ |
| 46 | - public function __construct( $sparql_service, $uri_service ) { |
|
| 46 | + public function __construct($sparql_service, $uri_service) { |
|
| 47 | 47 | |
| 48 | - $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Rebuild_Service' ); |
|
| 48 | + $this->log = Wordlift_Log_Service::get_logger('Wordlift_Rebuild_Service'); |
|
| 49 | 49 | |
| 50 | 50 | $this->sparql_service = $sparql_service; |
| 51 | 51 | $this->uri_service = $uri_service; |
@@ -60,29 +60,29 @@ discard block |
||
| 60 | 60 | public function rebuild() { |
| 61 | 61 | |
| 62 | 62 | // Give ourselves some time to process the data. |
| 63 | - set_time_limit( 21600 ); // 6 hours |
|
| 63 | + set_time_limit(21600); // 6 hours |
|
| 64 | 64 | |
| 65 | 65 | // Clear out all generated URIs, since the dataset URI might have changed |
| 66 | 66 | // in the process. |
| 67 | 67 | $this->uri_service->delete_all(); |
| 68 | 68 | |
| 69 | 69 | // Delete all the triples in the remote dataset. |
| 70 | - $this->sparql_service->queue( 'DELETE { ?s ?p ?o } WHERE { ?s ?p ?o };' ); |
|
| 70 | + $this->sparql_service->queue('DELETE { ?s ?p ?o } WHERE { ?s ?p ?o };'); |
|
| 71 | 71 | |
| 72 | 72 | // Go through the list of published entities and posts and call the (legacy) |
| 73 | 73 | // `wl_linked_data_save_post` function for each one. We're using the `process` |
| 74 | 74 | // function which is provided by the parent `Wordlift_Listable` abstract class |
| 75 | 75 | // and will cycle through all the posts w/ a very small memory footprint |
| 76 | 76 | // in order to avoid memory errors. |
| 77 | - $this->process( function ( $post ) { |
|
| 78 | - wl_linked_data_save_post( $post->ID ); |
|
| 77 | + $this->process(function($post) { |
|
| 78 | + wl_linked_data_save_post($post->ID); |
|
| 79 | 79 | }, array( |
| 80 | 80 | 'post_status' => 'publish', |
| 81 | - 'post_type' => array( 'entity', 'post' ) |
|
| 82 | - ) ); |
|
| 81 | + 'post_type' => array('entity', 'post') |
|
| 82 | + )); |
|
| 83 | 83 | |
| 84 | 84 | // If we're being called as AJAX, die here. |
| 85 | - if ( DOING_AJAX ) { |
|
| 85 | + if (DOING_AJAX) { |
|
| 86 | 86 | wp_die(); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return array A array of items (or an empty array if no items are found). |
| 101 | 101 | */ |
| 102 | - function find( $offset = 0, $limit = 10, $args = array() ) { |
|
| 102 | + function find($offset = 0, $limit = 10, $args = array()) { |
|
| 103 | 103 | |
| 104 | - return get_posts( wp_parse_args( $args, array( |
|
| 104 | + return get_posts(wp_parse_args($args, array( |
|
| 105 | 105 | 'offset' => $offset, |
| 106 | 106 | 'numberposts' => $limit, |
| 107 | 107 | 'fields' => 'all', |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | 'order' => 'ASC', |
| 110 | 110 | 'post_status' => 'any', |
| 111 | 111 | 'post_type' => 'post' |
| 112 | - ) ) ); |
|
| 112 | + ))); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | } |
@@ -29,671 +29,671 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class Wordlift { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * The loader that's responsible for maintaining and registering all hooks that power |
|
| 34 | - * the plugin. |
|
| 35 | - * |
|
| 36 | - * @since 1.0.0 |
|
| 37 | - * @access protected |
|
| 38 | - * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 39 | - */ |
|
| 40 | - protected $loader; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The unique identifier of this plugin. |
|
| 44 | - * |
|
| 45 | - * @since 1.0.0 |
|
| 46 | - * @access protected |
|
| 47 | - * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 48 | - */ |
|
| 49 | - protected $plugin_name; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * The current version of the plugin. |
|
| 53 | - * |
|
| 54 | - * @since 1.0.0 |
|
| 55 | - * @access protected |
|
| 56 | - * @var string $version The current version of the plugin. |
|
| 57 | - */ |
|
| 58 | - protected $version; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * The Thumbnail service. |
|
| 62 | - * |
|
| 63 | - * @since 3.1.5 |
|
| 64 | - * @access private |
|
| 65 | - * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 66 | - */ |
|
| 67 | - private $thumbnail_service; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * The UI service. |
|
| 71 | - * |
|
| 72 | - * @since 3.2.0 |
|
| 73 | - * @access private |
|
| 74 | - * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 75 | - */ |
|
| 76 | - private $ui_service; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * The Schema service. |
|
| 80 | - * |
|
| 81 | - * @since 3.3.0 |
|
| 82 | - * @access private |
|
| 83 | - * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 84 | - */ |
|
| 85 | - private $schema_service; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * The Entity service. |
|
| 89 | - * |
|
| 90 | - * @since 3.1.0 |
|
| 91 | - * @access private |
|
| 92 | - * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 93 | - */ |
|
| 94 | - private $entity_service; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * The Topic Taxonomy service. |
|
| 98 | - * |
|
| 99 | - * @since 3.5.0 |
|
| 100 | - * @access private |
|
| 101 | - * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 102 | - */ |
|
| 103 | - private $topic_taxonomy_service; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * The User service. |
|
| 107 | - * |
|
| 108 | - * @since 3.1.7 |
|
| 109 | - * @access private |
|
| 110 | - * @var \Wordlift_User_Service $user_service The User service. |
|
| 111 | - */ |
|
| 112 | - private $user_service; |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * The Timeline service. |
|
| 116 | - * |
|
| 117 | - * @since 3.1.0 |
|
| 118 | - * @access private |
|
| 119 | - * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 120 | - */ |
|
| 121 | - private $timeline_service; |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * The Redirect service. |
|
| 125 | - * |
|
| 126 | - * @since 3.2.0 |
|
| 127 | - * @access private |
|
| 128 | - * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 129 | - */ |
|
| 130 | - private $redirect_service; |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * The Notice service. |
|
| 134 | - * |
|
| 135 | - * @since 3.3.0 |
|
| 136 | - * @access private |
|
| 137 | - * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 138 | - */ |
|
| 139 | - private $notice_service; |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * The Entity list customization. |
|
| 143 | - * |
|
| 144 | - * @since 3.3.0 |
|
| 145 | - * @access private |
|
| 146 | - * @var \Wordlift_List_Service $entity_list_service The Entity list service. |
|
| 147 | - */ |
|
| 148 | - private $entity_list_service; |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * The Entity Types Taxonomy Walker. |
|
| 152 | - * |
|
| 153 | - * @since 3.1.0 |
|
| 154 | - * @access private |
|
| 155 | - * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 156 | - */ |
|
| 157 | - private $entity_types_taxonomy_walker; |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * The ShareThis service. |
|
| 161 | - * |
|
| 162 | - * @since 3.2.0 |
|
| 163 | - * @access private |
|
| 164 | - * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 165 | - */ |
|
| 166 | - private $sharethis_service; |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * The PrimaShop adapter. |
|
| 170 | - * |
|
| 171 | - * @since 3.2.3 |
|
| 172 | - * @access private |
|
| 173 | - * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 174 | - */ |
|
| 175 | - private $primashop_adapter; |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * The WordLift Dashboard adapter. |
|
| 179 | - * |
|
| 180 | - * @since 3.4.0 |
|
| 181 | - * @access private |
|
| 182 | - * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 183 | - */ |
|
| 184 | - private $dashboard_service; |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * The entity type service. |
|
| 188 | - * |
|
| 189 | - * @since 3.6.0 |
|
| 190 | - * @access private |
|
| 191 | - * @var \Wordlift_Entity_Type_Service |
|
| 192 | - */ |
|
| 193 | - private $entity_type_service; |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 197 | - * |
|
| 198 | - * @since 3.6.0 |
|
| 199 | - * @access private |
|
| 200 | - * @var \Wordlift_Entity_Link_Service |
|
| 201 | - */ |
|
| 202 | - private $entity_link_service; |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * The page service instance which processes the page output in order to insert schema.org microdata to export the |
|
| 206 | - * correct page title to Google+. |
|
| 207 | - * |
|
| 208 | - * @since 3.5.3 |
|
| 209 | - * @access private |
|
| 210 | - * @var \Wordlift_Page_Service |
|
| 211 | - */ |
|
| 212 | - private $page_service; |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * A {@link Wordlift_Sparql_Service} instance. |
|
| 216 | - * |
|
| 217 | - * @var 3.6.0 |
|
| 218 | - * @access private |
|
| 219 | - * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 220 | - */ |
|
| 221 | - private $sparql_service; |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * A {@link Wordlift_Import_Service} instance. |
|
| 225 | - * |
|
| 226 | - * @since 3.6.0 |
|
| 227 | - * @access private |
|
| 228 | - * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 229 | - */ |
|
| 230 | - private $import_service; |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * A {@link Wordlift_Rebuild_Service} instance. |
|
| 234 | - * |
|
| 235 | - * @since 3.6.0 |
|
| 236 | - * @access private |
|
| 237 | - * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 238 | - */ |
|
| 239 | - private $rebuild_service; |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * Define the core functionality of the plugin. |
|
| 243 | - * |
|
| 244 | - * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 245 | - * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 246 | - * the public-facing side of the site. |
|
| 247 | - * |
|
| 248 | - * @since 1.0.0 |
|
| 249 | - */ |
|
| 250 | - public function __construct() { |
|
| 251 | - |
|
| 252 | - $this->plugin_name = 'wordlift'; |
|
| 253 | - $this->version = '3.6.0-dev'; |
|
| 254 | - $this->load_dependencies(); |
|
| 255 | - $this->set_locale(); |
|
| 256 | - $this->define_admin_hooks(); |
|
| 257 | - $this->define_public_hooks(); |
|
| 258 | - |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - /** |
|
| 262 | - * Load the required dependencies for this plugin. |
|
| 263 | - * |
|
| 264 | - * Include the following files that make up the plugin: |
|
| 265 | - * |
|
| 266 | - * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 267 | - * - Wordlift_i18n. Defines internationalization functionality. |
|
| 268 | - * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 269 | - * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 270 | - * |
|
| 271 | - * Create an instance of the loader which will be used to register the hooks |
|
| 272 | - * with WordPress. |
|
| 273 | - * |
|
| 274 | - * @since 1.0.0 |
|
| 275 | - * @access private |
|
| 276 | - */ |
|
| 277 | - private function load_dependencies() { |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * The class responsible for orchestrating the actions and filters of the |
|
| 281 | - * core plugin. |
|
| 282 | - */ |
|
| 283 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * The class responsible for defining internationalization functionality |
|
| 287 | - * of the plugin. |
|
| 288 | - */ |
|
| 289 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Provide support functions to sanitize data. |
|
| 293 | - */ |
|
| 294 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * The Redirect service. |
|
| 298 | - */ |
|
| 299 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 300 | - |
|
| 301 | - /** |
|
| 302 | - * The Log service. |
|
| 303 | - */ |
|
| 304 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * The configuration service. |
|
| 308 | - */ |
|
| 309 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * The entity post type service. |
|
| 313 | - */ |
|
| 314 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * The entity link service. |
|
| 318 | - */ |
|
| 319 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * The Query builder. |
|
| 323 | - */ |
|
| 324 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * The Schema service. |
|
| 328 | - */ |
|
| 329 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 330 | - |
|
| 331 | - /** |
|
| 332 | - * The UI service. |
|
| 333 | - */ |
|
| 334 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * The Thumbnail service. |
|
| 338 | - */ |
|
| 339 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * The Entity Types Taxonomy service. |
|
| 343 | - */ |
|
| 344 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 345 | - |
|
| 346 | - /** |
|
| 347 | - * The Entity service. |
|
| 348 | - */ |
|
| 349 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * The User service. |
|
| 353 | - */ |
|
| 354 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * The Timeline service. |
|
| 358 | - */ |
|
| 359 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 360 | - |
|
| 361 | - /** |
|
| 362 | - * The Topic Taxonomy service. |
|
| 363 | - */ |
|
| 364 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 365 | - |
|
| 366 | - |
|
| 367 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php'; |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * The SPARQL service. |
|
| 371 | - */ |
|
| 372 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 373 | - |
|
| 374 | - /** |
|
| 375 | - * The WordLift import service. |
|
| 376 | - */ |
|
| 377 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * The WordLift URI service. |
|
| 381 | - */ |
|
| 382 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 383 | - |
|
| 384 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 388 | - */ |
|
| 389 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 390 | - |
|
| 391 | - /** |
|
| 392 | - * The class responsible for defining all actions that occur in the admin area. |
|
| 393 | - */ |
|
| 394 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * The class to customize the entity list admin page. |
|
| 398 | - */ |
|
| 399 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 400 | - |
|
| 401 | - /** |
|
| 402 | - * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 403 | - */ |
|
| 404 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 405 | - |
|
| 406 | - /** |
|
| 407 | - * The Notice service. |
|
| 408 | - */ |
|
| 409 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * The PrimaShop adapter. |
|
| 413 | - */ |
|
| 414 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 32 | + /** |
|
| 33 | + * The loader that's responsible for maintaining and registering all hooks that power |
|
| 34 | + * the plugin. |
|
| 35 | + * |
|
| 36 | + * @since 1.0.0 |
|
| 37 | + * @access protected |
|
| 38 | + * @var Wordlift_Loader $loader Maintains and registers all hooks for the plugin. |
|
| 39 | + */ |
|
| 40 | + protected $loader; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The unique identifier of this plugin. |
|
| 44 | + * |
|
| 45 | + * @since 1.0.0 |
|
| 46 | + * @access protected |
|
| 47 | + * @var string $plugin_name The string used to uniquely identify this plugin. |
|
| 48 | + */ |
|
| 49 | + protected $plugin_name; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * The current version of the plugin. |
|
| 53 | + * |
|
| 54 | + * @since 1.0.0 |
|
| 55 | + * @access protected |
|
| 56 | + * @var string $version The current version of the plugin. |
|
| 57 | + */ |
|
| 58 | + protected $version; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * The Thumbnail service. |
|
| 62 | + * |
|
| 63 | + * @since 3.1.5 |
|
| 64 | + * @access private |
|
| 65 | + * @var \Wordlift_Thumbnail_Service $thumbnail_service The Thumbnail service. |
|
| 66 | + */ |
|
| 67 | + private $thumbnail_service; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * The UI service. |
|
| 71 | + * |
|
| 72 | + * @since 3.2.0 |
|
| 73 | + * @access private |
|
| 74 | + * @var \Wordlift_UI_Service $ui_service The UI service. |
|
| 75 | + */ |
|
| 76 | + private $ui_service; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * The Schema service. |
|
| 80 | + * |
|
| 81 | + * @since 3.3.0 |
|
| 82 | + * @access private |
|
| 83 | + * @var \Wordlift_Schema_Service $schema_service The Schema service. |
|
| 84 | + */ |
|
| 85 | + private $schema_service; |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * The Entity service. |
|
| 89 | + * |
|
| 90 | + * @since 3.1.0 |
|
| 91 | + * @access private |
|
| 92 | + * @var \Wordlift_Entity_Service $entity_service The Entity service. |
|
| 93 | + */ |
|
| 94 | + private $entity_service; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * The Topic Taxonomy service. |
|
| 98 | + * |
|
| 99 | + * @since 3.5.0 |
|
| 100 | + * @access private |
|
| 101 | + * @var \Wordlift_Topic_Taxonomy_Service The Topic Taxonomy service. |
|
| 102 | + */ |
|
| 103 | + private $topic_taxonomy_service; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * The User service. |
|
| 107 | + * |
|
| 108 | + * @since 3.1.7 |
|
| 109 | + * @access private |
|
| 110 | + * @var \Wordlift_User_Service $user_service The User service. |
|
| 111 | + */ |
|
| 112 | + private $user_service; |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * The Timeline service. |
|
| 116 | + * |
|
| 117 | + * @since 3.1.0 |
|
| 118 | + * @access private |
|
| 119 | + * @var \Wordlift_Timeline_Service $timeline_service The Timeline service. |
|
| 120 | + */ |
|
| 121 | + private $timeline_service; |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * The Redirect service. |
|
| 125 | + * |
|
| 126 | + * @since 3.2.0 |
|
| 127 | + * @access private |
|
| 128 | + * @var \Wordlift_Redirect_Service $redirect_service The Redirect service. |
|
| 129 | + */ |
|
| 130 | + private $redirect_service; |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * The Notice service. |
|
| 134 | + * |
|
| 135 | + * @since 3.3.0 |
|
| 136 | + * @access private |
|
| 137 | + * @var \Wordlift_Notice_Service $notice_service The Notice service. |
|
| 138 | + */ |
|
| 139 | + private $notice_service; |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * The Entity list customization. |
|
| 143 | + * |
|
| 144 | + * @since 3.3.0 |
|
| 145 | + * @access private |
|
| 146 | + * @var \Wordlift_List_Service $entity_list_service The Entity list service. |
|
| 147 | + */ |
|
| 148 | + private $entity_list_service; |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * The Entity Types Taxonomy Walker. |
|
| 152 | + * |
|
| 153 | + * @since 3.1.0 |
|
| 154 | + * @access private |
|
| 155 | + * @var \Wordlift_Entity_Types_Taxonomy_Walker $entity_types_taxonomy_walker The Entity Types Taxonomy Walker |
|
| 156 | + */ |
|
| 157 | + private $entity_types_taxonomy_walker; |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * The ShareThis service. |
|
| 161 | + * |
|
| 162 | + * @since 3.2.0 |
|
| 163 | + * @access private |
|
| 164 | + * @var \Wordlift_ShareThis_Service $sharethis_service The ShareThis service. |
|
| 165 | + */ |
|
| 166 | + private $sharethis_service; |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * The PrimaShop adapter. |
|
| 170 | + * |
|
| 171 | + * @since 3.2.3 |
|
| 172 | + * @access private |
|
| 173 | + * @var \Wordlift_PrimaShop_Adapter $primashop_adapter The PrimaShop adapter. |
|
| 174 | + */ |
|
| 175 | + private $primashop_adapter; |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * The WordLift Dashboard adapter. |
|
| 179 | + * |
|
| 180 | + * @since 3.4.0 |
|
| 181 | + * @access private |
|
| 182 | + * @var \Wordlift_Dashboard_Service $dashboard_service The WordLift Dashboard service; |
|
| 183 | + */ |
|
| 184 | + private $dashboard_service; |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * The entity type service. |
|
| 188 | + * |
|
| 189 | + * @since 3.6.0 |
|
| 190 | + * @access private |
|
| 191 | + * @var \Wordlift_Entity_Type_Service |
|
| 192 | + */ |
|
| 193 | + private $entity_type_service; |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * The entity link service used to mangle links to entities with a custom slug or even w/o a slug. |
|
| 197 | + * |
|
| 198 | + * @since 3.6.0 |
|
| 199 | + * @access private |
|
| 200 | + * @var \Wordlift_Entity_Link_Service |
|
| 201 | + */ |
|
| 202 | + private $entity_link_service; |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * The page service instance which processes the page output in order to insert schema.org microdata to export the |
|
| 206 | + * correct page title to Google+. |
|
| 207 | + * |
|
| 208 | + * @since 3.5.3 |
|
| 209 | + * @access private |
|
| 210 | + * @var \Wordlift_Page_Service |
|
| 211 | + */ |
|
| 212 | + private $page_service; |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * A {@link Wordlift_Sparql_Service} instance. |
|
| 216 | + * |
|
| 217 | + * @var 3.6.0 |
|
| 218 | + * @access private |
|
| 219 | + * @var \Wordlift_Sparql_Service $sparql_service A {@link Wordlift_Sparql_Service} instance. |
|
| 220 | + */ |
|
| 221 | + private $sparql_service; |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * A {@link Wordlift_Import_Service} instance. |
|
| 225 | + * |
|
| 226 | + * @since 3.6.0 |
|
| 227 | + * @access private |
|
| 228 | + * @var \Wordlift_Import_Service $import_service A {@link Wordlift_Import_Service} instance. |
|
| 229 | + */ |
|
| 230 | + private $import_service; |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * A {@link Wordlift_Rebuild_Service} instance. |
|
| 234 | + * |
|
| 235 | + * @since 3.6.0 |
|
| 236 | + * @access private |
|
| 237 | + * @var \Wordlift_Rebuild_Service $rebuild_service A {@link Wordlift_Rebuild_Service} instance. |
|
| 238 | + */ |
|
| 239 | + private $rebuild_service; |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * Define the core functionality of the plugin. |
|
| 243 | + * |
|
| 244 | + * Set the plugin name and the plugin version that can be used throughout the plugin. |
|
| 245 | + * Load the dependencies, define the locale, and set the hooks for the admin area and |
|
| 246 | + * the public-facing side of the site. |
|
| 247 | + * |
|
| 248 | + * @since 1.0.0 |
|
| 249 | + */ |
|
| 250 | + public function __construct() { |
|
| 251 | + |
|
| 252 | + $this->plugin_name = 'wordlift'; |
|
| 253 | + $this->version = '3.6.0-dev'; |
|
| 254 | + $this->load_dependencies(); |
|
| 255 | + $this->set_locale(); |
|
| 256 | + $this->define_admin_hooks(); |
|
| 257 | + $this->define_public_hooks(); |
|
| 258 | + |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * Load the required dependencies for this plugin. |
|
| 263 | + * |
|
| 264 | + * Include the following files that make up the plugin: |
|
| 265 | + * |
|
| 266 | + * - Wordlift_Loader. Orchestrates the hooks of the plugin. |
|
| 267 | + * - Wordlift_i18n. Defines internationalization functionality. |
|
| 268 | + * - Wordlift_Admin. Defines all hooks for the admin area. |
|
| 269 | + * - Wordlift_Public. Defines all hooks for the public side of the site. |
|
| 270 | + * |
|
| 271 | + * Create an instance of the loader which will be used to register the hooks |
|
| 272 | + * with WordPress. |
|
| 273 | + * |
|
| 274 | + * @since 1.0.0 |
|
| 275 | + * @access private |
|
| 276 | + */ |
|
| 277 | + private function load_dependencies() { |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * The class responsible for orchestrating the actions and filters of the |
|
| 281 | + * core plugin. |
|
| 282 | + */ |
|
| 283 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * The class responsible for defining internationalization functionality |
|
| 287 | + * of the plugin. |
|
| 288 | + */ |
|
| 289 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Provide support functions to sanitize data. |
|
| 293 | + */ |
|
| 294 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * The Redirect service. |
|
| 298 | + */ |
|
| 299 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 300 | + |
|
| 301 | + /** |
|
| 302 | + * The Log service. |
|
| 303 | + */ |
|
| 304 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * The configuration service. |
|
| 308 | + */ |
|
| 309 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * The entity post type service. |
|
| 313 | + */ |
|
| 314 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 315 | + |
|
| 316 | + /** |
|
| 317 | + * The entity link service. |
|
| 318 | + */ |
|
| 319 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * The Query builder. |
|
| 323 | + */ |
|
| 324 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * The Schema service. |
|
| 328 | + */ |
|
| 329 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 330 | + |
|
| 331 | + /** |
|
| 332 | + * The UI service. |
|
| 333 | + */ |
|
| 334 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * The Thumbnail service. |
|
| 338 | + */ |
|
| 339 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * The Entity Types Taxonomy service. |
|
| 343 | + */ |
|
| 344 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 345 | + |
|
| 346 | + /** |
|
| 347 | + * The Entity service. |
|
| 348 | + */ |
|
| 349 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * The User service. |
|
| 353 | + */ |
|
| 354 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * The Timeline service. |
|
| 358 | + */ |
|
| 359 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 360 | + |
|
| 361 | + /** |
|
| 362 | + * The Topic Taxonomy service. |
|
| 363 | + */ |
|
| 364 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 365 | + |
|
| 366 | + |
|
| 367 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php'; |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * The SPARQL service. |
|
| 371 | + */ |
|
| 372 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 373 | + |
|
| 374 | + /** |
|
| 375 | + * The WordLift import service. |
|
| 376 | + */ |
|
| 377 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * The WordLift URI service. |
|
| 381 | + */ |
|
| 382 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 383 | + |
|
| 384 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
|
| 388 | + */ |
|
| 389 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 390 | + |
|
| 391 | + /** |
|
| 392 | + * The class responsible for defining all actions that occur in the admin area. |
|
| 393 | + */ |
|
| 394 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * The class to customize the entity list admin page. |
|
| 398 | + */ |
|
| 399 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 400 | + |
|
| 401 | + /** |
|
| 402 | + * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
|
| 403 | + */ |
|
| 404 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 405 | + |
|
| 406 | + /** |
|
| 407 | + * The Notice service. |
|
| 408 | + */ |
|
| 409 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * The PrimaShop adapter. |
|
| 413 | + */ |
|
| 414 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 415 | 415 | |
| 416 | - /** |
|
| 417 | - * The WordLift Dashboard service. |
|
| 418 | - */ |
|
| 419 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 416 | + /** |
|
| 417 | + * The WordLift Dashboard service. |
|
| 418 | + */ |
|
| 419 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 420 | 420 | |
| 421 | - /** |
|
| 422 | - * The class responsible for defining all actions that occur in the public-facing |
|
| 423 | - * side of the site. |
|
| 424 | - */ |
|
| 425 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 421 | + /** |
|
| 422 | + * The class responsible for defining all actions that occur in the public-facing |
|
| 423 | + * side of the site. |
|
| 424 | + */ |
|
| 425 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 426 | 426 | |
| 427 | - /** |
|
| 428 | - * The shortcode abstract class. |
|
| 429 | - */ |
|
| 430 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 427 | + /** |
|
| 428 | + * The shortcode abstract class. |
|
| 429 | + */ |
|
| 430 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 431 | 431 | |
| 432 | - /** |
|
| 433 | - * The Timeline shortcode. |
|
| 434 | - */ |
|
| 435 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 432 | + /** |
|
| 433 | + * The Timeline shortcode. |
|
| 434 | + */ |
|
| 435 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 436 | 436 | |
| 437 | - /** |
|
| 438 | - * The Navigator shortcode. |
|
| 439 | - */ |
|
| 440 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 437 | + /** |
|
| 438 | + * The Navigator shortcode. |
|
| 439 | + */ |
|
| 440 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 441 | 441 | |
| 442 | - /** |
|
| 443 | - * The chord shortcode. |
|
| 444 | - */ |
|
| 445 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 442 | + /** |
|
| 443 | + * The chord shortcode. |
|
| 444 | + */ |
|
| 445 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 446 | 446 | |
| 447 | - /** |
|
| 448 | - * The geomap shortcode. |
|
| 449 | - */ |
|
| 450 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 447 | + /** |
|
| 448 | + * The geomap shortcode. |
|
| 449 | + */ |
|
| 450 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 451 | 451 | |
| 452 | - /** |
|
| 453 | - * The ShareThis service. |
|
| 454 | - */ |
|
| 455 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 452 | + /** |
|
| 453 | + * The ShareThis service. |
|
| 454 | + */ |
|
| 455 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 456 | 456 | |
| 457 | - $this->loader = new Wordlift_Loader(); |
|
| 457 | + $this->loader = new Wordlift_Loader(); |
|
| 458 | 458 | |
| 459 | - // Instantiate a global logger. |
|
| 460 | - global $wl_logger; |
|
| 461 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 459 | + // Instantiate a global logger. |
|
| 460 | + global $wl_logger; |
|
| 461 | + $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 462 | 462 | |
| 463 | - // Create the configuration service. |
|
| 464 | - $configuration_service = new Wordlift_Configuration_Service(); |
|
| 463 | + // Create the configuration service. |
|
| 464 | + $configuration_service = new Wordlift_Configuration_Service(); |
|
| 465 | 465 | |
| 466 | - // Create an entity type service instance. It'll be later bound to the init action. |
|
| 467 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() ); |
|
| 466 | + // Create an entity type service instance. It'll be later bound to the init action. |
|
| 467 | + $this->entity_type_service = new Wordlift_Entity_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() ); |
|
| 468 | 468 | |
| 469 | - // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 470 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_type_service, $configuration_service->get_entity_base_path() ); |
|
| 469 | + // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
|
| 470 | + $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_type_service, $configuration_service->get_entity_base_path() ); |
|
| 471 | 471 | |
| 472 | - // Create an instance of the UI service. |
|
| 473 | - $this->ui_service = new Wordlift_UI_Service(); |
|
| 472 | + // Create an instance of the UI service. |
|
| 473 | + $this->ui_service = new Wordlift_UI_Service(); |
|
| 474 | 474 | |
| 475 | - // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 476 | - $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 475 | + // Create an instance of the Thumbnail service. Later it'll be hooked to post meta events. |
|
| 476 | + $this->thumbnail_service = new Wordlift_Thumbnail_Service(); |
|
| 477 | 477 | |
| 478 | - // Create an instance of the Schema service. |
|
| 479 | - $this->schema_service = new Wordlift_Schema_Service(); |
|
| 478 | + // Create an instance of the Schema service. |
|
| 479 | + $this->schema_service = new Wordlift_Schema_Service(); |
|
| 480 | 480 | |
| 481 | - // Create an instance of the Notice service. |
|
| 482 | - $this->notice_service = new Wordlift_Notice_Service(); |
|
| 481 | + // Create an instance of the Notice service. |
|
| 482 | + $this->notice_service = new Wordlift_Notice_Service(); |
|
| 483 | 483 | |
| 484 | - // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 485 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service ); |
|
| 484 | + // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
|
| 485 | + $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service ); |
|
| 486 | 486 | |
| 487 | - // Create an instance of the User service. |
|
| 488 | - $this->user_service = new Wordlift_User_Service(); |
|
| 487 | + // Create an instance of the User service. |
|
| 488 | + $this->user_service = new Wordlift_User_Service(); |
|
| 489 | 489 | |
| 490 | - // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 491 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 490 | + // Create a new instance of the Timeline service and Timeline shortcode. |
|
| 491 | + $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 492 | 492 | |
| 493 | - // Create a new instance of the Redirect service. |
|
| 494 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 493 | + // Create a new instance of the Redirect service. |
|
| 494 | + $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 495 | 495 | |
| 496 | - // Create a new instance of the Redirect service. |
|
| 497 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service ); |
|
| 496 | + // Create a new instance of the Redirect service. |
|
| 497 | + $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service ); |
|
| 498 | 498 | |
| 499 | - // Initialize the shortcodes. |
|
| 500 | - new Wordlift_Navigator_Shortcode(); |
|
| 501 | - new Wordlift_Chord_Shortcode(); |
|
| 502 | - new Wordlift_Geomap_Shortcode(); |
|
| 503 | - new Wordlift_Timeline_Shortcode(); |
|
| 499 | + // Initialize the shortcodes. |
|
| 500 | + new Wordlift_Navigator_Shortcode(); |
|
| 501 | + new Wordlift_Chord_Shortcode(); |
|
| 502 | + new Wordlift_Geomap_Shortcode(); |
|
| 503 | + new Wordlift_Timeline_Shortcode(); |
|
| 504 | 504 | |
| 505 | - // Create entity list customization (wp-admin/edit.php) |
|
| 506 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service ); |
|
| 505 | + // Create entity list customization (wp-admin/edit.php) |
|
| 506 | + $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service ); |
|
| 507 | 507 | |
| 508 | - $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 508 | + $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
|
| 509 | 509 | |
| 510 | - $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 510 | + $this->topic_taxonomy_service = new Wordlift_Topic_Taxonomy_Service(); |
|
| 511 | 511 | |
| 512 | - // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 513 | - $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 512 | + // Create an instance of the ShareThis service, later we hook it to the_content and the_excerpt filters. |
|
| 513 | + $this->sharethis_service = new Wordlift_ShareThis_Service(); |
|
| 514 | 514 | |
| 515 | - // Create an instance of the PrimaShop adapter. |
|
| 516 | - $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 515 | + // Create an instance of the PrimaShop adapter. |
|
| 516 | + $this->primashop_adapter = new Wordlift_PrimaShop_Adapter(); |
|
| 517 | 517 | |
| 518 | - $this->page_service = new Wordlift_Page_Service(); |
|
| 518 | + $this->page_service = new Wordlift_Page_Service(); |
|
| 519 | 519 | |
| 520 | - $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 520 | + $this->sparql_service = new Wordlift_Sparql_Service(); |
|
| 521 | 521 | |
| 522 | - // Create an import service instance to hook later to WP's import function. |
|
| 523 | - $this->import_service = new Wordlift_Import_Service( $this->entity_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() ); |
|
| 522 | + // Create an import service instance to hook later to WP's import function. |
|
| 523 | + $this->import_service = new Wordlift_Import_Service( $this->entity_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() ); |
|
| 524 | 524 | |
| 525 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 525 | + $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 526 | 526 | |
| 527 | - // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 528 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 529 | - } |
|
| 527 | + // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
|
| 528 | + $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 529 | + } |
|
| 530 | 530 | |
| 531 | - /** |
|
| 532 | - * Define the locale for this plugin for internationalization. |
|
| 533 | - * |
|
| 534 | - * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 535 | - * with WordPress. |
|
| 536 | - * |
|
| 537 | - * @since 1.0.0 |
|
| 538 | - * @access private |
|
| 539 | - */ |
|
| 540 | - private function set_locale() { |
|
| 531 | + /** |
|
| 532 | + * Define the locale for this plugin for internationalization. |
|
| 533 | + * |
|
| 534 | + * Uses the Wordlift_i18n class in order to set the domain and to register the hook |
|
| 535 | + * with WordPress. |
|
| 536 | + * |
|
| 537 | + * @since 1.0.0 |
|
| 538 | + * @access private |
|
| 539 | + */ |
|
| 540 | + private function set_locale() { |
|
| 541 | 541 | |
| 542 | - $plugin_i18n = new Wordlift_i18n(); |
|
| 543 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 542 | + $plugin_i18n = new Wordlift_i18n(); |
|
| 543 | + $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 544 | 544 | |
| 545 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 545 | + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 546 | 546 | |
| 547 | - } |
|
| 547 | + } |
|
| 548 | 548 | |
| 549 | - /** |
|
| 550 | - * Register all of the hooks related to the admin area functionality |
|
| 551 | - * of the plugin. |
|
| 552 | - * |
|
| 553 | - * @since 1.0.0 |
|
| 554 | - * @access private |
|
| 555 | - */ |
|
| 556 | - private function define_admin_hooks() { |
|
| 549 | + /** |
|
| 550 | + * Register all of the hooks related to the admin area functionality |
|
| 551 | + * of the plugin. |
|
| 552 | + * |
|
| 553 | + * @since 1.0.0 |
|
| 554 | + * @access private |
|
| 555 | + */ |
|
| 556 | + private function define_admin_hooks() { |
|
| 557 | 557 | |
| 558 | - $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 558 | + $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 559 | 559 | |
| 560 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 561 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 560 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 561 | + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 562 | 562 | |
| 563 | - // Hook the init action to the Topic Taxonomy service. |
|
| 564 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 563 | + // Hook the init action to the Topic Taxonomy service. |
|
| 564 | + $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 565 | 565 | |
| 566 | - // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 567 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 566 | + // Hook the deleted_post_meta action to the Thumbnail service. |
|
| 567 | + $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 568 | 568 | |
| 569 | - // Hook the added_post_meta action to the Thumbnail service. |
|
| 570 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 569 | + // Hook the added_post_meta action to the Thumbnail service. |
|
| 570 | + $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 571 | 571 | |
| 572 | - // Hook the updated_post_meta action to the Thumbnail service. |
|
| 573 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 572 | + // Hook the updated_post_meta action to the Thumbnail service. |
|
| 573 | + $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 574 | 574 | |
| 575 | - // Hook posts inserts (or updates) to the user service. |
|
| 576 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 575 | + // Hook posts inserts (or updates) to the user service. |
|
| 576 | + $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 577 | 577 | |
| 578 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 579 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 578 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 579 | + $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 580 | 580 | |
| 581 | - // Register custom allowed redirect hosts. |
|
| 582 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 583 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 584 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 585 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 586 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 587 | - // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 588 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 581 | + // Register custom allowed redirect hosts. |
|
| 582 | + $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 583 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 584 | + $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 585 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 586 | + $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 587 | + // Hook the AJAX wordlift_redirect action to the Redirect service. |
|
| 588 | + $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 589 | 589 | |
| 590 | - // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 591 | - // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 592 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 593 | - $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 ); |
|
| 594 | - |
|
| 595 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 596 | - $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' ); |
|
| 597 | - |
|
| 598 | - // Entity listing customization (wp-admin/edit.php) |
|
| 599 | - // Add custom columns |
|
| 600 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 601 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 602 | - // Add 4W selection |
|
| 603 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 604 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 605 | - |
|
| 606 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 607 | - |
|
| 608 | - // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 609 | - // entities. |
|
| 610 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 611 | - |
|
| 612 | - // Filter imported post meta. |
|
| 613 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 614 | - |
|
| 615 | - // Notify the import service when an import starts and ends. |
|
| 616 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 617 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 618 | - |
|
| 619 | - // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 620 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 621 | - |
|
| 622 | - } |
|
| 623 | - |
|
| 624 | - /** |
|
| 625 | - * Register all of the hooks related to the public-facing functionality |
|
| 626 | - * of the plugin. |
|
| 627 | - * |
|
| 628 | - * @since 1.0.0 |
|
| 629 | - * @access private |
|
| 630 | - */ |
|
| 631 | - private function define_public_hooks() { |
|
| 632 | - |
|
| 633 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 634 | - |
|
| 635 | - // Register the entity post type. |
|
| 636 | - $this->loader->add_action( 'init', $this->entity_type_service, 'register' ); |
|
| 637 | - |
|
| 638 | - // Bind the link generation and handling hooks to the entity link service. |
|
| 639 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 640 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 641 | - $this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 ); |
|
| 642 | - $this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 ); |
|
| 643 | - |
|
| 644 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 645 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 646 | - |
|
| 647 | - // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 648 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 649 | - |
|
| 650 | - // Hook the ShareThis service. |
|
| 651 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 652 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 653 | - |
|
| 654 | - $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX ); |
|
| 655 | - $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX ); |
|
| 656 | - |
|
| 657 | - } |
|
| 658 | - |
|
| 659 | - /** |
|
| 660 | - * Run the loader to execute all of the hooks with WordPress. |
|
| 661 | - * |
|
| 662 | - * @since 1.0.0 |
|
| 663 | - */ |
|
| 664 | - public function run() { |
|
| 665 | - $this->loader->run(); |
|
| 666 | - } |
|
| 667 | - |
|
| 668 | - /** |
|
| 669 | - * The name of the plugin used to uniquely identify it within the context of |
|
| 670 | - * WordPress and to define internationalization functionality. |
|
| 671 | - * |
|
| 672 | - * @since 1.0.0 |
|
| 673 | - * @return string The name of the plugin. |
|
| 674 | - */ |
|
| 675 | - public function get_plugin_name() { |
|
| 676 | - return $this->plugin_name; |
|
| 677 | - } |
|
| 678 | - |
|
| 679 | - /** |
|
| 680 | - * The reference to the class that orchestrates the hooks with the plugin. |
|
| 681 | - * |
|
| 682 | - * @since 1.0.0 |
|
| 683 | - * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 684 | - */ |
|
| 685 | - public function get_loader() { |
|
| 686 | - return $this->loader; |
|
| 687 | - } |
|
| 688 | - |
|
| 689 | - /** |
|
| 690 | - * Retrieve the version number of the plugin. |
|
| 691 | - * |
|
| 692 | - * @since 1.0.0 |
|
| 693 | - * @return string The version number of the plugin. |
|
| 694 | - */ |
|
| 695 | - public function get_version() { |
|
| 696 | - return $this->version; |
|
| 697 | - } |
|
| 590 | + // Hook save_post to the entity service to update custom fields (such as alternate labels). |
|
| 591 | + // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
|
| 592 | + $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 593 | + $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 ); |
|
| 594 | + |
|
| 595 | + $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 596 | + $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' ); |
|
| 597 | + |
|
| 598 | + // Entity listing customization (wp-admin/edit.php) |
|
| 599 | + // Add custom columns |
|
| 600 | + $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 601 | + $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 602 | + // Add 4W selection |
|
| 603 | + $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 604 | + $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 605 | + |
|
| 606 | + $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 607 | + |
|
| 608 | + // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
|
| 609 | + // entities. |
|
| 610 | + $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 611 | + |
|
| 612 | + // Filter imported post meta. |
|
| 613 | + $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 614 | + |
|
| 615 | + // Notify the import service when an import starts and ends. |
|
| 616 | + $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 617 | + $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 618 | + |
|
| 619 | + // Hook the AJAX wl_rebuild action to the Rebuild Service. |
|
| 620 | + $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 621 | + |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + /** |
|
| 625 | + * Register all of the hooks related to the public-facing functionality |
|
| 626 | + * of the plugin. |
|
| 627 | + * |
|
| 628 | + * @since 1.0.0 |
|
| 629 | + * @access private |
|
| 630 | + */ |
|
| 631 | + private function define_public_hooks() { |
|
| 632 | + |
|
| 633 | + $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 634 | + |
|
| 635 | + // Register the entity post type. |
|
| 636 | + $this->loader->add_action( 'init', $this->entity_type_service, 'register' ); |
|
| 637 | + |
|
| 638 | + // Bind the link generation and handling hooks to the entity link service. |
|
| 639 | + $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 640 | + $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 641 | + $this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 ); |
|
| 642 | + $this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 ); |
|
| 643 | + |
|
| 644 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 645 | + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 646 | + |
|
| 647 | + // Hook the AJAX wl_timeline action to the Timeline service. |
|
| 648 | + $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 649 | + |
|
| 650 | + // Hook the ShareThis service. |
|
| 651 | + $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 652 | + $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 653 | + |
|
| 654 | + $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX ); |
|
| 655 | + $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX ); |
|
| 656 | + |
|
| 657 | + } |
|
| 658 | + |
|
| 659 | + /** |
|
| 660 | + * Run the loader to execute all of the hooks with WordPress. |
|
| 661 | + * |
|
| 662 | + * @since 1.0.0 |
|
| 663 | + */ |
|
| 664 | + public function run() { |
|
| 665 | + $this->loader->run(); |
|
| 666 | + } |
|
| 667 | + |
|
| 668 | + /** |
|
| 669 | + * The name of the plugin used to uniquely identify it within the context of |
|
| 670 | + * WordPress and to define internationalization functionality. |
|
| 671 | + * |
|
| 672 | + * @since 1.0.0 |
|
| 673 | + * @return string The name of the plugin. |
|
| 674 | + */ |
|
| 675 | + public function get_plugin_name() { |
|
| 676 | + return $this->plugin_name; |
|
| 677 | + } |
|
| 678 | + |
|
| 679 | + /** |
|
| 680 | + * The reference to the class that orchestrates the hooks with the plugin. |
|
| 681 | + * |
|
| 682 | + * @since 1.0.0 |
|
| 683 | + * @return Wordlift_Loader Orchestrates the hooks of the plugin. |
|
| 684 | + */ |
|
| 685 | + public function get_loader() { |
|
| 686 | + return $this->loader; |
|
| 687 | + } |
|
| 688 | + |
|
| 689 | + /** |
|
| 690 | + * Retrieve the version number of the plugin. |
|
| 691 | + * |
|
| 692 | + * @since 1.0.0 |
|
| 693 | + * @return string The version number of the plugin. |
|
| 694 | + */ |
|
| 695 | + public function get_version() { |
|
| 696 | + return $this->version; |
|
| 697 | + } |
|
| 698 | 698 | |
| 699 | 699 | } |
@@ -280,194 +280,194 @@ discard block |
||
| 280 | 280 | * The class responsible for orchestrating the actions and filters of the |
| 281 | 281 | * core plugin. |
| 282 | 282 | */ |
| 283 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-loader.php'; |
|
| 283 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-loader.php'; |
|
| 284 | 284 | |
| 285 | 285 | /** |
| 286 | 286 | * The class responsible for defining internationalization functionality |
| 287 | 287 | * of the plugin. |
| 288 | 288 | */ |
| 289 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-i18n.php'; |
|
| 289 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-i18n.php'; |
|
| 290 | 290 | |
| 291 | 291 | /** |
| 292 | 292 | * Provide support functions to sanitize data. |
| 293 | 293 | */ |
| 294 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sanitizer.php'; |
|
| 294 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sanitizer.php'; |
|
| 295 | 295 | |
| 296 | 296 | /** |
| 297 | 297 | * The Redirect service. |
| 298 | 298 | */ |
| 299 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-redirect-service.php'; |
|
| 299 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-redirect-service.php'; |
|
| 300 | 300 | |
| 301 | 301 | /** |
| 302 | 302 | * The Log service. |
| 303 | 303 | */ |
| 304 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-log-service.php'; |
|
| 304 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-log-service.php'; |
|
| 305 | 305 | |
| 306 | 306 | /** |
| 307 | 307 | * The configuration service. |
| 308 | 308 | */ |
| 309 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-configuration-service.php'; |
|
| 309 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-configuration-service.php'; |
|
| 310 | 310 | |
| 311 | 311 | /** |
| 312 | 312 | * The entity post type service. |
| 313 | 313 | */ |
| 314 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-type-service.php'; |
|
| 314 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-type-service.php'; |
|
| 315 | 315 | |
| 316 | 316 | /** |
| 317 | 317 | * The entity link service. |
| 318 | 318 | */ |
| 319 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-link-service.php'; |
|
| 319 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-link-service.php'; |
|
| 320 | 320 | |
| 321 | 321 | /** |
| 322 | 322 | * The Query builder. |
| 323 | 323 | */ |
| 324 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-query-builder.php'; |
|
| 324 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-query-builder.php'; |
|
| 325 | 325 | |
| 326 | 326 | /** |
| 327 | 327 | * The Schema service. |
| 328 | 328 | */ |
| 329 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-schema-service.php'; |
|
| 329 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-schema-service.php'; |
|
| 330 | 330 | |
| 331 | 331 | /** |
| 332 | 332 | * The UI service. |
| 333 | 333 | */ |
| 334 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-ui-service.php'; |
|
| 334 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-ui-service.php'; |
|
| 335 | 335 | |
| 336 | 336 | /** |
| 337 | 337 | * The Thumbnail service. |
| 338 | 338 | */ |
| 339 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-thumbnail-service.php'; |
|
| 339 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-thumbnail-service.php'; |
|
| 340 | 340 | |
| 341 | 341 | /** |
| 342 | 342 | * The Entity Types Taxonomy service. |
| 343 | 343 | */ |
| 344 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 344 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-types-taxonomy-service.php'; |
|
| 345 | 345 | |
| 346 | 346 | /** |
| 347 | 347 | * The Entity service. |
| 348 | 348 | */ |
| 349 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-entity-service.php'; |
|
| 349 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-entity-service.php'; |
|
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * The User service. |
| 353 | 353 | */ |
| 354 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-user-service.php'; |
|
| 354 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-user-service.php'; |
|
| 355 | 355 | |
| 356 | 356 | /** |
| 357 | 357 | * The Timeline service. |
| 358 | 358 | */ |
| 359 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-timeline-service.php'; |
|
| 359 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-timeline-service.php'; |
|
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | 362 | * The Topic Taxonomy service. |
| 363 | 363 | */ |
| 364 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 364 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-topic-taxonomy-service.php'; |
|
| 365 | 365 | |
| 366 | 366 | |
| 367 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-page-service.php'; |
|
| 367 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-page-service.php'; |
|
| 368 | 368 | |
| 369 | 369 | /** |
| 370 | 370 | * The SPARQL service. |
| 371 | 371 | */ |
| 372 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-sparql-service.php'; |
|
| 372 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-sparql-service.php'; |
|
| 373 | 373 | |
| 374 | 374 | /** |
| 375 | 375 | * The WordLift import service. |
| 376 | 376 | */ |
| 377 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-import-service.php'; |
|
| 377 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-import-service.php'; |
|
| 378 | 378 | |
| 379 | 379 | /** |
| 380 | 380 | * The WordLift URI service. |
| 381 | 381 | */ |
| 382 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-uri-service.php'; |
|
| 382 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-uri-service.php'; |
|
| 383 | 383 | |
| 384 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-listable.php'; |
|
| 384 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-listable.php'; |
|
| 385 | 385 | |
| 386 | 386 | /** |
| 387 | 387 | * The WordLift rebuild service, used to rebuild the remote dataset using the local data. |
| 388 | 388 | */ |
| 389 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wordlift-rebuild-service.php'; |
|
| 389 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-wordlift-rebuild-service.php'; |
|
| 390 | 390 | |
| 391 | 391 | /** |
| 392 | 392 | * The class responsible for defining all actions that occur in the admin area. |
| 393 | 393 | */ |
| 394 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin.php'; |
|
| 394 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin.php'; |
|
| 395 | 395 | |
| 396 | 396 | /** |
| 397 | 397 | * The class to customize the entity list admin page. |
| 398 | 398 | */ |
| 399 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-entity-list.php'; |
|
| 399 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-entity-list.php'; |
|
| 400 | 400 | |
| 401 | 401 | /** |
| 402 | 402 | * The Entity Types Taxonomy Walker (transforms checkboxes into radios). |
| 403 | 403 | */ |
| 404 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 404 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-entity-types-taxonomy-walker.php'; |
|
| 405 | 405 | |
| 406 | 406 | /** |
| 407 | 407 | * The Notice service. |
| 408 | 408 | */ |
| 409 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-notice-service.php'; |
|
| 409 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-notice-service.php'; |
|
| 410 | 410 | |
| 411 | 411 | /** |
| 412 | 412 | * The PrimaShop adapter. |
| 413 | 413 | */ |
| 414 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-primashop-adapter.php'; |
|
| 414 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-primashop-adapter.php'; |
|
| 415 | 415 | |
| 416 | 416 | /** |
| 417 | 417 | * The WordLift Dashboard service. |
| 418 | 418 | */ |
| 419 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard.php'; |
|
| 419 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard.php'; |
|
| 420 | 420 | |
| 421 | 421 | /** |
| 422 | 422 | * The class responsible for defining all actions that occur in the public-facing |
| 423 | 423 | * side of the site. |
| 424 | 424 | */ |
| 425 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-public.php'; |
|
| 425 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-public.php'; |
|
| 426 | 426 | |
| 427 | 427 | /** |
| 428 | 428 | * The shortcode abstract class. |
| 429 | 429 | */ |
| 430 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-shortcode.php'; |
|
| 430 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-shortcode.php'; |
|
| 431 | 431 | |
| 432 | 432 | /** |
| 433 | 433 | * The Timeline shortcode. |
| 434 | 434 | */ |
| 435 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-timeline-shortcode.php'; |
|
| 435 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-timeline-shortcode.php'; |
|
| 436 | 436 | |
| 437 | 437 | /** |
| 438 | 438 | * The Navigator shortcode. |
| 439 | 439 | */ |
| 440 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-navigator-shortcode.php'; |
|
| 440 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-navigator-shortcode.php'; |
|
| 441 | 441 | |
| 442 | 442 | /** |
| 443 | 443 | * The chord shortcode. |
| 444 | 444 | */ |
| 445 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-chord-shortcode.php'; |
|
| 445 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-chord-shortcode.php'; |
|
| 446 | 446 | |
| 447 | 447 | /** |
| 448 | 448 | * The geomap shortcode. |
| 449 | 449 | */ |
| 450 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-geomap-shortcode.php'; |
|
| 450 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-geomap-shortcode.php'; |
|
| 451 | 451 | |
| 452 | 452 | /** |
| 453 | 453 | * The ShareThis service. |
| 454 | 454 | */ |
| 455 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wordlift-sharethis-service.php'; |
|
| 455 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-wordlift-sharethis-service.php'; |
|
| 456 | 456 | |
| 457 | 457 | $this->loader = new Wordlift_Loader(); |
| 458 | 458 | |
| 459 | 459 | // Instantiate a global logger. |
| 460 | 460 | global $wl_logger; |
| 461 | - $wl_logger = Wordlift_Log_Service::get_logger( 'WordLift' ); |
|
| 461 | + $wl_logger = Wordlift_Log_Service::get_logger('WordLift'); |
|
| 462 | 462 | |
| 463 | 463 | // Create the configuration service. |
| 464 | 464 | $configuration_service = new Wordlift_Configuration_Service(); |
| 465 | 465 | |
| 466 | 466 | // Create an entity type service instance. It'll be later bound to the init action. |
| 467 | - $this->entity_type_service = new Wordlift_Entity_Type_Service( Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path() ); |
|
| 467 | + $this->entity_type_service = new Wordlift_Entity_Type_Service(Wordlift_Entity_Service::TYPE_NAME, $configuration_service->get_entity_base_path()); |
|
| 468 | 468 | |
| 469 | 469 | // Create an entity link service instance. It'll be later bound to the post_type_link and pre_get_posts actions. |
| 470 | - $this->entity_link_service = new Wordlift_Entity_Link_Service( $this->entity_type_service, $configuration_service->get_entity_base_path() ); |
|
| 470 | + $this->entity_link_service = new Wordlift_Entity_Link_Service($this->entity_type_service, $configuration_service->get_entity_base_path()); |
|
| 471 | 471 | |
| 472 | 472 | // Create an instance of the UI service. |
| 473 | 473 | $this->ui_service = new Wordlift_UI_Service(); |
@@ -482,19 +482,19 @@ discard block |
||
| 482 | 482 | $this->notice_service = new Wordlift_Notice_Service(); |
| 483 | 483 | |
| 484 | 484 | // Create an instance of the Entity service, passing the UI service to draw parts of the Entity admin page. |
| 485 | - $this->entity_service = new Wordlift_Entity_Service( $this->ui_service, $this->schema_service, $this->notice_service ); |
|
| 485 | + $this->entity_service = new Wordlift_Entity_Service($this->ui_service, $this->schema_service, $this->notice_service); |
|
| 486 | 486 | |
| 487 | 487 | // Create an instance of the User service. |
| 488 | 488 | $this->user_service = new Wordlift_User_Service(); |
| 489 | 489 | |
| 490 | 490 | // Create a new instance of the Timeline service and Timeline shortcode. |
| 491 | - $this->timeline_service = new Wordlift_Timeline_Service( $this->entity_service ); |
|
| 491 | + $this->timeline_service = new Wordlift_Timeline_Service($this->entity_service); |
|
| 492 | 492 | |
| 493 | 493 | // Create a new instance of the Redirect service. |
| 494 | - $this->redirect_service = new Wordlift_Redirect_Service( $this->entity_service ); |
|
| 494 | + $this->redirect_service = new Wordlift_Redirect_Service($this->entity_service); |
|
| 495 | 495 | |
| 496 | 496 | // Create a new instance of the Redirect service. |
| 497 | - $this->dashboard_service = new Wordlift_Dashboard_Service( $this->entity_service ); |
|
| 497 | + $this->dashboard_service = new Wordlift_Dashboard_Service($this->entity_service); |
|
| 498 | 498 | |
| 499 | 499 | // Initialize the shortcodes. |
| 500 | 500 | new Wordlift_Navigator_Shortcode(); |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | new Wordlift_Timeline_Shortcode(); |
| 504 | 504 | |
| 505 | 505 | // Create entity list customization (wp-admin/edit.php) |
| 506 | - $this->entity_list_service = new Wordlift_Entity_List_Service( $this->entity_service ); |
|
| 506 | + $this->entity_list_service = new Wordlift_Entity_List_Service($this->entity_service); |
|
| 507 | 507 | |
| 508 | 508 | $this->entity_types_taxonomy_walker = new Wordlift_Entity_Types_Taxonomy_Walker(); |
| 509 | 509 | |
@@ -520,12 +520,12 @@ discard block |
||
| 520 | 520 | $this->sparql_service = new Wordlift_Sparql_Service(); |
| 521 | 521 | |
| 522 | 522 | // Create an import service instance to hook later to WP's import function. |
| 523 | - $this->import_service = new Wordlift_Import_Service( $this->entity_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri() ); |
|
| 523 | + $this->import_service = new Wordlift_Import_Service($this->entity_type_service, $this->entity_service, $this->schema_service, $this->sparql_service, wl_configuration_get_redlink_dataset_uri()); |
|
| 524 | 524 | |
| 525 | - $uri_service = new Wordlift_Uri_Service( $GLOBALS['wpdb'] ); |
|
| 525 | + $uri_service = new Wordlift_Uri_Service($GLOBALS['wpdb']); |
|
| 526 | 526 | |
| 527 | 527 | // Create a Rebuild Service instance, which we'll later bound to an ajax call. |
| 528 | - $this->rebuild_service = new Wordlift_Rebuild_Service( $this->sparql_service, $uri_service ); |
|
| 528 | + $this->rebuild_service = new Wordlift_Rebuild_Service($this->sparql_service, $uri_service); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | /** |
@@ -540,9 +540,9 @@ discard block |
||
| 540 | 540 | private function set_locale() { |
| 541 | 541 | |
| 542 | 542 | $plugin_i18n = new Wordlift_i18n(); |
| 543 | - $plugin_i18n->set_domain( $this->get_plugin_name() ); |
|
| 543 | + $plugin_i18n->set_domain($this->get_plugin_name()); |
|
| 544 | 544 | |
| 545 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
| 545 | + $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); |
|
| 546 | 546 | |
| 547 | 547 | } |
| 548 | 548 | |
@@ -555,69 +555,69 @@ discard block |
||
| 555 | 555 | */ |
| 556 | 556 | private function define_admin_hooks() { |
| 557 | 557 | |
| 558 | - $plugin_admin = new Wordlift_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
| 558 | + $plugin_admin = new Wordlift_Admin($this->get_plugin_name(), $this->get_version()); |
|
| 559 | 559 | |
| 560 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
| 561 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
| 560 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
|
| 561 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); |
|
| 562 | 562 | |
| 563 | 563 | // Hook the init action to the Topic Taxonomy service. |
| 564 | - $this->loader->add_action( 'init', $this->topic_taxonomy_service, 'init', 0 ); |
|
| 564 | + $this->loader->add_action('init', $this->topic_taxonomy_service, 'init', 0); |
|
| 565 | 565 | |
| 566 | 566 | // Hook the deleted_post_meta action to the Thumbnail service. |
| 567 | - $this->loader->add_action( 'deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4 ); |
|
| 567 | + $this->loader->add_action('deleted_post_meta', $this->thumbnail_service, 'deleted_post_meta', 10, 4); |
|
| 568 | 568 | |
| 569 | 569 | // Hook the added_post_meta action to the Thumbnail service. |
| 570 | - $this->loader->add_action( 'added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 570 | + $this->loader->add_action('added_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 571 | 571 | |
| 572 | 572 | // Hook the updated_post_meta action to the Thumbnail service. |
| 573 | - $this->loader->add_action( 'updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4 ); |
|
| 573 | + $this->loader->add_action('updated_post_meta', $this->thumbnail_service, 'added_or_updated_post_meta', 10, 4); |
|
| 574 | 574 | |
| 575 | 575 | // Hook posts inserts (or updates) to the user service. |
| 576 | - $this->loader->add_action( 'wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3 ); |
|
| 576 | + $this->loader->add_action('wp_insert_post', $this->user_service, 'wp_insert_post', 10, 3); |
|
| 577 | 577 | |
| 578 | 578 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 579 | - $this->loader->add_action( 'wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 579 | + $this->loader->add_action('wp_ajax_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 580 | 580 | |
| 581 | 581 | // Register custom allowed redirect hosts. |
| 582 | - $this->loader->add_filter( 'allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts' ); |
|
| 582 | + $this->loader->add_filter('allowed_redirect_hosts', $this->redirect_service, 'allowed_redirect_hosts'); |
|
| 583 | 583 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 584 | - $this->loader->add_action( 'wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect' ); |
|
| 584 | + $this->loader->add_action('wp_ajax_wordlift_redirect', $this->redirect_service, 'ajax_redirect'); |
|
| 585 | 585 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 586 | - $this->loader->add_action( 'wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats' ); |
|
| 586 | + $this->loader->add_action('wp_ajax_wordlift_get_stats', $this->dashboard_service, 'ajax_get_stats'); |
|
| 587 | 587 | // Hook the AJAX wordlift_redirect action to the Redirect service. |
| 588 | - $this->loader->add_action( 'wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets' ); |
|
| 588 | + $this->loader->add_action('wp_dashboard_setup', $this->dashboard_service, 'add_dashboard_widgets'); |
|
| 589 | 589 | |
| 590 | 590 | // Hook save_post to the entity service to update custom fields (such as alternate labels). |
| 591 | 591 | // We have a priority of 9 because we want to be executed before data is sent to Redlink. |
| 592 | - $this->loader->add_action( 'save_post', $this->entity_service, 'save_post', 9, 3 ); |
|
| 593 | - $this->loader->add_action( 'save_post_entity', $this->entity_service, 'set_rating_for', 10, 1 ); |
|
| 592 | + $this->loader->add_action('save_post', $this->entity_service, 'save_post', 9, 3); |
|
| 593 | + $this->loader->add_action('save_post_entity', $this->entity_service, 'set_rating_for', 10, 1); |
|
| 594 | 594 | |
| 595 | - $this->loader->add_action( 'edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1 ); |
|
| 596 | - $this->loader->add_action( 'in_admin_header', $this->entity_service, 'in_admin_header' ); |
|
| 595 | + $this->loader->add_action('edit_form_before_permalink', $this->entity_service, 'edit_form_before_permalink', 10, 1); |
|
| 596 | + $this->loader->add_action('in_admin_header', $this->entity_service, 'in_admin_header'); |
|
| 597 | 597 | |
| 598 | 598 | // Entity listing customization (wp-admin/edit.php) |
| 599 | 599 | // Add custom columns |
| 600 | - $this->loader->add_filter( 'manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns' ); |
|
| 601 | - $this->loader->add_filter( 'manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2 ); |
|
| 600 | + $this->loader->add_filter('manage_entity_posts_columns', $this->entity_list_service, 'register_custom_columns'); |
|
| 601 | + $this->loader->add_filter('manage_entity_posts_custom_column', $this->entity_list_service, 'render_custom_columns', 10, 2); |
|
| 602 | 602 | // Add 4W selection |
| 603 | - $this->loader->add_action( 'restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope' ); |
|
| 604 | - $this->loader->add_filter( 'posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope' ); |
|
| 603 | + $this->loader->add_action('restrict_manage_posts', $this->entity_list_service, 'restrict_manage_posts_classification_scope'); |
|
| 604 | + $this->loader->add_filter('posts_clauses', $this->entity_list_service, 'posts_clauses_classification_scope'); |
|
| 605 | 605 | |
| 606 | - $this->loader->add_filter( 'wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args' ); |
|
| 606 | + $this->loader->add_filter('wp_terms_checklist_args', $this->entity_types_taxonomy_walker, 'terms_checklist_args'); |
|
| 607 | 607 | |
| 608 | 608 | // Hook the PrimaShop adapter to <em>prima_metabox_entity_header_args</em> in order to add header support for |
| 609 | 609 | // entities. |
| 610 | - $this->loader->add_filter( 'prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2 ); |
|
| 610 | + $this->loader->add_filter('prima_metabox_entity_header_args', $this->primashop_adapter, 'prima_metabox_entity_header_args', 10, 2); |
|
| 611 | 611 | |
| 612 | 612 | // Filter imported post meta. |
| 613 | - $this->loader->add_filter( 'wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3 ); |
|
| 613 | + $this->loader->add_filter('wp_import_post_meta', $this->import_service, 'wp_import_post_meta', 10, 3); |
|
| 614 | 614 | |
| 615 | 615 | // Notify the import service when an import starts and ends. |
| 616 | - $this->loader->add_action( 'import_start', $this->import_service, 'import_start', 10, 0 ); |
|
| 617 | - $this->loader->add_action( 'import_end', $this->import_service, 'import_end', 10, 0 ); |
|
| 616 | + $this->loader->add_action('import_start', $this->import_service, 'import_start', 10, 0); |
|
| 617 | + $this->loader->add_action('import_end', $this->import_service, 'import_end', 10, 0); |
|
| 618 | 618 | |
| 619 | 619 | // Hook the AJAX wl_rebuild action to the Rebuild Service. |
| 620 | - $this->loader->add_action( 'wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild' ); |
|
| 620 | + $this->loader->add_action('wp_ajax_wl_rebuild', $this->rebuild_service, 'rebuild'); |
|
| 621 | 621 | |
| 622 | 622 | } |
| 623 | 623 | |
@@ -630,29 +630,29 @@ discard block |
||
| 630 | 630 | */ |
| 631 | 631 | private function define_public_hooks() { |
| 632 | 632 | |
| 633 | - $plugin_public = new Wordlift_Public( $this->get_plugin_name(), $this->get_version() ); |
|
| 633 | + $plugin_public = new Wordlift_Public($this->get_plugin_name(), $this->get_version()); |
|
| 634 | 634 | |
| 635 | 635 | // Register the entity post type. |
| 636 | - $this->loader->add_action( 'init', $this->entity_type_service, 'register' ); |
|
| 636 | + $this->loader->add_action('init', $this->entity_type_service, 'register'); |
|
| 637 | 637 | |
| 638 | 638 | // Bind the link generation and handling hooks to the entity link service. |
| 639 | - $this->loader->add_filter( 'post_type_link', $this->entity_link_service, 'post_type_link', 10, 4 ); |
|
| 640 | - $this->loader->add_action( 'pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1 ); |
|
| 641 | - $this->loader->add_filter( 'wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3 ); |
|
| 642 | - $this->loader->add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4 ); |
|
| 639 | + $this->loader->add_filter('post_type_link', $this->entity_link_service, 'post_type_link', 10, 4); |
|
| 640 | + $this->loader->add_action('pre_get_posts', $this->entity_link_service, 'pre_get_posts', 10, 1); |
|
| 641 | + $this->loader->add_filter('wp_unique_post_slug_is_bad_flat_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_flat_slug', 10, 3); |
|
| 642 | + $this->loader->add_filter('wp_unique_post_slug_is_bad_hierarchical_slug', $this->entity_link_service, 'wp_unique_post_slug_is_bad_hierarchical_slug', 10, 4); |
|
| 643 | 643 | |
| 644 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 645 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 644 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
|
| 645 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
|
| 646 | 646 | |
| 647 | 647 | // Hook the AJAX wl_timeline action to the Timeline service. |
| 648 | - $this->loader->add_action( 'wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline' ); |
|
| 648 | + $this->loader->add_action('wp_ajax_nopriv_wl_timeline', $this->timeline_service, 'ajax_timeline'); |
|
| 649 | 649 | |
| 650 | 650 | // Hook the ShareThis service. |
| 651 | - $this->loader->add_filter( 'the_content', $this->sharethis_service, 'the_content', 99 ); |
|
| 652 | - $this->loader->add_filter( 'the_excerpt', $this->sharethis_service, 'the_excerpt', 99 ); |
|
| 651 | + $this->loader->add_filter('the_content', $this->sharethis_service, 'the_content', 99); |
|
| 652 | + $this->loader->add_filter('the_excerpt', $this->sharethis_service, 'the_excerpt', 99); |
|
| 653 | 653 | |
| 654 | - $this->loader->add_action( 'wp_head', $this->page_service, 'wp_head', PHP_INT_MAX ); |
|
| 655 | - $this->loader->add_action( 'wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX ); |
|
| 654 | + $this->loader->add_action('wp_head', $this->page_service, 'wp_head', PHP_INT_MAX); |
|
| 655 | + $this->loader->add_action('wp_footer', $this->page_service, 'wp_head', - PHP_INT_MAX); |
|
| 656 | 656 | |
| 657 | 657 | } |
| 658 | 658 | |