Skip to content

Commit

Permalink
Ajout modification du permalien des catégories
Browse files Browse the repository at this point in the history
  • Loading branch information
eoxia-amandine committed Sep 7, 2020
1 parent d2beb55 commit 0a4f598
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/annonce/action/annonce.action.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ public function announce_taxonomy() {
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'rewrite' => array(
'slug' => get_option( 'permalink_annonce_tax', 'announce_taxonomy' ),
),
);
register_taxonomy( 'announce_taxonomy', array( 'announce' ), $args );
}
Expand Down
24 changes: 24 additions & 0 deletions modules/option/action/option.action.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,16 @@ public function add_permalink_setting() {
'permalink',
'permalink_session_annonce'
);
add_settings_field(
'permalink_annonce_tax',
__('Permalink Announce taxonomy', 'annonces'),
array($this, 'eg_setting_tax_callback_function'),
'permalink',
'permalink_session_annonce'
);

register_setting('permalink', 'permalink_annonce');
register_setting('permalink', 'permalink_annonce_tax');
}

/**
Expand All @@ -93,6 +101,17 @@ public function eg_setting_callback_function() {
include $main_view;
}

/**
* Display permalink field view
*
* @return void
* @since 2.0.0
*/
public function eg_setting_tax_callback_function() {
$main_view = \annonces\Annonces_Util::get_instance()->get_module_view_path('option', 'permalink-field-tax.view');
include $main_view;
}

/**
* Update manually permalink data
*
Expand All @@ -104,6 +123,11 @@ public function update_permalink_setting_value() {
$permalink_annonce = !empty($_POST['permalink_annonce']) ? sanitize_title($_POST['permalink_annonce']) : '';
update_option('permalink_annonce', $permalink_annonce);
}

if (isset($_POST['permalink_annonce'])) {
$permalink_annonce_tax = !empty($_POST['permalink_annonce_tax']) ? sanitize_title($_POST['permalink_annonce_tax']) : '';
update_option('permalink_annonce_tax', $permalink_annonce_tax);
}
}

}
Expand Down
16 changes: 16 additions & 0 deletions modules/option/view/permalink-field-tax.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Permalink field view in permalink option page.
*
* @author Eoxia <[email protected]>
* @copyright (c) 2006-2018 Eoxia <[email protected]>
* @license AGPLv3 <https://spdx.org/licenses/AGPL-3.0-or-later.html>
* @package Annonces\option\View
* @since 2.0.0
*/

namespace annonces;

defined( 'ABSPATH' ) || exit; ?>

<input type="text" name="permalink_annonce_tax" id="permalink_annonce_tax" value="<?php echo esc_attr( get_option( 'permalink_annonce_tax', 'announce_taxonomy' ) ); ?>" class="code" />

0 comments on commit 0a4f598

Please sign in to comment.