Example #1
0
 /**
  *
  */
 public static function pricetable($atts, $content = null, $code = null)
 {
     if ($atts == 'generator') {
         global $wpdb;
         $prices_list = array();
         $pricetables = $wpdb->get_results('SELECT ID, post_title FROM ' . $wpdb->posts . ' WHERE post_type = "pricetable"');
         if (is_array($pricetables)) {
             foreach ($pricetables as $key => $value) {
                 $prices_list[$value->ID] = $pricetables[$key]->post_title;
             }
         } else {
             $price_list[0] = __('Please install Price Table plugin...', MISS_ADMIN_TEXTDOMAIN);
         }
         $option = array('name' => __('Blog Grid Layout', MISS_ADMIN_TEXTDOMAIN), 'value' => 'pricetable', 'options' => array(array('name' => __('Select Table', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Choose "Pricing Table" to use.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'id', 'type' => 'select', 'options' => $prices_list), 'shortcode_has_atts' => true));
         return $option;
     }
     extract(shortcode_atts(array('id' => ''), $atts));
     $pricetable = new WP_Query();
     $pricetable->query(array('post_type' => 'pricetable', 'post_id' => $id));
     while ($pricetable->have_posts()) {
         $pricetable->the_post();
         $prices_list[get_the_ID()] = get_the_title();
         $out = '[price_table id="' . $id . '"]';
     }
     return do_shortcode($out);
 }
 /**
  * Create a new slide and echo the admin HTML
  */
 public function ajax_create_slide()
 {
     // security check
     if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'metaslider_addslide')) {
         echo "<tr><td colspan='2'>" . __("Security check failed. Refresh page and try again.", 'metaslider') . "</td></tr>";
         die;
     }
     $slider_id = absint($_POST['slider_id']);
     $selection = $_POST['selection'];
     if (is_array($selection) && count($selection) && $slider_id > 0) {
         foreach ($selection as $slide_id) {
             $this->set_slide($slide_id);
             $this->set_slider($slider_id);
             if ($this->slide_exists_in_slideshow($slider_id, $slide_id)) {
                 echo "<tr><td colspan='2'>ID: {$slide_id} \"" . get_the_title($slide_id) . "\" - " . __("Failed to add slide. Slide already exists in slideshow.", 'metaslider') . "</td></tr>";
             } else {
                 if (!$this->slide_is_unassigned_or_image_slide($slider_id, $slide_id)) {
                     echo "<tr><td colspan='2'>ID: {$slide_id} \"" . get_the_title($slide_id) . "\" - " . __("Failed to add slide. Slide is not of type 'image'.", 'metaslider') . "</td></tr>";
                 } else {
                     $this->tag_slide_to_slider();
                     $this->add_or_update_or_delete_meta($slide_id, 'type', 'image');
                     // override the width and height to kick off the AJAX image resizing on save
                     $this->settings['width'] = 0;
                     $this->settings['height'] = 0;
                     echo $this->get_admin_slide();
                 }
             }
         }
     }
     die;
 }
Example #3
0
function blog_summary_shortcode($attr)
{
    // Describes what attributes to parse from shortcode; only 'count'
    extract(shortcode_atts(array('count' => '5', 'grouptag' => 'ul', 'entrytag' => 'li', 'titletag' => 'h4', 'datetag' => 'span', 'commentstag' => 'span', 'summarytag' => 'div'), $attr));
    // Queries to populate our loop based on shortcode count attribute
    $r = new WP_Query("showposts={$count}&what_to_show=posts&nopaging=0&post_status=publish");
    // Only run if we have posts; can't run this through searches
    if ($r->have_posts() && !is_search()) {
        // If we're using a Sandbox-friendly theme . . .
        if (function_exists('sandbox_body_class')) {
            // We can't have double hfeed classes, otherwise it won't parse
            $groupclasses = 'xoxo';
        } else {
            // Otherwise, use hfeed to ensure hAtom compliance
            $groupclasses = 'xoxo hfeed';
        }
        // Begin the output for shortcode and inserts in the group tag what classes we have
        $output = '<' . $grouptag . ' class="' . $groupclasses . '">';
        // Begins our loop for returning posts
        while ($r->have_posts()) {
            // Sets which post from our loop we're at
            $r->the_post();
            // Allows the_date() with multiple posts within a single day
            unset($previousday);
            // If we're using a Sandbox-friendly theme . . .
            if (function_exists('sandbox_post_class')) {
                // Let's use semantic classes with each entry element
                $entryclasses = sandbox_post_class(false);
            } else {
                // Otherwise, use hentry to ensure hAtom compliance
                $entryclasses = 'hentry';
            }
            // Begin entry wrapper and inserts what classes we got from above
            $output .= "\n" . '<' . $entrytag . ' class="' . $entryclasses . '">';
            // Post title
            $output .= "\n" . '<' . $titletag . ' class="entry-title"><a href="' . get_permalink() . '" title="' . sprintf(__('Permalink to %s', 'blog_summary'), the_title_attribute('echo=0')) . '" rel="bookmark">' . get_the_title() . '</a></' . $titletag . '>';
            // Post date with hAtom support
            $output .= "\n" . '<' . $datetag . ' class="entry-date"><abbr class="published" title="' . get_the_time('Y-m-d\\TH:i:sO') . '">' . sprintf(__('%s', 'blog_summary'), the_date('', '', '', false)) . '</abbr></' . $datetag . '>';
            // Comments number
            $output .= "\n" . '<' . $commentstag . ' class="entry-comments"><a href="' . get_permalink() . '#comments" title="' . sprintf(__('Comments to %s', 'blog_summary'), the_title_attribute('echo=0')) . '">' . sprintf(__('Comments (%s)', 'blog_summary'), apply_filters('comments_number', get_comments_number())) . '</a></' . $commentstag . '>';
            // Post excerpt with hAtom support
            $output .= "\n" . '<' . $summarytag . ' class="entry-summary">' . "\n" . apply_filters('the_excerpt', get_the_excerpt()) . '</' . $summarytag . '>';
            // Close each post LI
            $output .= "\n" . '</' . $entrytag . '>';
            // Finish the have_posts() query
        }
        // while ( $r->have_posts() ) :
        // Close the parent UL
        $output .= "\n" . '</' . $grouptag . '>';
        // Rewinds loop from $r->the_post();
        rewind_posts();
        // End the initial IF statement
    }
    // if ( $r->have_posts() ) :
    // Clears our query to put the loop back where it was
    wp_reset_query();
    // $r = new WP_Query()
    // Returns $output to the shortcode
    return $output;
}
 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $numberposts = isset($instance['numberposts']) ? $instance['numberposts'] : 1;
     $termargs = array('post_type' => 'glossary', 'post_status' => 'publish', 'numberposts' => $numberposts, 'orderby' => 'rand');
     if ($group = $instance['group']) {
         $termargs['tax_query'] = array(array('taxonomy' => 'wpglossarygroup', 'field' => 'slug', 'terms' => $group));
     }
     $terms = get_posts($termargs);
     if ($terms && count($terms)) {
         echo '<ul class="wpglossary widget-list">';
         foreach ($terms as $term) {
             setup_postdata($term);
             $title = '<a href="' . apply_filters('wpg_term_link', get_post_permalink($term->ID)) . '">' . get_the_title($term->ID) . '</a>';
             $desc = '';
             $display = $instance['display'];
             if ($display && $display != 'title') {
                 $desc = $display == 'full' ? apply_filters('the_content', get_the_content(), $main = false) : wpautop(get_the_excerpt());
                 $desc = '<br>' . $desc;
             }
             echo '<li>' . $title . $desc . '</li>';
         }
         wp_reset_postdata();
         echo '</ul>';
     } else {
         echo '<em>' . __('No terms available', 'wp-glossary') . '</em>';
     }
     echo $after_widget;
 }
Example #5
0
File: totc.php Project: Ruxton/ToTC
function totc_children($atts)
{
    global $post;
    global $more;
    $more = 0;
    $return = "";
    $oldpost = $post;
    if ($post->ID) {
        $args = array('post_parent' => $post->ID, 'post_type' => 'page', 'orderby' => 'date', 'order' => 'DESC');
        $children = get_posts($args);
        if ($children) {
            foreach ($children as $post) {
                setup_postdata($post);
                $more = 0;
                $content = get_the_content('');
                $content = apply_filters('the_content', $content);
                $content = str_replace(']]>', ']]&gt;', $content);
                $return .= '<h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>
' . $content;
            }
        }
    }
    setup_postdata($oldpost);
    return $return;
}
Example #6
0
 /**
  * Default widget front end display method.
  *
  * @since 1.0.0
  *
  * @param array $args Args specific to the widget area (sidebar).
  * @param array $instance Widget instance settings.
  */
 function widget($args, $instance)
 {
     extract($args);
     $instance['title_raw'] = $instance['title'];
     $instance['title'] = apply_filters('widget_title', empty($instance['title']) ? get_the_title($instance['post_id']) : $instance['title'], $instance, $this->id_base);
     $instance['title'] = apply_filters('audiotheme_widget_title', $instance['title'], $instance, $args, $this->id_base);
     echo $before_widget;
     // Output filter is for backwards compatibility.
     if ($output = apply_filters('audiotheme_widget_video_output', '', $instance, $args)) {
         echo empty($instance['title']) ? '' : $before_title . $instance['title'] . $after_title;
         echo $output;
     } else {
         $post = get_post($instance['post_id']);
         $image_size = apply_filters('audiotheme_widget_video_image_size', 'thumbnail', $instance, $args);
         $image_size = apply_filters('audiotheme_widget_video_image_size-' . $args['id'], $image_size, $instance, $args);
         $data = array();
         $data['args'] = $args;
         $data['after_title'] = $args['after_title'];
         $data['before_title'] = $args['before_title'];
         $data['image_size'] = $image_size;
         $data['post'] = get_post($instance['post_id']);
         $data = array_merge($instance, $data);
         $template = audiotheme_locate_template(array("widgets/{$args['id']}_video.php", 'widgets/video.php'));
         audiotheme_load_template($template, $data);
     }
     echo $after_widget;
 }
Example #7
0
 /**
  * Latest blog posts
  *
  * @param int    $limit post display limit
  *
  * @param string $thumbnail_size
  *
  * @return array
  */
 public static function getRecent($limit = 10, $thumbnail_size = 'thumbnail')
 {
     $args = array('numberposts' => $limit, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending', 'suppress_filters' => true);
     $array_out = array();
     $recent_posts = \get_posts(\wp_parse_args($args));
     /*$like_bool    = Option::get_theme_option( 'blog_list_like' );
       if ( $like_bool === '1' ) {
           $PostLike = \SilverWp\Ajax\PostLike::getInstance();
       }*/
     foreach ($recent_posts as $key => $recent) {
         \setup_postdata($recent);
         $post_id = $recent->ID;
         //$array_out[ $key ] = $recent;
         $array_out[$key]['ID'] = $post_id;
         $array_out[$key]['post_title'] = \get_the_title($post_id);
         $array_out[$key]['url'] = \get_the_permalink($post_id);
         $array_out[$key]['post_author'] = \get_the_author();
         $array_out[$key]['post_date'] = \get_the_date('', $post_id);
         $array_out[$key]['post_date_utc'] = \get_the_time('c', $post_id);
         //$array_out[ $key ]['post_like'] = ($like_bool === '1') ? $PostLike->getPostLikeCount($post_id) : '';
         $array_out[$key]['post_comment_count'] = $recent->comment_count;
         if (strpos($recent->post_content, '<!--more-->') || empty($recent->post_excerpt)) {
             $array_out[$key]['post_excerpt'] = \get_the_excerpt();
         } else {
             $array_out[$key]['post_excerpt'] = $recent->post_excerpt;
         }
         $array_out[$key]['image_html'] = \get_the_post_thumbnail($post_id, $thumbnail_size);
         // Thumbnail
         $array_out[$key]['categories'] = self::getTaxonomy($post_id);
     }
     \wp_reset_postdata();
     return $array_out;
 }
Example #8
0
 /**
  * Compile the schema.org event data into an array
  */
 public function get_data($post = null, $args = array())
 {
     if (!$post instanceof WP_Post) {
         $post = Tribe__Main::post_id_helper($post);
     }
     $post = get_post($post);
     if (!$post instanceof WP_Post) {
         return array();
     }
     $data = (object) array();
     // We may need to prevent the context to be triggered
     if (!isset($args['context']) || false !== $args['context']) {
         $data->{'@context'} = 'http://schema.org';
     }
     $data->{'@type'} = $this->type;
     $data->name = esc_js(get_the_title($post));
     $data->description = esc_js(tribe_events_get_the_excerpt($post));
     if (has_post_thumbnail($post)) {
         $data->image = wp_get_attachment_url(get_post_thumbnail_id($post));
     }
     $data->url = esc_url_raw(get_permalink($post));
     // Index by ID: this will allow filter code to identify the actual event being referred to
     // without injecting an additional property
     return array($post->ID => $data);
 }
Example #9
0
 /**
  * Returning Image Information Array
  * @since 1.5
  */
 function miss_image_signature($thumb)
 {
     if (get_post_meta(get_the_ID(), 'app_lightbox', true) == "yes" && get_post_meta(get_the_ID(), 'app_embed', true) != "") {
         $link = array('href' => get_post_meta(get_the_ID(), 'app_embed', true), 'title' => get_the_title(), 'class' => "prettyPhoto");
         $img = array('src' => $thumb, 'alt' => sprintf(__("%1{$s} on Youtube", MISS_TEXTDOMAIN), get_the_title()), 'title' => sprintf(__("Watch %1{$s} on Youtube", MISS_TEXTDOMAIN), get_the_title()), 'class' => "image-resize w loadOnVisible");
     } else {
         if (get_post_meta(get_the_ID(), '_image', true)) {
             $link = array('href' => get_post_meta(get_the_ID(), '_image', true), 'title' => get_the_title(), 'class' => "prettyPhoto");
             $img = array('src' => $thumb, 'alt' => sprintf(__('Open Image %1$s', MISS_TEXTDOMAIN), get_the_title()), 'title' => sprintf(__('Show %1$s', MISS_TEXTDOMAIN), get_the_title()), 'class' => "image-resize w loadOnVisible");
         } else {
             if (get_post_meta(get_the_ID(), 'app_lightbox', true) == "no" && get_post_meta(get_the_ID(), 'app_embed', true) == "") {
                 $link = array('href' => get_permalink(), 'title' => get_the_title(), 'class' => "pic");
                 $img = array('src' => $thumb, 'alt' => sprintf(__('Find Out More About %1$s', MISS_TEXTDOMAIN), get_the_title()), 'title' => sprintf(__('Find Out More', MISS_TEXTDOMAIN), get_the_title()), 'class' => "image-resize w loadOnVisible");
             } else {
                 if (get_post_meta(get_the_ID(), 'app_lightbox', true) == "no" && get_post_meta(get_the_ID(), 'app_embed', true) != "") {
                     $link = array('href' => get_permalink(), 'title' => get_the_title(), 'class' => "video");
                     $img = array('src' => $thumb, 'alt' => sprintf(__('Find Out More About %1$s', MISS_TEXTDOMAIN), get_the_title()), 'title' => sprintf(__('Find Out More', MISS_TEXTDOMAIN), get_the_title()), 'class' => "image-resize w loadOnVisible");
                 } else {
                     $link = array('href' => get_permalink(), 'title' => get_the_title(), 'class' => "pic");
                     $img = array('src' => $thumb, 'alt' => sprintf(__('Find Out More About %1$s', MISS_TEXTDOMAIN), get_the_title()), 'title' => sprintf(__('Find Out More', MISS_TEXTDOMAIN), get_the_title()), 'class' => "image-resize w loadOnVisible");
                 }
             }
         }
     }
     return array('link' => $link, 'img' => $img);
 }
Example #10
0
    function featured_index()
    {
        $output = '';
        $args = array('tag' => 'featured', 'posts_per_page' => 3);
        query_posts($args);
        if (have_posts()) {
            while (have_posts()) {
                the_post();
                $the_img = $this->get_img_src(get_the_ID());
                if ($the_img == 'zero') {
                }
                $output .= '<div class=" mdl-cell mdl-cell--4-col mdl-card mdl-shadow--2dp">';
                $output .= ' <div class="mdl-card__title mdl-card--expand" style="background-image: url( \' ' . $the_img . '  \' )">
							  </div>
							  <div class="mdl-card__supporting-text">
								' . get_the_title() . '
							  </div>
							  <div class="mdl-card__actions mdl-card--border">
								<a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">
								  View Updates
								</a>
							  </div>';
                $output .= '</div>';
            }
        } else {
            $output = 'gagal';
        }
        wp_reset_query();
        return $output;
    }
function wpml_link_to_element($element_id, $element_type = 'post', $link_text = '', $optional_parameters = array(), $anchor = '', $echoit = true)
{
    if (!function_exists('icl_link_to_element')) {
        switch ($element_type) {
            case 'post':
            case 'page':
                $ret = '<a href="' . get_permalink($element_id) . '">';
                if ($anchor) {
                    $ret .= $anchor;
                } else {
                    $ret .= get_the_title($element_id);
                }
                $ret .= '<a>';
                break;
            case 'tag':
            case 'post_tag':
                $tag = get_term_by('id', $element_id, 'tag', ARRAY_A);
                $ret = '<a href="' . get_tag_link($element_id) . '">' . $tag->name . '</a>';
            case 'category':
                $ret = '<a href="' . get_tag_link($element_id) . '">' . get_the_category_by_ID($element_id) . '</a>';
            default:
                $ret = '';
        }
        if ($echoit) {
            echo $ret;
        } else {
            return $ret;
        }
    } else {
        return icl_link_to_element($element_id, $element_type, $link_text, $optional_parameters, $anchor, $echoit);
    }
}
Example #12
0
/**
 * Page titles
 */
function spring_title()
{
    if (is_home()) {
        if (get_option('page_for_posts', true)) {
            return get_the_title(get_option('page_for_posts', true));
        } else {
            return __('Latest Posts', 'spring-theme');
        }
    } elseif (is_archive()) {
        $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
        if ($term) {
            return apply_filters('single_term_title', $term->name);
        } elseif (is_post_type_archive()) {
            return apply_filters('the_title', get_queried_object()->labels->name);
        } elseif (is_day()) {
            return sprintf(__('Daily Archives: %s', 'spring-theme'), get_the_date());
        } elseif (is_month()) {
            return sprintf(__('Monthly Archives: %s', 'spring-theme'), get_the_date('F Y'));
        } elseif (is_year()) {
            return sprintf(__('Yearly Archives: %s', 'spring-theme'), get_the_date('Y'));
        } elseif (is_author()) {
            $author = get_queried_object();
            return sprintf(__('Author Archives: %s', 'spring-theme'), $author->display_name);
        } else {
            return single_cat_title('', false);
        }
    } elseif (is_search()) {
        return sprintf(__('Search Results for %s', 'spring-theme'), get_search_query());
    } elseif (is_404()) {
        return __('Not Found', 'spring-theme');
    } else {
        return get_the_title();
    }
}
 /**
  * Renders an HTML Dropdown of all the Give Forms
  *
  * @access public
  * @since  1.0
  *
  * @param array $args Arguments for the dropdown
  *
  * @return string $output Give forms dropdown
  */
 public function forms_dropdown($args = array())
 {
     $defaults = array('name' => 'forms', 'id' => 'forms', 'class' => '', 'multiple' => false, 'selected' => 0, 'chosen' => false, 'number' => 30, 'placeholder' => sprintf(__('Select a %s', 'give'), give_get_forms_label_singular()));
     $args = wp_parse_args($args, $defaults);
     $forms = get_posts(array('post_type' => 'give_forms', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => $args['number']));
     $options = array();
     if ($forms) {
         $options[0] = sprintf(__('Select a %s', 'give'), give_get_forms_label_singular());
         foreach ($forms as $form) {
             $options[absint($form->ID)] = esc_html($form->post_title);
         }
     } else {
         $options[0] = __('No Give Forms Found', 'give');
     }
     // This ensures that any selected forms are included in the drop down
     if (is_array($args['selected'])) {
         foreach ($args['selected'] as $item) {
             if (!in_array($item, $options)) {
                 $options[$item] = get_the_title($item);
             }
         }
     } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
         if (!in_array($args['selected'], $options)) {
             $options[$args['selected']] = get_the_title($args['selected']);
         }
     }
     $output = $this->select(array('name' => $args['name'], 'selected' => $args['selected'], 'id' => $args['id'], 'class' => $args['class'], 'options' => $options, 'chosen' => $args['chosen'], 'multiple' => $args['multiple'], 'placeholder' => $args['placeholder'], 'show_option_all' => false, 'show_option_none' => false));
     return $output;
 }
 function woocommerce_order_get_items($items)
 {
     if (isset($_GET['post']) && get_post_type($_GET['post']) == 'shop_order') {
         global $sitepress_settings;
         foreach ($items as $index => $item) {
             foreach ($item as $key => $item_data) {
                 if ($key == 'product_id') {
                     $tr_product_id = apply_filters('translate_object_id', $item_data, 'product', false, $sitepress_settings['admin_default_language']);
                     if (!is_null($tr_product_id)) {
                         $items[$index][$key] = $tr_product_id;
                         $items[$index]['name'] = get_the_title($tr_product_id);
                     }
                 }
                 if ($key == 'variation_id') {
                     $tr_variation_id = apply_filters('translate_object_id', $item_data, 'product_variation', false, $sitepress_settings['admin_default_language']);
                     if (!is_null($tr_variation_id)) {
                         $items[$index][$key] = $tr_variation_id;
                     }
                 }
                 if (substr($key, 0, 3) == 'pa_') {
                     global $wpdb, $woocommerce_wpml;
                     //attr is taxonomy
                     $term_id = $woocommerce_wpml->products->wcml_get_term_id_by_slug($key, $item_data);
                     $tr_id = apply_filters('translate_object_id', $term_id, $key, false, $sitepress_settings['admin_default_language']);
                     if (!is_null($tr_id)) {
                         $translated_slug = $wpdb->get_var($wpdb->prepare("\r\n                                    SELECT t.slug FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_id, $key));
                         $items[$index][$key] = $translated_slug;
                     }
                 }
             }
         }
     }
     return $items;
 }
Example #15
0
/**
 * Return current page title
 * @return string current title
 */
function ap_page_title()
{
    $pages = anspress()->pages;
    $current_page = get_query_var('ap_page');
    if (is_question()) {
        $new_title = ap_question_title_with_solved_prefix();
    } elseif (is_ap_edit()) {
        $new_title = __('Edit post', 'ap');
    } elseif (is_ap_search()) {
        $new_title = sprintf(ap_opt('search_page_title'), sanitize_text_field(get_query_var('ap_s')));
    } elseif (is_ask()) {
        $new_title = ap_opt('ask_page_title');
    } elseif (is_ap_users()) {
        $new_title = ap_opt('users_page_title');
    } elseif ($current_page == '' && !is_question() && get_query_var('question_name') == '') {
        $new_title = ap_opt('base_page_title');
    } elseif (get_query_var('parent') != '') {
        $new_title = sprintf(__('Discussion on "%s"', 'ap'), get_the_title(get_query_var('parent')));
    } elseif (isset($pages[$current_page]['title'])) {
        $new_title = $pages[$current_page]['title'];
    } else {
        $new_title = __('Error 404', 'ap');
    }
    $new_title = apply_filters('ap_page_title', $new_title);
    return $new_title;
}
 public function the_title($params, $template)
 {
     $default_params = array('id' => null);
     // merge default params with the provided ones
     $params = array_merge($default_params, $params);
     return get_the_title($params['id']);
 }
Example #17
0
function gdl_social_share_title()
{
    $title = str_replace(' ', '%20', get_the_title());
    $title = str_replace('{', '%7B', $title);
    $title = str_replace('}', '%7D', $title);
    return strip_tags($title);
}
 /**
  * Outputs the HTML for this widget.
  *
  * @param array  An array of standard parameters for widgets in this theme 
  * @param array  An array of settings for this widget instance 
  * @return void Echoes it's output
  **/
 public function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $count = esc_attr($instance['count']);
     $count = 0 < $count && $count < 10 ? $count : 2;
     $loop = new WP_Query(array('post_type' => 'event', 'posts_per_page' => $count, 'order' => 'ASC', 'orderby' => 'meta_value_num', 'meta_key' => '_event_start', 'meta_query' => array(array('key' => '_event_end', 'value' => time(), 'compare' => '>'))));
     if ($loop->have_posts()) {
         echo $before_widget;
         if ($instance['title']) {
             echo $before_title . apply_filters('widget_title', $instance['title']) . $after_title;
         }
         echo '<ul>';
         while ($loop->have_posts()) {
             $loop->the_post();
             global $post;
             $output = '<span class="meta">' . date(get_option('date_format'), get_post_meta(get_the_ID(), '_event_start', true)) . '</span> <a href="' . get_permalink() . '">' . get_the_title() . '</a>';
             $read_more = apply_filters('em4wp_events_manager_upcoming_widget_output', $output, $post);
             if ($read_more) {
                 echo '<li>' . $read_more . '</li>';
             }
         }
         if ($instance['more_text']) {
             echo '<li><a href="' . get_post_type_archive_link('event') . '">' . esc_attr($instance['more_text']) . '</a></li>';
         }
         echo '</ul>';
         echo $after_widget;
     }
     wp_reset_postdata();
 }
Example #19
0
function wptuts_first_shortcode($atts, $content = null)
{
    $post_url = get_permalink($post->ID);
    $post_title = get_the_title($post->ID);
    $tweet = '<a href="http://twitter.com/home/?status=Read ' . $post_title . ' at ' . $post_url . '">Share on Twitter</a>';
    return $tweet;
}
Example #20
0
function truncate_title($amount)
{
    $truncate = get_the_title();
    $truncate = substr($truncate, 0, $amount);
    echo $truncate;
    echo "...";
}
Example #21
0
function swp_buffer_button_html($array)
{
    // If we've already generated this button, just use our existing html
    if (isset($_GLOBALS['sw']['buttons'][$array['postID']]['buffer'])) {
        $array['resource']['buffer'] = $_GLOBALS['sw']['buttons'][$array['postID']]['buffer'];
        // If not, let's check if Buffer is activated and create the button HTML
    } elseif (isset($array['options']['newOrderOfIcons']['buffer']) && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['buffer'])) {
        // Collect the Title
        $title = get_post_meta($array['postID'], 'nc_ogTitle', true);
        if (!$title) {
            $title = get_the_title();
        }
        $array['totes'] += $array['shares']['buffer'];
        ++$array['count'];
        $array['resource']['buffer'] = '<div class="nc_tweetContainer swp_buffer" data-id="' . $array['count'] . '" data-network="buffer">';
        $link = urlencode(urldecode(swp_process_url($array['url'], 'buffer', $array['postID'])));
        $array['resource']['buffer'] .= '<a target="_blank" href="http://bufferapp.com/add?url=' . $link . '&text=' . urlencode(html_entity_decode($title, ENT_COMPAT, 'UTF-8')) . '" data-link="http://bufferapp.com/add?url=' . $link . '&text=' . urlencode(html_entity_decode($title, ENT_COMPAT, 'UTF-8')) . '" class="nc_tweet buffer_link">';
        if ($array['options']['totesEach'] && $array['shares']['totes'] >= $array['options']['minTotes'] && $array['shares']['buffer'] > 0) {
            $array['resource']['buffer'] .= '<span class="iconFiller">';
            $array['resource']['buffer'] .= '<span class="spaceManWilly">';
            $array['resource']['buffer'] .= '<i class="sw sw-buffer"></i>';
            $array['resource']['buffer'] .= '<span class="swp_share"> ' . __('Buffer', 'social-warfare') . '</span>';
            $array['resource']['buffer'] .= '</span></span>';
            $array['resource']['buffer'] .= '<span class="swp_count">' . swp_kilomega($array['shares']['buffer']) . '</span>';
        } else {
            $array['resource']['buffer'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-buffer"></i><span class="swp_share"> ' . __('Buffer', 'social-warfare') . '</span></span></span></span>';
        }
        $array['resource']['buffer'] .= '</a>';
        $array['resource']['buffer'] .= '</div>';
        // Store these buttons so that we don't have to generate them for each set
        $_GLOBALS['sw']['buttons'][$array['postID']]['buffer'] = $array['resource']['buffer'];
    }
    return $array;
}
Example #22
0
function moxie_press_endpoint_data()
{
    global $wp_query;
    // get query vars
    $json = $wp_query->get('json');
    $name = $wp_query->get('name');
    // use this template redirect only if json is requested
    if ($json != 'true') {
        return;
    }
    // build the query
    $movie_data = array();
    // default args
    $args = array('post_type' => 'movie', 'posts_per_page' => 100);
    if ($name != '') {
        $args['name'] = $name;
    }
    // add name if provided in query
    // check if this particular request is cached, if not, perform the query
    if (false === ($moxie_cached_request = get_transient('moxie_cached_request_' . json_encode($args)))) {
        $moxie_cached_request = new WP_Query($args);
        set_transient('moxie_cached_request_' . json_encode($args), $moxie_cached_request);
    }
    // prepare the object we want to send as response
    if ($moxie_cached_request->have_posts()) {
        while ($moxie_cached_request->have_posts()) {
            $moxie_cached_request->the_post();
            $id = get_the_ID();
            $movie_data[] = array('id' => $id, 'title' => get_the_title(), 'poster_url' => get_post_meta($id, 'moxie_press_poster_url', true), 'rating' => get_post_meta($id, 'moxie_press_rating', true), 'year' => get_post_meta($id, 'moxie_press_year', true), 'short_description' => get_post_meta($id, 'moxie_press_description', true), 'mdbid' => get_post_meta($id, 'moxie_press_mdbid', true));
        }
        wp_reset_postdata();
    }
    // send json data using built-in WP function
    wp_send_json(array('data' => $movie_data));
}
Example #23
0
function rum_post_cta_meta_box_list()
{
    global $post;
    // store global post object for later resetting after our query
    // using wp_reset_postdata() doesn't work so we are manually resetting the global
    $post_old = $post;
    // initialize variables
    $options = '';
    // get plugin option array and store in a variable
    $plugin_option_array = get_option('rum_post_cta_plugin_options');
    // fetch values from the plugin option variable array
    $post_cta_post_type = $plugin_option_array['post_type'];
    // retrieve the custom meta box value
    $post_cta_id = get_post_meta($post->ID, 'rum_post_cta_id', true);
    // set query arguments
    $args = array('post_type' => $post_cta_post_type, 'nopaging' => true);
    // execute the query
    $cta_post_query = new WP_Query($args);
    // The Loop
    while ($cta_post_query->have_posts()) {
        $cta_post_query->the_post();
        $post_title = get_the_title();
        $post_ID = get_the_id();
        $options .= '<option value="' . esc_attr($post_ID) . '" ' . selected($post_cta_id, $post_ID) . '>' . $post_title . '</option>';
    }
    // restore the global $post variable of the main query loop
    // wp_reset_postdata(); doesn't work so we are manually resetting it back
    // restore global post object
    $post = $post_old;
    setup_postdata($post);
    return $options;
}
 static function get_posts($args = array(), $current = 0)
 {
     $deff = array('post_type' => 'page', 'posts_per_page' => 40, 'post_status' => 'publish');
     if (empty($args)) {
         $args = $deff;
     } else {
         if (!isset($args['post_type'])) {
             $args['post_type'] = $deff['post_type'];
         }
         if (!isset($args['posts_per_page'])) {
             $args['posts_per_page'] = $deff['posts_per_page'];
         }
         if (!isset($args['post_status'])) {
             $args['post_status'] = $deff['post_status'];
         }
     }
     $query = new WP_Query($args);
     $rett = array(0 => __(' - Select from list - ', 'materialize'));
     if (count($query->posts)) {
         foreach ($query->posts as $p) {
             $rett[$p->ID] = esc_attr(get_the_title($p->ID));
         }
     }
     if (absint($current) > 0 && !isset($rett[$current])) {
         $p_ = get_post($current);
         if (isset($p_->ID)) {
             $rett[$p_->ID] = esc_attr(get_the_title($p_->ID));
         }
     }
     return $rett;
 }
function image_cpt_shortcode($attr)
{
    if ($attr['page'] <= 10) {
        $per_page['page'] = $attr['page'];
    } else {
        $per_page['page'] = 10;
    }
    $output = '<h2 class="winner-title">Hall of Winners</h2><h3 class="winner-subtitle">Congratulations to all of our winners</h3>';
    $args = array('post_type' => 'image_post_type', 'posts_per_page' => $per_page['page']);
    $loop = new WP_query($args);
    if ($loop->have_posts()) {
        while ($loop->have_posts()) {
            $loop->the_post();
            $output .= '<div class="winner-div"><h3>';
            $output .= get_the_title();
            $output .= '</h3>';
            if (has_post_thumbnail()) {
                // check if the post has a post thumbnail assigned to it.
                $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($loop->ID), 'full');
                $url = $thumb['0'];
                $output .= '<img src="' . $url . '"/>';
            }
            $output .= '</div>';
        }
    } else {
        // if no content, include the "no posts found" template.
        get_template_part('content', 'none');
    }
    return $output;
}
function al_portfolio_meta_tags()
{
    $post_type = get_post_type();
    if ('portfolio' == $post_type) {
        $title = get_post_meta(get_the_ID(), "al_pf_og_title", TRUE);
        $title = !empty($title) ? $title : get_the_title();
        $meta = array('og:title' => $title, 'og:url' => get_permalink());
        $desc = get_post_meta(get_the_ID(), "al_pf_og_description", TRUE);
        $desc = !empty($desc) ? $desc : false;
        if ($desc) {
            $meta['og:description'] = $desc;
        }
        if (has_post_thumbnail()) {
            $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
            $meta['og:image'] = $thumbnail[0];
        }
        if (get_post_format() == 'gallery') {
            $images = rwmb_meta('al_pf_gallery_images', 'type=image&size=full');
            if (is_array($images)) {
                foreach ($images as $image) {
                    $meta['images'][] = $image['url'];
                }
            }
        }
        foreach ($meta as $key => $value) {
            if ($key == 'images') {
                foreach ($value as $image) {
                    echo '<meta property="og:image" content="' . $image . '" />';
                }
            } else {
                echo '<meta property="' . $key . '" content="' . $value . '" />';
            }
        }
    }
}
Example #27
0
/**
 * Wp in Progress
 * 
 * @author WPinProgress
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
 * It is also available at this URL: http://www.gnu.org/licenses/gpl-3.0.txt
 */
function novalite_get_title()
{
    global $post;
    $title = get_the_title();
    if (!empty($title)) {
        if (is_home() || is_category() || is_search()) {
            ?>
				
			<h3 class="title"> <a href="<?php 
            echo get_permalink($post->ID);
            ?>
"> <?php 
            echo $title;
            ?>
 </a> </h3>
				
	<?php 
        } else {
            ?>
			
			<h1 class="title"> <?php 
            echo $title;
            ?>
 </h1>
			
	<?php 
        }
    }
}
Example #28
-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;
 }
Example #29
-1
 /**
  * Prints HTML with meta information for the categories, tags and comments.
  */
 function xmaps_entry_footer()
 {
     // Hide category and tag text for pages.
     if ('post' === get_post_type()) {
         /* translators: used between list items, there is a space after the comma */
         $categories_list = get_the_category_list(esc_html__(', ', 'xmaps'));
         if ($categories_list && xmaps_categorized_blog()) {
             printf('<span class="cat-links">' . esc_html__('Posted in %1$s', 'xmaps') . '</span>', $categories_list);
             // WPCS: XSS OK.
         }
         /* translators: used between list items, there is a space after the comma */
         $tags_list = get_the_tag_list('', esc_html__(', ', 'xmaps'));
         if ($tags_list) {
             printf('<span class="tags-links">' . esc_html__('Tagged %1$s', 'xmaps') . '</span>', $tags_list);
             // WPCS: XSS OK.
         }
     }
     if (!is_single() && !post_password_required() && (comments_open() || get_comments_number())) {
         echo '<span class="comments-link">';
         /* translators: %s: post title */
         comments_popup_link(sprintf(wp_kses(__('Leave a Comment<span class="screen-reader-text"> on %s</span>', 'xmaps'), array('span' => array('class' => array()))), get_the_title()));
         echo '</span>';
     }
     edit_post_link(sprintf(esc_html__('Edit %s', 'xmaps'), the_title('<span class="screen-reader-text">"', '"</span>', false)), '<span class="edit-link">', '</span>');
 }
Example #30
-7
 function widget($args, $instance)
 {
     global $post;
     extract($args, EXTR_SKIP);
     echo $before_widget;
     $title = empty($instance['title']) ? __('Recent Posts', 'lan-thinkupthemes') : apply_filters('widget_title', $instance['title']);
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $posts = new WP_Query('orderby=date&posts_per_page=' . $instance['postcount'] . '');
     while ($posts->have_posts()) {
         $posts->the_post();
         // Insert post date if needed.
         if ($instance['postdate'] == 'on') {
             $date_input = '<a href="' . get_permalink() . '" class="date">' . get_the_date('M j, Y') . '</a>';
         }
         // HTML output
         echo '<div class="recent-posts">';
         if (has_post_thumbnail() and $instance['imageswitch'] == 'on') {
             echo '<div class="image">', '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, array(65, 65)) . '<div class="image-overlay"></div></a>', '</div>', '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>';
         } else {
             echo '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>';
         }
         echo '</div>';
     }
     wp_reset_query();
     echo $after_widget;
 }