/**
  * Add special Simmer classes for recipes.
  *
  * @since 1.2.0
  * @see post_class()
  *
  * @param  array        $classes   The existing classes as generated by WordPress.
  * @param  string|array $class     Optional. Any custom classes passed by the post_class() function.
  * @param  int|bool     $recipe_id Optional. The current recipe ID.
  * @return array        $classes   The newly generated recipe classes.
  */
 public function add_recipe_classes($classes, $class = '', $recipe_id = false)
 {
     if (simmer_get_object_type() !== get_post_type($recipe_id) || !$recipe_id) {
         return $classes;
     }
     $classes[] = 'simmer-recipe';
     // Check for ingredients and add the appropriate classes.
     $ingredients = simmer_get_the_ingredients();
     if (!empty($ingredients)) {
         $classes[] = 'simmer-has-ingredients';
         $classes[] = 'simmer-ingredients-' . zeroise(count($ingredients), 2);
     } else {
         $classes[] = 'simmer-no-ingredients';
     }
     // Check for instructions and add the appropriate classes.
     $instructions = simmer_get_the_instructions();
     if (!empty($instructions)) {
         $classes[] = 'simmer-has-instructions';
         $classes[] = 'simmer-instructions-' . zeroise(count($instructions), 2);
     } else {
         $classes[] = 'simmer-no-instructions';
     }
     /**
      * Filter the recipe classes.
      *
      * @since 1.2.0
      *
      * @param array  $classes   The generated recipe classes.
      * @param string $class     Optional. Additional classes to to add, passed by the post_class function.
      * @param int    $recipe_id Optional. The current recipe's ID.
      */
     $classes = apply_filters('simmer_recipe_classes', $classes, $class, $recipe_id);
     return $classes;
 }
 function meta_box()
 {
     global $wpdb, $post, $wp_locale;
     $ed = get_post_meta($post->ID, '_expiration_date', true);
     if ($ed) {
         $edy = date('Y', $ed);
         $edm = date('m', $ed);
         $edd = date('d', $ed);
     } else {
         $edy = $edm = $edd = '';
     }
     $month = '<select id="edm" name="edm" index="5002">';
     $month .= '<option value=""';
     if ($edm == '') {
         $month .= ' selected="selected"';
     }
     $month .= '></option>\\n';
     for ($i = 1; $i < 13; $i = $i + 1) {
         $month .= '<option value="' . zeroise($i, 2) . '"';
         if ($i == $edm) {
             $month .= ' selected="selected"';
         }
         $month .= '>' . $wp_locale->get_month($i) . '</option>';
     }
     $month .= '</select>';
     $day = '<input type="text" id="edd" name="edd" value="' . $edd . '" size="2" maxlength="2" autocomplete="off" index="5003" />';
     $year = '<input type="text" id="edy" name="edy" value="' . $edy . '" size="4" maxlength="4" autocomplete="off" index="5001" />';
     echo '<input type="hidden" name="expiration_date_nonce" value="' . wp_create_nonce('expiration_date') . '">';
     echo '<p>' . __('Post expires at the end of (Year/Month/Day)', 'Hetjens_Expiration_Date') . '<br />' . $year . ' ' . $month . ' ' . $day . '</p>';
     echo '<p>' . __('Leave blank for no expiration date.', 'Hetjens_Expiration_Date') . '</p>';
 }
 function _b_wp_archives_monthly_show($options, $wp_num = '')
 {
     $block_style = $options[0] ? $options[0] : 0;
     $with_count = $options[1] == 0 ? false : true;
     $tpl_file = empty($options[2]) ? 'wp_archives_monthly.html' : $options[2];
     $sel_value = '';
     if (current_wp()) {
         if (!empty($_SERVER['PATH_INFO'])) {
             permlink_to_param();
         }
         init_param('GET', 'm', 'string', '');
         init_param('GET', 'year', 'integer', '');
         init_param('GET', 'monthnum', 'integer', '');
         init_param('GET', 'day', 'integer', '');
         if (strlen(get_param('m')) == 6) {
             $sel_value = get_param('m');
         } else {
             if (test_param('year') && test_param('monthnum') && !test_param('day')) {
                 $sel_value = get_param('year') . zeroise(get_param('monthnum'), 2);
             }
         }
     }
     $block['wp_num'] = $wp_num;
     $block['divid'] = 'wpArchive' . $wp_num;
     $block['siteurl'] = wp_siteurl();
     $block['style'] = block_style_get(false);
     $block['block_style'] = $block_style;
     $block['with_count'] = $with_count;
     $now = current_time('mysql');
     $postHandler =& wp_handler('Post');
     $criteria =& new CriteriaCompo(new Criteria('post_date', $now, '<'));
     $criteria->add(new Criteria('post_status', 'publish'));
     $criteria->setSort('post_date');
     $criteria->setOrder('DESC');
     $criteria->setGroupby('YEAR(post_date), MONTH(post_date)');
     $postObjects =& $postHandler->getObjects($criteria, false, 'DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts');
     $block['records'] = array();
     if ($postObjects) {
         foreach ($postObjects as $postObject) {
             $this_year = $postObject->getExtraVar('year');
             $this_month = $postObject->getExtraVar('month');
             $_record['url'] = get_month_link($this_year, $this_month);
             $_record['text'] = format_month($this_year, $GLOBALS['month'][zeroise($this_month, 2)]);
             if ($with_count) {
                 $_record['count'] = '&nbsp;(' . $postObject->getExtraVar('posts') . ')';
             } else {
                 $_record['count'] = '';
             }
             $_record['select'] = $sel_value == $this_year . zeroise($this_month, 2) ? 'selected="selected"' : '';
             $block['records'][] = $_record;
         }
     }
     $_wpTpl =& new WordPresTpl('theme');
     $_wpTpl->assign('block', $block);
     if (!$_wpTpl->tpl_exists($tpl_file)) {
         $tpl_file = 'wp_archives_monthly.html';
     }
     $block['content'] = $_wpTpl->fetch($tpl_file);
     return $block;
 }
Esempio n. 4
0
 public function render($user)
 {
     global $wp_locale;
     echo '<tr>';
     echo '<th><label for="' . $this->_id . '">' . $this->_params['label'] . '</label></th>';
     echo '<td>';
     $time_adj = current_time('timestamp');
     $date = $this->_value($user);
     $jj = $date ? mysql2date('d', $date, false) : gmdate('d', $time_adj);
     $mm = $date ? mysql2date('m', $date, false) : gmdate('m', $time_adj);
     $aa = $date ? mysql2date('Y', $date, false) : gmdate('Y', $time_adj);
     $month = '<label><span class="screen-reader-text">' . __('Month') . '</span><select id="' . $this->_id . '_mm" name="' . $this->_name . '[mm]"' . ">\n";
     for ($i = 1; $i < 13; $i = $i + 1) {
         $monthnum = zeroise($i, 2);
         $monthtext = $wp_locale->get_month_abbrev($wp_locale->get_month($i));
         $month .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected($monthnum, $mm, false) . '>';
         $month .= sprintf(__('%1$s-%2$s'), $monthnum, $monthtext) . "</option>\n";
     }
     $month .= '</select></label>';
     $day = '<label><span class="screen-reader-text">' . __('Day') . '</span><input type="text" id="' . $this->_id . '_jj" name="' . $this->_name . '[jj]" value="' . $jj . '" size="2" maxlength="2"' . ' autocomplete="off" /></label>';
     $year = '<label><span class="screen-reader-text">' . __('Year') . '</span><input type="text" id="' . $this->_id . '_aa" name="' . $this->_name . '[aa]" value="' . $aa . '" size="4" maxlength="4"' . ' autocomplete="off" /></label>';
     echo $day . $month . $year;
     echo $this->_description();
     echo '</td>';
     echo '</tr>';
 }
Esempio n. 5
0
    public function html($meta, $repeatable = null)
    {
        global $wp_locale;
        is_array($meta);
        $name = is_null($repeatable) ? $this->_name : $this->_name . '[' . $repeatable . ']';
        $id = is_null($repeatable) ? $this->_id : $this->_id . '_' . $repeatable;
        echo '<tr>';
        echo '
			<th scope="row">
				<label for="' . $id . '_jj">' . $this->_label . '</label>
			</th>
			<td>
        ';
        $jj = $meta ? mysql2date('d', $meta, false) : '';
        $mm = $meta ? mysql2date('m', $meta, false) : '';
        $aa = $meta ? mysql2date('Y', $meta, false) : '';
        $month = '<label><span class="screen-reader-text">' . __('Month') . '</span><select id="' . $id . '_mm" name="' . $name . '[mm]"' . ' ' . $this->_inputAttr() . '>';
        $month .= "\t\t\t" . '<option value="" data-text="" ' . selected('', $mm, false) . '>';
        $month .= "--</option>\n";
        for ($i = 1; $i < 13; $i = $i + 1) {
            $monthnum = zeroise($i, 2);
            $monthtext = $wp_locale->get_month_abbrev($wp_locale->get_month($i));
            $month .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected($monthnum, $mm, false) . '>';
            $month .= sprintf(__('%1$s-%2$s'), $monthnum, $monthtext) . "</option>\n";
        }
        $month .= '</select></label>';
        $day = '<label><span class="screen-reader-text">' . __('Day') . '</span><input type="number" min="1" max="31" id="' . $id . '_jj" name="' . $name . '[jj]" value="' . $jj . '" size="2" maxlength="2"' . ' autocomplete="off" ' . $this->_inputAttr() . '></label>';
        $year = '<label><span class="screen-reader-text">' . __('Year') . '</span><input type="number" id="' . $id . '_aa" name="' . $name . '[aa]" value="' . $aa . '" size="4" maxlength="4"' . ' autocomplete="off" ' . $this->_inputAttr() . '></label>';
        echo $day . $month . $year;
        if (!empty($this->_description)) {
            echo '<p class="description">' . $this->_description . '</p>';
        }
        echo '</td>';
        echo '</tr>';
    }
 /**
  * Gets the posted value of the setting.
  *
  * @since  1.0.0
  * @access public
  * @return mixed
  */
 public function get_posted_value()
 {
     // Get the posted year, month, and day.
     $year = !empty($_POST["ccp_{$this->manager->name}_setting_{$this->name}_year"]) ? zeroise(absint($_POST["ccp_{$this->manager->name}_setting_{$this->name}_year"]), 4) : '';
     $month = !empty($_POST["ccp_{$this->manager->name}_setting_{$this->name}_month"]) ? zeroise(absint($_POST["ccp_{$this->manager->name}_setting_{$this->name}_month"]), 2) : '';
     $day = !empty($_POST["ccp_{$this->manager->name}_setting_{$this->name}_day"]) ? zeroise(absint($_POST["ccp_{$this->manager->name}_setting_{$this->name}_day"]), 2) : '';
     $new_date = $year && $month && $day ? "{$year}-{$month}-{$day} 00:00:00" : '';
     return $new_date;
 }
/**
 * Create the date options fields for exporting a given post type.
 *
 * @global wpdb      $wpdb      WordPress database object.
 * @global WP_Locale $wp_locale Date and Time Locale object.
 *
 * @since 3.1.0
 *
 * @param string $post_type The post type. Default 'post'.
 */
function export_plus_date_options($post_type = 'post')
{
    global $wpdb, $wp_locale;
    $start = $wpdb->get_results($wpdb->prepare("\n\t\tSELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month, DAY( post_date ) AS day\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_type = %s AND post_status != 'auto-draft'\n\t\tORDER BY post_date ASC\n\t\tLIMIT 1\n\t", $post_type));
    if (!$start) {
        return;
    }
    $start_date = array('start_year' => $start[0]->year, 'start_month' => zeroise($start[0]->month, 2), 'start_day' => zeroise($start[0]->day, 2));
    return $start_date;
}
function aec_touch_time($edit = 1, $for_post = 1, $tab_index = 0, $commentID = 0)
{
    global $wp_locale, $post, $aecomments;
    $multi = 0;
    $comment = get_comment($commentID);
    if ($for_post) {
        $edit = !(in_array($post->post_status, array('draft', 'pending')) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt));
    }
    $tab_index_attribute = '';
    if ((int) $tab_index > 0) {
        $tab_index_attribute = " tabindex=\"{$tab_index}\"";
    }
    // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
    $time_adj = current_time('timestamp');
    $post_date = $for_post ? $post->post_date : $comment->comment_date;
    $jj = $edit ? mysql2date('d', $post_date, false) : gmdate('d', $time_adj);
    $mm = $edit ? mysql2date('m', $post_date, false) : gmdate('m', $time_adj);
    $aa = $edit ? mysql2date('Y', $post_date, false) : gmdate('Y', $time_adj);
    $hh = $edit ? mysql2date('H', $post_date, false) : gmdate('H', $time_adj);
    $mn = $edit ? mysql2date('i', $post_date, false) : gmdate('i', $time_adj);
    $ss = $edit ? mysql2date('s', $post_date, false) : gmdate('s', $time_adj);
    $cur_jj = gmdate('d', $time_adj);
    $cur_mm = gmdate('m', $time_adj);
    $cur_aa = gmdate('Y', $time_adj);
    $cur_hh = gmdate('H', $time_adj);
    $cur_mn = gmdate('i', $time_adj);
    $month = "<select " . ($multi ? '' : 'id="mm" ') . "name=\"mm\"{$tab_index_attribute}>\n";
    for ($i = 1; $i < 13; $i = $i + 1) {
        $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
        if ($i == $mm) {
            $month .= ' selected="selected"';
        }
        $month .= '>' . $wp_locale->get_month_abbrev($wp_locale->get_month($i)) . "</option>\n";
    }
    $month .= '</select>';
    $day = '<input type="text" ' . ($multi ? '' : 'id="jj" ') . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
    $year = '<input type="text" ' . ($multi ? '' : 'id="aa" ') . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
    $hour = '<input type="text" ' . ($multi ? '' : 'id="hh" ') . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
    $minute = '<input type="text" ' . ($multi ? '' : 'id="mn" ') . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
    echo '<div class="timestamp-wrap">';
    /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */
    printf(__('%1$s%2$s, %3$s @ %4$s : %5$s', 'ajaxEdit'), $month, $day, $year, $hour, $minute);
    echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
    if ($multi) {
        return;
    }
    echo "\n\n";
    foreach (array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit) {
        echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . ${$timeunit} . '" />' . "\n";
        $cur_timeunit = 'cur_' . $timeunit;
        echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . ${$cur_timeunit} . '" />' . "\n";
    }
}
function antispambot($email_address, $hex_encoding = 0)
{
    $email_no_spam_address = '';
    for ($i = 0, $len = strlen($email_address); $i < $len; $i++) {
        $j = rand(0, 1 + $hex_encoding);
        if ($j == 0) {
            $email_no_spam_address .= '&#' . ord($email_address[$i]) . ';';
        } elseif ($j == 1) {
            $email_no_spam_address .= $email_address[$i];
        } elseif ($j == 2) {
            $email_no_spam_address .= '%' . zeroise(dechex(ord($email_address[$i])), 2);
        }
    }
    return str_replace('@', '&#64;', $email_no_spam_address);
}
Esempio n. 10
0
 public static function touch_time($edit = false, $tab_index = 0, $multi = 0)
 {
     global $wp_locale;
     $tab_index_attribute = '';
     if ((int) $tab_index > 0) {
         $tab_index_attribute = " tabindex=\"{$tab_index}\"";
     }
     $time_adj = current_time('timestamp');
     $jj = $edit ? mysql2date('d', $post_date, false) : gmdate('d', $time_adj);
     $mm = $edit ? mysql2date('m', $post_date, false) : gmdate('m', $time_adj);
     $aa = $edit ? mysql2date('Y', $post_date, false) : gmdate('Y', $time_adj);
     $hh = $edit ? mysql2date('H', $post_date, false) : gmdate('H', $time_adj);
     $mn = $edit ? mysql2date('i', $post_date, false) : gmdate('i', $time_adj);
     $ss = $edit ? mysql2date('s', $post_date, false) : gmdate('s', $time_adj);
     $cur_jj = gmdate('d', $time_adj);
     $cur_mm = gmdate('m', $time_adj);
     $cur_aa = gmdate('Y', $time_adj);
     $cur_hh = gmdate('H', $time_adj);
     $cur_mn = gmdate('i', $time_adj);
     $month = "<select " . ($multi ? '' : 'id="mm" ') . "name=\"mm\"{$tab_index_attribute}>\n";
     for ($i = 1; $i < 13; $i = $i + 1) {
         $monthnum = zeroise($i, 2);
         $month .= "\t\t\t" . '<option value="' . $monthnum . '"';
         if ($i == $mm) {
             $month .= ' selected="selected"';
         }
         /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
         $month .= '>' . sprintf(__('%1$s-%2$s'), $monthnum, $wp_locale->get_month_abbrev($wp_locale->get_month($i))) . "</option>\n";
     }
     $month .= '</select>';
     $day = '<input type="text" ' . ($multi ? '' : 'id="jj" ') . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
     $year = '<input type="text" ' . ($multi ? '' : 'id="aa" ') . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
     $hour = '<input type="text" ' . ($multi ? '' : 'id="hh" ') . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
     $minute = '<input type="text" ' . ($multi ? '' : 'id="mn" ') . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
     echo '<div class="timestamp-wrap">';
     /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
     printf(__('%1$s %2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute);
     echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
     if ($multi) {
         return;
     }
     echo "\n\n";
     foreach (array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit) {
         echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . ${$timeunit} . '" />' . "\n";
         $cur_timeunit = 'cur_' . $timeunit;
         echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . ${$cur_timeunit} . '" />' . "\n";
     }
 }
Esempio n. 11
0
function archives_cloud($smallest = 50, $largest = 200, $unit = "%", $cold = "", $hot = "", $before = '', $after = '', $exclude = '')
{
    global $month, $wpdb;
    $now = current_time('mysql');
    $results = $wpdb->get_results('SELECT DISTINCT YEAR(post_date) AS `year`,' . ' MONTH(post_date) AS `month`,' . ' count(ID) AS `posts` ' . ' FROM ' . $wpdb->posts . ' WHERE post_date < "' . $now . '" AND post_status = "publish"' . ' GROUP BY YEAR(post_date), MONTH(post_date)' . ' ORDER BY post_date DESC');
    $content = array();
    foreach ($results as $key => $val) {
        # normalize the values to fit into KingCloud Class content var
        $content[$key]['url'] = get_month_link($val->year, $val->month);
        $content[$key]['text'] = sprintf('%s %d', $month[zeroise($val->month, 2)], $val->year);
        $content[$key]['title'] = $val->posts . ' Artikel';
        $content[$key]['count'] = $val->posts;
    }
    $cloud = new KingCloud($content, $smallest, $largest, $unit, $cold, $hot, $before, $after);
    $cloud->output();
}
 /**
  * Create the date options fields for exporting a given post type.
  *
  * @global wpdb      $wpdb      WordPress database object.
  * @global WP_Locale $wp_locale Date and Time Locale object.
  *
  * @since 3.1.0
  *
  * @param string $post_type The post type. Default 'post'.
  */
 function export_date_options($post_type = 'post')
 {
     global $wpdb, $wp_locale;
     $months = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month FROM {$wpdb->posts} WHERE post_type = %s AND post_status != 'auto-draft' ORDER BY post_date DESC", $post_type));
     $month_count = count($months);
     if (!$month_count || 1 == $month_count && 0 == $months[0]->month) {
         return;
     }
     foreach ($months as $date) {
         if (0 == $date->year) {
             continue;
         }
         $month = zeroise($date->month, 2);
         echo '<option value="' . $date->year . '-' . $month . '">' . $wp_locale->get_month($month) . ' ' . $date->year . '</option>';
     }
 }
Esempio n. 13
0
function get_blix_archive($show_comment_count = 0, $before = '<h4>', $after = '</h4>', $year = 0, $post_type = 'post', $limit = 100)
{
    global $month, $wpdb;
    $result = '';
    if ($year) {
        $AND_year = " AND YEAR(post_date)='{$year}'";
    }
    if ($limit) {
        $LIMIT = " LIMIT {$limit}";
    }
    $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM " . $wpdb->posts . " WHERE post_type='{$post_type}' {$AND_year} AND post_status='publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC");
    if ($arcresults) {
        foreach ($arcresults as $arcresult) {
            $url = get_month_link($arcresult->year, $arcresult->month);
            $text = sprintf('%s %d', $month[zeroise($arcresult->month, 2)], $arcresult->year);
            $result .= get_archives_link($url, $text, '', $before, $after);
            $thismonth = zeroise($arcresult->month, 2);
            $thisyear = $arcresult->year;
            $arcresults2 = $wpdb->get_results("SELECT ID, post_date, post_title, comment_status, guid, comment_count FROM " . $wpdb->posts . " WHERE post_date LIKE '{$thisyear}-{$thismonth}-%' AND post_status='publish' AND post_type='{$post_type}' AND post_password='' ORDER BY post_date DESC {$LIMIT}");
            if ($arcresults2) {
                $result .= "<ul class=\"postspermonth\">\n";
                foreach ($arcresults2 as $arcresult2) {
                    if ($arcresult2->post_date != '0000-00-00 00:00:00') {
                        $url = get_permalink($arcresult2->ID);
                        //$arcresult2->guid;
                        $arc_title = $arcresult2->post_title;
                        if ($arc_title) {
                            $text = strip_tags($arc_title);
                        } else {
                            $text = $arcresult2->ID;
                        }
                        $result .= "<li>" . get_archives_link($url, $text, '');
                        if ($show_comment_count) {
                            $cc = $arcresult2->comment_count;
                            if ($arcresult2->comment_status == "open" or $comments_count > 0) {
                                $result .= " ({$cc})";
                            }
                        }
                        $result .= "</li>\n";
                    }
                }
                $result .= "</ul>\n";
            }
        }
    }
    return $result;
}
Esempio n. 14
0
function dt_archives_shortcode()
{
    global $month, $wpdb, $wp_version;
    // a mysql query to get the list of distinct years and months that posts have been created
    $sql = 'SELECT
			DISTINCT YEAR(post_date) AS year,
			MONTH(post_date) AS month,
			count(ID) as posts
		FROM ' . $wpdb->posts . '
		WHERE post_status="publish"
			AND post_type="post"
			AND post_password=""
		GROUP BY YEAR(post_date),
			MONTH(post_date)
		ORDER BY post_date DESC';
    // use get_results to do a query directly on the database
    $archiveSummary = $wpdb->get_results($sql);
    // if there are any posts
    if ($archiveSummary) {
        $output = '<div class="archives">';
        // loop through the posts
        foreach ($archiveSummary as $date) {
            // reset the query variable
            unset($bmWp);
            // create a new query variable for the current month and year combination
            $bmWp = new WP_Query('year=' . $date->year . '&monthnum=' . zeroise($date->month, 2) . '&posts_per_page=-1');
            // if there are any posts for that month display them
            if ($bmWp->have_posts()) {
                // display the archives heading
                $url = get_month_link($date->year, $date->month);
                $text = $month[zeroise($date->month, 2)] . ' ' . $date->year;
                $output .= get_archives_link($url, $text, '', '<h3>', '</h3>');
                $output .= '<ul class="postspermonth">';
                // display an unordered list of posts for the current month
                while ($bmWp->have_posts()) {
                    $bmWp->the_post();
                    $output .= '<li><a href="' . get_permalink($bmWp->post) . '" title="' . esc_html($text, 1) . '">' . wptexturize($bmWp->post->post_title) . '</a></li>';
                }
                $output .= '</ul>';
            }
        }
        $output .= '</div><!-- .archives -->';
        return $output;
    }
}
 function b_wp_archives_monthly_show($options, $wp_num = "")
 {
     $block_style = $options[0] ? $options[0] : 0;
     $with_count = $options[1] == 0 ? false : true;
     $id = 1;
     $GLOBALS['use_cache'] = 1;
     if ($wp_num == "") {
         $GLOBALS['wp_id'] = $wp_num;
         $GLOBALS['wp_inblock'] = 1;
         require dirname(__FILE__) . '/../wp-config.php';
         $GLOBALS['wp_inblock'] = 0;
     }
     $sel_value = '';
     if (current_wp()) {
         init_param('GET', 'm', 'string', '');
         init_param('GET', 'year', 'integer', '');
         init_param('GET', 'monthnum', 'integer', '');
         if (strlen(get_param('m')) == 6) {
             $sel_value = get_param('m');
         } else {
             if (test_param('year') && test_param('monthnum')) {
                 $sel_value = get_param('year') . zeroise(get_param('monthnum'), 2);
             }
         }
     }
     ob_start();
     block_style_get($wp_num);
     if ($block_style == 0) {
         // Simple Listing
         echo "<ul class='wpBlockList'>\n";
         get_archives('monthly', '', 'html', '', '', $with_count);
         echo "</ul>\n";
     } else {
         // Dropdown Listing
         echo '<form name="archiveform' . $wp_num . '" id="archiveform' . $wp_num . '" action="#">';
         echo '<select name="archive_chrono" onchange="window.location = (document.forms.archiveform' . $wp_num . '.archive_chrono[document.forms.archiveform' . $wp_num . '.archive_chrono.selectedIndex].value);"> ';
         echo '<option value="">' . _WP_BY_MONTHLY . '</option>';
         get_archives('monthly', '', 'option', '', '', $with_count, $sel_value);
         echo '</select>';
         echo '</form>';
     }
     $block['content'] = ob_get_contents();
     ob_end_clean();
     return $block;
 }
Esempio n. 16
0
function archives_list_cx()
{
    global $wpdb, $month;
    $lastpost = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_date <'" . current_time('mysql') . "' AND post_status='publish' AND post_type='post' AND post_password='' ORDER BY post_date DESC LIMIT 1");
    $output = get_option('cx_archives_' . $lastpost);
    if (empty($output)) {
        $output = '';
        $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'cx_archives_%'");
        $q = "SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM {$wpdb->posts} p WHERE post_date <'" . current_time('mysql') . "' AND post_status='publish' AND post_type='post' AND post_password='' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC";
        $monthresults = $wpdb->get_results($q);
        if ($monthresults) {
            foreach ($monthresults as $monthresult) {
                $thismonth = zeroise($monthresult->month, 2);
                $thisyear = $monthresult->year;
                $q = "SELECT ID, post_date, post_title, comment_count FROM {$wpdb->posts} p WHERE post_date LIKE '{$thisyear}-{$thismonth}-%' AND post_date AND post_status='publish' AND post_type='post' AND post_password='' ORDER BY post_date DESC";
                $postresults = $wpdb->get_results($q);
                if ($postresults) {
                    $text = sprintf('%s %d', $month[zeroise($monthresult->month, 2)], $monthresult->year);
                    $postcount = count($postresults);
                    $output .= '<ul class="archives-list"><li><span class="archives-yearmonth">' . $text . ' &nbsp;(' . count($postresults) . '&nbsp;' . __('篇文章', 'freephp') . ')</span><ul class="archives-monthlisting">' . "\n";
                    foreach ($postresults as $postresult) {
                        if ($postresult->post_date != '0000-00-00 00:00:00') {
                            $url = get_permalink($postresult->ID);
                            $arc_title = $postresult->post_title;
                            if ($arc_title) {
                                $text = wptexturize(strip_tags($arc_title));
                            } else {
                                $text = $postresult->ID;
                            }
                            $title_text = __('查看', 'freephp') . ', &quot;' . wp_specialchars($text, 1) . '&quot;';
                            $output .= '<li>' . mysql2date('d日', $postresult->post_date) . ':&nbsp;' . "<a href='{$url}' title='{$title_text}'>{$text}</a>";
                            $output .= '&nbsp;(' . $postresult->comment_count . ')';
                            $output .= '</li>' . "\n";
                        }
                    }
                }
                $output .= '</ul></li></ul>' . "\n";
            }
            update_option('cx_archives_' . $lastpost, $output);
        } else {
            $output = '<div class="errorbox">' . __('目前还没有文章.', 'freephp') . '</div>' . "\n";
        }
    }
    echo $output;
}
Esempio n. 17
0
function get_tvsc_data_editoriale($post, $args)
{
    $metabox_id = $args['args']['id'];
    global $post, $wp_locale;
    // Use nonce for verification
    wp_nonce_field(plugin_basename(__FILE__), 'tvsc_data_editoriale_nonce');
    $time_adj = current_time('timestamp');
    $month = get_post_meta($post->ID, $metabox_id . '_month', true);
    if (empty($month)) {
        $month = gmdate('m', $time_adj);
    }
    $day = get_post_meta($post->ID, $metabox_id . '_day', true);
    if (empty($day)) {
        $day = gmdate('d', $time_adj);
    }
    $year = get_post_meta($post->ID, $metabox_id . '_year', true);
    if (empty($year)) {
        $year = gmdate('Y', $time_adj);
    }
    $hour = get_post_meta($post->ID, $metabox_id . '_hour', true);
    if (empty($hour)) {
        $hour = gmdate('H', $time_adj);
    }
    $min = get_post_meta($post->ID, $metabox_id . '_minute', true);
    if (empty($min)) {
        $min = gmdate('i', $time_adj);
    }
    $month_s = '<select name="' . $metabox_id . '_month">';
    for ($i = 1; $i < 13; $i = $i + 1) {
        $month_s .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
        if ($i == $month) {
            $month_s .= ' selected="selected"';
        }
        $month_s .= '>' . $wp_locale->get_month_abbrev($wp_locale->get_month($i)) . "</option>\n";
    }
    $month_s .= '</select>';
    echo $month_s;
    echo '<input type="text" name="' . $metabox_id . '_day" value="' . $day . '" size="2" maxlength="2" />';
    echo '<input type="text" name="' . $metabox_id . '_year" value="' . $year . '" size="4" maxlength="4" /> @ ';
    echo '<input type="text" name="' . $metabox_id . '_hour" value="' . $hour . '" size="2" maxlength="2"/>:';
    echo '<input type="text" name="' . $metabox_id . '_minute" value="' . $min . '" size="2" maxlength="2" />';
}
function sre2t_the_post_dates()
{
    global $wpdb, $wp_locale;
    $dateoptions = '';
    $types = "'" . implode("', '", get_post_types(array('public' => true, 'can_export' => true), 'names')) . "'";
    if (function_exists(get_post_stati)) {
        $stati = "'" . implode("', '", get_post_stati(array('internal' => false), 'names')) . "'";
    } else {
        $stati = "'" . implode("', '", get_post_statuses(array('internal' => false), 'names')) . "'";
    }
    if ($monthyears = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, YEAR(DATE_ADD(post_date, INTERVAL 1 MONTH)) AS `eyear`, MONTH(DATE_ADD(post_date, INTERVAL 1 MONTH)) AS `emonth` FROM {$wpdb->posts} WHERE post_type IN ({$types}) AND post_status IN ({$stati}) ORDER BY post_date ASC ")) {
        foreach ($monthyears as $k => $monthyear) {
            $monthyears[$k]->lmonth = $wp_locale->get_month($monthyear->month, 2);
        }
        for ($s = 0, $e = count($monthyears) - 1; $e >= 0; $s++, $e--) {
            //$dateoptions .= "\t<option value=\"" . $monthyears[$s]->year . '-' . zeroise( $monthyears[$s]->month, 2 ) . '">' . $monthyears[$s]->lmonth . ' ' . $monthyears[$s]->year . "</option>\n";
            $dateoptions .= "\t<option value=\"" . $monthyears[$e]->eyear . '-' . zeroise($monthyears[$e]->emonth, 2) . '">' . $monthyears[$e]->lmonth . ' ' . $monthyears[$e]->year . "</option>\n";
        }
    }
    return $dateoptions;
}
 function _b_wp_archives_monthly_show($options, $wp_num = '')
 {
     $block_style = $options[0] ? $options[0] : 0;
     $with_count = $options[1] == 0 ? false : true;
     $sel_value = '';
     if (current_wp()) {
         if (!empty($_SERVER['PATH_INFO'])) {
             permlink_to_param();
         }
         init_param('GET', 'm', 'string', '');
         init_param('GET', 'year', 'integer', '');
         init_param('GET', 'monthnum', 'integer', '');
         if (strlen(get_param('m')) == 6) {
             $sel_value = get_param('m');
         } else {
             if (test_param('year') && test_param('monthnum')) {
                 $sel_value = get_param('year') . zeroise(get_param('monthnum'), 2);
             }
         }
     }
     ob_start();
     block_style_get($wp_num);
     if ($block_style == 0) {
         // Simple Listing
         echo '<ul class="wpBlockList">' . "\n";
         get_archives('monthly', '', 'html', '', '', $with_count);
         echo '</ul>' . "\n";
     } else {
         // Dropdown Listing
         echo '<form name="archiveform' . $wp_num . '" id="archiveform' . $wp_num . '" action="#">';
         echo '<select name="archive_chrono" onchange="window.location = (document.forms.archiveform' . $wp_num . '.archive_chrono[document.forms.archiveform' . $wp_num . '.archive_chrono.selectedIndex].value);"> ';
         echo '<option value="' . wp_siteurl() . '">' . _WP_BY_MONTHLY . '</option>';
         get_archives('monthly', '', 'option', '', '', $with_count, $sel_value);
         echo '</select>';
         echo '</form>';
     }
     $block['content'] = ob_get_contents();
     ob_end_clean();
     return $block;
 }
/**
 * Function BX_archive
 * ------------------------------------------------------
 * This function is based on WP's built-in get_archives()
 * It outputs the following:
 *
 * <h3><a href="link">Month Year</a></h3>
 * <ul class="postspermonth">
 *     <li><a href="link">Post title</a> (Comment count)</li>
 *     [..]
 * </ul>
 */
function BX_archive()
{
    global $month, $wpdb;
    $now = current_time('mysql');
    $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM " . $wpdb->posts . " WHERE post_date <'" . $now . "' AND post_status='publish' AND post_password='' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC");
    if ($arcresults) {
        foreach ($arcresults as $arcresult) {
            $url = get_month_link($arcresult->year, $arcresult->month);
            $text = sprintf('%s %d', $month[zeroise($arcresult->month, 2)], $arcresult->year);
            echo get_archives_link($url, $text, '', '<h3>', '</h3>');
            $thismonth = zeroise($arcresult->month, 2);
            $thisyear = $arcresult->year;
            $arcresults2 = $wpdb->get_results("SELECT ID, post_date, post_title, comment_status FROM " . $wpdb->posts . " WHERE post_date LIKE '{$thisyear}-{$thismonth}-%' AND post_status='publish' AND post_password='' ORDER BY post_date DESC");
            if ($arcresults2) {
                echo "<ul class=\"postspermonth\">\n";
                foreach ($arcresults2 as $arcresult2) {
                    if ($arcresult2->post_date != '0000-00-00 00:00:00') {
                        $url = get_permalink($arcresult2->ID);
                        $arc_title = $arcresult2->post_title;
                        if ($arc_title) {
                            $text = strip_tags($arc_title);
                        } else {
                            $text = $arcresult2->ID;
                        }
                        echo "<li>" . get_archives_link($url, $text, '');
                        $comments = mysql_query("SELECT * FROM " . $wpdb->comments . " WHERE comment_post_ID=" . $arcresult2->ID);
                        $comments_count = mysql_num_rows($comments);
                        if ($arcresult2->comment_status == "open" or $comments_count > 0) {
                            echo '&nbsp;(' . $comments_count . ')';
                        }
                        echo "</li>\n";
                    }
                }
                echo "</ul>\n";
            }
        }
    }
}
 public static function show_invoices_due()
 {
     global $typenow;
     if (!in_array($typenow, array(SI_Invoice::POST_TYPE, SI_Estimate::POST_TYPE))) {
         return;
     }
     $post_type = $typenow;
     global $wpdb, $wp_locale;
     $meta_key = SI_Invoice::POST_TYPE === $post_type ? '_due_date' : '_expiration_date';
     $months = $wpdb->get_results($wpdb->prepare("\n\t\t\tSELECT DISTINCT YEAR( FROM_UNIXTIME( {$wpdb->postmeta}.meta_value ) ) AS year, MONTH( FROM_UNIXTIME( {$wpdb->postmeta}.meta_value ) ) AS month\n\t\t\tFROM {$wpdb->posts} \n\t\t\tINNER JOIN {$wpdb->postmeta} ON ( {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id ) WHERE 1=1 \n\t\t\tAND ( ( {$wpdb->postmeta}.meta_key = '%s' AND CAST( {$wpdb->postmeta}.meta_value AS CHAR ) BETWEEN '1' AND '%s' ) )\n\t\t\tAND {$wpdb->posts}.post_type = %s\n\t\t\tORDER BY {$wpdb->postmeta}.meta_value DESC\n\t\t", $meta_key, current_time('timestamp'), $post_type));
     // Due Dates filter
     $m = isset($_GET['dm']) ? (int) $_GET['dm'] : 0;
     printf('<label for="filter-by-duedate" class="screen-reader-text">%s</label>', __('Filter due date', 'sprout-invoices'));
     echo '<select name="dm" id="filter-by-duedate">';
     printf('<option %s value="0">%s</option>', selected($m, 0, false), __('All due dates', 'sprout-invoices'));
     foreach ($months as $arc_row) {
         if (0 == $arc_row->year) {
             continue;
         }
         $month = zeroise($arc_row->month, 2);
         $year = $arc_row->year;
         printf("<option %s value='%s'>%s</option>\n", selected($m, $year . $month, false), esc_attr($arc_row->year . $month), sprintf(__('%1$s %2$d'), $wp_locale->get_month($month), $year));
     }
     echo '</select>';
     // Clients filter
     $args = array('post_type' => SI_Client::POST_TYPE, 'post_status' => 'publish', 'posts_per_page' => -1, 'fields' => 'ids');
     $client_ids = get_posts($args);
     $current_client_id = isset($_GET['client_id']) ? (int) $_GET['client_id'] : 0;
     printf('<label for="filter-by-client" class="screen-reader-text">%s</label>', __('Filter by client', 'sprout-invoices'));
     echo '<select name="client_id" id="filter-by-client">';
     printf('<option %s value="0">%s</option>', selected($current_client_id, 0, false), __('All clients', 'sprout-invoices'));
     foreach ($client_ids as $client_id) {
         printf("<option %s value='%s'>%s</option>\n", selected($client_id, $current_client_id, false), esc_attr($client_id), get_the_title($client_id));
     }
     echo '</select>';
 }
Esempio n. 22
0
function dlm_touch_time($timestamp)
{
    global $wp_locale;
    $jj = mysql2date('d', $timestamp, false);
    $mm = mysql2date('m', $timestamp, false);
    $aa = mysql2date('Y', $timestamp, false);
    $hh = mysql2date('H', $timestamp, false);
    $mn = mysql2date('i', $timestamp, false);
    $ss = mysql2date('s', $timestamp, false);
    $month = "<select name=\"mm\">\n";
    for ($i = 1; $i < 13; $i = $i + 1) {
        $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
        if ($i == $mm) {
            $month .= ' selected="selected"';
        }
        $month .= '>' . $wp_locale->get_month_abbrev($wp_locale->get_month($i)) . "</option>\n";
    }
    $month .= '</select>';
    $day = '<input type="text" name="jj" value="' . $jj . '" size="2" maxlength="2" />';
    $year = '<input type="text" name="aa" value="' . $aa . '" size="4" maxlength="4" />';
    $hour = '<input type="text" name="hh" value="' . $hh . '" size="2" maxlength="2" />';
    $minute = '<input type="text" name="mn" value="' . $mn . '" size="2" maxlength="2" />';
    printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute);
}
Esempio n. 23
0
/**
 * Retrieve the permalink for the day archives with year and month.
 *
 * @since 1.0.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param bool|int $year  False for current year. Integer of year.
 * @param bool|int $month False for current month. Integer of month.
 * @param bool|int $day   False for current day. Integer of day.
 * @return string The permalink for the specified day, month, and year archive.
 */
function get_day_link($year, $month, $day)
{
    global $wp_rewrite;
    if (!$year) {
        $year = gmdate('Y', current_time('timestamp'));
    }
    if (!$month) {
        $month = gmdate('m', current_time('timestamp'));
    }
    if (!$day) {
        $day = gmdate('j', current_time('timestamp'));
    }
    $daylink = $wp_rewrite->get_day_permastruct();
    if (!empty($daylink)) {
        $daylink = str_replace('%year%', $year, $daylink);
        $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
        $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
        $daylink = home_url(user_trailingslashit($daylink, 'day'));
    } else {
        $daylink = home_url('?m=' . $year . zeroise($month, 2) . zeroise($day, 2));
    }
    /**
     * Filter the day archive permalink.
     *
     * @since 1.5.0
     *
     * @param string $daylink Permalink for the day archive.
     * @param int    $year    Year for the archive.
     * @param int    $month   Month for the archive.
     * @param int    $day     The day for the archive.
     */
    return apply_filters('day_link', $daylink, $year, $month, $day);
}
 /**
  * Copy of the WordPress "touch_time" template function for use with a variety of different times
  *
  * @param array $args A set of name => value pairs to customise how the function operates. Available keys:
  *		'initial_amount': The upfront payment for the subscription, including sign up fees, as a string from the @see woocommerce_price(). Default empty string (no initial payment)
  *		'initial_description': The word after the initial payment amount to description the amount. Examples include "now" or "initial payment". Defaults to "up front".
  *		'recurring_amount': The amount charged per period. Default 0 (no recurring payment).
  *		'subscription_interval': How regularly the subscription payments are charged. Default 1, meaning each period e.g. per month.
  *		'subscription_period': The temporal period of the subscription. Should be one of {day|week|month|year} as used by @see self::get_subscription_period_strings()
  *		'subscription_length': The total number of periods the subscription should continue for. Default 0, meaning continue indefinitely.
  *		'trial_length': The total number of periods the subscription trial period should continue for.  Default 0, meaning no trial period.
  *		'trial_period': The temporal period for the subscription's trial period. Should be one of {day|week|month|year} as used by @see self::get_subscription_period_strings()
  * @since 1.2
  */
 public static function touch_time($args = array())
 {
     global $wp_locale;
     $args = wp_parse_args($args, array('date' => true, 'is_edit' => true, 'is_for_post' => true, 'tab_index' => 0, 'multiple' => false, 'echo' => true, 'include_time' => true, 'include_buttons' => true));
     if (empty($args['date'])) {
         return;
     }
     $tab_index_attribute = (int) $args['tab_index'] > 0 ? ' tabindex="' . $args['tab_index'] . '"' : '';
     $time_offset = gmdate('U') + get_option('gmt_offset') * 3600;
     $month = mysql2date('m', $args['date'], false);
     $month_input = '<select ' . ($args['multiple'] ? '' : 'id="edit-month" ') . 'name="edit-month"' . $tab_index_attribute . '>';
     for ($i = 1; $i < 13; $i = $i + 1) {
         $month_numeral = zeroise($i, 2);
         $month_input .= '<option value="' . $month_numeral . '"';
         $month_input .= $i == $month ? ' selected="selected"' : '';
         /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
         $month_input .= '>' . sprintf(__('%1$s-%2$s'), $month_numeral, $wp_locale->get_month_abbrev($wp_locale->get_month($i))) . "</option>\n";
     }
     $month_input .= '</select>';
     $day_input = '<input type="text" ' . ($args['multiple'] ? '' : 'id="edit-day" ') . 'name="edit-day" value="' . mysql2date('d', $args['date'], false) . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
     $year_input = '<input type="text" ' . ($args['multiple'] ? '' : 'id="edit-year" ') . 'name="edit-year" value="' . mysql2date('Y', $args['date'], false) . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
     if ($args['include_time']) {
         $hour_input = '<input type="text" ' . ($args['multiple'] ? '' : 'id="edit-hour" ') . 'name="edit-hour" value="' . mysql2date('H', $args['date'], false) . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
         $minute_input = '<input type="text" ' . ($args['multiple'] ? '' : 'id="edit-minute" ') . 'name="edit-minute" value="' . mysql2date('i', $args['date'], false) . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
         /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */
         $touch_time = sprintf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month_input, $day_input, $year_input, $hour_input, $minute_input);
     } else {
         /* translators: 1: month input, 2: day input, 3: year input */
         $touch_time = sprintf(__('%1$s%2$s, %3$s'), $month_input, $day_input, $year_input);
     }
     if ($args['include_buttons']) {
         $touch_time .= '<p>';
         $touch_time .= '<a href="#edit_timestamp" class="save-timestamp hide-if-no-js button">' . __('Change', WC_Subscriptions::$text_domain) . '</a>';
         $touch_time .= '<a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js">' . __('Cancel', WC_Subscriptions::$text_domain) . '</a>';
         $touch_time .= '</p>';
     }
     if ($args['echo']) {
         echo $touch_time;
     }
     return $touch_time;
 }
Esempio n. 25
0
/**
 * Converts email addresses characters to HTML entities to block spam bots.
 *
 * @since 0.71
 *
 * @param string $emailaddy Email address.
 * @param int $mailto Optional. Range from 0 to 1. Used for encoding.
 * @return string Converted email address.
 */
function antispambot($emailaddy, $mailto = 0)
{
    $emailNOSPAMaddy = '';
    srand((double) microtime() * 1000000);
    for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) {
        $j = floor(rand(0, 1 + $mailto));
        if ($j == 0) {
            $emailNOSPAMaddy .= '&#' . ord(substr($emailaddy, $i, 1)) . ';';
        } elseif ($j == 1) {
            $emailNOSPAMaddy .= substr($emailaddy, $i, 1);
        } elseif ($j == 2) {
            $emailNOSPAMaddy .= '%' . zeroise(dechex(ord(substr($emailaddy, $i, 1))), 2);
        }
    }
    $emailNOSPAMaddy = str_replace('@', '&#64;', $emailNOSPAMaddy);
    return $emailNOSPAMaddy;
}
Esempio n. 26
0
/**
 * Print out HTML form date elements for editing post or comment publish date.
 *
 * @since 0.71
 * @since 4.4.0 Converted to use get_comment() instead of the global `$comment`.
 *
 * @global WP_Locale  $wp_locale
 *
 * @param int|bool $edit      Accepts 1|true for editing the date, 0|false for adding the date.
 * @param int|bool $for_post  Accepts 1|true for applying the date to a post, 0|false for a comment.
 * @param int      $tab_index The tabindex attribute to add. Default 0.
 * @param int|bool $multi     Optional. Whether the additional fields and buttons should be added.
 *                            Default 0|false.
 */
function touch_time($edit = 1, $for_post = 1, $tab_index = 0, $multi = 0)
{
    global $wp_locale;
    $post = get_post();
    if ($for_post) {
        $edit = !(in_array($post->post_status, array('draft', 'pending')) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt));
    }
    $tab_index_attribute = '';
    if ((int) $tab_index > 0) {
        $tab_index_attribute = " tabindex=\"{$tab_index}\"";
    }
    // todo: Remove this?
    // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
    $time_adj = current_time('timestamp');
    $post_date = $for_post ? $post->post_date : get_comment()->comment_date;
    $jj = $edit ? mysql2date('d', $post_date, false) : gmdate('d', $time_adj);
    $mm = $edit ? mysql2date('m', $post_date, false) : gmdate('m', $time_adj);
    $aa = $edit ? mysql2date('Y', $post_date, false) : gmdate('Y', $time_adj);
    $hh = $edit ? mysql2date('H', $post_date, false) : gmdate('H', $time_adj);
    $mn = $edit ? mysql2date('i', $post_date, false) : gmdate('i', $time_adj);
    $ss = $edit ? mysql2date('s', $post_date, false) : gmdate('s', $time_adj);
    $cur_jj = gmdate('d', $time_adj);
    $cur_mm = gmdate('m', $time_adj);
    $cur_aa = gmdate('Y', $time_adj);
    $cur_hh = gmdate('H', $time_adj);
    $cur_mn = gmdate('i', $time_adj);
    $month = '<label><span class="screen-reader-text">' . __('Month') . '</span><select ' . ($multi ? '' : 'id="mm" ') . 'name="mm"' . $tab_index_attribute . ">\n";
    for ($i = 1; $i < 13; $i = $i + 1) {
        $monthnum = zeroise($i, 2);
        $monthtext = $wp_locale->get_month_abbrev($wp_locale->get_month($i));
        $month .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected($monthnum, $mm, false) . '>';
        /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
        $month .= sprintf(__('%1$s-%2$s'), $monthnum, $monthtext) . "</option>\n";
    }
    $month .= '</select></label>';
    $day = '<label><span class="screen-reader-text">' . __('Day') . '</span><input type="text" ' . ($multi ? '' : 'id="jj" ') . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
    $year = '<label><span class="screen-reader-text">' . __('Year') . '</span><input type="text" ' . ($multi ? '' : 'id="aa" ') . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" /></label>';
    $hour = '<label><span class="screen-reader-text">' . __('Hour') . '</span><input type="text" ' . ($multi ? '' : 'id="hh" ') . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
    $minute = '<label><span class="screen-reader-text">' . __('Minute') . '</span><input type="text" ' . ($multi ? '' : 'id="mn" ') . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>';
    echo '<div class="timestamp-wrap">';
    /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
    printf(__('%1$s %2$s, %3$s @ %4$s:%5$s'), $month, $day, $year, $hour, $minute);
    echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
    if ($multi) {
        return;
    }
    echo "\n\n";
    $map = array('mm' => array($mm, $cur_mm), 'jj' => array($jj, $cur_jj), 'aa' => array($aa, $cur_aa), 'hh' => array($hh, $cur_hh), 'mn' => array($mn, $cur_mn));
    foreach ($map as $timeunit => $value) {
        list($unit, $curr) = $value;
        echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $unit . '" />' . "\n";
        $cur_timeunit = 'cur_' . $timeunit;
        echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n";
    }
    ?>

<p>
<a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php 
    _e('OK');
    ?>
</a>
<a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js button-cancel"><?php 
    _e('Cancel');
    ?>
</a>
</p>
<?php 
}
Esempio n. 27
0
 if (strlen($imgalt)) {
     $pathtofile = get_settings('fileupload_realpath') . "/" . $imgalt;
     $img1 = $_POST['img1'];
 } else {
     $pathtofile = get_settings('fileupload_realpath') . "/" . $img1_name;
     $img1 = $_FILES['img1']['tmp_name'];
 }
 // makes sure not to upload duplicates, rename duplicates
 $i = 1;
 $pathtofile2 = $pathtofile;
 $tmppathtofile = $pathtofile2;
 $img2_name = $img1_name;
 while (file_exists($pathtofile2)) {
     $pos = strpos(strtolower($tmppathtofile), '.' . trim($imgtype));
     $pathtofile_start = substr($tmppathtofile, 0, $pos);
     $pathtofile2 = $pathtofile_start . '_' . zeroise($i++, 2) . '.' . trim($imgtype);
     $img2_name = explode('/', $pathtofile2);
     $img2_name = $img2_name[count($img2_name) - 1];
 }
 if (file_exists($pathtofile) && !strlen($imgalt)) {
     $i = explode(' ', get_settings('fileupload_allowedtypes'));
     $i = implode(', ', array_slice($i, 1, count($i) - 2));
     $moved = move_uploaded_file($img1, $pathtofile2);
     // if move_uploaded_file() fails, try copy()
     if (!$moved) {
         $moved = copy($img1, $pathtofile2);
     }
     if (!$moved) {
         die(sprintf(__("Couldn't upload your file to %s."), $pathtofile2));
     } else {
         chmod($pathtofile2, 0666);
Esempio n. 28
0
/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.0
 *
 * @param array $errors
 */
function media_upload_library_form($errors)
{
    global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types;
    media_upload_header();
    $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
    $form_action_url = admin_url("media-upload.php?type={$type}&tab=library&post_id={$post_id}");
    /** This filter is documented in wp-admin/includes/media.php */
    $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
    $form_class = 'media-upload-form validate';
    if (get_user_setting('uploader')) {
        $form_class .= ' html-uploader';
    }
    $q = $_GET;
    $q['posts_per_page'] = 10;
    $q['paged'] = isset($q['paged']) ? intval($q['paged']) : 0;
    if ($q['paged'] < 1) {
        $q['paged'] = 1;
    }
    $q['offset'] = ($q['paged'] - 1) * 10;
    if ($q['offset'] < 1) {
        $q['offset'] = 0;
    }
    list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query($q);
    ?>

<form id="filter" action="" method="get">
<input type="hidden" name="type" value="<?php 
    echo esc_attr($type);
    ?>
" />
<input type="hidden" name="tab" value="<?php 
    echo esc_attr($tab);
    ?>
" />
<input type="hidden" name="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />
<input type="hidden" name="post_mime_type" value="<?php 
    echo isset($_GET['post_mime_type']) ? esc_attr($_GET['post_mime_type']) : '';
    ?>
" />
<input type="hidden" name="context" value="<?php 
    echo isset($_GET['context']) ? esc_attr($_GET['context']) : '';
    ?>
" />

<p id="media-search" class="search-box">
	<label class="screen-reader-text" for="media-search-input"><?php 
    _e('Search Media');
    ?>
:</label>
	<input type="search" id="media-search-input" name="s" value="<?php 
    the_search_query();
    ?>
" />
	<?php 
    submit_button(__('Search Media'), 'button', '', false);
    ?>
</p>

<ul class="subsubsub">
<?php 
    $type_links = array();
    $_num_posts = (array) wp_count_attachments();
    $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
    foreach ($matches as $_type => $reals) {
        foreach ($reals as $real) {
            if (isset($num_posts[$_type])) {
                $num_posts[$_type] += $_num_posts[$real];
            } else {
                $num_posts[$_type] = $_num_posts[$real];
            }
        }
    }
    // If available type specified by media button clicked, filter by that type
    if (empty($_GET['post_mime_type']) && !empty($num_posts[$type])) {
        $_GET['post_mime_type'] = $type;
        list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
    }
    if (empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all') {
        $class = ' class="current"';
    } else {
        $class = '';
    }
    $type_links[] = '<li><a href="' . esc_url(add_query_arg(array('post_mime_type' => 'all', 'paged' => false, 'm' => false))) . '"' . $class . '>' . __('All Types') . '</a>';
    foreach ($post_mime_types as $mime_type => $label) {
        $class = '';
        if (!wp_match_mime_types($mime_type, $avail_post_mime_types)) {
            continue;
        }
        if (isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type'])) {
            $class = ' class="current"';
        }
        $type_links[] = '<li><a href="' . esc_url(add_query_arg(array('post_mime_type' => $mime_type, 'paged' => false))) . '"' . $class . '>' . sprintf(translate_nooped_plural($label[2], $num_posts[$mime_type]), '<span id="' . $mime_type . '-counter">' . number_format_i18n($num_posts[$mime_type]) . '</span>') . '</a>';
    }
    /**
     * Filter the media upload mime type list items.
     *
     * Returned values should begin with an <li> tag.
     *
     * @since 3.1.0
     *
     * @param array $type_links An array of list items containing mime type link HTML.
     */
    echo implode(' | </li>', apply_filters('media_upload_mime_type_links', $type_links)) . '</li>';
    unset($type_links);
    ?>
</ul>

<div class="tablenav">

<?php 
    $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($wp_query->found_posts / 10), 'current' => $q['paged']));
    if ($page_links) {
        echo "<div class='tablenav-pages'>{$page_links}</div>";
    }
    ?>

<div class="alignleft actions">
<?php 
    $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM {$wpdb->posts} WHERE post_type = 'attachment' ORDER BY post_date DESC";
    $arc_result = $wpdb->get_results($arc_query);
    $month_count = count($arc_result);
    $selected_month = isset($_GET['m']) ? $_GET['m'] : 0;
    if ($month_count && !(1 == $month_count && 0 == $arc_result[0]->mmonth)) {
        ?>
<select name='m'>
<option<?php 
        selected($selected_month, 0);
        ?>
 value='0'><?php 
        _e('All dates');
        ?>
</option>
<?php 
        foreach ($arc_result as $arc_row) {
            if ($arc_row->yyear == 0) {
                continue;
            }
            $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
            if ($arc_row->yyear . $arc_row->mmonth == $selected_month) {
                $default = ' selected="selected"';
            } else {
                $default = '';
            }
            echo "<option{$default} value='" . esc_attr($arc_row->yyear . $arc_row->mmonth) . "'>";
            echo esc_html($wp_locale->get_month($arc_row->mmonth) . " {$arc_row->yyear}");
            echo "</option>\n";
        }
        ?>
</select>
<?php 
    }
    ?>

<?php 
    submit_button(__('Filter &#187;'), 'button', 'post-query-submit', false);
    ?>

</div>

<br class="clear" />
</div>
</form>

<form enctype="multipart/form-data" method="post" action="<?php 
    echo esc_url($form_action_url);
    ?>
" class="<?php 
    echo $form_class;
    ?>
" id="library-form">

<?php 
    wp_nonce_field('media-form');
    //media_upload_form( $errors );
    ?>

<script type="text/javascript">
<!--
jQuery(function($){
	var preloaded = $(".media-item.preloaded");
	if ( preloaded.length > 0 ) {
		preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
		updateMediaForm();
	}
});
-->
</script>

<div id="media-items">
<?php 
    add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
    echo get_media_items(null, $errors);
    ?>
</div>
<p class="ml-submit">
<?php 
    submit_button(__('Save all changes'), 'button savebutton', 'save', false);
    ?>
<input type="hidden" name="post_id" id="post_id" value="<?php 
    echo (int) $post_id;
    ?>
" />
</p>
</form>
<?php 
}
Esempio n. 29
0
    /**
     * Display a monthly dropdown for filtering items
     *
     * @since 3.1.0
     * @access protected
     *
     * @global wpdb      $wpdb
     * @global WP_Locale $wp_locale
     *
     * @param string $post_type
     */
    protected function months_dropdown($post_type)
    {
        global $wpdb, $wp_locale;
        /**
         * Filter whether to remove the 'Months' drop-down from the post list table.
         *
         * @since 4.2.0
         *
         * @param bool   $disable   Whether to disable the drop-down. Default false.
         * @param string $post_type The post type.
         */
        if (apply_filters('disable_months_dropdown', false, $post_type)) {
            return;
        }
        $extra_checks = "AND post_status != 'auto-draft'";
        if (!isset($_GET['post_status']) || 'trash' !== $_GET['post_status']) {
            $extra_checks .= " AND post_status != 'trash'";
        } elseif (isset($_GET['post_status'])) {
            $extra_checks = $wpdb->prepare(' AND post_status = %s', $_GET['post_status']);
        }
        $months = $wpdb->get_results($wpdb->prepare("\n\t\t\tSELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month\n\t\t\tFROM {$wpdb->posts}\n\t\t\tWHERE post_type = %s\n\t\t\t{$extra_checks}\n\t\t\tORDER BY post_date DESC\n\t\t", $post_type));
        /**
         * Filter the 'Months' drop-down results.
         *
         * @since 3.7.0
         *
         * @param object $months    The months drop-down query results.
         * @param string $post_type The post type.
         */
        $months = apply_filters('months_dropdown_results', $months, $post_type);
        $month_count = count($months);
        if (!$month_count || 1 == $month_count && 0 == $months[0]->month) {
            return;
        }
        $m = isset($_GET['m']) ? (int) $_GET['m'] : 0;
        ?>
		<label for="filter-by-date" class="screen-reader-text"><?php 
        _e('Filter by date');
        ?>
</label>
		<select name="m" id="filter-by-date">
			<option<?php 
        selected($m, 0);
        ?>
 value="0"><?php 
        _e('All dates');
        ?>
</option>
<?php 
        foreach ($months as $arc_row) {
            if (0 == $arc_row->year) {
                continue;
            }
            $month = zeroise($arc_row->month, 2);
            $year = $arc_row->year;
            printf("<option %s value='%s'>%s</option>\n", selected($m, $year . $month, false), esc_attr($arc_row->year . $month), sprintf(__('%1$s %2$d'), $wp_locale->get_month($month), $year));
        }
        ?>
		</select>
<?php 
    }
    /**
     * Generate the table navigation above or below the table
     */
    public function display_tablenav($which)
    {
        ?>
	<div class="tablenav <?php 
        echo esc_attr($which);
        ?>
">
		<?php 
        if ('top' == $which) {
            ?>
			<div class="alignleft actions">
				<select name="filter_status">
					<option value=""><?php 
            _e('Any status', 'download-monitor');
            ?>
</option>
					<option
						value="failed" <?php 
            selected($this->filter_status, 'failed');
            ?>
><?php 
            _e('Failed', 'download-monitor');
            ?>
</option>
					<option
						value="redirected" <?php 
            selected($this->filter_status, 'redirected');
            ?>
><?php 
            _e('Redirected', 'download-monitor');
            ?>
</option>
					<option
						value="completed" <?php 
            selected($this->filter_status, 'completed');
            ?>
><?php 
            _e('Completed', 'download-monitor');
            ?>
</option>
				</select>
				<?php 
            global $wpdb, $wp_locale;
            $months = $wpdb->get_results("\n\t\t\t\t\t\t\tSELECT DISTINCT YEAR( download_date ) AS year, MONTH( download_date ) AS month\n\t\t\t\t\t\t\tFROM {$wpdb->download_log}\n\t\t\t\t\t\t\tWHERE type = 'download'\n\t\t\t\t\t\t\tORDER BY download_date DESC\n\t\t\t\t\t\t");
            $month_count = count($months);
            if ($month_count && !(1 == $month_count && 0 == $months[0]->month)) {
                $m = isset($_GET['filter_month']) ? $_GET['filter_month'] : 0;
                ?>
					<select name="filter_month">
						<option <?php 
                selected($m, 0);
                ?>
 value='0'><?php 
                _e('Show all dates');
                ?>
</option>
						<?php 
                foreach ($months as $arc_row) {
                    if (0 == $arc_row->year) {
                        continue;
                    }
                    $month = zeroise($arc_row->month, 2);
                    $year = $arc_row->year;
                    printf("<option %s value='%s'>%s</option>\n", selected($m, $year . '-' . $month, false), esc_attr($year . '-' . $month), sprintf(__('%1$s %2$d'), $wp_locale->get_month($month), $year));
                }
                ?>
					</select>
				<?php 
            }
            ?>
				<select name="logs_per_page">
					<option value="25"><?php 
            _e('25 per page', 'download-monitor');
            ?>
</option>
					<option
						value="50" <?php 
            selected($this->logs_per_page, 50);
            ?>
><?php 
            _e('50 per page', 'download-monitor');
            ?>
</option>
					<option
						value="100" <?php 
            selected($this->logs_per_page, 100);
            ?>
><?php 
            _e('100 per page', 'download-monitor');
            ?>
</option>
					<option
						value="200" <?php 
            selected($this->logs_per_page, 200);
            ?>
><?php 
            _e('200 per page', 'download-monitor');
            ?>
</option>
					<option
						value="-1" <?php 
            selected($this->logs_per_page, -1);
            ?>
><?php 
            _e('Show All', 'download-monitor');
            ?>
</option>
				</select>
				<input type="hidden" name="post_type" value="dlm_download"/>
				<input type="hidden" name="page" value="download-monitor-logs"/>
				<input type="submit" value="<?php 
            _e('Filter', 'download-monitor');
            ?>
" class="button"/>
			</div>
		<?php 
        }
        ?>
		<?php 
        $this->extra_tablenav($which);
        $this->pagination($which);
        ?>
		<br class="clear"/>
		</div><?php 
    }