12, 'show_search' => 'true', 'type' => 'newest', ), $atts, 'arshid6social_members' ); /** @var Components\Members\Members|null $comp */ $comp = ARSHID6SOCIAL()->component( 'members' ); if ( ! $comp ) { return ''; } global $arshid6social_is_page; $arshid6social_is_page = true; $per_page = absint( $atts['per_page'] ); $result = $comp->get_members( array( 'type' => sanitize_key( $atts['type'] ), 'per_page' => $per_page, ) ); return ARSHID6SOCIAL()->template()->get_template( 'members/directory.php', array( 'members' => $result['members'], 'total' => $result['total'], 'per_page' => $per_page, 'show_search' => filter_var( $atts['show_search'], FILTER_VALIDATE_BOOLEAN ), 'block_mode' => true, ), true ); } // ------------------------------------------------------------------------- // [arshid6social_who_to_follow per_page="3" type="newest"] // ------------------------------------------------------------------------- /** * Renders a compact "Who to follow" member list for sidebars. * * Unlike [arshid6social_members] (which is removed on profile pages to avoid * conflict), this shortcode is never removed and renders server-side so * the right sidebar always shows suggested members. * * @param array|string $atts Shortcode attributes. */ public function who_to_follow( $atts ): string { $atts = shortcode_atts( array( 'per_page' => (int) get_option( 'arshid6social_who_to_follow_per_page', 3 ), 'type' => 'newest', ), $atts, 'arshid6social_who_to_follow' ); /** @var Components\Members\Members|null $comp */ $comp = ARSHID6SOCIAL()->component( 'members' ); if ( ! $comp ) { return ''; } $viewer_id = get_current_user_id(); $exclude = $viewer_id ? array( $viewer_id ) : array(); $result = $comp->get_members( array( 'type' => sanitize_key( $atts['type'] ), 'per_page' => absint( $atts['per_page'] ), 'exclude' => $exclude, ) ); if ( empty( $result['members'] ) ) { return ''; } $friends_comp = ARSHID6SOCIAL()->component( 'friends' ); $fallback_avatar = esc_url( get_avatar_url( 0, array( 'default' => 'mm', 'size' => 48, ) ) ); $primary_color = esc_attr( get_option( 'arshid6social_primary_color', '#1d9bf0' ) ); $s_row = 'display:flex;flex-direction:row;align-items:center;gap:12px;padding:8px 16px;'; $s_avtr = 'display:block;flex-shrink:0;width:44px;height:44px;border-radius:50%;overflow:hidden;line-height:0;'; $s_img = 'width:44px;height:44px;max-width:44px;border-radius:50%;object-fit:cover;display:block;'; $s_name = 'flex:1;min-width:0;font-size:14px;font-weight:600;line-height:1.3;color:var(--a6sc-text);text-decoration:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block;'; $icons = array( 'not_friends' => '', 'pending_sent' => '', 'pending_received' => '', 'friends' => '', ); ob_start(); echo '
'; foreach ( $result['members'] as $m ) { if ( (int) $m['id'] === $viewer_id ) { continue; } $status = ( $viewer_id && $friends_comp ) ? $friends_comp->get_friendship_status( $viewer_id, (int) $m['id'] ) : 'not_friends'; $labels = array( 'not_friends' => __( 'Add Friend', '6arshid-social-community' ), 'pending_sent' => __( 'Pending', '6arshid-social-community' ), 'pending_received' => __( 'Accept', '6arshid-social-community' ), 'friends' => __( 'Friends', '6arshid-social-community' ), ); $btn_label = $labels[ $status ] ?? __( 'Add Friend', '6arshid-social-community' ); $btn_icon = $icons[ $status ] ?? $icons['not_friends']; ?>
<?php echo esc_attr( $m['name'] ); ?>
'; return ob_get_clean(); } // ------------------------------------------------------------------------- // [arshid6social_activity per_page="10" show_composer="true" show_stories="true" show_feed="true" scope="site"] // ------------------------------------------------------------------------- /** * Renders the activity feed. * * @param array|string $atts Shortcode attributes. */ public function activity( $atts ): string { $atts = shortcode_atts( array( 'per_page' => 10, 'show_composer' => 'true', 'show_stories' => 'true', 'show_feed' => 'true', 'scope' => 'site', ), $atts, 'arshid6social_activity' ); /** @var Components\Activity\Activity|null $comp */ $comp = ARSHID6SOCIAL()->component( 'activity' ); if ( ! $comp ) { return ''; } global $arshid6social_is_page; $arshid6social_is_page = true; $per_page = absint( $atts['per_page'] ); $show_composer = filter_var( $atts['show_composer'], FILTER_VALIDATE_BOOLEAN ); $show_stories = filter_var( $atts['show_stories'], FILTER_VALIDATE_BOOLEAN ); $show_feed = filter_var( $atts['show_feed'], FILTER_VALIDATE_BOOLEAN ); $scope = sanitize_key( $atts['scope'] ); $nonce = wp_create_nonce( 'arshid6social_activity' ); ob_start(); ?>
component( 'stories' ); if ( $stories_comp ) { $viewer_id = get_current_user_id(); $stories = $stories_comp->get_tray( $viewer_id ); // Show tray if viewer is logged in (to add story) OR if there are visible stories. if ( is_user_logged_in() || ! empty( $stories ) ) { \Arshid6Social\Template_Loader::instance()->get_template( 'stories/tray.php', array( 'stories' => $stories, 'viewer_id' => $viewer_id, 'stories_obj' => $stories_comp, ) ); } } } ?>
9, 'show_search' => 'true', 'show_create' => 'true', 'status' => 'public', ), $atts, 'arshid6social_groups' ); /** @var Components\Groups\Groups|null $comp */ $comp = ARSHID6SOCIAL()->component( 'groups' ); if ( ! $comp ) { return ''; } global $arshid6social_is_page; $arshid6social_is_page = true; $per_page = absint( $atts['per_page'] ); $status = sanitize_key( $atts['status'] ); $statuses = ( 'all' === $status ) ? array( 'public', 'private' ) : array( 'public' ); $result = $comp->get_groups( array( 'status' => $statuses, 'per_page' => $per_page, ) ); return ARSHID6SOCIAL()->template()->get_template( 'groups/directory.php', array( 'groups' => $result['groups'], 'total' => $result['total'], 'per_page' => $per_page, 'show_search' => filter_var( $atts['show_search'], FILTER_VALIDATE_BOOLEAN ), 'show_create_button' => filter_var( $atts['show_create'], FILTER_VALIDATE_BOOLEAN ), 'block_mode' => true, ), true ); } // ------------------------------------------------------------------------- // [arshid6social_messages] // ------------------------------------------------------------------------- /** * Renders the private messages inbox. * * @param array|string $atts Shortcode attributes. */ public function messages( $atts ): string { if ( ! is_user_logged_in() ) { return '
' . wp_kses( sprintf( /* translators: %s: login URL */ __( 'Please log in to view your messages.', '6arshid-social-community' ), esc_url( wp_login_url( get_permalink() ) ) ), array( 'a' => array( 'href' => array() ) ) ) . '
'; } /** @var Components\Messages\Messages|null $comp */ $comp = ARSHID6SOCIAL()->component( 'messages' ); if ( ! $comp ) { return ''; } global $arshid6social_is_page; $arshid6social_is_page = true; $thread_id = 0; $compose_recipient_id = 0; // phpcs:disable WordPress.Security.NonceVerification $thread_uid = sanitize_text_field( wp_unslash( $_GET['thread'] ?? '' ) ); if ( $thread_uid ) { $thread_id = \Arshid6Social\Components\Messages\Messages::thread_id_from_uid( $thread_uid ); } $user_uid = sanitize_text_field( wp_unslash( $_GET['to'] ?? '' ) ); if ( $user_uid ) { $compose_recipient_id = \Arshid6Social\Components\Messages\Messages::user_id_from_uid( $user_uid ); } // phpcs:enable return ARSHID6SOCIAL()->template()->get_template( 'messages/inbox.php', array( 'thread_id' => $thread_id, 'compose_recipient_id' => $compose_recipient_id, ), true ); } // ------------------------------------------------------------------------- // [arshid6social_notifications] // ------------------------------------------------------------------------- /** * Renders the current user's full notifications page. * * @param array|string $atts Shortcode attributes (none currently). */ public function notifications( $atts ): string { if ( ! is_user_logged_in() ) { return '
' . wp_kses( sprintf( /* translators: %s: login URL */ __( 'Please log in to view your notifications.', '6arshid-social-community' ), esc_url( wp_login_url( get_permalink() ) ) ), array( 'a' => array( 'href' => array() ) ) ) . '
'; } global $arshid6social_is_page; $arshid6social_is_page = true; return ARSHID6SOCIAL()->template()->get_template( 'notifications/page.php', array(), true ); } // ------------------------------------------------------------------------- // [arshid6social_profile id="42"] or [arshid6social_profile slug="john-doe"] // ------------------------------------------------------------------------- /** * Renders a user profile card inline. * * @param array|string $atts Shortcode attributes. */ public function profile( $atts ): string { $atts = shortcode_atts( array( 'id' => 0, 'slug' => '', ), $atts, 'arshid6social_profile' ); $user_id = absint( $atts['id'] ); if ( ! $user_id && $atts['slug'] ) { $user = get_user_by( 'slug', sanitize_title( $atts['slug'] ) ); if ( $user ) { $user_id = $user->ID; } } if ( ! $user_id ) { $user_id = get_current_user_id(); } if ( ! $user_id ) { return ''; } /** @var Components\Members\Members|null $comp */ $comp = ARSHID6SOCIAL()->component( 'members' ); if ( ! $comp ) { return ''; } global $arshid6social_is_page; $arshid6social_is_page = true; $member = $comp->format_member( get_userdata( $user_id ), get_current_user_id() ?: null ); return ARSHID6SOCIAL()->template()->get_template( 'members/profile.php', array( 'member' => $member, 'profile_user' => get_userdata( $user_id ), ), true ); } // ------------------------------------------------------------------------- // Cinematic splash wrapper helpers (shared by all auth pages) // ------------------------------------------------------------------------- /** * Enqueues the (locally bundled) fonts stylesheet used by the cinematic splash pages. * * Instrument Serif and Inter are self-hosted under assets/fonts/ so the plugin * never makes a request to fonts.googleapis.com. */ private function enqueue_splash_fonts(): void { $handle = 'arshid6social-splash-fonts'; if ( ! wp_style_is( $handle, 'enqueued' ) ) { wp_enqueue_style( $handle, ARSHID6SOCIAL_ASSETS_URL . 'css/splash-fonts.css', array(), ARSHID6SOCIAL_VERSION ); } } /** * Returns the background media URL for the splash. * Priority: admin-uploaded option → CDN default video → bundled plugin asset. */ private function splash_video_url(): string { $custom = (string) get_option( 'arshid6social_home_video_url', '' ); if ( $custom ) { return apply_filters( 'arshid6social_home_video_url', $custom ); } $bundled = plugins_url( 'assets/videos/home-bg.mp4', ARSHID6SOCIAL_PLUGIN_FILE ); return apply_filters( 'arshid6social_home_video_url', $bundled ); } /** Returns 'image' when the admin uploaded a still image, 'video' otherwise. */ private function splash_bg_type(): string { if ( ! get_option( 'arshid6social_home_video_url', '' ) ) { return 'video'; } $type = (string) get_option( 'arshid6social_home_bg_type', 'video' ); return in_array( $type, array( 'video', 'image' ), true ) ? $type : 'video'; } // ------------------------------------------------------------------------- // [arshid6social_dashboard] // ------------------------------------------------------------------------- /** * Dashboard placeholder — redirect is handled by template_redirect (see Plugin class). * This shortcode outputs nothing; the redirect fires before rendering. */ public function dashboard( $atts ): string { return ''; } // ------------------------------------------------------------------------- // [arshid6social_marketplace] // ------------------------------------------------------------------------- /** * Renders the full Marketplace homepage: search bar, category grid, listings. * * @param array|string $atts Shortcode attributes. */ public function marketplace( $atts ): string { if ( ! get_option( 'arshid6social_marketplace_enabled', false ) ) { return ''; } global $arshid6social_is_page, $wpdb; $arshid6social_is_page = true; // Route sub-views via ?action= query param. $action = sanitize_key( wp_unslash( $_GET['action'] ?? '' ) ); // phpcs:ignore WordPress.Security.NonceVerification if ( 'post' === $action || 'edit' === $action ) { return $this->listing_form( $atts ); } if ( 'view' === $action ) { return $this->listing_detail(); } // Guests: check access setting. $allow_guests = (bool) get_option( 'arshid6social_marketplace_allow_guests', true ); if ( ! $allow_guests && ! is_user_logged_in() ) { return '
' . wp_kses( sprintf( /* translators: %s: login URL */ __( 'Please log in to browse the Marketplace.', '6arshid-social-community' ), esc_url( wp_login_url( get_permalink() ) ) ), array( 'a' => array( 'href' => array() ) ) ) . '
'; } // Load top-level categories. $categories = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery "SELECT * FROM {$wpdb->prefix}arshid6social_categories WHERE parent_id = 0 ORDER BY sort_order ASC, id ASC" ) ?: array(); return ARSHID6SOCIAL()->template()->get_template( 'marketplace/main.php', array( 'categories' => $categories, 'current_user' => wp_get_current_user(), ), true ); } // ------------------------------------------------------------------------- // [arshid6social_listing_form] // ------------------------------------------------------------------------- /** * Renders the Create / Edit Listing wizard. * Requires the user to be logged in. */ public function listing_form( $atts ): string { if ( ! get_option( 'arshid6social_marketplace_enabled', false ) ) { return ''; } if ( ! is_user_logged_in() ) { return '
' . wp_kses( sprintf( /* translators: %s: login URL */ __( 'Please log in to post a listing.', '6arshid-social-community' ), esc_url( wp_login_url( get_permalink() ) ) ), array( 'a' => array( 'href' => array() ) ) ) . '
'; } // Verified-only guard (soft check — AJAX will enforce too). if ( get_option( 'arshid6social_marketplace_require_verified', false ) ) { $verification = ARSHID6SOCIAL()->component( 'verification' ); if ( $verification && ! $verification->is_verified( get_current_user_id() ) ) { return '
' . esc_html__( 'Only verified users can post listings.', '6arshid-social-community' ) . '
'; } } $categories = Components\Marketplace\Marketplace_Listings::get_category_select_options(); $max_photos = (int) get_option( 'arshid6social_marketplace_max_photos', 10 ); $max_mb = (int) get_option( 'arshid6social_marketplace_max_photo_size_mb', 5 ); return ARSHID6SOCIAL()->template()->get_template( 'marketplace/listing-form.php', array( 'categories' => $categories, 'max_photos' => $max_photos, 'max_mb' => $max_mb, ), true ); } // ------------------------------------------------------------------------- // Listing detail page (internal — routed from marketplace shortcode) // ------------------------------------------------------------------------- /** * Renders a single listing's detail page. * Routed by marketplace() when ?action=view&id={uid}. */ private function listing_detail(): string { global $wpdb; $uid = sanitize_key( wp_unslash( $_GET['id'] ?? '' ) ); // phpcs:ignore WordPress.Security.NonceVerification if ( ! $uid ) { return '

' . esc_html__( 'Listing not found.', '6arshid-social-community' ) . '

'; } $current_user_id = get_current_user_id(); // Look up by uid first; fall back to numeric id for old rows if ( ctype_digit( $uid ) ) { $listing = $wpdb->get_row( $wpdb->prepare( // phpcs:ignore WordPress.DB.DirectDatabaseQuery "SELECT * FROM {$wpdb->prefix}arshid6social_listings WHERE id = %d", (int) $uid ) ); } else { $listing = $wpdb->get_row( $wpdb->prepare( // phpcs:ignore WordPress.DB.DirectDatabaseQuery "SELECT * FROM {$wpdb->prefix}arshid6social_listings WHERE uid = %s", $uid ) ); } if ( ! $listing ) { return '

' . esc_html__( 'Listing not found.', '6arshid-social-community' ) . '

'; } // Status gate — guests/other users can only see active listings $is_owner = ( $current_user_id && (int) $listing->seller_id === $current_user_id ); $is_admin = current_user_can( 'manage_options' ); if ( ! in_array( $listing->status, array( 'active', 'sold' ), true ) && ! $is_owner && ! $is_admin ) { return '

' . esc_html__( 'This listing is not available.', '6arshid-social-community' ) . '

'; } // Increment view counter (skip for owner) if ( ! $is_owner ) { $wpdb->query( $wpdb->prepare( // phpcs:ignore WordPress.DB.DirectDatabaseQuery "UPDATE {$wpdb->prefix}arshid6social_listings SET views = views + 1 WHERE id = %d", (int) $listing->id ) ); } $photos = Components\Marketplace\Marketplace_Listings::get_photos( (int) $listing->id ); $seller = get_userdata( (int) $listing->seller_id ); $cat = $listing->category_id ? $wpdb->get_row( $wpdb->prepare( // phpcs:ignore WordPress.DB.DirectDatabaseQuery "SELECT name, icon FROM {$wpdb->prefix}arshid6social_categories WHERE id = %d", $listing->category_id ) ) : null; $base_url = get_permalink( (int) get_option( 'arshid6social_page_marketplace', 0 ) ) ?: home_url( '/' . get_option( 'arshid6social_marketplace_slug', 'marketplace' ) . '/' ); return ARSHID6SOCIAL()->template()->get_template( 'marketplace/listing-single.php', array( 'listing' => $listing, 'photos' => $photos, 'seller' => $seller, 'category' => $cat, 'is_owner' => $is_owner, 'is_admin' => $is_admin, 'current_user_id' => $current_user_id, 'base_url' => $base_url, ), true ); } // ------------------------------------------------------------------------- // [arshid6social_my_listings] // ------------------------------------------------------------------------- /** Renders the current user's listings dashboard. */ public function my_listings( $atts ): string { if ( ! get_option( 'arshid6social_marketplace_enabled', false ) || ! is_user_logged_in() ) { return ''; } // Implemented in Step 3. return '

' . esc_html__( 'My listings coming soon.', '6arshid-social-community' ) . '

'; } // ------------------------------------------------------------------------- // [arshid6social_saved_listings] // ------------------------------------------------------------------------- /** Renders the current user's saved/favorited listings. */ public function saved_listings( $atts ): string { if ( ! get_option( 'arshid6social_marketplace_enabled', false ) || ! is_user_logged_in() ) { return ''; } // Implemented in Step 7. return '

' . esc_html__( 'Saved listings coming soon.', '6arshid-social-community' ) . '

'; } // ------------------------------------------------------------------------- // [arshid6social_seller_listings user_id="0"] // ------------------------------------------------------------------------- /** Renders listings by a specific seller (for seller profile mini-page). */ public function seller_listings( $atts ): string { if ( ! get_option( 'arshid6social_marketplace_enabled', false ) ) { return ''; } $atts = shortcode_atts( array( 'user_id' => 0 ), $atts, 'arshid6social_seller_listings' ); $user_id = absint( $atts['user_id'] ) ?: get_current_user_id(); if ( ! $user_id ) { return ''; } // Implemented in Step 8. return '

' . esc_html__( 'Seller listings coming soon.', '6arshid-social-community' ) . '

'; } // ------------------------------------------------------------------------- // [arshid6social_ads placement="sidebar" limit="0"] // ------------------------------------------------------------------------- /** * Renders active ads for the given placement context. * * @param array|string $atts Shortcode attributes. */ public function ads( $atts ): string { $atts = shortcode_atts( array( 'placement' => 'sidebar', 'limit' => 0, ), $atts, 'arshid6social_ads' ); return Components\Ads\Ads::render_sidebar_ads( absint( $atts['limit'] ) ); } // ------------------------------------------------------------------------- // [arshid6social_home] // ------------------------------------------------------------------------- /** * Renders the Social-style social network homepage splash: fullscreen looping video background, * glassmorphic login card, and Instrument Serif typography. * Logged-in users are redirected to the activity feed by Plugin::handle_auth_page_redirects(). */ public function home( $atts ): string { if ( is_user_logged_in() ) { return ''; } $redirect = home_url( '/activity/' ); $register_url = get_option( 'users_can_register' ) ? wp_registration_url() : ''; $forgot_url = wp_lostpassword_url(); $login_url = wp_login_url( $redirect ); $site_name = get_bloginfo( 'name' ); $home_logo_id = (int) get_option( 'arshid6social_logo_desktop', 0 ); $home_logo_url = $home_logo_id ? wp_get_attachment_image_url( $home_logo_id, 'full' ) : ''; if ( ! $home_logo_url && has_custom_logo() ) { $home_logo_url = (string) wp_get_attachment_image_url( (int) get_theme_mod( 'custom_logo' ), 'full' ); } $bg_url = $this->splash_video_url(); $bg_type = $this->splash_bg_type(); ob_start(); ?> enqueue_splash_fonts(); ?>