Sunday, December 7, 2025

17 Auto pages Manu

 Prompt:

can you create plugin to add menu at top for pages like login, contactus, tutorials, projects, equivalence. Create the above pages with some sample text. Add the page background as lucid dark theme radiant and add contrast some sample content text

Here is a single-file WordPress plugin that:

  • Creates top menu with pages: Login, ContactUs, Tutorials, Projects, Equivalence

  • Auto-creates these pages with sample text

  • Applies a lucid dark radiant background and contrasting text through plugin-injected CSS

  • Keeps the code clean and simple


WordPress Plugin: Auto Menu + Pages + Dark Theme Background

Create a folder:

wp-content/plugins/auto-menu-pages

Inside it create a file:

auto-menu-pages.php

Paste the following:

<?php
/*
Plugin Name: Auto Menu & Sample Pages
Description: Creates top menu with sample pages and applies dark radiant background.
Version: 1.0 Dated 6.12.2025
Author: RMC
*/

// Create pages on activation
function amp_create_pages() {
    $pages = [
        'Login' => 'This is the login page. Add your form here.',
        'ContactUs' => 'This is the contact page. Students can reach you here.',
        'Tutorials' => 'This page lists all tutorials. Add your lessons here.',
        'Projects' => 'This page displays projects. Add sample student projects here.',
        'Equivalence' => 'This page explains equivalence and related academic details.'
    ];

    $created_page_ids = [];

    foreach ($pages as $title => $content) {
        $page_check = get_page_by_title($title);
        if (!isset($page_check->ID)) {
            $page_id = wp_insert_post([
                'post_title'   => $title,
                'post_content' => $content,
                'post_status'  => 'publish',
                'post_type'    => 'page'
            ]);
            $created_page_ids[] = $page_id;
        } else {
            $created_page_ids[] = $page_check->ID;
        }
    }

    // Create menu
    $menu_name = 'Top Menu Auto';
    $menu_exists = wp_get_nav_menu_object($menu_name);

    if (!$menu_exists) {
        $menu_id = wp_create_nav_menu($menu_name);
        foreach ($created_page_ids as $pid) {
            wp_update_nav_menu_item($menu_id, 0, [
                'menu-item-title'  => get_the_title($pid),
                'menu-item-object' => 'page',
                'menu-item-object-id' => $pid,
                'menu-item-type'   => 'post_type',
                'menu-item-status' => 'publish'
            ]);
        }

        // Assign menu to "primary" location
        $locations = get_theme_mod('nav_menu_locations');
        $locations['primary'] = $menu_id;
        set_theme_mod('nav_menu_locations', $locations);
    }
}
register_activation_hook(__FILE__, 'amp_create_pages');

// Apply dark radiant background
function amp_dark_background_styles() {
    echo "
    <style>
        body {
            background: radial-gradient(circle at top, #1a1a1a, #000000);
            color: #e6e6e6;
            font-size: 18px;
            line-height: 1.6;
        }
        .entry-content, .page-content, article {
            background: rgba(255, 255, 255, 0.05);
            padding: 20px;
            border-radius: 10px;
            backdrop-filter: blur(4px);
        }
        a { color: #66ccff; }
        a:hover { color: #33aaff; }
    </style>
    ";
}
add_action('wp_head', 'amp_dark_background_styles');


How It Works

✔ Creates pages automatically

Each page receives simple sample content.

✔ Creates a top navigation menu

Menu is assigned to theme’s Primary location.

✔ Adds a lucid dark radiant background

Dark smooth gradient
Subtle glass-blur box for page content
Contrast text for readability


💡 How to Install

  1. Create folder:
    wp-content/plugins/auto-menu-pages/

  2. Create file:
    auto-menu-pages.php

  3. Paste code

  4. Go to WordPress Admin → Plugins

  5. Activate Auto Menu & Sample Pages



No comments:

Post a Comment

17 Auto pages Manu

 Prompt: can you create plugin to add menu at top for pages like login, contactus, tutorials, projects, equivalence. Create the above pages ...