id ) { wp_enqueue_script( 'air-wp-sync-term-hooks', plugins_url( 'modules/term/assets/js/hooks.js', AIR_WP_SYNC_PLUGIN_FILE ), array( 'air-wp-sync-admin' ), AIR_WP_SYNC_VERSION, false ); } } /** * Add module l10n strings * * @param array $l10n_strings Localization strings. * * @return array */ public function add_l10n_strings( $l10n_strings ) { return array_merge( $l10n_strings, array( 'requiredTermNameErrorMessage' => __( 'It is mandatory to map the term name.', 'air-wp-sync' ), ) ); } /** * {@inheritDoc} * * @param \WP_Post $post Post object holding the importer config. * * @return void */ public function render_settings( $post ) { $taxonomies = Air_WP_Sync_Term_Helpers::get_taxonomies(); $view = include_once __DIR__ . '/views/settings.php'; $view( $taxonomies ); } /** * {@inheritDoc} * * @param \WP_Post $post Post object holding the importer config. */ public function get_importer_instance( $post ) { return new Air_WP_Sync_Term_Importer( $post, $this, new Air_WP_Sync_Filters() ); } /** * Register destinations */ public function register_destinations() { new Air_WP_Sync_Term_Destination( new Air_WP_Sync_Markdown_Formatter( new Air_WP_Sync_Parsedown() ), new Air_WP_Sync_Interval_Formatter() ); new Air_WP_Sync_Term_Meta_Destination( new Air_WP_Sync_Markdown_Formatter( new Air_WP_Sync_Parsedown() ), new Air_WP_Sync_Attachments_Formatter() ); } /** * Add required email rule to mapping rules * * @param array $rules Mapping validation rules. */ public function add_mapping_validation_rules( $rules ) { $rules[] = 'requiredTermName'; return $rules; } /** * {@inheritDoc} */ public function get_mapping_options() { return apply_filters( 'airwpsync/get_wp_fields', array(), $this->slug ); } /** * {@inheritDoc} */ public function get_extra_config() { return array( 'featuresByTaxonomy' => $this->get_features_by_taxonomy(), ); } /** * Get available features by post type * * @return array */ protected function get_features_by_taxonomy() { $features = array(); foreach ( Air_WP_Sync_Term_Helpers::get_taxonomies() as $taxonomy ) { /** * Filters features by taxonomy. * * @param array $features Features. * @param WP_Taxonomy $taxonomy Taxonomy. */ $features[ $taxonomy->name ] = apply_filters( 'airwpsync/features_by_taxonomy', array(), $taxonomy ); } return $features; } }