/**
  *
  *	Change status of votes
  *
  */
 function avfr_change_status()
 {
     global $avfr_db;
     $post_id = $_POST['post_id'];
     $current_status = get_post_meta($post_id, '_avfr_status', true);
     $new_status = $_POST['new_status'];
     if ($new_status != $current_status && current_user_can('manage_options')) {
         update_post_meta($post_id, '_avfr_status', $new_status);
         echo 'success';
     }
     // for email
     $post_author_id = get_post_field('post_author', $post_id);
     $reciever_info = get_userdata($post_author_id);
     $entry = get_post($post_id);
     $search = array('{{writer-name}}', '{{avfr-title}}', '{{votes}}');
     $replace = array($reciever_info->user_login, $entry->post_title, avfr_get_votes($post_id));
     if ('on' == avfr_get_option('avfr_send_mail_' . $new_status . '_writer', 'avfr_settings_mail')) {
         $reciever_email = get_the_author_meta('user_email', $post_author_id);
         $content = avfr_get_option('avfr_mail_content_' . $new_status . '_writer', 'avfr_settings_mail');
         $mail_content = str_replace($search, $replace, $content);
         wp_mail($reciever_email, 'Feature Request ' . $entry->post_title . ' ' . $new_status . '.', $mail_content);
     }
     if ('on' == avfr_get_option('avfr_send_mail_' . $new_status . '_voters', 'avfr_settings_mail')) {
         $reciever_emails = $avfr_db->avfr_get_voters_email($post_id);
         $content = avfr_get_option('avfr_mail_content_' . $new_status . '_voters', 'avfr_settings_mail');
         $mail_content = str_replace($search, $replace, $content);
         wp_mail($reciever_emails, 'Request ' . $entry->post_title . ' ' . $new_status . '.', $mail_content);
     }
     exit;
     // Ajax
 }
 function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'rate':
             $download = get_post_meta($item['ID'], '_download_id', true);
             $type = eddc_get_commission_type($download);
             if ('percentage' == $type) {
                 return $item[$column_name] . '%';
             } else {
                 return edd_currency_filter(edd_sanitize_amount($item[$column_name]));
             }
         case 'status':
             return $item[$column_name];
         case 'amount':
             return edd_currency_filter(edd_format_amount($item[$column_name]));
         case 'date':
             return date_i18n(get_option('date_format'), strtotime(get_post_field('post_date', $item['ID'])));
         case 'download':
             $download = !empty($item['download']) ? $item['download'] : false;
             return $download ? '<a href="' . esc_url(add_query_arg('download', $download)) . '" title="' . __('View all commissions for this item', 'eddc') . '">' . get_the_title($download) . '</a>' . (!empty($item['variation']) ? ' - ' . $item['variation'] : '') : '';
         case 'payment':
             $payment = get_post_meta($item['ID'], '_edd_commission_payment_id', true);
             return $payment ? '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $payment)) . '" title="' . __('View payment details', 'eddc') . '">#' . $payment . '</a> - ' . edd_get_payment_status(get_post($payment), true) : '';
         default:
             return print_r($item, true);
             //Show the whole array for troubleshooting purposes
     }
 }
 /**
  * Get the data being exported
  *
  * @access      public
  * @since       1.2
  * @return      array
  */
 public function get_data()
 {
     global $edd_logs;
     $data = array();
     $args = array('nopaging' => true, 'post_type' => 'edd_payment', 'meta_key' => '_edd_payment_shipping_status', 'meta_value' => '1', 'fields' => 'ids');
     $payments = get_posts($args);
     if ($payments) {
         foreach ($payments as $payment) {
             $user_info = edd_get_payment_meta_user_info($payment);
             $downloads = edd_get_payment_meta_cart_details($payment);
             $products = '';
             if ($downloads) {
                 foreach ($downloads as $key => $download) {
                     // Display the Downoad Name
                     $products .= get_the_title($download['id']);
                     if ($key != count($downloads) - 1) {
                         $products .= ' / ';
                     }
                 }
             }
             $data[] = array('id' => $payment, 'date' => get_post_field('post_date', $payment), 'first_name' => $user_info['first_name'], 'last_name' => $user_info['last_name'], 'email' => $user_info['email'], 'address' => $user_info['shipping_info']['address'], 'address2' => !empty($user_info['shipping_info']['address2']) ? $user_info['shipping_info']['address2'] : '', 'city' => $user_info['shipping_info']['city'], 'state' => $user_info['shipping_info']['state'], 'zip' => $user_info['shipping_info']['zip'], 'country' => $user_info['shipping_info']['country'], 'amount' => edd_get_payment_amount($payment), 'tax' => edd_get_payment_tax($payment), 'gateway' => edd_get_payment_gateway($payment), 'key' => edd_get_payment_key($payment), 'products' => $products, 'status' => get_post_field('post_status', $payment));
         }
     }
     $data = apply_filters('edd_export_get_data', $data);
     $data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
     return $data;
 }
function wpdt_wpas_before_tickets_list()
{
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $args = array('post_type' => 'ticket', 'post_status' => 'any', 'order' => 'DESC', 'orderby' => 'date', 'posts_per_page' => 20, 'paged' => $paged, 'no_found_rows' => false, 'cache_results' => false, 'update_post_term_cache' => false, 'update_post_meta_cache' => false);
    if (isset($_REQUEST['searchString']) && $_REQUEST['searchString'] != '') {
        $results = array();
        $args['post_title_like'] = $_REQUEST['searchString'];
        $args['order'] = 'ASC';
        $args['orderby'] = 'title';
        global $wpas_tickets;
        $wpas_tickets = new WP_Query($args);
        if ($wpas_tickets->have_posts()) {
            while ($wpas_tickets->have_posts()) {
                $wpas_tickets->the_post();
                $url = site_url() . "/ticket/" . get_post_field('post_name', get_post());
                $return_value = get_the_title();
                $results[] = array('value' => $return_value, 'slug' => get_the_permalink(), 'url' => $url, 'tokens' => explode(' ', get_the_title()), 'css_class' => 'no_class');
            }
        } else {
            $results['value'] = 'No results found.';
        }
        wp_reset_postdata();
        echo json_encode($results);
        exit;
    }
    global $wpas_tickets;
    $wpas_tickets = new WP_Query($args);
}
 public function displayPatreonCampaignBanner($patreon_level)
 {
     /* patreon banner when user patronage not high enough */
     /* TODO: get marketing collateral */
     //return '<img src="http://placehold.it/500x150?text=PATREON MARKETING COLLATERAL"/>';
     //TAO get the patreon pitch page and display it
     //TAO this is the patreon pitch page
     $TAO_patreon_pitch_page_url = get_option('tao-patreon-pitch-page', '');
     //if options comes back with something, then replace the $content
     if ($TAO_patreon_pitch_page_url) {
         //I have a full url from the options page, convert that into an DI
         $TAO_patreon_pitch_page_id = url_to_postid($TAO_patreon_pitch_page_url);
         //the id was found, get the content of that post now
         if ($TAO_patreon_pitch_page_id) {
             //Display a message for the viewer to usnderstand why they cannot see the content if the option is filled out
             $TAO_patreon_pitch_reason = get_option('tao-patreon-pitch-reason', '');
             if ($TAO_patreon_pitch_reason) {
                 //check to see if $patreon_level exists in string and replace it with $patreon_level var
                 $TAO_patreon_pitch_reason = str_replace('$patreon_level', '$' . $patreon_level, $TAO_patreon_pitch_reason);
                 //$content = '[message_box type="note" icon="yes"]' . $TAO_patreon_pitch_reason . '[/message_box][hr]';
                 $content = $TAO_patreon_pitch_reason;
             }
             //get the content from a post ID, which is the patreon pitch page
             $content .= get_post_field('post_content', $TAO_patreon_pitch_page_id);
             return $content;
         }
     }
 }
function displayContactBySubsidiary()
{
    $obj = get_post_type_object('contact_subsidiary');
    echo "<h2>";
    echo $obj->labels->singular_name;
    echo "</h2>";
    echo "<div style='width:400px; float:left;'>";
    $loop2 = new WP_Query(array('post_type' => 'contact_subsidiary', 'posts_per_page' => -1));
    while ($loop2->have_posts()) {
        $loop2->the_post();
        $postid = get_the_ID();
        echo "Title: " . ($title_contact_subsidiary = get_the_title());
        echo "</br>";
        $meta_value_internal = get_post_meta($postid, 'subsidiaries_internal', true);
        if ($meta_value_internal !== "") {
            foreach ($meta_value_internal as $value_internal) {
                //print_r($value_internal);
                echo $title_internal = $value_internal['internal-subsidiary-title'];
                echo $description_internal = $value_internal['internal-subsidiary-description'];
            }
        } else {
            echo "Content: " . ($content_contact_subsidiary = get_post_field('post_content', $post->ID));
        }
        echo "<hr>";
        echo "</br>";
    }
    echo "</div>";
}
/**
 * Returns whether the current user is the creator of the given campaign.
 *
 * @param   int     $campaign_id
 * @return  boolean
 * @since   1.0.0
 */
function charitable_is_current_campaign_creator($campaign_id = null)
{
    if (is_null($campaign_id)) {
        $campaign_id = charitable_get_current_campaign_id();
    }
    return get_post_field('post_author', $campaign_id) == get_current_user_id();
}
 /**
  * Updates post_meta with number of words
  * @author Eric Wennerberg
  * @since 0.0.7
  * @version 0.2.0
  * @param str $post_id
  * @return int $words;
  */
 function helpers_calculate_read_time($post_id)
 {
     $content = apply_filters('the_content', get_post_field('post_content', $post_id, 'raw'));
     $words = str_word_count($content);
     update_post_meta($post_id, 'flavour_num_words', $words);
     return $words;
 }
function dwqa_get_latest_action_date($question = false, $before = '<span>', $after = '</span>')
{
    if (!$question) {
        $question = get_the_ID();
    }
    global $post;
    $message = '';
    $latest_answer = dwqa_get_latest_answer($question);
    $last_activity_date = $latest_answer ? $latest_answer->post_date : get_post_field('post_date', $question);
    $post_id = $latest_answer ? $latest_answer->ID : $question;
    $author_id = $post->post_author;
    if ($author_id == 0 || dwqa_is_anonymous($post_id)) {
        $anonymous_name = get_post_meta($post_id, '_dwqa_anonymous_name', true);
        if ($anonymous_name) {
            $author_link = $anonymous_name . ' ';
        } else {
            $author_link = __('Anonymous', 'dwqa') . ' ';
        }
    } else {
        $display_name = get_the_author_meta('display_name', $author_id);
        $author_url = get_author_posts_url($author_id);
        $author_avatar = wp_cache_get('avatar_of_' . $author_id, 'dwqa');
        if (false === $author_avatar) {
            $author_avatar = get_avatar($author_id, 12);
            wp_cache_set('avatar_of_' . $author_id, $author_avatar, 'dwqa', 60 * 60 * 24 * 7);
        }
        $author_link = sprintf('<span class="dwqa-author">%3$s</span>', $author_url, esc_attr(sprintf(__('Posts by %s'), $display_name)), $display_name, $author_avatar);
    }
    if ($last_activity_date && $post->last_activity_type == 'answer') {
        $date = dwqa_human_time_diff(strtotime($last_activity_date), false, get_option('date_format'));
        return sprintf(__('%s respondida <span class="dwqa-date">%s</span>', 'dwqa'), $author_link, $date);
    }
    return sprintf(__('%s perguntou <span class="dwqa-date">%s</span>', 'dwqa'), $author_link, get_the_date());
}
Beispiel #10
-1
 function olr_custom_column_date($column_name, $id)
 {
     $meta_key = 'olr_custom_column';
     $column = get_post_meta($id, $meta_key, true);
     if ($column_name == 'Phone') {
         echo $column['Phone'];
     }
     if ($column_name == 'Email') {
         echo $column['Email'];
     }
     if ($column_name == 'editor') {
         echo nl2br(get_post_field('post_content', $id));
     }
     if ($column_name == 'Tables') {
         $type_tables = '';
         if ($column['Type_of_Tables'] != '') {
             $type_tables = ' ( ' . $column['Type_of_Tables'] . ' )';
         }
         echo $column['Tables'] . $type_tables;
     }
     if ($column_name == 'Persons') {
         echo $column['Persons'];
     }
     if ($column_name == 'Booking Date') {
         echo $column['Booking_Date'] . ', ' . $column['Booking_Time'];
     }
     if ($column_name == 'Confirmation Key') {
         echo $column['Confirmation_Key'];
     }
     if ($column_name == 'status') {
         $status = get_post_status($id);
         echo '<span class="' . $status . '">' . ucfirst($status) . '</span>';
     }
 }
Beispiel #11
-1
function get_flexslider()
{
    //get attachments
    $attachments = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'order' => 'ASC'));
    //open slider
    $slider .= '
    <!-- Start Flexslider -->
    <div class="flexslider">
        <ul class="slides">
    ';
    //get conditional slider
    if ($attachments) {
        foreach ($attachments as $attachment_id => $attachment) {
            $theUrl = wp_get_attachment_url($attachment_id);
            $theCaption = get_post_field('post_excerpt', $attachment->ID);
            $slider .= '
            <li data-thumb="' . $theUrl . '">
                <img src="' . $theUrl . '" alt="slider1"/>
            </li>
            ';
        }
    }
    //end slider
    $slider .= '
        </ul>
        </div>
        <!-- End Flexslider -->
    ';
    //return slider
    return $slider;
}
function save_inquiry($post_id)
{
    if (!wp_is_post_revision($post_id)) {
        $forms = get_field('forms', 'option');
        $post_type = get_post_field('post_type', $post_id);
        foreach ($forms as $form) {
            if ($post_type == $form['post_type']) {
                $title = $form['title'];
                $title = str_replace('newpost', $post_id, $title);
                $title = do_shortcode($title);
                $slug = str_replace(' ', '-', strtolower($title));
                $post = array("post_title" => $title, 'ID' => $post_id, 'post_name' => $slug);
                wp_update_post($post);
                $headers = array('Content-Type: text/html; charset=UTF-8');
                $subject = $title . ' (' . $post_id . ')';
                $email_html = site_url() . '?acf-cf-email=' . $post_id;
                if (!empty($form['template'])) {
                    $email_html = $email_html . '&template=' . $form['template'];
                }
                $message = file_get_contents($email_html);
                if ($form['no_email'] == false) {
                    $recipient = $form['email'];
                    $mail = wp_mail($recipient, $subject, $message, $headers);
                }
            }
        }
        return $post_id;
    }
}
 /**
  * Displaying Prodcuts
  *
  * Does prepare the data for displaying the products in the table.
  * 
  * @package Social Deals Engine
  * @since 1.0.0
  */
 function display_sales_logs()
 {
     $prefix = WPS_DEALS_META_PREFIX;
     $logs_data = array();
     $paged = $this->get_paged();
     $sale = empty($_GET['s']) ? $this->get_sorted_sales_log() : null;
     $log_query = array('post_parent' => $sale, 'log_type' => 'sales', 'meta_query' => $this->get_meta_query());
     $logsdata = $this->logs->get_connected_logs($log_query);
     if ($logsdata) {
         foreach ($logsdata as $log) {
             $order_id = get_post_meta($log->ID, $prefix . 'log_payment_id', true);
             // Make sure this payment hasn't been deleted
             if (get_post($order_id)) {
                 $user_info = $this->model->wps_deals_get_ordered_user_details($order_id);
                 $cart_items = $this->model->wps_deals_get_post_meta_ordered($order_id);
                 $cart_items = $cart_items['deals_details'];
                 $date = $this->model->wps_deals_get_date_format(strtotime(get_post_field('post_date', $order_id)), true);
                 $amount = 0;
                 if (is_array($cart_items) && is_array($user_info)) {
                     foreach ($cart_items as $item) {
                         $price_override = isset($item['deal_sale_price']) ? $item['deal_sale_price'] : null;
                         if (isset($item['deal_id']) && $item['deal_id'] == $log->post_parent) {
                             $amount = $item['deal_sale_price'];
                             $qty = $item['deal_quantity'];
                         }
                     }
                     $amount = $this->currency->wps_deals_formatted_value($amount);
                     $logs_data[] = array('ID' => $log->ID, 'order_id' => $order_id, 'deals' => $log->post_parent, 'amount' => $amount, 'quantity' => $qty, 'user_id' => $user_info['user_id'], 'user_name' => $user_info['first_name'] . ' ' . $user_info['last_name'], 'date' => $date);
                 }
             }
         }
     }
     return $logs_data;
 }
Beispiel #14
-1
 function add_media_to_collection($mediaId, $collectionId, $isRemove = false)
 {
     $id = get_post_meta($collectionId, 'lrid_to_id', true);
     $content = get_post_field('post_content', $id);
     preg_match_all('/\\[gallery.*ids="([0-9,]*)"\\]/', $content, $results);
     if (!empty($results) && !empty($results[1])) {
         $str = $results[1][0];
         $ids = !empty($str) ? explode(',', $str) : array();
         $index = array_search($mediaId, $ids, false);
         if ($isRemove) {
             if ($index !== FALSE) {
                 unset($ids[$index]);
             }
         } else {
             // If mediaId already there then exit.
             if ($index !== FALSE) {
                 return;
             }
             array_push($ids, $mediaId);
         }
         // Replace the array within the gallery shortcode.
         $content = str_replace('ids="' . $str, 'ids="' . implode(',', $ids), $content);
         $post = array('ID' => $id, 'post_content' => $content);
         wp_update_post($post);
     }
 }
Beispiel #15
-1
 public function shortcode($atts, $content = null)
 {
     $this->content = $this->sanitize_content($content);
     $this->atts = $this->sanitize_attributes($atts);
     // override shortcode atts for uploaded image
     if ($this->is_uploaded_image()) {
         $image_id = $this->atts['image_id'];
         $image_src = wp_get_attachment_image_src($image_id, 'full');
         if (!$image_src) {
             return '';
         }
         if (get_post_meta($image_id, 'dt-img-hide-title', true)) {
             $this->atts['image_title'] = '';
         } else {
             $this->atts['image_title'] = get_the_title($image_id);
         }
         $this->atts['image'] = $image_src[0];
         $this->atts['hd_image'] = '';
         $this->atts['image_alt'] = esc_attr(get_post_meta($image_id, '_wp_attachment_image_alt', true));
         $this->atts['media'] = esc_url(get_post_meta($image_id, 'dt-video-url', true));
         $post_content = get_post_field('post_content', $image_id);
         $this->content = $this->sanitize_content($post_content);
     }
     $output = '';
     $output .= '<div ' . $this->get_container_html_class('shortcode-single-image-wrap') . $this->get_container_inline_style() . '>';
     $output .= $this->get_media();
     $output .= $this->get_caption();
     $output .= '</div>';
     return $output;
 }
Beispiel #16
-1
 function notify($new_status, $old_status, $post)
 {
     global $current_site;
     if ('answer' != $post->post_type || 'publish' != $new_status || $new_status == $old_status) {
         return;
     }
     $author = get_userdata($post->post_author);
     $question_id = $post->post_parent;
     $question = get_post($question_id);
     $subscribers = get_post_meta($question_id, '_sub');
     if (!in_array($question->post_author, $subscribers)) {
         $subscribers[] = $question->post_author;
     }
     // Notify question author too
     $subject = sprintf(__('[%s] New answer on "%s"'), get_option('blogname'), $question->post_title);
     $content = sprintf(__('%s added a new answer to %s:', QA_TEXTDOMAIN), _qa_html('a', array('href' => qa_get_url('user', $post->post_author)), $author->user_nicename), _qa_html('a', array('href' => qa_get_url('single', $question_id)), get_post_field('post_title', $question_id)));
     $content .= "<br/><br/>" . $post->post_content . "<br/><br/>";
     cache_users($subscribers);
     $admin_email = get_site_option('admin_email');
     if ($admin_email == '') {
         $admin_email = 'admin@' . $current_site->domain;
     }
     $from_email = $admin_email;
     $message_headers = "MIME-Version: 1.0\n" . "From: " . $current_site->site_name . " <{$from_email}>\n" . "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n";
     foreach ($subscribers as $subscriber_id) {
         // Don't notify the author of the answer
         if ($post->post_author != $subscriber_id) {
             $msg = $content . sprintf(__('To manage your subscription, visit <a href="%s">the question</a>.', QA_TEXTDOMAIN), qa_get_url('single', $post->ID));
         } else {
             $msg = $content;
         }
         wp_mail(get_user_option('user_email', $subscriber_id), $subject, $msg, $message_headers);
     }
 }
 public function remove_word($post_id)
 {
     if (!in_array(get_post_type($post_id), $this->post_types)) {
         return $post_id;
     }
     $do_word = get_post_meta($post_id, 'remove_word_formatting', true) === 'ano';
     if (!$do_word) {
         return $post_id;
     }
     $content = get_post_field('post_content', $post_id);
     if (empty($content)) {
         return $post_id;
     }
     $dom = \Cibulka::Base('DOMDocument');
     $dom->loadHTML($content);
     $dom->unwrap($this->els);
     // Remove unnecessary elements
     $dom->remove_attrs($this->attrs);
     // Remove attributes
     $content = $dom->get_content();
     if (empty($content)) {
         return false;
     }
     $result = array('ID' => $post_id, 'post_content' => $content);
     remove_action('save_post', array($this, 'remove_word'), 12);
     $result = wp_update_post($result);
     add_action('save_post', array($this, 'remove_word'), 12, 1);
     update_post_meta($post_id, 'remove_word_formatting', 'ne');
     return $result;
 }
Beispiel #18
-1
/**
 * Parse email template tags
 *
 * @since       3.0
 * @param       string $message The email body
 * @param       int $download_id The ID for a given download
 * @param       int $commission_id The ID of this commission
 * @param       int $commission_amount The amount of the commission
 * @param       int $rate The commission rate of the user
 * @return      string $message The email body
 */
function eddc_parse_template_tags($message, $download_id, $commission_id, $commission_amount, $rate)
{
    $meta = get_post_meta($commission_id, '_edd_commission_info', true);
    $variation = get_post_meta($commission_id, '_edd_commission_download_variation', true);
    $download = get_the_title($download_id) . (!empty($variation) ? ' - ' . $variation : '');
    $amount = html_entity_decode(edd_currency_filter(edd_format_amount($commission_amount)));
    $date = date_i18n(get_option('date_format'), strtotime(get_post_field('post_date', $commission_id)));
    $user = get_userdata($meta['user_id']);
    if (!empty($user->first_name)) {
        $name = $user->first_name;
        if (!empty($user->last_name)) {
            $fullname = $name . ' ' . $user->last_name;
        } else {
            $fullname = $name;
        }
    } else {
        $name = $user->display_name;
        $fullname = $name;
    }
    $message = str_replace('{download}', $download, $message);
    $message = str_replace('{amount}', $amount, $message);
    $message = str_replace('{date}', $date, $message);
    $message = str_replace('{rate}', $rate, $message);
    $message = str_replace('{name}', $name, $message);
    $message = str_replace('{fullname}', $fullname, $message);
    return $message;
}
Beispiel #19
-1
 static function options($forum_id = 0, $admin = false)
 {
     $forum_id = bbp_get_forum_id($forum_id);
     if ($cached = wp_cache_get($forum_id, 'forum_options')) {
         return $cached;
     }
     $forum_options = self::$defaults;
     if (get_post_meta($forum_id, 'bbpkr_custom_settings', true)) {
         $forum_options = array_merge($forum_options, (array) get_post_meta($forum_id, 'bbpkr_options', true));
         // var_dump( $this->options()['skin'], $options);
     } elseif (!$admin) {
         // follow closest parent forum custom settings
         $forum_parent = (int) get_post_field('post_parent', $forum_id);
         if ($forum_parent) {
             while ($forum_parent) {
                 if (get_post_meta($forum_parent, 'bbpkr_custom_settings', true)) {
                     $forum_options = array_merge($forum_options, (array) get_post_meta($forum_parent, 'bbpkr_options', true));
                     break;
                 }
                 $forum_parent = (int) get_post_field('post_parent', $forum_parent);
             }
         }
     }
     $return = array_merge(bbpresskr()->options(), (array) $forum_options);
     wp_cache_set($forum_id, $return, 'forum_options');
     return $return;
 }
 function get_object($src_name, $object_id, $cols = '')
 {
     // special cases to take advantage of cached post/link
     if ('post' == $src_name) {
         if ($cols && !strpos($cols, ',')) {
             return get_post_field($cols, $object_id, 'raw');
         } else {
             return get_post($object_id);
         }
     } elseif ('link' == $src_name) {
         return get_bookmark($object_id);
     } else {
         if (!($src = $this->get($src_name))) {
             return;
         }
         global $wpdb;
         if (!$cols) {
             $cols = '*';
         }
         if (empty($object_id)) {
             return array();
         }
         return scoper_get_row("SELECT {$cols} FROM {$src->table} WHERE {$src->cols->id} = '{$object_id}' LIMIT 1");
     }
     // end switch
 }
Beispiel #21
-1
function wolf_breadcrumbs()
{
    if (!is_home() && !is_search()) {
        $breadcrumb = '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">';
        $breadcrumb .= '<ul class="breadcrumb">';
        $page_id = get_the_ID();
        if (is_page()) {
            $breadcrumb .= wolf_breadcrumbs_get_home_link() . wolf_breadcrumbs_get_parent_page_link($page_id);
        } elseif (is_single()) {
            if ('' != get_query_var('attachment_id') || '' != get_query_var('attachment')) {
                $post = get_post(get_post_field('post_parent', get_the_ID()));
                $breadcrumb .= wolf_breadcrumbs_get_home_link() . wolf_breadcrumbs_get_category_links($post->ID) . wolf_breadcrumbs_get_parent_page_link($post->ID) . wolf_breadcrumbs_get_page_title($page_id);
            } else {
                $breadcrumb .= wolf_breadcrumbs_get_home_link() . wolf_breadcrumbs_get_category_links($page_id) . wolf_breadcrumbs_get_page_title($page_id);
            }
        } elseif (is_archive()) {
            if (is_author()) {
                $breadcrumb .= wolf_breadcrumbs_get_home_link() . __('Archives', 'wolf') . ' ' . __('/', 'wolf') . ' ' . wolf_breadcrumbs_get_author_display_name();
            } elseif ('' != get_query_var('year') || '' != get_query_var('monthnum') || '' != get_query_var('m') || '' != get_query_var('day')) {
                $breadcrumb .= wolf_breadcrumbs_get_home_link() . __('Archives', 'wolf') . ' ' . __('/', 'wolf') . ' ' . wolf_breadcrumbs_get_date_labels();
            } else {
                $breadcrumb .= wolf_breadcrumbs_get_home_link() . __('Archives', 'wolf') . ' ' . __('/', 'wolf') . ' ' . wolf_breadcrumbs_get_category_links();
            }
        }
        $breadcrumb .= '</ul></div>';
        return $breadcrumb;
    }
}
Beispiel #22
-1
 /**
  * @see CPAC_Column::get_value()
  * @since 2.4.7
  */
 public function get_value($id)
 {
     $raw_value = $this->get_raw_value($id);
     // Get page to link to
     switch ($this->get_option('post_link_to')) {
         case 'edit_post':
             $link = get_edit_post_link($raw_value);
             break;
         case 'view_post':
             $link = get_permalink($raw_value);
             break;
         case 'edit_author':
             $link = get_edit_user_link(get_post_field('post_author', $raw_value));
             break;
         case 'view_author':
             $link = get_author_posts_url(get_post_field('post_author', $raw_value));
             break;
     }
     // Get property of post to display
     switch ($this->get_option('post_property_display')) {
         case 'author':
             $label = get_the_author_meta('display_name', get_post_field('post_author', $raw_value));
             break;
         case 'id':
             $label = $raw_value;
             break;
         default:
             $label = get_the_title($raw_value);
             break;
     }
     $value = $link ? "<a href='{$link}'>{$label}</a>" : $label;
     return $value;
 }
Beispiel #23
-1
/**
 * Testimonials custom columns content.
 */
function showcase_posts_columns($column, $post_id)
{
    global $post;
    switch ($column) {
        case 'showcase_image':
            $sc_carousel_thumb = get_the_post_thumbnail($post_id, 'thumbnail');
            echo sprintf('<a href="%1$s" title="%2$s">%3$s</a>', admin_url('post.php?post=' . $post_id . '&action=edit'), get_the_title(), $sc_carousel_thumb);
            break;
        case 'showcase_texto':
            $sc_carousel_texto = get_post_field('post_content', $post_id);
            /* or you can use get_the_title() */
            $sc_carousel_getlength = strlen($sc_carousel_texto);
            $sc_carousel_thelength = 120;
            echo substr($sc_carousel_texto, 0, $sc_carousel_thelength);
            if ($sc_carousel_getlength > $sc_carousel_thelength) {
                echo "...";
            }
            break;
        case 'showcase_url':
            $vc_showcase_facebook = get_post_meta($post_id, 'vc_showcase_facebook', true);
            $vc_showcase_google_plus = get_post_meta($post_id, 'vc_showcase_google_plus', true);
            $vc_showcase_linkedin = get_post_meta($post_id, 'vc_showcase_linkedin', true);
            $vc_showcase_custom_link = get_post_meta($post_id, 'vc_showcase_custom_link', true);
            echo !empty($vc_showcase_facebook) ? sprintf('<a href="%1$s" target="_blank">%1$s</a><br />', esc_url($vc_showcase_facebook)) : '';
            echo !empty($vc_showcase_google_plus) ? sprintf('<a href="%1$s" target="_blank">%1$s</a><br />', esc_url($vc_showcase_google_plus)) : '';
            echo !empty($vc_showcase_linkedin) ? sprintf('<a href="%1$s" target="_blank">%1$s</a><br />', esc_url($vc_showcase_linkedin)) : '';
            echo !empty($vc_showcase_custom_link) ? sprintf('<a href="%1$s" target="_blank">%1$s</a><br />', esc_url($vc_showcase_custom_link)) : '';
            break;
    }
}
 function convert_post_edit_caps($rs_reqd_caps, $post_type)
 {
     global $revisionary, $scoper;
     if (!empty($revisionary->skip_revision_allowance) || !rvy_get_option('pending_revisions')) {
         return $rs_reqd_caps;
     }
     $post_id = $scoper->data_sources->detect('id', 'post');
     // don't need to fudge the capreq for post.php unless existing post has public/private status
     $status = get_post_field('post_status', $post_id, 'post');
     $status_obj = get_post_status_object($status);
     if (empty($status_obj->public) && empty($status_obj->private) && 'future' != $status) {
         return $rs_reqd_caps;
     }
     if ($type_obj = get_post_type_object($post_type)) {
         $replace_caps = array('edit_published_posts', 'edit_private_posts', 'publish_posts', $type_obj->cap->edit_published_posts, $type_obj->cap->edit_private_posts, $type_obj->cap->publish_posts);
         $use_cap_req = $type_obj->cap->edit_posts;
     } else {
         $replace_caps = array();
     }
     if (array_intersect($rs_reqd_caps, $replace_caps)) {
         foreach ($rs_reqd_caps as $key => $cap_name) {
             if (in_array($cap_name, $replace_caps)) {
                 $rs_reqd_caps[$key] = $use_cap_req;
             }
         }
     }
     return $rs_reqd_caps;
 }
 function flt_dropdown_pages($orig_options_html)
 {
     if (!strpos($orig_options_html, 'parent_id') || !$orig_options_html || is_content_administrator_rs()) {
         return $orig_options_html;
     }
     $post_type = awp_post_type_from_uri();
     // User can't associate or de-associate a page with Main page unless they have edit_pages blog-wide.
     // Prepend the Main Page option if appropriate (or, to avoid submission errors, if we generated no other options)
     if (!$GLOBALS['scoper_admin_filters']->user_can_associate_main($post_type)) {
         $is_new = $GLOBALS['post']->post_status == 'auto-draft';
         if (!$is_new) {
             global $post;
             $object_id = !empty($post->ID) ? $post->ID : $GLOBALS['scoper']->data_sources->detect('id', 'post', 0, 'post');
             $stored_parent_id = !empty($post->ID) ? $post->post_parent : get_post_field('post_parent', $object_id);
         }
         if ($is_new || $stored_parent_id) {
             $mat = array();
             preg_match('/<option[^v]* value="">[^<]*<\\/option>/', $orig_options_html, $mat);
             if (!empty($mat[0])) {
                 return str_replace($mat[0], '', $orig_options_html);
             }
         }
     }
     return $orig_options_html;
 }
function new_reply_notification($reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0, $is_edit = false, $reply_to = 0)
{
    $admin_email = get_option('admin_email');
    $user_id = (int) $reply_author_id;
    $reply_id = bbp_get_reply_id($reply_id);
    $topic_id = bbp_get_topic_id($topic_id);
    $forum_id = bbp_get_forum_id($forum_id);
    $email_subject = get_option('bbpress_notify_newreply_email_subject');
    $email_body = get_option('bbpress_notify_newreply_email_body');
    $blog_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    $topic_title = html_entity_decode(strip_tags(bbp_get_topic_title($topic_id)), ENT_NOQUOTES, 'UTF-8');
    $topic_content = html_entity_decode(strip_tags(bbp_get_topic_content($topic_id)), ENT_NOQUOTES, 'UTF-8');
    $topic_excerpt = html_entity_decode(strip_tags(bbp_get_topic_excerpt($topic_id, 100)), ENT_NOQUOTES, 'UTF-8');
    $topic_author = bbp_get_topic_author($topic_id);
    $topic_url = bbp_get_topic_permalink($topic_id);
    $topic_reply = bbp_get_reply_url($topic_id);
    $reply_url = bbp_get_reply_url($reply_id);
    $reply_content = get_post_field('post_content', $reply_id, 'raw');
    $reply_author = bbp_get_topic_author($user_id);
    $email_subject = $blog_name . " New Reply Alert: " . $topic_title;
    $email_body = $blog_name . ": {$topic_title}\n\r";
    $email_body .= $reply_content;
    $email_body .= "\n\r--------------------------------\n\r";
    $email_body .= "Reply Url: " . $reply_url . "\n\rAuthor: {$reply_author}" . "\n\rYou can reply at: {$reply_url}";
    @wp_mail($admin_email, $email_subject, $email_body);
}
 /**
  *  Generate array with: recent/popular/most commented posts
  * @param string $sort Sort type (recent/popular/most commented)
  * @param integer $items Number of items to be extracted
  * @param boolean $image_post Extract or no post image
  * @param integer $image_width Set width of post image
  * @param integer $image_height Set height of post image
  * @param string $image_class Set class of post image
  * @param boolean $date_post Extract or no post date
  * @param string $date_format Set date format
  * @param string $post_type Set post type
  * @param string $category Set category from where posts would be extracted
  * @since  Gameszone 1.0
  */
 function tfuse_shortcode_posts($args = null)
 {
     $defaults = array('sort' => 'recent', 'items' => 5, 'image_post' => true, 'image_width' => 54, 'image_height' => 54, 'image_class' => 'post-thumbnail', 'date_post' => true, 'date_format' => 'jS F Y', 'post_type' => 'post', 'category' => '', 'specialites' => '');
     extract(wp_parse_args($args, $defaults));
     global $post;
     $tf_cat_ID = !empty($category) && empty($specialites) ? get_cat_ID($category) : '';
     $specialites = empty($category) && !empty($specialites) ? $specialites : '';
     if ($sort == 'recent') {
         $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'post_date', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'Specialites' => $specialites, 'posts_per_page' => $items));
         $posts = $query->get_posts();
     } elseif ($sort == 'popular') {
         $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'meta_value', 'meta_key' => TF_THEME_PREFIX . '_post_viewed', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'posts_per_page' => $items));
         $posts = $query->get_posts();
     } elseif ($sort == 'commented') {
         $query = new WP_Query(array('post_type' => $post_type, 'orderby' => 'comment_count', 'order ' => 'DESC', 'cat' => $tf_cat_ID, 'posts_per_page' => $items));
         $posts = $query->get_posts();
     } else {
         return false;
     }
     $tf_post_option = array();
     $count = 0;
     if (!empty($posts)) {
         foreach ($posts as $post_elm) {
             setup_postdata($post_elm);
             $img = '';
             if ($image_post == true) {
                 $post_image_src = wp_get_attachment_url(get_post_thumbnail_id($post_elm->ID, 'post-thumbnails'));
                 if (!empty($post_image_src)) {
                     $get_image = new TF_GET_IMAGE();
                     $img = $get_image->properties(array('class' => $image_class, 'alt' => get_the_title($post_elm->ID)))->width($image_width)->height($image_height)->src($post_image_src)->resize(true)->get_img();
                 }
             }
             if (!empty($img)) {
                 $tf_post_option[$count]['post_img'] = $img;
             } else {
                 $tf_post_option[$count]['post_img'] = '';
             }
             if ($date_post) {
                 $time_format = apply_filters('tfuse_widget_time_format', $date_format);
                 $tf_post_option[$count]['post_date_post'] = get_the_time($time_format, $post_elm->ID);
             } else {
                 $tf_post_option[$count]['post_date_post'] = get_the_date('F jS, Y');
             }
             $tf_post_option[$count]['post_class'] = is_singular() && $post->ID == $post_elm->ID ? 'current-menu-item post_' . $sort : 'post_' . $sort;
             $tf_post_option[$count]['post_title'] = get_the_title($post_elm->ID);
             $tf_post_option[$count]['post_link'] = get_permalink($post_elm->ID);
             $tf_post_option[$count]['post_id'] = $post_elm->ID;
             $tf_post_option[$count]['post_author_link'] = get_author_posts_url(get_the_author_meta('ID'));
             $tf_post_option[$count]['post_author_name'] = get_the_author();
             $tf_post_option[$count]['post_comnt_numb'] = get_comments_number($post_elm->ID);
             $tf_post_option[$count]['post_comnt_numb_link'] = tfuse_get_comments(true, $post_elm->ID);
             $tf_post_option[$count]['post_content'] = get_post_field('post_content', $post_elm->ID);
             $tf_post_option[$count]['post_loveit_number'] = get_post_meta($post_elm->ID, TF_THEME_PREFIX . '_post_viewed', true);
             $count++;
         }
         wp_reset_postdata();
     }
     return $tf_post_option;
 }
Beispiel #28
-1
 /**
  * @see CPAC_Column::get_raw_value()
  * @since 2.0.3
  */
 public function get_raw_value($post_id)
 {
     $parent_id = get_post_field('post_parent', $post_id);
     if (!$parent_id || !is_numeric($parent_id)) {
         return false;
     }
     return $parent_id;
 }
Beispiel #29
-1
 /**
  * Get the field value for a post.
  *
  * @param int $post_id The target post's id. Or leave blank for he current post if in the loop.
  * @param bool $include_wp_fields Whether or not to include the default WP fields.
  * @param string $field The ACF field id or name. Return all fields if blank.
  * @return array
  */
 public static function get_post_field($post_id = 0, $include_wp_fields = true, $field = '')
 {
     if ($include_wp_fields && !$field) {
         $wp_fields = ['post_id' => $post_id, 'permalink' => get_permalink($post_id), 'title' => get_the_title($post_id), 'content' => apply_filters('the_content', get_post_field('post_content', $post_id))];
         return array_merge($wp_fields, self::get_field($post_id));
     }
     return self::get_field($post_id, $field);
 }
Beispiel #30
-1
function add_contact_info_to_purchase_note($product_id)
{
    $post_author_id = get_post_field('post_author', $product_id);
    $contact_name = get_the_author_meta('user_lastname', $post_author_id) . get_the_author_meta('user_firstname', $post_author_id);
    $contact_email = get_the_author_meta('user_email', $post_author_id);
    $contact_info = sprintf(__("<b>Seller Information</b>\nName: %s\nEmail: %s", 'artgorae'), $contact_name, $contact_email);
    update_post_meta($product_id, '_purchase_note', $contact_info);
}