Plugin Directory

Changeset 663612


Ignore:
Timestamp:
02/05/2013 07:48:47 AM (13 years ago)
Author:
bholub
Message:

adding ability to embed to a page

Location:
wodtogether-whiteboards/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • wodtogether-whiteboards/trunk/readme.txt

    r590689 r663612  
    33Tags: embed, post, crossfit
    44Requires at least: 3.0
    5 Tested up to: 3.4
    6 Stable tag: 2.0.6
     5Tested up to: 3.5.1
     6Stable tag: 2.0.7
    77License: GPLv2
    88
     
    2222
    2323== Changelog ==
     24= 2.0.7 =
     25* adding ability to embed Todays WOD on static page instead of in blog posts
    2426= 2.0.6 =
    2527* adjusting counter position, handling click directly on counter
  • wodtogether-whiteboards/trunk/wodtogether-whiteboards.php

    r590681 r663612  
    4343    add_settings_field('wodtogether_date_offset', 'Whiteboard Date Setting', 'wodtogether_setting_date_offset', 'wodtogether', 'wodtogether_main');
    4444    add_settings_field('wodtogether_required_category', 'Required Category', 'wodtogether_setting_required_category', 'wodtogether', 'wodtogether_main');
    45     add_settings_field('wodtogether_iframe_height', 'iFrame Height (in pixels)', 'wodtogether_setting_iframe_height', 'wodtogether', 'wodtogether_main');
    46     add_settings_field('wodtogether_auto_resize', 'Attempt Auto-Resize', 'wodtogether_setting_auto_resize', 'wodtogether', 'wodtogether_main');
     45    add_settings_field('wodtogether_static_page', 'Static Page (Today\'s WOD)', 'wodtogether_setting_static_page', 'wodtogether', 'wodtogether_main');
    4746    add_settings_field('wodtogether_show_wods', 'Show WOD Details by Default', 'wodtogether_setting_show_wods', 'wodtogether', 'wodtogether_main');
    4847}
     
    7776    echo "</select>";
    7877}
    79 function wodtogether_setting_iframe_height() {
    80     $options = get_option('wodtogether_options');
    81     if (!$options['iframe_height']) {
    82         $options['iframe_height'] = 700;
    83     }
    84     echo "<input id='wodtogether_iframe_height' name='wodtogether_options[iframe_height]' size='20' type='text' value='{$options['iframe_height']}' />";
    85 }
    86 function wodtogether_setting_auto_resize() {
    87     $options = get_option('wodtogether_options');
    88    
    89     $checked = (isset($options['auto_resize']) && $options['auto_resize']) ? ' checked' : '';
    90     echo "<input id='wodtogether_auto_resize' name='wodtogether_options[auto_resize]' {$checked} type='checkbox' value='1' />
    91     <p><strong>Recommended!</strong> This will attempt to automatically resize the whiteboard iframe so there are no scrollbars.</p>";
     78function wodtogether_setting_static_page() {
     79    $options = get_option('wodtogether_options');
     80    echo "<select id='wodtogether_static_page' name='wodtogether_options[static_page]'><option value=''>None </option>";
     81   
     82    $blog_pages = get_pages();
     83   
     84    foreach($blog_pages as $page) {
     85        $selected = ($options['static_page'] == $page->ID) ? ' selected' : '';
     86        echo "<option value=\"{$page->ID}\"{$selected}>{$page->post_title}</option>";
     87    }
     88   
     89    echo "</select>
     90    <p><strong>Note:</strong> If you want to show Today's WOD on a static Page (instead of/in addition to on each blog post), select a page in the dropdown.</p>";
    9291}
    9392function wodtogether_setting_show_wods() {
     
    108107    }
    109108   
    110     if (!is_numeric($input['iframe_height'])) {
    111         $input['date_offset'] = 700; // default to 700
    112     }
    113    
    114109    if (!is_numeric($input['show_wods'])) {
    115110        $input['show_wods'] = 0; // default to off
     
    117112   
    118113    $input['required_category'] = trim($input['required_category']);
     114   
     115    if (!is_numeric($input['static_page'])) {
     116        $input['static_page'] = 0; // default to main site
     117    }
    119118   
    120119    return $input;
     
    143142);
    144143
     144add_filter( 'page_template', 'wodtogether_page_template' );
     145function wodtogether_page_template( $page_template )
     146{
     147    global $wodtogetherSettings;
     148   
     149    $pageID = get_the_ID();
     150    if ( is_page( $pageID ) && $wodtogetherSettings['static_page'] == $pageID) {
     151        $page_template = dirname( __FILE__ ) . '/wod.php';
     152    }
     153    return $page_template;
     154}
     155
     156
    145157/**
    146158 * Show whiteboard on each post
    147159 */
    148160add_filter('the_content', 'showWhiteboard');
    149 function showWhiteboard($input)
     161function showWhiteboard($input, $todays_wods=false)
    150162{
    151163    global $whiteboarded;
    152164    global $wodtogetherSettings;
    153165   
    154     if (isset($wodtogetherSettings['required_category']) && $wodtogetherSettings['required_category']) {
     166    if (!is_page( $wodtogetherSettings['static_page'] ) && isset($wodtogetherSettings['required_category']) && $wodtogetherSettings['required_category']) {
    155167        $post_categories = get_the_category();
    156168        $has_required_category = false;
     
    170182   
    171183    $date_offset = (isset($wodtogetherSettings['date_offset']) && $wodtogetherSettings['date_offset']) ? 86400 : 0;
    172     $date = date('Y-m-d', strtotime($GLOBALS['post']->post_date) + $date_offset);
     184   
     185    $datestr = ($todays_wods) ? 'today' : $GLOBALS['post']->post_date;
     186    $date = date('Y-m-d', strtotime($datestr) + $date_offset);
    173187   
    174188    // show a max of 5 whiteboards per screen
    175189    if ($whiteboarded >= 5) {
    176         return $input . "<br /><a href=\"http://wodtogether.com/whiteboard/view/date/{$date}/gym/{$gym_id}/embed/remote{$show_wods}\">View Whitebaord</a>";
     190        return $input . "<br /><a href=\"http://wodtogether.com/whiteboard/view/date/{$date}/gym/{$gym_id}/embed/remote{$show_wods}\" class=\"wodtogether_wb_button btn btn-large\">View Whitebaord</a>";
    177191    }
    178192   
Note: See TracChangeset for help on using the changeset viewer.