function eventbrite_format_time()
 {
     $start = eventbrite_event_start()->local;
     $end = eventbrite_event_end()->local;
     $event_time = sprintf('%s <br> %s - %s <br> %s - %s', esc_html(mysql2date('l', $start)) . 's', esc_html(mysql2date('g:i A', $start)), esc_html(mysql2date('g:i A', $end)), esc_html(mysql2date('F j', $start)), esc_html(mysql2date('F j Y', $end)));
     return $event_time;
 }
示例#2
0
 /** ************************************************************************
  * Recommended. This method is called when the parent class can't find a method
  * specifically build for a given column. Generally, it's recommended to include
  * one method for each column you want to render, keeping your package class
  * neat and organized. For example, if the class needs to process a column
  * named 'title', it would first see if a method named $this->column_title() 
  * exists - if it does, that method will be used. If it doesn't, this one will
  * be used. Generally, you should try to use custom column methods as much as 
  * possible. 
  * 
  * Since we have defined a column_title() method later on, this method doesn't
  * need to concern itself with any column with a name of 'title'. Instead, it
  * needs to handle everything else.
  * 
  * For more detailed insight into how columns are handled, take a look at 
  * WP_List_Table::single_row_columns()
  * 
  * @param array $item A singular item (one full row's worth of data)
  * @param array $column_name The name/slug of the column to be processed
  * @return string Text or HTML to be placed inside the column <td>
  **************************************************************************/
 function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'order_id':
         case 'buyer_userid':
         case 'buyer_name':
         case 'PaymentMethod':
         case 'eBayPaymentStatus':
         case 'CheckoutStatus':
         case 'CompleteStatus':
         case 'status':
             return $item[$column_name];
         case 'total':
             return number_format($item[$column_name], 2, ',', '.');
         case 'date_created':
         case 'LastTimeModified':
             // use date format from wp
             $date = mysql2date(get_option('date_format'), $item[$column_name]);
             $time = mysql2date('H:i', $item[$column_name]);
             return sprintf('%1$s <br><span style="color:silver">%2$s</span>', $date, $time);
         default:
             return print_r($item, true);
             //Show the whole array for troubleshooting purposes
     }
 }
示例#3
0
function sys_recent_posts($atts, $content = null)
{
    extract(shortcode_atts(array('limit' => '2', 'description' => '40', 'cat_id' => '23', 'thumb' => 'true', 'postdate' => ''), $atts));
    $out = '<div class="widget_postslist sc">';
    $out .= '<ul>';
    global $wpdb;
    $myposts = get_posts("numberposts={$limit}&offset=0&cat={$cat_id}");
    foreach ($myposts as $post) {
        $post_date = $post->post_date;
        $post_date = mysql2date('F j, Y', $post_date, false);
        $out .= "<li>";
        if ($thumb == "true") {
            $thumbid = get_post_thumbnail_id($post->ID);
            $imgsrc = wp_get_attachment_image_src($thumbid, array(9999, 9999));
            $out .= '<div class="thumb"><a href="' . get_permalink($post->ID) . '" title="' . $post->post_title . '">';
            if ($thumbid) {
                $out .= atp_resize('', $imgsrc['0'], '50', '50', 'imgborder', '');
            } else {
                //$out .= '<img class="imgborder" src="'.THEME_URI.'/images/no-image.jpg'.'"  alt="' .$post->post_title. '" />';
            }
            $out .= '</a></div>';
        }
        $out .= '<div class="pdesc"><a href="' . get_permalink($post->ID) . '" rel="bookmark">' . $post->post_title . '</a>';
        if ($postdate == "true") {
            $out .= '<div class="w-postmeta"><span>' . $post_date . '</span></div>';
        } else {
            $out .= '<p>' . wp_html_excerpt($post->post_content, $description, '...') . '</p>';
        }
        $out .= '</div></li>';
    }
    $out .= '</ul></div>';
    return $out;
    wp_reset_query();
}
/**
 * Performs post queries for internal linking.
 *
 * @since 3.1.0
 *
 * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments.
 * @return array Results.
 */
function wp_link_query($args = array())
{
    $pts = get_post_types(array('publicly_queryable' => true), 'objects');
    $pt_names = array_keys($pts);
    $query = array('post_type' => $pt_names, 'suppress_filters' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'post_status' => 'publish', 'order' => 'DESC', 'orderby' => 'post_date', 'posts_per_page' => 20);
    $args['pagenum'] = isset($args['pagenum']) ? absint($args['pagenum']) : 1;
    if (isset($args['s'])) {
        $query['s'] = $args['s'];
    }
    $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ($args['pagenum'] - 1) : 0;
    // Do main query.
    $get_posts = new WP_Query();
    $posts = $get_posts->query($query);
    // Check if any posts were found.
    if (!$get_posts->post_count) {
        return false;
    }
    // Build results.
    $results = array();
    foreach ($posts as $post) {
        if ('post' == $post->post_type) {
            $info = mysql2date(__('Y/m/d'), $post->post_date);
        } else {
            $info = $pts[$post->post_type]->labels->singular_name;
        }
        $results[] = array('ID' => $post->ID, 'title' => trim(esc_html(strip_tags(get_the_title($post)))), 'permalink' => get_permalink($post->ID), 'info' => $info);
    }
    return $results;
}
示例#5
0
 /**
  * @param string $url
  * @param string $format
  * @param int    $maxwidth
  * @param int    $maxheight
  * @param string $callback
  *
  * @return array|WP_JSON_Response|WP_Error
  */
 public function get_oembed_response($url, $format = 'json', $maxwidth = 640, $maxheight = 420, $callback = '')
 {
     if ('json' !== $format) {
         return new WP_Error('json_oembed_invalid_format', __('Format not supported.'), array('status' => 501));
     }
     $id = Helper::url_to_postid($url);
     if (0 === $id || !in_array(get_post_type($id), $this->type)) {
         return new WP_Error('json_oembed_invalid_url', __('Invalid URL.'), array('status' => 404));
     }
     if (320 > $maxwidth || 180 > $maxheight) {
         return new WP_Error('json_oembed_invalid_dimensions', __('Not implemented.'), array('status' => 501));
     }
     /** @var array $post */
     $post = get_post($id, ARRAY_A);
     // Link headers (see RFC 5988)
     $response = new WP_JSON_Response();
     $response->header('Last-Modified', mysql2date('D, d M Y H:i:s', $post['post_modified_gmt']) . 'GMT');
     $post = $this->prepare_response($post, $maxwidth, $maxheight);
     if (is_wp_error($post)) {
         return $post;
     }
     $response->link_header('alternate', get_permalink($id), array('type' => 'text/html'));
     $response->set_data($post);
     if ('' !== $callback) {
         $_GET['_jsonp'] = $callback;
     }
     return $response;
 }
示例#6
0
 /**
  * Set up global post data.
  *
  * @since 1.5.0
  *
  * @param object $post Post data.
  * @uses do_action_ref_array() Calls 'the_post'
  * @return bool True when finished.
  */
 function setup_postdata_custom($post)
 {
     global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages;
     $id = (int) $post->ID;
     $authordata = get_userdata($post->post_author);
     $currentday = mysql2date('d.m.y', $post->post_date, false);
     $currentmonth = mysql2date('m', $post->post_date, false);
     $numpages = 1;
     $multipage = 0;
     $page = get_query_var('page');
     if (!$page) {
         $page = 1;
     }
     if (is_single() || is_page() || is_feed()) {
         $more = 1;
     }
     $content = $post->post_content;
     $pages = array($post->post_content);
     /**
      * Fires once the post data has been setup.
      *
      * @since 2.8.0
      *
      * @param WP_Post &$post The Post object (passed by reference).
      */
     do_action_ref_array('the_post', array(&$post));
     return true;
 }
示例#7
0
 function Red_Item($values, $type = '', $match = '')
 {
     if (is_object($values)) {
         foreach ($values as $key => $value) {
             $this->{$key} = $value;
         }
         if ($this->match_type) {
             $this->match = Red_Match::create($this->match_type, $this->action_data);
             $this->match->id = $this->id;
             $this->match->action_code = $this->action_code;
         }
         if ($this->action_type) {
             $this->action = Red_Action::create($this->action_type, $this->action_code);
             $this->match->action = $this->action;
         } else {
             $this->action = Red_Action::create('nothing', 0);
         }
         if ($this->last_access == '0000-00-00 00:00:00') {
             $this->last_access = 0;
         } else {
             $this->last_access = mysql2date('U', $this->last_access);
         }
     } else {
         $this->url = $values;
         $this->type = $type;
         $this->match = $match;
     }
 }
 /**
  * Filter the date and time fields.
  *
  * @param   mixed   $value
  * @param   string  $key
  * @param   array   $data
  * @return  mixed
  * @access  public
  * @since   1.0.0
  */
 public function set_custom_field_data($value, $key, $data)
 {
     switch ($key) {
         case 'date':
             if (isset($data['post_date'])) {
                 $value = mysql2date('l, F j, Y', $data['post_date']);
             }
             break;
         case 'time':
             if (isset($data['post_date'])) {
                 $value = mysql2date('H:i A', $data['post_date']);
             }
             break;
         case 'status':
             if (isset($data['post_status'])) {
                 $value = $this->statuses[$data['post_status']];
             }
             break;
         case 'address':
             $value = str_replace('<br/>', PHP_EOL, charitable_get_donation($data['donation_id'])->get_donor_address());
             break;
         case 'phone':
             $value = charitable_get_donation($data['donation_id'])->get_donor()->get_donor_meta('phone');
             break;
         case 'donation_gateway':
             $value = charitable_get_donation($data['donation_id'])->get_gateway_object()->get_name();
             break;
     }
     return $value;
 }
示例#9
0
function email_back($id)
{
    global $wpdb, $email_send_comment;
    $reply_id = mysql_escape_string($_REQUEST['comment_reply_ID']);
    $post_id = mysql_escape_string($_REQUEST['comment_post_ID']);
    if ($reply_id == 0 || $_REQUEST["email"] != get_settings('admin_email') && !isset($_REQUEST['comment_email_back'])) {
        return;
    }
    $comment = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_ID='{$id}' LIMIT 0, 1");
    $reply_comment = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_ID='{$reply_id}' LIMIT 0, 1");
    $post = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE ID='{$post_id}' LIMIT 0, 1");
    $comment = $comment[0];
    $reply_comment = $reply_comment[0];
    $post = $post[0];
    $title = $post->post_title;
    $author = $reply_comment->comment_author;
    $url = get_permalink($post_id);
    $to = $reply_comment->comment_author_email;
    if ($to == "") {
        return;
    }
    $subject = "The author replied your comment at [" . get_bloginfo() . "]'" . $title;
    $date = mysql2date('Y.m.d H:i', $reply_comment->comment_date);
    $message = "\r\n\t<div>\r\n\t\t<p>Dear {$author}:<p>\r\n\t\t<p>{$comment->comment_content}</p>\r\n\t\t<div style='color:grey;'><small>{$date}, your comment at " . get_bloginfo() . "<a href='{$url}#comment-{$id}'>{$title}</a>: </small>\r\n\t\t\t<blockquote>\r\n\t\t\t\t<p>{$reply_comment->comment_content}</p>\r\n\t\t\t</blockquote>\r\n\t\t</div>\r\n\t</div>";
    // strip out some chars that might cause issues, and assemble vars
    $site_name = get_bloginfo();
    $site_email = get_settings('admin_email');
    $charset = get_settings('blog_charset');
    $headers = "From: \"{$site_name}\" <{$site_email}>\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: text/html; charset=\"{$charset}\"\n";
    $email_send_comment = "Email notification has sent to " . $to . " with subject '" . $subject . "'";
    return wp_mail($to, $subject, $message, $headers);
}
示例#10
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>';
 }
示例#11
0
function tool_html_time($p = array())
{
    /* Info
    
    				Takes a databasefield datevalue like 20130227 or
    				a date/time value like 2013022701230 and
    				returns a formated time tag.
    			*/
    $p += array('field' => false, 'format' => 'd.m.Y', 'timezone' => false);
    if ($p['field']) {
        $date_time = str_split($p['field'], 8);
        $date_arr = str_split($date_time[0], 2);
        if (!isset($date_time[1])) {
            $date_time[1] = '';
        }
        $time_arr = str_split(str_pad($date_time[1], 6, '0', STR_PAD_RIGHT), 2);
        $mysql2date_input_format = $date_arr[0] . $date_arr[1] . '-' . $date_arr[2] . '-' . $date_arr[3] . ' ' . $time_arr[0] . ':' . $time_arr[0] . ':' . $time_arr[0];
        $timestamp = mysql2date('U', $mysql2date_input_format);
        // use custom timezone
        if ($p['timezone']) {
            $timezone_default = date_default_timezone_get();
            date_default_timezone_set($p['timezone']);
        }
        $time = date('c', $timestamp);
        $text = date($p['format'], $timestamp);
        // define default timezone
        if ($p['timezone']) {
            date_default_timezone_set($timezone_default);
        }
        return '<time datetime="' . $time . '">' . $text . '</time>';
    } else {
        return false;
    }
}
示例#12
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>';
    }
 /**
  * Retrieve ranking
  *
  * Overrides the $type to set to 'post', then passes through to the post
  * endpoints.
  *
  * @see WP_JSON_Posts::get_posts()
  */
 public function get_ranking($filter = array(), $context = 'view')
 {
     $ids = sga_ranking_get_date($filter);
     $posts_list = array();
     foreach ($ids as $id) {
         $posts_list[] = get_post($id);
     }
     $response = new WP_JSON_Response();
     if (!$posts_list) {
         $response->set_data(array());
         return $response;
     }
     // holds all the posts data
     $struct = array();
     $response->header('Last-Modified', mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT');
     foreach ($posts_list as $post) {
         $post = get_object_vars($post);
         // Do we have permission to read this post?
         if (!$this->check_read_permission($post)) {
             continue;
         }
         $response->link_header('item', json_url('/posts/' . $post['ID']), array('title' => $post['post_title']));
         $post_data = $this->prepare_post($post, $context);
         if (is_wp_error($post_data)) {
             continue;
         }
         $struct[] = $post_data;
     }
     $response->set_data($struct);
     return $response;
 }
function cforms2_dashboard()
{
    global $wpdb, $cformsSettings;
    if (!current_user_can('track_cforms')) {
        return;
    }
    $WHERE = '';
    for ($i = 0; $i < $cformsSettings['global']['cforms_formcount']; $i++) {
        $no = $i == 0 ? '' : $i + 1;
        if ($cformsSettings['form' . $no]['cforms' . $no . '_dashboard'] == '1') {
            $WHERE .= "'{$no}',";
        }
    }
    if ($WHERE != '') {
        $WHERE = "WHERE form_id in (" . substr($WHERE, 0, -1) . ")";
    } else {
        return;
    }
    $entries = $wpdb->get_results("SELECT * FROM {$wpdb->cformssubmissions} {$WHERE} ORDER BY sub_date DESC LIMIT 0,5");
    $content .= "<style>\n" . "img.dashboardIcon{\n" . "vertical-align: middle;\n" . "margin-right: 6px;\n" . "}\n" . "</style>\n" . "<ul>";
    if (count($entries) > 0) {
        foreach ($entries as $entry) {
            $dateConv = mysql2date(get_option('date_format'), $entry->sub_date);
            $content .= '<li><img class="dashboardIcon" alt="" src="' . plugin_dir_url(__FILE__) . 'images/cformsicon.png">' . "<a title=\"" . __('click for details', 'cforms2') . "\" href='admin.php?page=" . plugin_dir_path(plugin_basename(__FILE__)) . "/cforms-database.php&d-id={$entry->id}#entry{$entry->id}'>{$entry->email}</a> " . __('via', 'cforms2') . " <strong>" . $cformsSettings['form' . $entry->form_id]['cforms' . $entry->form_id . '_fname'] . "</strong>" . " on " . $dateConv . "</li>";
        }
    } else {
        $content .= '<li>' . __('No entries yet', 'cforms2') . '</li>';
    }
    $content .= "</ul><p class=\"youhave\"><a href='admin.php?page=" . plugin_dir_path(plugin_basename(__FILE__)) . "/cforms-database.php'>" . __('Visit the cforms tracking page for all entries ', 'cforms2') . " &raquo;</a> </p>";
    echo $content;
}
示例#15
0
/**
 * Created by PhpStorm.
 * User: hoantv
 * Date: 2015-01-17
 * Time: 2:09 PM
 */
function cupid_result_search_callback()
{
    ob_start();
    function cupid_search_title_filter($where, &$wp_query)
    {
        global $wpdb;
        if ($keyword = $wp_query->get('search_prod_title')) {
            $where .= ' AND ((' . $wpdb->posts . '.post_title LIKE \'%' . $wpdb->esc_like($keyword) . '%\'';
            $where .= ' OR ' . $wpdb->posts . '.post_excerpt LIKE \'%' . $wpdb->esc_like($keyword) . '%\'';
            $where .= ' OR ' . $wpdb->posts . '.post_content LIKE \'%' . $wpdb->esc_like($keyword) . '%\'))';
        }
        return $where;
    }
    $keyword = $_REQUEST['keyword'];
    if ($keyword) {
        $search_query = array('search_prod_title' => $keyword, 'order' => 'DESC', 'orderby' => 'date', 'post_status' => 'publish', 'post_type' => array('post', 'cupid_classes'), 'nopaging' => true);
        add_filter('posts_where', 'cupid_search_title_filter', 10, 2);
        $search = new WP_Query($search_query);
        remove_filter('posts_where', 'cupid_search_title_filter', 10, 2);
        $newdata = array();
        if ($search && count($search->post) > 0) {
            foreach ($search->posts as $post) {
                $shortdesc = $post->post_excerpt;
                $newdata[] = array('id' => $post->ID, 'title' => $post->post_title, 'guid' => get_permalink($post->ID), 'date' => mysql2date('M d Y', $post->post_date), 'shortdesc' => $shortdesc);
            }
        } else {
            $newdata[] = array('id' => -1, 'title' => __('Sorry, but nothing matched your search terms. Please try again with different keywords.', 'cupid'), 'guid' => '', 'date' => null, 'shortdesc' => '');
        }
        ob_end_clean();
        echo json_encode($newdata);
    }
    die;
    // this is required to return a proper result
}
 public function get()
 {
     $license = $this->get_license();
     $downloads = $this->get_downloads();
     $config = ["alwaysShowHours" => true, "alwaysShowControls" => true, "chaptersVisible" => true, "permalink" => get_permalink($this->post->ID), "publicationDate" => mysql2date("c", $this->post->post_date), "title" => get_the_title($this->post->ID), "subtitle" => wptexturize(convert_chars(trim($this->episode->subtitle))), "summary" => nl2br(wptexturize(convert_chars(trim($this->episode->summary)))), "poster" => $this->episode->cover_art_with_fallback()->setWidth(500)->url(), "show" => ['title' => $this->podcast->title, 'subtitle' => $this->podcast->subtitle, 'summary' => $this->podcast->summary, 'poster' => $this->podcast->cover_art()->setWidth(500)->url(), 'url' => \Podlove\get_landing_page_url()], "license" => ["name" => $license['name'], "url" => $license['url']], "downloads" => $downloads, "duration" => $this->episode->get_duration(), "features" => ["current", "progress", "duration", "tracks", "fullscreen", "volume"], "chapters" => json_decode($this->episode->get_chapters('json')), "languageCode" => $this->podcast->language];
     return $config;
 }
示例#17
0
 /**
  * Search for publications.
  *
  * @param array $args
  * @return array
  */
 private function publication_query($args = array())
 {
     $query = array('post_type' => 'seoslides-slideset', 'suppress_filters' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'post_status' => 'publish', 'order' => 'DESC', 'orderby' => 'post_date', 'posts_per_page' => 20);
     $args['pagenum'] = isset($args['pagenum']) ? absint($args['pagenum']) : 1;
     if (isset($args['s'])) {
         $query['s'] = $args['s'];
     }
     $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ($args['pagenum'] - 1) : 0;
     // Run the query
     $get_posts = new WP_Query();
     $posts = $get_posts->query($query);
     $results = array();
     if (0 === $get_posts->post_count) {
         return $results;
     }
     // Populate results
     foreach ($posts as $post) {
         // Get the embed ID for the first slide in the presentation
         $slideset = new SEOSlides_Slideset($post->ID);
         /** @var SEOSlides_Embed $embed */
         $embed = SEOSlides_Module_Provider::get('SEOSlides Embed');
         $embed_id = $embed->get_embed_unique_id($post->ID, $slideset->first_slide()->slug);
         $embed_url = $embed->get_embed_url($post->ID, $slideset->first_slide()->slug);
         $shortcode = '[seoslides embed_id="' . $embed_id . '"';
         $shortcode .= ' script_src="' . preg_replace('/\\/(slides|embeds)\\//', '/embed-script/', $embed_url) . '"';
         $shortcode .= ' overview_src="' . get_permalink($post) . '"';
         $shortcode .= ' title="' . get_the_title($post) . '"';
         $shortcode .= ' site_src="' . get_home_url() . '"';
         $shortcode .= ' site_title="' . get_bloginfo('name') . '"';
         $shortcode .= ' /]';
         $results[] = array('ID' => $post->ID, 'title' => trim(esc_html(strip_tags(get_the_title($post)))), 'shortcode' => esc_attr($shortcode), 'info' => mysql2date(__('Y/m/d'), $post->post_date));
     }
     return $results;
 }
function jl_brd_dashboard_recent_drafts($drafts = false)
{
    if (!$drafts) {
        $drafts_query = new WP_Query(array('post_type' => 'any', 'post_status' => array('draft', 'pending'), 'posts_per_page' => 150, 'orderby' => 'modified', 'order' => 'DESC'));
        $drafts =& $drafts_query->posts;
    }
    if ($drafts && is_array($drafts)) {
        $list = array();
        foreach ($drafts as $draft) {
            $url = get_edit_post_link($draft->ID);
            $title = _draft_or_post_title($draft->ID);
            $last_id = get_post_meta($draft->ID, '_edit_last', true);
            $last_user = get_userdata($last_id);
            $last_modified = '<i>' . esc_html($last_user->display_name) . '</i>';
            $item = '<h4><a href="' . $url . '" title="' . sprintf(__('Edit ?%s?'), esc_attr($title)) . '">' . esc_html($title) . '</a>' . '<abbr> ' . $draft->post_status . ' ' . $draft->post_type . '</abbr>' . '<abbr style="display:block;margin-left:0;">' . sprintf(__('Last edited by %1$s on %2$s at %3$s'), $last_modified, mysql2date(get_option('date_format'), $draft->post_modified), mysql2date(get_option('time_format'), $draft->post_modified)) . '</abbr></h4>';
            if ($the_content = preg_split('#\\s#', strip_shortcodes(strip_tags($draft->post_content), 11, PREG_SPLIT_NO_EMPTY))) {
                $item .= '<p>' . join(' ', array_slice($the_content, 0, 10)) . (10 < count($the_content) ? '&hellip;' : '') . '</p>';
            }
            $list[] = $item;
        }
        ?>
	<ul>
		<li><?php 
        echo join("</li>\n<li>", $list);
        ?>
</li>
	</ul>
<?php 
    } else {
        _e('There are no drafts at the moment');
    }
}
示例#19
0
 public function get_related($id = '', $filter = array(), $context = 'view')
 {
     $option = get_option('sirp_options');
     $num = !empty($filter['num']) ? (int) $filter['num'] : (int) $option['display_num'];
     $ids = sirp_get_related_posts_id_api($num, $id);
     $posts_list = array();
     foreach ($ids as $id) {
         $posts_list[] = get_post($id['ID']);
     }
     $response = new WP_JSON_Response();
     if (!$posts_list) {
         $response->set_data(array());
         return $response;
     }
     $struct = array();
     $response->header('Last-Modified', mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT');
     foreach ($posts_list as $post) {
         $post = get_object_vars($post);
         if (!$this->check_read_permission($post)) {
             continue;
         }
         $response->link_header('item', json_url('/posts/' . $post['ID']), array('title' => $post['post_title']));
         $post_data = $this->prepare_post($post, $context);
         if (is_wp_error($post_data)) {
             continue;
         }
         $struct[] = $post_data;
     }
     $response->set_data($struct);
     return $response;
 }
function ipad_html($post)
{
    global $ml_html_banners_enable;
    $ml_html_banners_enable = get_option("ml_html_banners_enable");
    $prefiltered_html = ml_filters_get_filtered($post->post_content);
    $prefiltered_html = str_replace("\n", "<p></p>", $prefiltered_html);
    $html = str_get_html($prefiltered_html);
    $img_tags = $html->find('img');
    $iframe_tags = $html->find('iframe');
    $object_tags = $html->find('object');
    $embed_tags = $html->find('embed');
    $tags = array_merge($img_tags, $iframe_tags, $object_tags, $embed_tags);
    $scripts = $html->find('script');
    //on center, with specific width and no height
    foreach ($tags as $e) {
        //no width or height
        if (isset($e->width)) {
            $e->width = null;
        }
        if (isset($e->height)) {
            $e->height = null;
        }
        $e->style = "max-width:520px;margin-top:20px;margin-bottom:20px;";
        if ($e->tag == "iframe" || $e->tag == "object" || $e->tag == "embed") {
            //should be a video
            $e->width = 500;
            $e->height = 300;
        }
        //center
        $e->outertext = "<center><div class=\"wp2android_media\">" . $e->outertext . "</div></center><p></p>";
    }
    foreach ($scripts as $s) {
        $s->outertext = "";
    }
    //JAVASCRIPT INCLUDES
    //HEAD
    $header = "<head>" . $header_js;
    $header .= "<meta name=\"viewport\" content=\"width=device-width; minimum-scale=1.0; maximum-scale=1.0;\" />";
    $header .= "<link rel=\"StyleSheet\" href=\"" . plugin_dir_url(__FILE__) . "css/ipad.css\" type=\"text/css\"  media=\"screen\">";
    $header .= "<link rel=\"StyleSheet\" href=\"" . plugin_dir_url(__FILE__) . "css/ipad_portrait.css\" type=\"text/css\"  media=\"screen\" id=\"orient_css\">";
    $header .= ml_filters_header($post->postID);
    $header .= "</head>";
    $init_html = "<html manifest=\"" . plugin_dir_url(__FILE__ + "../") . "manifest.php\">" . $header;
    $title = "<h1 class='title' align='left'>" . $post->post_title . "</h1>";
    $author = get_author_name($post->post_author);
    $text_author = "";
    if (strcmp($author, "admin") != 0) {
        if (strcmp($author, "") != 0) {
            $text_author = " &bull; " . get_author_name($post->post_author);
        }
    }
    if (get_post_type($post->ID) != "page") {
        $title .= "<p class='details'>" . mysql2date('F j Y', $post->post_date) . "" . $text_author . "</p><p>&nbsp;</p>";
    }
    $final_html = $init_html;
    $final_html .= "<body><div id=\"content\">";
    $final_html .= $spaces;
    $final_html .= $title . $html->save() . $spaces . "<br/><br/><br/><br/><br/><br/><br/><br/></div></body></html>";
    return $final_html;
}
 public function render_single_reply_html($reply)
 {
     $reply_timestamp = mysql2date('M. n', $reply->post_date_gmt);
     $reply_author = get_post_meta($reply->ID, 'reply_author');
     $output = '<div class="ticket-reply-body">' . wpautop(stripslashes($reply->post_content)) . '</div>' . '<div class="ticket-reply-meta">' . '<span class="ticket-reply-author">' . esc_html($reply_author) . '</span>' . '<span class="ticket-reply-timestamp">' . esc_html($reply_timestamp) . '</span>' . '</div>';
     return $output;
 }
 function column_date($post)
 {
     if ('0000-00-00 00:00:00' == $post->post_date) {
         $t_time = $h_time = __('Unpublished');
         $time_diff = 0;
     } else {
         $t_time = get_the_time(__('Y/m/d g:i:s A'));
         $m_time = $post->post_date;
         $time = get_post_time('G', true, $post);
         $time_diff = time() - $time;
         if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
             $h_time = sprintf(__('%s ago'), human_time_diff($time));
         } else {
             $h_time = mysql2date(__('Y/m/d'), $m_time);
         }
     }
     if ('excerpt' == $mode) {
         echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
     } else {
         echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
     }
     echo '<br />';
     if ('publish' == $post->post_status) {
         _e('Published');
     } elseif ('future' == $post->post_status) {
         if ($time_diff > 0) {
             echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
         } else {
             _e('Scheduled');
         }
     } else {
         _e('Last Modified');
     }
 }
示例#23
0
 public function widget($args, $instance)
 {
     $title = apply_filters('widget_title', @$instance['title']);
     echo $args['before_widget'];
     if (!empty($title)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     $ans_count = ap_question_get_the_answer_count();
     $last_active = ap_question_get_the_active_ago();
     $total_subs = ap_question_get_the_subscriber_count();
     $view_count = ap_question_get_the_view_count();
     echo '<div class="ap-widget-inner">';
     if (is_question()) {
         echo '<ul class="ap-stats-widget">';
         echo '<li><span class="stat-label apicon-pulse">' . __('Active', 'ap') . '</span><span class="stat-value"><time class="published updated" itemprop="dateModified" datetime="' . mysql2date('c', $last_active) . '">' . ap_human_time(mysql2date('U', $last_active)) . '</time></span></li>';
         echo '<li><span class="stat-label apicon-eye">' . __('Views', 'ap') . '</span><span class="stat-value">' . sprintf(_n('One time', '%d times', $view_count, 'ap'), $view_count) . '</span></li>';
         echo '<li><span class="stat-label apicon-answer">' . __('Answers', 'ap') . '</span><span class="stat-value">' . sprintf(_n('%2$s1%3$s answer', '%2$s%1$d%3$s answers', $ans_count, 'ap'), $ans_count, '<span data-view="answer_count">', '</span>') . '</span></li>';
         echo '<li><span class="stat-label apicon-mail">' . __('Followers', 'ap') . '</span><span class="stat-value">' . sprintf(_n('1 follower', '%d followers', $total_subs, 'ap'), $total_subs) . '</span></li>';
         echo '</ul>';
     } else {
         _e('This widget can only be used in single question page', 'ap');
     }
     echo '</div>';
     echo $args['after_widget'];
 }
    private function get_related_posts_content()
    {
        $related_posts = ep_more_like_this(get_the_ID(), null);
        $rp_content = ' <hr class="above-related-posts" /><div class="related-posts-head">';
        $rp_content .= __('Related Posts', 'elasticpress');
        $rp_content .= '</div>';
        if ($related_posts['found_posts'] > 0) {
            $rp_content .= '<ul class="ep4wpe-related-posts">';
            $post_limit = get_site_option(namespace\POST_COUNT_FIELD, namespace\MAX_RELATED_POSTS);
            for ($i = 0; $i < $post_limit; $i++) {
                $rp = $related_posts['posts'][$i];
                $rp_date = mysql2date('F j, Y', $rp['post_date']);
                $rp_content .= <<<RELATEDPOST
<li class="related-post-item">
  <a href="{$rp['permalink']}" rel="bookmark" title="{$rp['post_title']}" class="related-post-link" >{$rp['post_title']}</a>
  <span class="related-post-date">{$rp_date}</span>
</li>
RELATEDPOST;
            }
            $rp_content .= '</ul>';
        } else {
            $rp_content .= '<span class="no-related-posts">' . __('No related posts found.', 'elasticpress') . '</span>';
        }
        return $rp_content;
    }
function get_recent_comments_name($start = 0, $author = "", $div = "SP", $no_comments = 5, $before = '<li>', $after = '</li>', $show_pass_post = false)
{
    global $wpdb, $tablecomments, $tableposts, $total;
    $request = "select T1.comment_post_ID, T1.comment_date, T1.comment_ID, T1.comment_content, T1.comment_author, T1.comment_date, T1.comment_reply_ID from {$tablecomments} as T1 left join {$tablecomments} as T2 ON (T2.comment_author = '{$author}' OR T2.comment_ID = 1) WHERE ((T2.comment_author = '{$author}' AND T2.comment_ID = T1.comment_reply_ID) OR (T1.comment_author = '{$author}' AND T2.comment_ID = 1)) ";
    $request .= " ORDER BY T1.comment_date DESC LIMIT {$start}, {$no_comments}";
    $comments = $wpdb->get_results($request);
    $output = '';
    if (!empty($comments)) {
        foreach ($comments as $comment) {
            $total = $total + 1;
            $comment_author = stripslashes($comment->comment_author);
            $comment_content = strip_tags($comment->comment_content);
            $comment_content = stripslashes($comment_content);
            $comment_excerpt = substr($comment_content, 0, 100);
            $comment_excerpt = utf8_trim_1($comment_excerpt);
            $posturl = get_permalink($comment->comment_post_ID);
            $permalink = $posturl . "#comment-" . $comment->comment_ID;
            $posttitle = get_the_title($comment->comment_post_ID);
            $commentdate = mysql2date('Y.m.d H:i', $comment->comment_date);
            $output .= $before . '<a href="' . $comment->comment_author_url . '" title="作者网站" target="_blank">' . $comment_author . '</a>&#22312;&#25991;&#31456;<a href="' . $permalink . '" onclick="ajaxShowPost(\'' . get_settings('home') . '/wp-content/themes/yuewei/jscript/getpost.php?id=' . $comment->comment_post_ID . '\', \'' . $div . '\', \'comment-' . $comment->comment_ID . '\'); window.location.href=\'#' . 'comment-' . $comment->comment_ID . '\';return false;" title="发表于' . $commentdate . '">' . $posttitle . '</a>&#35828;&#65306; <span class="grey">' . $comment_excerpt . '...</span>' . $after;
        }
    }
    if ($output == '') {
        echo '<li>' . $author . ', 您好!</li><li>你目前还没有发表任何留言,当你发表留言后,在这里可以直接察看最近你所发表过的留言以及他人对你的留言的回复</li>';
    } else {
        echo $author . '最近的留言以及获得的回复:';
        echo $output;
    }
}
示例#26
0
 /**
  * @param $entry
  */
 private static function migrate_legacy_entry($entry)
 {
     echo '<li>Importing live blog entry: ' . esc_html(substr($entry->post, 0, 100)) . '&hellip;</li>';
     $import = array('post_status' => 'publish', 'post_type' => 'liveblog_entry', 'post_author' => $entry->author, 'post_title' => 'Imported legacy liveblog post', 'post_content' => $entry->post, 'post_date' => mysql2date('Y-m-d H:i:s', $entry->dt), 'tax_input' => array('liveblog' => 'legacy-' . $entry->lbid));
     wp_insert_post($import);
     self::remove_legacy_entry($entry);
 }
 function sort_comment_by_date($a, $b)
 {
     if ($b->ID == $a->ID) {
         return mysql2date('U', $a->comment_date) - mysql2date('U', $b->comment_date);
     }
     return mysql2date('U', $b->post_date) - mysql2date('U', $a->post_date);
 }
示例#28
0
/**
 * Retrieves page date the same way it is retrieved in native panel :
 * see /wp-admin/includes/class-wp-posts-list-table.php
 */
function apm_get_page_date($node)
{
    global $mode;
    $post_date = $node->publication_date;
    $post_date_gmt = $node->publication_date_gmt;
    //For legacy, because APM didn't set the gmt date at page creation before :
    if ($node->status == 2 && '0000-00-00 00:00:00' == $post_date_gmt) {
        $post_date_gmt = date('Y-m-d H:i:s', strtotime($post_date) - get_option('gmt_offset') * 3600);
    }
    if ('0000-00-00 00:00:00' == $post_date) {
        $t_time = $h_time = __('Unpublished');
        $time_diff = 0;
    } else {
        $t_time = mysql2date(__('Y/m/d g:i:s A'), $post_date, true);
        $m_time = $post_date;
        $time = mysql2date('G', $post_date_gmt, false);
        $time_diff = time() - $time;
        if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
            $h_time = sprintf(__('%s ago'), human_time_diff($time));
        } else {
            $h_time = mysql2date(__('Y/m/d'), $m_time);
        }
    }
    $page_date = '<abbr title="' . $t_time . '">' . apply_filters('apm_post_date_column_time', $h_time, $node, 'apm-date', $mode) . '</abbr>';
    return $page_date;
}
 function column_date($post)
 {
     $html = '';
     if ('0000-00-00 00:00:00' == $post->post_date) {
         $t_time = $h_time = __('Unpublished', 'jetpack');
         $time_diff = 0;
     } else {
         $t_time = date(__('Y/m/d g:i:s A', 'jetpack'), mysql2date('G', $post->post_date));
         $m_time = $post->post_date;
         $time = get_post_time('G', true, $post);
         $time_diff = time() - $time;
         if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
             $h_time = sprintf(__('%s ago', 'jetpack'), human_time_diff($time));
         } else {
             $h_time = mysql2date(__('Y/m/d', 'jetpack'), $m_time);
         }
     }
     $html .= '<abbr title="' . esc_attr($t_time) . '">' . esc_html($h_time) . '</abbr>';
     $html .= '<br />';
     if ('publish' == $post->post_status) {
         $html .= esc_html__('Published', 'jetpack');
     } elseif ('future' == $post->post_status) {
         if ($time_diff > 0) {
             $html .= '<strong class="attention">' . esc_html__('Missed schedule', 'jetpack') . '</strong>';
         } else {
             $html .= esc_html__('Scheduled', 'jetpack');
         }
     } else {
         $html .= esc_html__('Last Modified', 'jetpack');
     }
     return $html;
 }
 /**
  * This method display default column
  *
  * @return string $item[ $column_name ]
  * @author Amaury Balmer, Alexandre Sadowski
  */
 function column_default($item, $column_name)
 {
     $value = '';
     switch ($column_name) {
         case 'from_name':
         case 'from':
         case 'subject':
         case 'email':
             $value = $item[$column_name];
             break;
         case 'add_date':
         case 'scheduled_from':
             $value = mysql2date('d/m/Y H:i:s', $item[$column_name]);
             break;
         case 'todo':
             $value = self::getCampaignTodo($item['id']);
             break;
         case 'current_status':
             $value = Bea_Sender_Client::getStatus($item[$column_name]);
             break;
         case 'success':
             $value = self::getCampaignSend($item['id']);
             break;
         case 'failed':
             $value = self::getCampaignFailed($item['id']);
             break;
         case 'bounced':
             $value = self::getCampaignBounced($item['id']);
             break;
         default:
             //Show the whole array for troubleshooting purposes
             break;
     }
     return apply_filters('manage_' . $this->screen->id . '_custom_column', $value, $item, $column_name);
 }