Exemplo n.º 1
0
/**
 * Renders the Feed Processing metabox
 *
 * @since 3.7
 */
function wprss_feed_processing_meta_box_callback()
{
    global $post;
    // Get the post meta
    $state = get_post_meta($post->ID, 'wprss_state', TRUE);
    $activate = get_post_meta($post->ID, 'wprss_activate_feed', TRUE);
    $pause = get_post_meta($post->ID, 'wprss_pause_feed', TRUE);
    $update_interval = get_post_meta($post->ID, 'wprss_update_interval', TRUE);
    $age_limit = get_post_meta($post->ID, 'wprss_age_limit', FALSE);
    $age_unit = get_post_meta($post->ID, 'wprss_age_unit', FALSE);
    $age_limit = count($age_limit) === 0 ? wprss_get_general_setting('limit_feed_items_age') : $age_limit[0];
    $age_unit = count($age_unit) === 0 ? wprss_get_general_setting('limit_feed_items_age_unit') : $age_unit[0];
    // Set default strings for activate and pause times
    $default_activate = 'immediately';
    $default_pause = 'never';
    // Prepare the states
    $states = array('active' => __('Active', WPRSS_TEXT_DOMAIN), 'paused' => __('Paused', WPRSS_TEXT_DOMAIN));
    // Prepare the schedules
    $default_interval = __('Default', WPRSS_TEXT_DOMAIN);
    $wprss_schedules = apply_filters('wprss_schedules', wprss_get_schedules());
    $default_interval_key = wprss_get_default_feed_source_update_interval();
    $schedules = array_merge(array($default_interval_key => array('display' => $default_interval, 'interval' => $default_interval)), $wprss_schedules);
    // Inline help
    $help = WPRSS_Help::get_instance();
    $help_options = array('tooltip_handle_class_extra' => $help->get_options('tooltip_handle_class_extra') . ' ' . $help->get_options('tooltip_handle_class') . '-side');
    ?>

        <div class="wprss-meta-side-setting">
            <label for="wprss_state">Feed state:</label>
            <select id="wprss_state" name="wprss_state">
                <?php 
    foreach ($states as $value => $label) {
        ?>
                    <option value="<?php 
        echo $value;
        ?>
" <?php 
        selected($state, $value);
        ?>
 ><?php 
        echo $label;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
			<?php 
    echo $help->tooltip('field_wprss_state', null, $help_options);
    ?>
        </div>

        <div class="wprss-meta-side-setting">
            <p>
                <label for="">Activate feed: </label>
                <strong id="wprss-activate-feed-viewer"><?php 
    echo $activate !== '' ? $activate : $default_activate;
    ?>
</strong>
                <a href="#">Edit</a>
				<?php 
    echo $help->tooltip('field_wprss_activate_feed', null, $help_options);
    ?>
            </p>
            <div class="wprss-meta-slider" data-collapse-viewer="wprss-activate-feed-viewer" data-default-value="<?php 
    echo $default_activate;
    ?>
">
                <input id="wprss_activate_feed" class="wprss-datetimepicker-from-today" name="wprss_activate_feed" value="<?php 
    echo $activate;
    ?>
" />
                <span class="description">
                    Current UTC time is:<br/><code><?php 
    echo date('d/m/Y H:i:s', current_time('timestamp', 1));
    ?>
</code>
                </span>
            </div>
        </div>

        <div class="wprss-meta-side-setting">
            <p>
                <label for="">Pause feed: </label>
                <strong id="wprss-pause-feed-viewer"><?php 
    echo $pause !== '' ? $pause : $default_pause;
    ?>
</strong>
                <a href="#">Edit</a>
				<?php 
    echo $help->tooltip('field_wprss_pause_feed', null, $help_options);
    ?>
            </p>
            <div class="wprss-meta-slider" data-collapse-viewer="wprss-pause-feed-viewer" data-default-value="<?php 
    echo $default_pause;
    ?>
">
                <input id="wprss_pause_feed" class="wprss-datetimepicker-from-today" name="wprss_pause_feed" value="<?php 
    echo $pause;
    ?>
" />
                <span class="description">
                    Current UTC time is:<br/><code><?php 
    echo date('d/m/Y H:i:s', current_time('timestamp', 1));
    ?>
</code>
                </span>
            </div>
        </div>


        <div class="wprss-meta-side-setting">
            <p>
                <label for="">Update interval: </label>
                <strong id="wprss-feed-update-interval-viewer">
                    <?php 
    if ($update_interval === '' || $update_interval === wprss_get_default_feed_source_update_interval()) {
        echo $default_interval;
    } else {
        echo wprss_interval($schedules[$update_interval]['interval']);
    }
    ?>
                </strong>
                <a href="#">Edit</a>
				<?php 
    echo $help->tooltip('field_wprss_update_interval', null, $help_options);
    ?>
            </p>
            <div class="wprss-meta-slider" data-collapse-viewer="wprss-feed-update-interval-viewer" data-default-value="<?php 
    echo $default_interval;
    ?>
">
                <select id="feed-update-interval" name="wprss_update_interval">
                <?php 
    foreach ($schedules as $value => $schedule) {
        ?>
                    <?php 
        $text = $value === wprss_get_default_feed_source_update_interval() ? $default_interval : wprss_interval($schedule['interval']);
        ?>
                    <option value="<?php 
        echo $value;
        ?>
" <?php 
        selected($update_interval, $value);
        ?>
 ><?php 
        echo $text;
        ?>
</option>
                <?php 
    }
    ?>
                </select>
            </div>
        </div>


        <div class="wprss-meta-side-setting">
            <p>
                <label id="wprss-age-limit-feed-label" for="" data-when-empty="Delete old feed items:">Delete feed items older than: </label>
                <strong id="wprss-age-limit-feed-viewer"><?php 
    echo $age_limit . ' ' . $age_unit;
    ?>
</strong>
                <a href="#">Edit</a>
				<?php 
    echo $help->tooltip('field_wprss_age_limit', null, $help_options);
    ?>
            </p>
            <div class="wprss-meta-slider" data-collapse-viewer="wprss-age-limit-feed-viewer" data-label="#wprss-age-limit-feed-label" data-default-value="" data-empty-controller="#limit-feed-items-age" data-hybrid="#limit-feed-items-age, #limit-feed-items-age-unit">
                <input id="limit-feed-items-age" name="wprss_age_limit" type="number" min="0" class="wprss-number-roller" placeholder="No limit" value="<?php 
    echo $age_limit;
    ?>
" />

                <select id="limit-feed-items-age-unit" name="wprss_age_unit">
                <?php 
    foreach (wprss_age_limit_units() as $unit) {
        ?>
                    <option value="<?php 
        echo $unit;
        ?>
" <?php 
        selected($age_unit, $unit);
        ?>
 ><?php 
        echo $unit;
        ?>
</option>
                <?php 
    }
    ?>
                </select>
            </div>
        </div>


        <?php 
}
Exemplo n.º 2
0
/**
 * Renders the Feed Processing metabox
 * 
 * @since 3.7
 */
function wprss_feed_processing_meta_box_callback()
{
    global $post;
    // Get the post meta
    $state = get_post_meta($post->ID, 'wprss_state', TRUE);
    $activate = get_post_meta($post->ID, 'wprss_activate_feed', TRUE);
    $pause = get_post_meta($post->ID, 'wprss_pause_feed', TRUE);
    $update_interval = get_post_meta($post->ID, 'wprss_update_interval', TRUE);
    $age_limit = get_post_meta($post->ID, 'wprss_age_limit', FALSE);
    $age_unit = get_post_meta($post->ID, 'wprss_age_unit', FALSE);
    $age_limit = count($age_limit) === 0 ? wprss_get_general_setting('limit_feed_items_age') : $age_limit[0];
    $age_unit = count($age_unit) === 0 ? wprss_get_general_setting('limit_feed_items_age_unit') : $age_unit[0];
    // Set default strings for activate and pause times
    $default_activate = 'immediately';
    $default_pause = 'never';
    // Prepare the states
    $states = array('active' => __('Active', 'wprss'), 'paused' => __('Paused', 'wprss'));
    // Prepare the schedules
    $default_interval = __('Default', 'wprss');
    $wprss_schedules = apply_filters('wprss_schedules', wprss_get_schedules());
    $default_interval_key = wprss_get_default_feed_source_update_interval();
    $schedules = array_merge(array($default_interval_key => array('display' => $default_interval, 'interval' => $default_interval)), $wprss_schedules);
    ?>

        <div class="wprss-meta-side-setting">
            <label for="wprss_state">Feed state:</label>
            <select id="wprss_state" name="wprss_state">
                <?php 
    foreach ($states as $value => $label) {
        ?>
                    <option value="<?php 
        echo $value;
        ?>
" <?php 
        selected($state, $value);
        ?>
 ><?php 
        echo $label;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
        </div>

        <div class="wprss-meta-side-setting">
            <p>
                <label for="">Activate feed: </label>
                <strong id="wprss-activate-feed-viewer"><?php 
    echo $activate !== '' ? $activate : $default_activate;
    ?>
</strong>
                <a href="#">Edit</a>
            </p>
            <div class="wprss-meta-slider" data-collapse-viewer="wprss-activate-feed-viewer" data-default-value="<?php 
    echo $default_activate;
    ?>
">
                <input id="wprss_activate_feed" class="wprss-datetimepicker-from-today" name="wprss_activate_feed" value="<?php 
    echo $activate;
    ?>
" />

                <label class="description" for="wprss_activate_feed">
                    Leave blank to activate the feed immediately.
                </label>

                <br/><br/>

                <span class="description">
                    <b>Note:</b> WordPress uses UTC time for schedules, not local time. Current UTC time is: <code><?php 
    echo date('d/m/Y H:i:s', current_time('timestamp', 1));
    ?>
</code>
                </span>
            </div>
        </div>

        <div class="wprss-meta-side-setting">
            <p>
                <label for="">Pause feed: </label>
                <strong id="wprss-pause-feed-viewer"><?php 
    echo $pause !== '' ? $pause : $default_pause;
    ?>
</strong>
                <a href="#">Edit</a>
            </p>
            <div class="wprss-meta-slider" data-collapse-viewer="wprss-pause-feed-viewer" data-default-value="<?php 
    echo $default_pause;
    ?>
">
                <input id="wprss_pause_feed" class="wprss-datetimepicker-from-today" name="wprss_pause_feed" value="<?php 
    echo $pause;
    ?>
" />
                <label class="description" for="wprss_pause_feed">
                    Leave blank to never pause the feed.
                </label>
                <br/><br/>
                <span class="description">
                    <b>Note:</b> WordPress uses UTC time for schedules, not local time. Current UTC time is: <code><?php 
    echo date('d/m/Y H:i:s', current_time('timestamp', 1));
    ?>
</code>
                </span>
            </div>
        </div>


        <div class="wprss-meta-side-setting">
            <p>
                <label for="">Update interval: </label>
                <strong id="wprss-feed-update-interval-viewer">
                    <?php 
    if ($update_interval === '' || $update_interval === wprss_get_default_feed_source_update_interval()) {
        echo $default_interval;
    } else {
        echo wprss_interval($schedules[$update_interval]['interval']);
    }
    ?>
                </strong>
                <a href="#">Edit</a>
            </p>
            <div class="wprss-meta-slider" data-collapse-viewer="wprss-feed-update-interval-viewer" data-default-value="<?php 
    echo $default_interval;
    ?>
">
                <select id="feed-update-interval" name="wprss_update_interval">
                <?php 
    foreach ($schedules as $value => $schedule) {
        ?>
                    <?php 
        $text = $value === wprss_get_default_feed_source_update_interval() ? $default_interval : wprss_interval($schedule['interval']);
        ?>
                    <option value="<?php 
        echo $value;
        ?>
" <?php 
        selected($update_interval, $value);
        ?>
 ><?php 
        echo $text;
        ?>
</option>
                <?php 
    }
    ?>
                </select>
                
                <br/>
                <span class='description' for='feed-update-interval'>
                    Enter the interval at which to update this feed. The feed will only be updated if it is <strong>active</strong>.
                </span>
            </div>
        </div>


        <div class="wprss-meta-side-setting">
            <p>
                <label id="wprss-age-limit-feed-label" for="" data-when-empty="Delete old feed items:">Delete feed items older than: </label>
                <strong id="wprss-age-limit-feed-viewer"><?php 
    echo $age_limit . ' ' . $age_unit;
    ?>
</strong>
                <a href="#">Edit</a>
            </p>
            <div class="wprss-meta-slider" data-collapse-viewer="wprss-age-limit-feed-viewer" data-label="#wprss-age-limit-feed-label" data-default-value="" data-empty-controller="#limit-feed-items-age" data-hybrid="#limit-feed-items-age, #limit-feed-items-age-unit">
                <input id="limit-feed-items-age" name="wprss_age_limit" type="number" min="0" class="wprss-number-roller" placeholder="No limit" value="<?php 
    echo $age_limit;
    ?>
" />

                <select id="limit-feed-items-age-unit" name="wprss_age_unit">
                <?php 
    foreach (wprss_age_limit_units() as $unit) {
        ?>
                    <option value="<?php 
        echo $unit;
        ?>
" <?php 
        selected($age_unit, $unit);
        ?>
 ><?php 
        echo $unit;
        ?>
</option>
                <?php 
    }
    ?>
                </select>
                
                <br/>
                <span class='description' for='limit-feed-items-age'>
                    Enter the maximum age of feed items to be stored in the database. Feed items older than the specified age will be deleted everyday at midnight.
                    <br/>
                    Leave empty for no limit.
                </span>
            </div>
        </div>

        
        <?php 
}
Exemplo n.º 3
0
/**
 * Pretty-prints the difference in two times.
 *
 * @since 3.0
 * @param time $older_date
 * @param time $newer_date
 * @return string The pretty time_since value
 * @link http://wordpress.org/extend/plugins/wp-crontrol/
 */
function wprss_time_since($older_date, $newer_date)
{
    return wprss_interval($newer_date - $older_date);
}