settings = new WPSlug_Settings(); $this->converter = new WPSlug_Converter(); $this->optimizer = new WPSlug_Optimizer(); add_action("admin_menu", [$this, "addAdminMenu"]); add_action("admin_init", [$this, "registerSettings"]); add_action("admin_enqueue_scripts", [$this, "enqueueScripts"]); add_action("admin_notices", [$this, "showAdminNotices"]); add_action("wp_ajax_wpslug_preview", [$this, "ajaxPreview"]); add_action("wp_ajax_wpslug_test_api", [$this, "ajaxTestApi"]); add_action("post_submitbox_start", [$this, "addPostMetaBox"]); add_filter("bulk_actions-edit-post", [$this, "addBulkAction"]); add_filter("bulk_actions-edit-page", [$this, "addBulkAction"]); add_filter( "handle_bulk_actions-edit-post", [$this, "handleBulkAction"], 10, 3 ); add_filter( "handle_bulk_actions-edit-page", [$this, "handleBulkAction"], 10, 3 ); add_action("admin_notices", [$this, "bulkActionNotice"]); add_action("load-options-permalink.php", [$this, "addPermalinkNotice"]); add_action("admin_head", [$this, "hideDefaultNotices"]); } public function hideDefaultNotices() { if (isset($_GET["page"]) && $_GET["page"] == "wpslug") { echo ""; } } public function addAdminMenu() { add_options_page( __("WPSlug Settings", "wpslug"), __("Slug", "wpslug"), "manage_options", "wpslug", [$this, "displayAdminPage"] ); } public function registerSettings() { register_setting("wpslug_settings", "wpslug_options", [ "type" => "array", "sanitize_callback" => [$this, "validateOptions"], "default" => [], "show_in_rest" => false, ]); add_filter("wp_redirect", [$this, "preventDefaultNotice"], 10, 2); } public function preventDefaultNotice($location, $status) { if (strpos($location, "options-general.php?page=wpslug") !== false) { if (strpos($location, "settings-updated=true") !== false) { return $location; } } return $location; } public function showAdminNotices() { if (isset($_GET["page"]) && $_GET["page"] == "wpslug") { if ( isset($_GET["settings-updated"]) && $_GET["settings-updated"] == "true" ) { $message = __("Settings saved successfully!", "wpslug"); echo '
' . esc_html($message) . "
' . esc_html($error_message) . "
|
|
"
min="0"
max="500"
class="small-text">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"
min="1"
max="30"
class="small-text">
|
|
|
|
|
|
|
"
class="regular-text">
|
|
|
true],
"objects"
);
foreach ($post_types as $post_type) {
$checked =
is_array($options["enabled_post_types"]) &&
in_array(
$post_type->name,
$options["enabled_post_types"]
)
? "checked"
: ""; ?>
true],
"objects"
);
foreach ($taxonomies as $taxonomy) {
$checked =
is_array($options["enabled_taxonomies"]) &&
in_array(
$taxonomy->name,
$options["enabled_taxonomies"]
)
? "checked"
: ""; ?>
|
|
" . sprintf( __("Successfully converted %d slug(s).", "wpslug"), $count ) . "
"; echo "