id, 'arshid6social-pages' ) ) { return; } wp_add_inline_style( 'arshid6social-admin', '.arshid6social-pages-table{width:100%;border-collapse:collapse;margin-block-start:1.5rem}.arshid6social-pages-table th,.arshid6social-pages-table td{padding:.75rem 1rem;border-bottom:1px solid #e2e8f0;text-align:left}.arshid6social-pages-table th{background:#f8fafc;font-weight:600;font-size:.8125rem;text-transform:uppercase;letter-spacing:.04em;color:#475569}.arshid6social-pages-table tr:last-child td{border-bottom:none}.arshid6social-shortcode-box{display:flex;align-items:center;gap:.5rem}.arshid6social-shortcode-code{font-family:monospace;background:#f1f5f9;border:1px solid #cbd5e1;border-radius:4px;padding:.25rem .625rem;font-size:.875rem;color:#1e40af}.arshid6social-copy-btn{cursor:pointer;background:#e0e7ff;border:none;border-radius:4px;padding:.25rem .625rem;font-size:.8125rem;color:#3730a3}.arshid6social-copy-btn:hover{background:#c7d2fe}.arshid6social-status-ok{color:#16a34a;font-weight:600}.arshid6social-status-missing{color:#dc2626;font-weight:600}.arshid6social-recreate-btn{background:#fef9c3;border:1px solid #fde047;border-radius:4px;padding:.25rem .75rem;cursor:pointer;font-size:.8125rem;color:#713f12}.arshid6social-sc-ref{margin-block-start:2rem}.arshid6social-sc-ref table{width:100%;border-collapse:collapse}.arshid6social-sc-ref th,.arshid6social-sc-ref td{padding:.625rem 1rem;border-bottom:1px solid #e2e8f0;text-align:left;font-size:.875rem}.arshid6social-sc-ref th{background:#f8fafc;font-weight:600;color:#475569}.arshid6social-sc-ref code{font-family:monospace;background:#f1f5f9;padding:.2rem .5rem;border-radius:3px;color:#1e40af}.arshid6social-assign-select{font-size:.875rem;border-radius:4px;border:1px solid #cbd5e1;padding:.3rem .5rem}.arshid6social-assign-view{font-size:1rem;text-decoration:none;opacity:.7}.arshid6social-assign-view:hover{opacity:1}' ); } /** * Renders the Pages & Shortcodes admin screen. */ public function render(): void { $pages = $this->get_page_definitions(); ?>

render_pages_table( $pages ); ?> render_shortcode_reference(); ?>
'publish', 'sort_column' => 'post_title', 'sort_order' => 'ASC', ) ); ?> $page ) : ?> post_status; $page_url = $is_ok ? get_permalink( $wp_page->ID ) : ''; ?>

✓ ✗
🔗
—
'[arshid6social_members]', 'attrs' => 'per_page="12" show_search="true" type="newest|active|alphabetical"', 'desc' => __( 'Displays the member directory with search bar and pagination.', '6arshid-social-community' ), 'example' => '[arshid6social_members per_page="20" type="active"]', ), array( 'code' => '[arshid6social_activity]', 'attrs' => 'per_page="10" show_composer="true" scope="site|friends|self"', 'desc' => __( 'Displays an activity feed with infinite scroll. Logged-in users see a post composer.', '6arshid-social-community' ), 'example' => '[arshid6social_activity scope="friends" show_composer="true"]', ), array( 'code' => '[arshid6social_groups]', 'attrs' => 'per_page="9" show_search="true" show_create="true" status="public|all"', 'desc' => __( 'Displays the group directory. Logged-in users see a "Create Group" button.', '6arshid-social-community' ), 'example' => '[arshid6social_groups per_page="12" status="public"]', ), array( 'code' => '[arshid6social_messages]', 'attrs' => '—', 'desc' => __( 'Displays the private messages inbox. Redirects guests to login.', '6arshid-social-community' ), 'example' => '[arshid6social_messages]', ), array( 'code' => '[arshid6social_notifications]', 'attrs' => '—', 'desc' => __( 'Displays the current user\'s notifications feed with mark-all-read and customizable preferences. Redirects guests to login.', '6arshid-social-community' ), 'example' => '[arshid6social_notifications]', ), array( 'code' => '[arshid6social_profile]', 'attrs' => 'id="0" slug=""', 'desc' => __( 'Displays a user profile. Uses the current logged-in user if no id or slug is given.', '6arshid-social-community' ), 'example' => '[arshid6social_profile id="5"]', ), array( 'code' => '[arshid6social_bookmarks]', 'attrs' => 'per_page="20"', 'desc' => __( 'Displays the current user\'s saved posts and bookmarked marketplace listings.', '6arshid-social-community' ), 'example' => '[arshid6social_bookmarks per_page="20"]', ), ); ?>

__( 'Security check failed.', '6arshid-social-community' ) ), 403 ); } if ( ! current_user_can( 'arshid6social_manage_settings' ) ) { wp_send_json_error( array( 'message' => __( 'Security check failed.', '6arshid-social-community' ) ), 403 ); } $page_key = sanitize_key( $_POST['page_key'] ?? '' ); // phpcs:ignore WordPress.Security.NonceVerification $pages = $this->get_page_definitions(); if ( ! isset( $pages[ $page_key ] ) ) { wp_send_json_error( array( 'message' => __( 'Unknown page key.', '6arshid-social-community' ) ) ); } $page = $pages[ $page_key ]; $page_id = wp_insert_post( array( 'post_title' => $page['title'], 'post_name' => $page['slug'], 'post_content' => $page['shortcode'], 'post_status' => 'publish', 'post_type' => 'page', 'comment_status' => 'closed', 'ping_status' => 'closed', ) ); if ( is_wp_error( $page_id ) ) { wp_send_json_error( array( 'message' => $page_id->get_error_message() ) ); } update_option( $page['option'], $page_id ); wp_send_json_success( array( 'page_id' => $page_id ) ); } /** * AJAX: Assigns an existing WordPress page to a plugin page slot. */ public function ajax_assign_page(): void { if ( ! check_ajax_referer( 'arshid6social_assign_page', 'nonce', false ) ) { wp_send_json_error( array( 'message' => __( 'Security check failed.', '6arshid-social-community' ) ), 403 ); } if ( ! current_user_can( 'arshid6social_manage_settings' ) ) { wp_send_json_error( array( 'message' => __( 'Security check failed.', '6arshid-social-community' ) ), 403 ); } $page_key = sanitize_key( $_POST['page_key'] ?? '' ); // phpcs:ignore WordPress.Security.NonceVerification $page_id = absint( $_POST['page_id'] ?? 0 ); // phpcs:ignore WordPress.Security.NonceVerification $pages = $this->get_page_definitions(); if ( ! isset( $pages[ $page_key ] ) ) { wp_send_json_error( array( 'message' => __( 'Unknown page key.', '6arshid-social-community' ) ) ); } if ( $page_id && ! get_post( $page_id ) ) { wp_send_json_error( array( 'message' => __( 'Page not found.', '6arshid-social-community' ) ) ); } update_option( $pages[ $page_key ]['option'], $page_id ); wp_send_json_success( array( 'page_id' => $page_id ) ); } /** * Returns the canonical page definition list. * * Components can append their own pages via the arshid6social_page_definitions filter. * * @return array */ private function get_page_definitions(): array { $pages = array( 'members' => array( 'title' => __( 'Members', '6arshid-social-community' ), 'slug' => 'members', 'shortcode' => '[arshid6social_members]', 'option' => 'arshid6social_page_members', 'description' => __( 'Member directory with search and filters', '6arshid-social-community' ), ), 'activity' => array( 'title' => __( 'Activity', '6arshid-social-community' ), 'slug' => 'activity', 'shortcode' => '[arshid6social_activity]', 'option' => 'arshid6social_page_activity', 'description' => __( 'Site-wide activity feed', '6arshid-social-community' ), ), 'groups' => array( 'title' => __( 'Groups', '6arshid-social-community' ), 'slug' => 'groups', 'shortcode' => '[arshid6social_groups]', 'option' => 'arshid6social_page_groups', 'description' => __( 'Group directory with join buttons', '6arshid-social-community' ), ), 'messages' => array( 'title' => __( 'Messages', '6arshid-social-community' ), 'slug' => 'messages', 'shortcode' => '[arshid6social_messages]', 'option' => 'arshid6social_page_messages', 'description' => __( 'Private messaging inbox', '6arshid-social-community' ), ), 'notifications' => array( 'title' => __( 'Notifications', '6arshid-social-community' ), 'slug' => 'notifications', 'shortcode' => '[arshid6social_notifications]', 'option' => 'arshid6social_page_notifications', 'description' => __( 'Personal notifications feed with customize options', '6arshid-social-community' ), ), ); /** * Filters the list of auto-managed plugin pages. * * Each entry is keyed by a short slug and has: title, slug, shortcode, option, description. * Use this hook to register additional component pages (e.g. Marketplace). * * @param array $pages */ return apply_filters( 'arshid6social_page_definitions', $pages ); } }