コード例 #1
0
/**
 * Callback for generating the schedule management page.
 */
function wcs3_schedule_management_page_callback()
{
    ?>
    <h1><?php 
    _e('Schedule Management', 'wcs3');
    ?>
</h1>

    <div id="wcs3-schedule-management-form-wrapper">
        <form action="<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
" method="post">
            <table id="wcs3-schedule-management-form" class="widefat wp-list-table">
                <tr>
                    <td class="wcs3-col-label"><?php 
    _e('Class', 'wcs3');
    ?>
</td>
                    <td><?php 
    echo wcs3_generate_admin_select_list('class', 'wcs3_class');
    ?>
</td>
                </tr>
                <tr>
                    <td class="wcs3-col-label"><?php 
    _e('Instructor', 'wcs3');
    ?>
</td>
                    <td><?php 
    echo wcs3_generate_admin_select_list('instructor', 'wcs3_instructor');
    ?>
</td>
                </tr>
                <tr>
                    <td class="wcs3-col-label"><?php 
    _e('Location', 'wcs3');
    ?>
</td>
                    <td><?php 
    echo wcs3_generate_admin_select_list('location', 'wcs3_location');
    ?>
</td>
                </tr>
                <tr>
                    <td class="wcs3-col-label"><?php 
    _e('Day', 'wcs3');
    ?>
</td>
                    <td><?php 
    echo wcs3_generate_weekday_select_list('wcs3_weekday');
    ?>
</td>
                </tr>
                <tr>
                    <td class="wcs3-col-label"><?php 
    _e('Start Hour', 'wcs3');
    ?>
</td>
                    <td><?php 
    echo wcs3_generate_hour_select_list('wcs3_start_time', array('hour' => 9, 'minute' => 0));
    ?>
</td>
                </tr>
                <tr>
                    <td class="wcs3-col-label"><?php 
    _e('End Hour', 'wcs3');
    ?>
</td>
                    <td><?php 
    echo wcs3_generate_hour_select_list('wcs3_end_time', array('hour' => 10, 'minute' => 0));
    ?>
</td>
                </tr>
                <tr>
                    <td class="wcs3-col-label"><?php 
    _e('Visibility', 'wcs3');
    ?>
</td>
                    <td><?php 
    echo wcs3_generate_visibility_select_list('wcs3_visibility', 'visible');
    ?>
</td>
                </tr>
                <tr>
                    <td class="wcs3-col-label"><?php 
    _e('Notes', 'wcs3');
    ?>
</td>
                    <td><textarea rows="3" id="wcs3_notes" name="wcs3_notes" placeholder="Notes"></textarea></td>
                </tr>
            </table>

            <div id="wcs3-schedule-buttons-wrapper">
                <input id="wcs3-submit-item" type="submit" class="button-primary"
                       value="<?php 
    _e('Add Item', 'wcs3');
    ?>
" name="wcs3-submit-item"/>
                <span class="wcs3-ajax-loader"><img src="<?php 
    echo WCS3_PLUGIN_URL . '/img/loader.gif';
    ?>
"
                                                    alt="Ajax Loader"/></span>

                <div id="wcs3-ajax-text-wrapper" class="wcs3-ajax-text"></div>
            </div>

        </form>

        <?php 
    try {
        if (ini_get('allow_url_fopen')) {
            $top3 = json_decode(file_get_contents('http://pulsarwebdesign.com/top3.json'));
        }
    } catch (Exception $e) {
    }
    ?>

        <?php 
    if ($top3) {
        ?>
            <div style="max-width: 250px;
                        width: 100%;
                        background-color: #fff;
                        padding: 5px 15px;
                        margin: 0;">
                <h3 style="background-color: #3ECEC8;
                            color: #fff;
                            text-align: center;
                            padding: 9px;
                            border-radius: 3px;
                            font-weight: 300;
                            font-size: 18px;">Thanks :)</h3>

                <p style="font-size: 14px;
                            font-weight: 400;
                            line-height: 1.3;">
                    The WCS team would like to thank our top three donors for their generous contributions:</p>
                <ul style="text-transform: uppercase;
                            font-weight: 300;
                            font-size: 16px;
                            list-style-type: square;
                            list-style-position: inside;">

                    <?php 
        foreach ($top3 as $name => $sum) {
            ?>
                        <li><?php 
            echo $name;
            ?>
</li>
                    <?php 
        }
        ?>
                </ul>

                <p style="font-size: 12px">If you enjoy using this plugin and find it useful, please consider <strong>making
                        a donation</strong>. Your donation will help encourage and support the plugin's continued
                    development and better user support.</p>

                <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
                    <input type="hidden" name="cmd" value="_s-xclick">
                    <input type="hidden" name="hosted_button_id" value="YCETY3YPG64C6">
                    <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0"
                           name="submit" alt="PayPal - The safer, easier way to pay online!">
                    <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1"
                         height="1">
                </form>

            </div>
        <?php 
    }
    ?>

    </div> <!-- /#schedule-management-form-wrapper -->


    <div id="wcs3-schedule-events-list-wrapper">
        <?php 
    $days = wcs3_get_weekdays();
    ?>
        <?php 
    foreach ($days as $key => $day) {
        ?>
            <div id="wcs3-schedule-day-<?php 
        echo $key;
        ?>
">
                <h3><?php 
        echo $day;
        ?>
</h3>
                <?php 
        echo wcs3_render_day_table($key);
        ?>
            </div>
        <?php 
    }
    ?>
    </div>

    <?php 
}
コード例 #2
0
/**
 * Settings page.
 */
function wcs3_standard_settings_page_callback()
{
    $wcs3_options = wcs3_load_settings();
    if (isset($_POST['wcs3_options_nonce'])) {
        // We got a submission
        $nonce = sanitize_text_field($_POST['wcs3_options_nonce']);
        $valid = wp_verify_nonce($nonce, 'wcs3_save_options');
        if ($valid === FALSE) {
            // Nonce verification failed.
            wcs3_options_message(__('Nonce verification failed', 'wcs3'), 'error');
        } else {
            wcs3_options_message(__('Options updated', 'wcs3'));
            // Create a validataion fields array:
            // id_of_field => validation_function_callback
            $fields = array('first_day_of_week' => 'wcs3_validate_weekday', '24_hour_mode' => 'wcs3_validate_yes_no', 'location_collision' => 'wcs3_validate_yes_no', 'instructor_collision' => 'wcs3_validate_yes_no', 'details_template' => 'wcs3_validate_html', 'allow_html_in_notes' => 'wcs3_validate_yes_no', 'color_base' => 'wcs3_validate_color', 'color_details_box' => 'wcs3_validate_color', 'color_text' => 'wcs3_validate_color', 'color_border' => 'wcs3_validate_color', 'color_headings_text' => 'wcs3_validate_color', 'color_headings_background' => 'wcs3_validate_color', 'color_background' => 'wcs3_validate_color', 'color_qtip_background' => 'wcs3_validate_color', 'color_links' => 'wcs3_validate_color');
            $wcs3_options = wcs3_perform_validation($fields, $wcs3_options);
            wcs3_save_settings($wcs3_options);
        }
    }
    ?>
    
    <h2><?php 
    _e('Weekly Class Schedule Settings', 'wcs3');
    ?>
</h2>
    <h4><?php 
    _e('Using Weekly Class Schedule', 'wcs3');
    ?>
</h4>
    <p>
        <?php 
    _e('To display all the classes in a single schedule, simply enter the shortcode', 'wcs3');
    ?>
<code>[wcs]</code>
        <?php 
    _e('inside a page or a post.', 'wcs3 ');
    ?>
        <?php 
    _e('It\'s also possible to output the schedule as a list using the list layout:', 'wcs3');
    ?>
<code>[wcs layout=list]</code>.
        <?php 
    _e('In order to filter a schedule by a specific class, instructor, location, or any other combination of the three, use the class, instructor, and location attributes. For example:');
    ?>
        <ul>
            <li>
                <div><code>[wcs location="Classroom A"]</code> (<?php 
    _e('Only display "Classroom A"');
    ?>
)</div>
                <div><code>[wcs instructor="John Doe"]</code> (<?php 
    _e('Only display classes by "John Doe"');
    ?>
)</div>
                <div><code>[wcs class="Yoga"]</code> (<?php 
    _e('Only display "Yoga" classes');
    ?>
)</div>
            </li>
        </ul>

    </p>
    
    <p> 
        <?php 
    _e('A finalized shortcode may look something like', 'wcs3');
    ?>
 <code>[wcs location="Classroom A" layout=list]</code>
    </p>  
    
    <form action="<?php 
    $_SERVER['PHP_SELF'];
    ?>
" method="post" name="wcs3_general_settings">
        <h3> <?php 
    _e('General Settings', 'wcs3');
    ?>
</h3>
        <table class="form-table">
            <tr>
                <th>
                    <?php 
    _e('First day of week', 'wcs3');
    ?>
<br/>
                    <div class="wcs3-description"><?php 
    _e('The day the schedule will start in', 'wcs3');
    ?>
</div>
                </th>
                <td><?php 
    echo wcs3_generate_weekday_select_list('wcs3_first_day_of_week', $wcs3_options['first_day_of_week']);
    ?>
</td>
            </tr>
            <tr>
                <th>
                    <?php 
    _e('Enable 24-hour mode', 'wcs3');
    ?>
                    <div class="wcs3-description"><?php 
    _e('Enabling this will display all the hours on the front-end in a 24 hour clock mode as opposed to 12 hour clock mode (AM/PM).', 'wcs3');
    ?>
</div>    
                </th>
                <td><?php 
    wcs3_bool_checkbox('wcs3_24_hour_mode', $wcs3_options['24_hour_mode'], __('Yes'));
    ?>
</td>
            </tr>
            <tr>
                <th>
                    <?php 
    _e('Detect location collisions', 'wcs3');
    ?>
                    <div class="wcs3-description"><?php 
    _e('Enabling this feature will prevent scheduling of multiple classes at the same location at the same time.', 'wcs3');
    ?>
</div>    
                </th>
                <td><?php 
    wcs3_bool_checkbox('wcs3_location_collision', $wcs3_options['location_collision'], __('Yes'));
    ?>
</td>
            </tr>
            <tr>
                <th>
                    <?php 
    _e('Detect instructor collisions', 'wcs3');
    ?>
                    <div class="wcs3-description"><?php 
    _e('Enabling this feature will prevent the scheduling of an instructor for multiple classes at the same.', 'wcs3');
    ?>
</div>    
                </th>
                <td><?php 
    wcs3_bool_checkbox('wcs3_instructor_collision', $wcs3_options['instructor_collision'], __('Yes'));
    ?>
</td>
            </tr>
            <tr>
                <th>
                    <?php 
    _e('Class Details Template', 'wcs3');
    ?>
                    <div class="wcs3-description"><?php 
    _e('Use placheolders to design the way the class details appear in the schedule. Certain HTML tags are allowed (to customize edit $wcs3_allowed_html in wcs.php).', 'wcs3');
    ?>
</div>
                    <br/>
                    <div class="wcs3-description"><strong><?php 
    _e('Available placeholders:', 'wcs3');
    ?>
</strong> [class], [instructor], [location], [start hour], [end hour], [notes].</div>
                </th>
                <td>
                    <textarea name="wcs3_details_template" cols="40" rows="6"><?php 
    echo $wcs3_options['details_template'];
    ?>
</textarea>
                </td>
            </tr>
            <tr>
                <th>
                    <?php 
    _e('Allow all HTML in notes', 'wcs3');
    ?>
                    <div class="wcs3-description"><?php 
    _e('Allow all HTML tags in notes field. PLEASE NOTE: Allowing all HTML tags has security implications so use at your own risk.', 'wcs3');
    ?>
</div>    
                </th>
                <td><?php 
    wcs3_bool_checkbox('wcs3_allow_html_in_notes', $wcs3_options['allow_html_in_notes'], __('Yes'));
    ?>
</td>
            </tr>
        </table>

        <?php 
    if (!is_plugin_active('wcs-expansion-pack-1/wcs-ex1.php')) {
        ?>
            <div class="ex1-link-box">
                <p>Check out the new <a href="http://pulsarwebdesign.com/downloads/weekly-class-schedule-expansion-pack-1" target="_blank">Expansion Pack</a> for additional features such as graphical representation of class duration, per class/instructor/location color customization, responsive layout, and more.</p>

                <p>
                    <img src="<?php 
        echo WCS3_PLUGIN_URL;
        ?>
/img/expansion-pack-1-graphic-624x315.jpg" alt="Expansion pack 1 graphic" />
                </p>
                <p style="text-align: center">
                    <a class="button button-primary" href="http://pulsarwebdesign.com/downloads/weekly-class-schedule-expansion-pack-1" target="_blank">Check it out!</a>
                </p>
            </div>
        <?php 
    }
    ?>
        
        <h3> <?php 
    _e('Appearance Settings', 'wcs3');
    ?>
</h3>
        <table class="form-table">
            <tr>
                <th>
                    <?php 
    _e('Base class', 'wcs3');
    ?>
<br/>
                    <div class="wcs3-description"><?php 
    _e('The default background color for classes in the schedule.', 'wcs3');
    ?>
</div>
                </th>
                <td><?php 
    wcs3_colorpicker('wcs3_color_base', $wcs3_options['color_base']);
    ?>
</td>
            </tr>
            <tr>
                <th>
                    <?php 
    _e('Class details box', 'wcs3');
    ?>
<br/>
                    <div class="wcs3-description"><?php 
    _e('Background color of the class details box which appears when hovering over a class.', 'wcs3');
    ?>
</div>
                </th>
                <td><?php 
    wcs3_colorpicker('wcs3_color_details_box', $wcs3_options['color_details_box']);
    ?>
</td>
            </tr>
            <tr>
                <th>
                    <?php 
    _e('Text', 'wcs3');
    ?>
<br/>
                    <div class="wcs3-description"><?php 
    _e('Text color of schedule entries/classes.', 'wcs3');
    ?>
</div>
                </th>
                <td><?php 
    wcs3_colorpicker('wcs3_color_text', $wcs3_options['color_text']);
    ?>
</td>
            </tr>
            <tr>
                <th>
                    <?php 
    _e('Border', 'wcs3');
    ?>
<br/>
                    <div class="wcs3-description"><?php 
    _e('This color is used for all borders in the schedule output.', 'wcs3');
    ?>
</div>
                </th>
                <td><?php 
    wcs3_colorpicker('wcs3_color_border', $wcs3_options['color_border']);
    ?>
</td>
            </tr>
            <tr>
                <th>
                    <?php 
    _e('Schedule headings color', 'wcs3');
    ?>
<br/>
                    <div class="wcs3-description"><?php 
    _e('Text color of the schedule headings (weekdays, hours).', 'wcs3');
    ?>
</div>
                </th>
                <td><?php 
    wcs3_colorpicker('wcs3_color_headings_text', $wcs3_options['color_headings_text']);
    ?>
</td>
            </tr>
            <tr>
                <th>
                    <?php 
    _e('Schedule headings background', 'wcs3');
    ?>
<br/>
                    <div class="wcs3-description"><?php 
    _e('Background color of the schedule headings (weekdays, hours).', 'wcs3');
    ?>
</div>
                </th>
                <td><?php 
    wcs3_colorpicker('wcs3_color_headings_background', $wcs3_options['color_headings_background']);
    ?>
</td>
            </tr>
            <tr>
                <th>
                    <?php 
    _e('Background', 'wcs3');
    ?>
<br/>
                    <div class="wcs3-description"><?php 
    _e('Background color for the entire schedule.', 'wcs3');
    ?>
</div>
                </th>
                <td><?php 
    wcs3_colorpicker('wcs3_color_background', $wcs3_options['color_background']);
    ?>
</td>
            </tr>
            <tr>
                <th>
                    <?php 
    _e('qTip background', 'wcs3');
    ?>
<br/>
                    <div class="wcs3-description"><?php 
    _e('Background color of the qTip pop-up box.', 'wcs3');
    ?>
</div>
                </th>
                <td><?php 
    wcs3_colorpicker('wcs3_color_qtip_background', $wcs3_options['color_qtip_background']);
    ?>
</td>
            </tr>
            <tr>
                <th>
                    <?php 
    _e('Links', 'wcs3');
    ?>
<br/>
                    <div class="wcs3-description"><?php 
    _e('The color of the links which appear in the class details box.', 'wcs3');
    ?>
</div>
                </th>
                <td><?php 
    wcs3_colorpicker('wcs3_color_links', $wcs3_options['color_links']);
    ?>
</td>
            </tr>
        </table>

        <?php 
    if (!is_plugin_active('wcs-expansion-pack-2/wcs-ex2.php')) {
        ?>
            <div class="ex1-link-box" style="max-width: 420px;">
                <p>Check out <a href="http://pulsarwebdesign.com/downloads/weekly-class-schedule-expansion-pack-2" target="_blank">Expansion Pack 2</a> for additional styling options such as shadows and border radius:</p>

                <p style="text-align: center;">
                    <img style="border: 1px solid #B7B7B7; border-radius: 7px;"
                            src="<?php 
        echo WCS3_PLUGIN_URL;
        ?>
/img/wcs-ex2-demo.gif" alt="Expansion pack 2 graphic" />
                </p>
                <p style="text-align: center">
                    <a class="button button-primary" href="http://pulsarwebdesign.com/downloads/weekly-class-schedule-expansion-pack-2" target="_blank">Check it out!</a>
                </p>
            </div>
        <?php 
    }
    ?>

        <?php 
    submit_button(__('Save Settings'));
    ?>
        <?php 
    wp_nonce_field('wcs3_save_options', 'wcs3_options_nonce');
    ?>
    </form>
    
    <?php 
}