$action ) { $type = sanitize_key( $action['type'] ?? 'external_link' ); if ( ! in_array( $type, array( 'copy_markdown', 'view_markdown', 'external_link' ), true ) ) { $type = 'external_link'; } $actions[] = array( 'id' => sanitize_key( $action['id'] ?? 'action_' . $idx ), 'enabled' => ! empty( $action['enabled'] ), 'label' => sanitize_text_field( $action['label'] ?? '' ), 'icon' => sanitize_text_field( $action['icon'] ?? '' ), 'type' => $type, 'link' => esc_url_raw( $action['link'] ?? '' ), 'order' => absint( $action['order'] ?? $idx ), ); } usort( $actions, fn( $a, $b ) => $a['order'] <=> $b['order'] ); } $sanitized['actions'] = $actions; return $sanitized; } /** * Enqueue admin assets. * * @param string $hook Current admin page hook. */ public static function enqueue_admin_assets( $hook ) { if ( 'settings_page_ajwa-settings' !== $hook ) { return; } wp_enqueue_media(); wp_enqueue_script( 'jquery-ui-sortable' ); wp_enqueue_style( 'ajwa-admin', AJWA_PLUGIN_URL . 'admin/admin.css', array(), AJWA_VERSION ); wp_enqueue_script( 'ajwa-admin', AJWA_PLUGIN_URL . 'admin/admin.js', array( 'jquery', 'jquery-ui-sortable' ), AJWA_VERSION, true ); wp_localize_script( 'ajwa-admin', 'ajwaAdmin', array( 'nonce' => wp_create_nonce( 'ajwa_admin_nonce' ), 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'default_icon' => AJWA_PLUGIN_URL . 'assets/icons/default.svg', ) ); } /** * Render the settings page. */ public static function render_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $settings = ajwa_get_settings(); $post_types = get_post_types( array( 'public' => true ), 'objects' ); $shortcode = '[ajwa_widget]'; ?>