Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • <?php
    /*
    Plugin Name: Events Config
    Description: Adds a custom HTML section before the events calendar.
    Version: 1.0
    Author: Codelyfe.github.io
    */

    // Register a new admin menu for the Events Config settings
    add_action('admin_menu', 'events_config_menu');

    function events_config_menu() {
    add_menu_page('Events Config', 'Events Config', 'manage_options', 'events-config', 'events_config_page', 'dashicons-calendar-alt');
    }

    // Display the Events Config settings page
    function events_config_page() {
    ?>
    <div class="wrap">
    <h1>Events Config</h1>
    <form method="post" action="options.php">
    <?php
    settings_fields('events_config_options');
    do_settings_sections('events-config');
    submit_button();
    ?>
    </form>
    </div>
    <?php
    }

    // Register and define the settings
    add_action('admin_init', 'events_config_settings');

    function events_config_settings() {
    register_setting('events_config_options', 'events_html');

    add_settings_section('events_config_main', 'Events Config Settings', 'events_config_section_text', 'events-config');

    add_settings_field('events_html', 'Event HTML Content', 'events_html_input', 'events-config', 'events_config_main');
    }

    function events_config_section_text() {
    echo '<p>Enter the custom HTML content for the events section.</p>';
    }

    function events_html_input() {
    $html = get_option('events_html');
    echo '<textarea name="events_html" style="width: 100%; height: 200px;">' . esc_textarea($html) . '</textarea>';
    }

    // Add custom HTML before the events HTML
    add_filter('tribe_events_before_html', 'events_custom_content');

    function events_custom_content($content) {
    $html = get_option('events_html');
    if (!empty($html)) {
    $content .= '<div style="margin: 0 auto; width: 50%;">' . $html . '</div><br/><br/>';
    }
    return $content;
    }

    If anyone is looking for a fix. You can use this code. Create a new folder and call it “eventeditor”. Then create a file called “eventconfig101.php”. Place the code above inside the PHP file. Zip the folder and upload the zip as a plugin.

    What does it do? It adds a new menu item “Event Config” for you to add custom HTML to the top of all the event pages.

    • This reply was modified 4 months, 1 week ago by codelyfe.
    Thread Starter codelyfe

    (@codelyfe)

    Figured it out! Thank you!

    Thread Starter codelyfe

    (@codelyfe)

    I see the “shipping and billing addresses” link but it goes to a 404?

    • This reply was modified 1 year, 7 months ago by codelyfe.
    Plugin Author codelyfe

    (@codelyfe)

    Settings are within the Widget section of WordPress.

Viewing 4 replies - 1 through 4 (of 4 total)