コード例 #1
2
function wpcf7_special_mail_tag_for_post_data($output, $name)
{
    if (!isset($_POST['_wpcf7_unit_tag']) || empty($_POST['_wpcf7_unit_tag'])) {
        return $output;
    }
    if (!preg_match('/^wpcf7-f(\\d+)-p(\\d+)-o(\\d+)$/', $_POST['_wpcf7_unit_tag'], $matches)) {
        return $output;
    }
    $post_id = (int) $matches[2];
    if (!($post = get_post($post_id))) {
        return $output;
    }
    $user = new WP_User($post->post_author);
    // For backwards compat.
    $name = preg_replace('/^wpcf7\\./', '_', $name);
    if ('_post_id' == $name) {
        $output = (string) $post->ID;
    } elseif ('_post_name' == $name) {
        $output = $post->post_name;
    } elseif ('_post_title' == $name) {
        $output = $post->post_title;
    } elseif ('_post_url' == $name) {
        $output = get_permalink($post->ID);
    } elseif ('_post_author' == $name) {
        $output = $user->display_name;
    } elseif ('_post_author_email' == $name) {
        $output = $user->user_email;
    }
    return $output;
}
 /**
  * Add Menu Cart to menu
  * 
  * @return menu items including cart
  */
 public function submenu_items()
 {
     $get_cart = jigoshop_cart::get_cart();
     $submenu_items = '';
     //see jigoshop/widgets/cart.php
     if (count($get_cart) > 0) {
         foreach ($get_cart as $cart_item_key => $values) {
             $_product = $values['data'];
             if ($_product->exists() && $values['quantity'] > 0) {
                 $item_thumbnail = has_post_thumbnail($_product->id) ? get_the_post_thumbnail($_product->id, 'shop_tiny') : jigoshop_get_image_placeholder('shop_tiny');
                 $item_name = $_product->get_title();
                 // Not used: Displays variations and cart item meta
                 $item_meta = jigoshop_cart::get_item_data($values);
                 $item_quantity = esc_attr($values['quantity']);
                 $item_price = $_product->get_price_html();
                 // Item permalink
                 $item_permalink = esc_attr(get_permalink($_product->id));
                 $submenu_items[] = array('item_thumbnail' => $item_thumbnail, 'item_name' => $item_name, 'item_quantity' => $item_quantity, 'item_price' => $item_price, 'item_permalink' => $item_permalink);
             }
         }
     } else {
         $submenu_items = '';
     }
     return $submenu_items;
 }
コード例 #3
1
 /**
  * Prints HTML with meta information for the current post-date/time and author.
  */
 function square_posted_on()
 {
     $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
     if (get_the_time('U') !== get_the_modified_time('U')) {
         $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
     }
     $time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date()));
     $posted_on = sprintf(esc_html_x('%s', 'post date', 'square'), '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $time_string . '</a>');
     $byline = sprintf(esc_html_x('by %s', 'post author', 'square'), '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>');
     $comment_count = get_comments_number();
     // get_comments_number returns only a numeric value
     if (comments_open()) {
         if ($comment_count == 0) {
             $comments = __('No Comments', 'square');
         } elseif ($comment_count > 1) {
             $comments = $comment_count . __(' Comments', 'square');
         } else {
             $comments = __('1 Comment', 'square');
         }
         $comment_link = '<a href="' . get_comments_link() . '">' . $comments . '</a>';
     } else {
         $comment_link = __(' Comment Closed', 'square');
     }
     echo '<span class="posted-on"><i class="fa fa-clock-o"></i>' . $posted_on . '</span><span class="byline"> ' . $byline . '</span><span class="comment-count"><i class="fa fa-comments-o"></i>' . $comment_link . "</span>";
     // WPCS: XSS OK.
 }
コード例 #4
0
function custom_rss_teaser($content)
{
    $teaser = preg_split('/<span id="(more-\\d+)"><\\/span>/', $content);
    $readmore = '<a href="' . get_permalink() . '">[前往围观...]</a>';
    $content = $teaser[0] . $readmore;
    return $content;
}
コード例 #5
0
 /**
  * Test the "get_certificate_url" method.
  */
 public function testGetCertificateUrl()
 {
     $entry = Edr_Crt_Test::get_instance()->addEntry(array('user_id' => 1, 'course_id' => 1, 'entry_status' => 'complete'));
     $edr_crt = Edr_Manager::get('edr_crt');
     $certificate_id = $edr_crt->create_certificate($entry);
     $this->assertEquals(get_permalink($certificate_id), $edr_crt->get_certificate_url($entry->ID));
 }
コード例 #6
0
 /**
  * Output the shortcode.
  *
  * @param array $atts
  */
 public static function output($atts)
 {
     // Check cart class is loaded or abort
     if (is_null(WC()->cart)) {
         return;
     }
     extract(shortcode_atts(array(), $atts));
     global $post;
     if (!empty($_REQUEST['orderid']) && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-order_tracking')) {
         $order_id = empty($_REQUEST['orderid']) ? 0 : esc_attr($_REQUEST['orderid']);
         $order_email = empty($_REQUEST['order_email']) ? '' : esc_attr($_REQUEST['order_email']);
         if (!$order_id) {
             echo '<p class="woocommerce-error">' . __('Please enter a valid order ID', 'woocommerce') . '</p>';
         } elseif (!$order_email) {
             echo '<p class="woocommerce-error">' . __('Please enter a valid order email', 'woocommerce') . '</p>';
         } else {
             $order = wc_get_order(apply_filters('woocommerce_shortcode_order_tracking_order_id', $order_id));
             if ($order && $order->get_id() && $order_email) {
                 if (strtolower($order->get_billing_email()) == strtolower($order_email)) {
                     do_action('woocommerce_track_order', $order->get_id());
                     wc_get_template('order/tracking.php', array('order' => $order));
                     return;
                 }
             } else {
                 echo '<p class="woocommerce-error">' . sprintf(__('Sorry, we could not find that order ID in our database.', 'woocommerce'), get_permalink($post->ID)) . '</p>';
             }
         }
     }
     wc_get_template('order/form-tracking.php');
 }
コード例 #7
0
ファイル: wpshortcodes.php プロジェクト: zacrobat/learnings
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;
}
コード例 #8
0
ファイル: functions-filters.php プロジェクト: KL-Kim/my-theme
/**
 * Filters the excerpt more output with internationalized text and a link to the post.
 *
 * @since  2.0.0
 * @access public
 * @param  string  $text
 * @return string
 */
function hybrid_excerpt_more($text)
{
    if (0 !== strpos($text, '<a')) {
        $text = sprintf(' <a href="%s" class="more-link">%s</a>', esc_url(get_permalink()), trim($text));
    }
    return $text;
}
コード例 #9
0
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 . '" />';
            }
        }
    }
}
コード例 #10
0
 function start_el(&$output, $page, $depth = 0, $args = array(), $current_page = 0)
 {
     if ($depth) {
         $indent = str_repeat("\t", $depth);
     } else {
         $indent = '';
     }
     extract($args, EXTR_SKIP);
     $css_class = array('page_item', 'page-item-' . $page->ID);
     if (!empty($current_page)) {
         $_current_page = get_post($current_page);
         if (in_array($page->ID, $_current_page->ancestors)) {
             $css_class[] = 'current_page_ancestor';
         }
         if ($page->ID == $current_page) {
             $css_class[] = 'current_page_item';
         } elseif ($_current_page && $page->ID == $_current_page->post_parent) {
             $css_class[] = 'current_page_parent';
         }
     } elseif ($page->ID == get_option('page_for_posts')) {
         $css_class[] = 'current_page_parent';
     }
     $css_class = implode(' ', apply_filters('page_css_class', $css_class, $page, $depth, $args, $current_page));
     $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '">' . $link_before . apply_filters('the_title', $page->post_title, $page->ID) . $link_after . '</a>';
     if (!empty($show_date)) {
         if ('modified' == $show_date) {
             $time = $page->post_modified;
         } else {
             $time = $page->post_date;
         }
         $output .= " " . mysql2date($date_format, $time);
     }
 }
コード例 #11
0
 protected function check_get_post_response($response, $post_obj, $context = 'view')
 {
     $response = json_ensure_response($response);
     $response_data = $response->get_data();
     $this->assertEquals($post_obj->ID, $response_data['ID']);
     $this->assertEquals($post_obj->post_name, $response_data['slug']);
     $this->assertEquals($post_obj->post_status, $response_data['status']);
     $this->assertEquals($post_obj->post_author, $response_data['author']);
     $this->assertArrayHasKey('parent', $response_data);
     $this->assertEquals(get_permalink($post_obj->ID), $response_data['link']);
     $this->assertEquals($post_obj->menu_order, $response_data['menu_order']);
     $this->assertEquals($post_obj->comment_status, $response_data['comment_status']);
     $this->assertEquals($post_obj->ping_status, $response_data['ping_status']);
     $this->assertEquals($post_obj->post_password, $response_data['password']);
     $this->assertEquals(is_sticky($post_obj->ID), $response_data['sticky']);
     // Check post parent.
     if ($post_obj->post_parent) {
         if (is_int($response_data['parent'])) {
             $this->assertEquals($post_obj->post_parent, $response_data['parent']);
         } else {
             $this->assertEquals($post_obj->post_parent, $response_data['parent']['ID']);
             $this->check_get_post_response($response_data['parent'], get_post($response_data['parent']['ID']), 'view-parent');
         }
     } else {
         $this->assertEmpty($response_data['parent']);
     }
     // Check post format.
     $post_format = get_post_format($post_obj->ID);
     if (empty($post_format)) {
         $this->assertEquals('standard', $response_data['format']);
     } else {
         $this->assertEquals(get_post_format($post_obj->ID), $response_data['format']);
     }
     // Check post dates.
     if ($post_obj->post_date_gmt === '0000-00-00 00:00:00') {
         $this->assertNull($response_data['date']);
         $this->assertNull($response_data['date_gmt']);
     } else {
         $this->assertEquals(json_mysql_to_rfc3339($post_obj->post_date), $response_data['date']);
         $this->assertEquals(json_mysql_to_rfc3339($post_obj->post_date_gmt), $response_data['date_gmt']);
     }
     if ($post_obj->post_modified_gmt === '0000-00-00 00:00:00') {
         $this->assertNull($response_data['modified']);
         $this->assertNull($response_data['modified_gmt']);
     } else {
         $this->assertEquals(json_mysql_to_rfc3339($post_obj->post_modified), $response_data['modified']);
         $this->assertEquals(json_mysql_to_rfc3339($post_obj->post_modified_gmt), $response_data['modified_gmt']);
     }
     // Check filtered values.
     $this->assertEquals(get_the_title($post_obj->ID), $response_data['title']);
     // TODO: apply content filter for more accurate testing.
     $this->assertEquals(wpautop($post_obj->post_content), $response_data['content']);
     // TODO: apply excerpt filter for more accurate testing.
     $this->assertEquals(wpautop($post_obj->post_excerpt), $response_data['excerpt']);
     $this->assertEquals($post_obj->guid, $response_data['guid']);
     if ($context === 'edit') {
         $this->assertEquals($post_obj->post_content, $response_data['content_raw']);
         $this->assertEquals($post_obj->post_excerpt, $response_data['excerpt_raw']);
     }
 }
コード例 #12
0
ファイル: title.php プロジェクト: f0rg3/salvation-army
/**
 * 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 
        }
    }
}
コード例 #13
0
ファイル: avatar.php プロジェクト: pivotlearning/wpsite
 /**
  * Get HTML markup for the post's "avatar" image according conditional
  * fallback model.
  *
  * Accepts an ordered array of named avatar $fallbacks. Also accepts a string
  * of space-separated classes to add to the default classes.
  * @param   Ai1ec_Event $event          The event to get the avatar for
  * @param   array|null  $fallback_order Order of fallback in searching for
  *                                      images, or null to use default
  * @param   string      $classes        A space-separated list of CSS classes
  *                                      to apply to the outer <div> element.
  * @param   boolean     $wrap_permalink Whether to wrap the element in a link
  *                                      to the event details page.
  *
  * @return  string                   String of HTML if image is found
  */
 public function get_event_avatar(Ai1ec_Event $event, $fallback_order = null, $classes = '', $wrap_permalink = true)
 {
     $source = $size = null;
     $url = $this->get_event_avatar_url($event, $fallback_order, $source, $size);
     if (empty($url)) {
         return '';
     }
     $url = esc_attr($url);
     $classes = esc_attr($classes);
     // Set the alt tag (helpful for SEO).
     $alt = $event->get('post')->post_title;
     $location = $this->_registry->get('view.event.location')->get_short_location($event);
     if (!empty($location)) {
         $alt .= ' @ ' . $location;
     }
     $alt = esc_attr($alt);
     $size_attr = $size[0] ? "width=\"{$size['0']}\" height=\"{$size['1']}\"" : "";
     $html = '<img src="' . $url . '" alt="' . $alt . '" ' . $size_attr . ' />';
     if ($wrap_permalink) {
         $permalink = add_query_arg('instance_id', $event->get('instance_id'), get_permalink($event->get('post_id')));
         $html = '<a href="' . $permalink . '">' . $html . '</a>';
     }
     $classes .= ' ai1ec-' . $source;
     $classes .= $size[0] > $size[1] ? ' ai1ec-landscape' : ' ai1ec-portrait';
     $html = '<div class="ai1ec-event-avatar timely ' . $classes . '">' . $html . '</div>';
     return $html;
 }
コード例 #14
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        $number = $instance['number'];
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
		<div class="recent-works-items clearfix">
		<?php 
        $args = array('post_type' => 'evolve_portfolio', 'posts_per_page' => $number, 'has_password' => false);
        $portfolio = new WP_Query($args);
        if ($portfolio->have_posts()) {
            ?>
		<?php 
            while ($portfolio->have_posts()) {
                $portfolio->the_post();
                ?>
		<?php 
                if (has_post_thumbnail()) {
                    ?>
		<?php 
                    $link_target = "";
                    $url_check = get_post_meta(get_the_ID(), 'pyre_link_icon_url', true);
                    if (!empty($url_check)) {
                        $new_permalink = get_post_meta(get_the_ID(), 'pyre_link_icon_url', true);
                        if (get_post_meta(get_the_ID(), 'pyre_link_icon_target', true) == "yes") {
                            $link_target = ' target="_blank"';
                        }
                    } else {
                        $new_permalink = get_permalink();
                    }
                    ?>
		<a href="<?php 
                    echo $new_permalink;
                    ?>
"<?php 
                    echo $link_target;
                    ?>
 title="<?php 
                    the_title();
                    ?>
">
			<?php 
                    the_post_thumbnail('recent-works-thumbnail');
                    ?>
		</a>
		<?php 
                }
            }
        }
        wp_reset_query();
        ?>
		</div>

		<?php 
        echo $after_widget;
    }
コード例 #15
0
 /**
  * Output the shortcode.
  *
  * @access public
  * @param array $atts
  * @return void
  */
 public static function output($atts)
 {
     global $woocommerce;
     $woocommerce->nocache();
     extract(shortcode_atts(array(), $atts));
     global $post;
     if (!empty($_REQUEST['orderid'])) {
         $woocommerce->verify_nonce('order_tracking');
         $order_id = empty($_REQUEST['orderid']) ? 0 : esc_attr($_REQUEST['orderid']);
         $order_email = empty($_REQUEST['order_email']) ? '' : esc_attr($_REQUEST['order_email']);
         if (!$order_id) {
             echo '<p class="woocommerce-error">' . __('Please enter a valid order ID', 'woocommerce') . '</p>';
         } elseif (!$order_email) {
             echo '<p class="woocommerce-error">' . __('Please enter a valid order email', 'woocommerce') . '</p>';
         } else {
             $order = new WC_Order(apply_filters('woocommerce_shortcode_order_tracking_order_id', $order_id));
             if ($order->id && $order_email) {
                 if (strtolower($order->billing_email) == strtolower($order_email)) {
                     do_action('woocommerce_track_order', $order->id);
                     woocommerce_get_template('order/tracking.php', array('order' => $order));
                     return;
                 }
             } else {
                 echo '<p class="woocommerce-error">' . sprintf(__('Sorry, we could not find that order id in our database.', 'woocommerce'), get_permalink($post->ID)) . '</p>';
             }
         }
     }
     woocommerce_get_template('order/form-tracking.php');
 }
コード例 #16
0
 function filter_woocommerce_ajax_params($woocommerce_params)
 {
     global $sitepress, $post;
     $value = array();
     $value = $woocommerce_params;
     if ($sitepress->get_current_language() !== $sitepress->get_default_language()) {
         $value['ajax_url'] = add_query_arg('lang', ICL_LANGUAGE_CODE, $woocommerce_params['ajax_url']);
         $value['checkout_url'] = add_query_arg('action', 'woocommerce-checkout', $value['ajax_url']);
     }
     if (!isset($post->ID)) {
         return $value;
     }
     $ch_pages = wp_cache_get('ch_pages', 'wcml_ch_pages');
     if (empty($ch_pages)) {
         $ch_pages = array('checkout_page_id' => get_option('woocommerce_checkout_page_id'), 'pay_page_id' => get_option('woocommerce_pay_page_id'), 'cart_page_id' => get_option('woocommerce_cart_page_id'));
         $ch_pages['translated_checkout_page_id'] = apply_filters('translate_object_id', $ch_pages['checkout_page_id'], 'page', false);
         $ch_pages['translated_pay_page_id'] = apply_filters('translate_object_id', $ch_pages['pay_page_id'], 'page', false);
         $ch_pages['translated_cart_page_id'] = apply_filters('translate_object_id', $ch_pages['cart_page_id'], 'page', false);
     }
     wp_cache_set('ch_pages', $ch_pages, 'wcml_ch_pages');
     if ($ch_pages['translated_cart_page_id'] == $post->ID) {
         $value['is_cart'] = 1;
         $value['cart_url'] = get_permalink($ch_pages['translated_cart_page_id']);
     } else {
         if ($ch_pages['translated_checkout_page_id'] == $post->ID || $ch_pages['checkout_page_id'] == $post->ID) {
             $value['is_checkout'] = 1;
             $_SESSION['wpml_globalcart_language'] = $sitepress->get_current_language();
         } else {
             if ($ch_pages['translated_pay_page_id'] == $post->ID) {
                 $value['is_pay_page'] = 1;
             }
         }
     }
     return $value;
 }
コード例 #17
0
/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works.
 *
 * @return void
 */
function wc_template_redirect()
{
    global $wp_query, $wp;
    // When default permalinks are enabled, redirect shop page to post type archive url
    if (!empty($_GET['page_id']) && get_option('permalink_structure') == "" && $_GET['page_id'] == wc_get_page_id('shop')) {
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    } elseif (is_page(wc_get_page_id('checkout')) && sizeof(WC()->cart->get_cart()) == 0 && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received'])) {
        wp_redirect(get_permalink(wc_get_page_id('cart')));
        exit;
    } elseif (isset($wp->query_vars['customer-logout'])) {
        wp_redirect(str_replace('&amp;', '&', wp_logout_url(get_permalink(wc_get_page_id('myaccount')))));
        exit;
    } elseif (is_search() && is_post_type_archive('product') && apply_filters('woocommerce_redirect_single_search_result', true) && $wp_query->found_posts == 1) {
        $product = wc_get_product($wp_query->post);
        if ($product->is_visible()) {
            wp_safe_redirect(get_permalink($product->id), 302);
            exit;
        }
    } elseif (is_add_payment_method_page()) {
        WC()->payment_gateways();
    } elseif (is_checkout()) {
        // Buffer the checkout page
        ob_start();
        // Ensure gateways and shipping methods are loaded early
        WC()->payment_gateways();
        WC()->shipping();
    }
}
コード例 #18
0
 public function testThemeTemplateIsCorrectForPost()
 {
     $post = $this->factory->post->create();
     $this->go_to_with_template(get_permalink($post));
     $this->assertTrue(is_single());
     $this->assertSame('single.php', self::get_theme_data('template_file'));
 }
コード例 #19
0
function lp_thumbnail_metabox()
{
    global $post;
    $template = get_post_meta($post->ID, 'lp-selected-template', true);
    $template = apply_filters('lp_selected_template', $template);
    $permalink = get_permalink($post->ID);
    $datetime = the_modified_date('YmjH', null, null, false);
    $permalink = $permalink . '?dt=' . $datetime;
    if (in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) {
        if (file_exists(LANDINGPAGES_UPLOADS_PATH . $template . '/thumbnail.png')) {
            $thumbnail = LANDINGPAGES_UPLOADS_URLPATH . $template . '/thumbnail.png';
        } else {
            $thumbnail = LANDINGPAGES_URLPATH . 'templates/' . $template . '/thumbnail.png';
        }
    } else {
        $thumbnail = 'http://s.wordpress.com/mshots/v1/' . urlencode(esc_url($permalink)) . '?w=250';
    }
    $permalink = apply_filters('lp_live_screenshot_url', $permalink);
    ?>
	<div >
		<div class="inside" style='margin-left:-8px;'>
			<table>
				<tr>
					<td>
						<?php 
    echo "<a href='{$permalink}' target='_blank' ><img src='{$thumbnail}' style='width:250px;height:250px;' title='" . __('Preview this theme', 'landing-pages') . " ,  ({$template})'></a>";
    ?>
					</td>
				</tr>
			</table>

		</div>
	</div>
	<?php 
}
コード例 #20
0
    function widget($args, $instance)
    {
        global $post;
        // Preserve global $post
        $preserve = $post;
        extract($args);
        // only useful on post pages
        if (!is_single()) {
            return;
        }
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Read Next', 'largo') : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        $related = new Largo_Related($instance['qty']);
        //get the related posts
        $rel_posts = new WP_Query(array('post__in' => $related->ids(), 'nopaging' => 1, 'posts_per_page' => $instance['qty'], 'ignore_sticky_posts' => 1));
        if ($rel_posts->have_posts()) {
            echo '<ul class="related">';
            while ($rel_posts->have_posts()) {
                $rel_posts->the_post();
                echo '<li>';
                echo '<a href="' . get_permalink() . '"/>' . get_the_post_thumbnail(get_the_ID(), 'thumbnail', array('class' => 'alignleft')) . '</a>';
                ?>
				<h4><a href="<?php 
                the_permalink();
                ?>
" title="Read: <?php 
                esc_attr(the_title('', '', FALSE));
                ?>
"><?php 
                the_title();
                ?>
</a></h4>
				<h5 class="byline">
					<span class="by-author"><?php 
                largo_byline(true, true);
                ?>
</span>
					<time class="entry-date updated dtstamp pubdate" datetime="<?php 
                echo esc_attr(get_the_date('c'));
                ?>
"><?php 
                largo_time();
                ?>
</time>
				</h5>
				<?php 
                // post excerpt/summary
                largo_excerpt(get_the_ID(), 2, false, '', true);
                echo '</li>';
            }
            echo "</ul>";
        }
        echo $after_widget;
        // Restore global $post
        wp_reset_postdata();
        $post = $preserve;
    }
コード例 #21
0
 /**
  * Batch has been successfully imported.
  *
  * @param Batch $batch
  */
 public function imported(Batch $batch)
 {
     $links = array();
     $output = '';
     $types = array('page', 'post');
     // Only keep published posts of type $types.
     $posts = array_filter($batch->get_posts(), function (Post $post) use($types) {
         return $post->get_post_status() == 'publish' && in_array($post->get_type(), $types);
     });
     // Create links for each of the posts.
     foreach ($posts as $post) {
         $post_id = $this->post_dao->get_id_by_guid($post->get_guid());
         $links[] = array('link' => get_permalink($post_id), 'title' => $post->get_title());
     }
     $links = apply_filters('sme_imported_post_links', $links);
     foreach ($links as $link) {
         $output .= '<li><a href="' . $link['link'] . '" target="_blank">' . $link['title'] . '</a></li>';
     }
     if ($output !== '') {
         $output = '<ul>' . $output . '</ul>';
         $message = '<h3>Posts deployed to ' . get_bloginfo('name') . ':</h3>' . $output;
         $this->api->add_deploy_message($batch->get_id(), $message, 'info', 102);
     }
     $this->api->add_deploy_message($batch->get_id(), 'Batch has been successfully imported!', 'success', 101);
 }
コード例 #22
0
ファイル: toc.php プロジェクト: elinberg/ericlinberg
function x_shortcode_toc_item($atts)
{
    extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'title' => '', 'page' => ''), $atts, 'x_toc_item'));
    $id = $id != '' ? 'id="' . esc_attr($id) . '"' : '';
    $class = $class != '' ? 'x-toc-item ' . esc_attr($class) : 'x-toc-item';
    $style = $style != '' ? 'style="' . $style . '"' : '';
    $title = $title != '' ? $title : '';
    switch ($page) {
        case 0:
            $page = '';
            break;
        case 1:
            $page = '';
            break;
        default:
            $page = $page;
            if (get_post_status(get_the_ID()) == "draft") {
                $page = '&page=' . $page;
            } else {
                $page = get_the_ID() == get_option('page_on_front') ? 'page/' . $page . '/' : $page . '/';
            }
    }
    $link = esc_url(get_permalink());
    $output = "<li {$id} class=\"{$class}\" {$style}><a href=" . $link . $page . " title=\"Go to {$title}\">" . $title . '</a></li>';
    return $output;
}
コード例 #23
0
ファイル: vc_grid_item.php プロジェクト: Angelpm28/ong-canada
function vc_gitem_create_link_real($atts, $post, $default_class = '', $title = '')
{
    $link = '';
    $target = '';
    $title_attr = '';
    if (isset($atts['link'])) {
        $link_css_class = 'vc_gitem-link' . (strlen($default_class) > 0 ? ' ' . $default_class : '');
        if ('custom' === $atts['link'] && !empty($atts['url'])) {
            $link = vc_build_link($atts['url']);
            if (strlen($link['target'])) {
                $target = ' target="' . esc_attr($link['target']) . '"';
            }
            if (strlen($link['title'])) {
                $title = $link['title'];
            }
            $link = 'a href="' . esc_attr($link['url']) . '" class="' . esc_attr($link_css_class) . '"';
        } elseif ('post_link' === $atts['link']) {
            $link = 'a href="' . get_permalink($post->ID) . '" class="' . esc_attr($link_css_class) . '"';
            if (!strlen($title)) {
                $title = the_title('', '', false);
            }
        } elseif ('image' === $atts['link']) {
            $href_link = vc_gitem_template_attribute_post_image_url('', array('post' => $post, 'data' => ''));
            $link = 'a href="' . $href_link . '" class="' . esc_attr($link_css_class) . '"';
        } elseif ('image_lightbox' === $atts['link']) {
            $link = 'a' . vc_gitem_template_attribute_post_image_url_attr_prettyphoto('', array('post' => $post, 'data' => $link_css_class));
        }
    }
    if (strlen($title) > 0) {
        $title_attr = ' title="' . esc_attr($title) . '"';
    }
    return apply_filters('vc_gitem_post_data_get_link_real_link', $link, $atts, $post, $link_css_class) . apply_filters('vc_gitem_post_data_get_link_real_target', $target, $atts, $post) . apply_filters('vc_gitem_post_data_get_link_real_title', $title_attr, $atts);
}
コード例 #24
0
 function woo_shortcode_view_full_article($atts)
 {
     $defaults = array('label' => __('Read full story', 'woothemes'), 'before' => '', 'after' => '');
     $atts = shortcode_atts($defaults, $atts);
     $output = sprintf('<span class="read-more">%1$s<a href="%3$s" title="%4$s">%4$s</a>%2$s</span> ', $atts['before'], $atts['after'], get_permalink(get_the_ID()), $atts['label']);
     return apply_filters('woo_shortcode_view_full_article', $output, $atts);
 }
コード例 #25
0
/**
 * Returns classic grid element for a given product
 *
 * @param object $post Product post object
 * @param string $archive_template
 * @return string
 */
function get_grid_archive_theme($post, $archive_template = null)
{
    $archive_template = isset($archive_template) ? $archive_template : get_product_listing_template();
    $return = '';
    if ($archive_template == 'grid') {
        $image_id = get_post_thumbnail_id($post->ID);
        $thumbnail_product = wp_get_attachment_image_src($image_id, 'classic-grid-listing');
        $product_name = get_product_name();
        if ($thumbnail_product) {
            $img_class['alt'] = $product_name;
            $img_class['class'] = 'classic-grid-image';
            $image = wp_get_attachment_image($image_id, 'classic-grid-listing', false, $img_class);
        } else {
            $url = default_product_thumbnail_url();
            $image = '<img src="' . $url . '" class="classic-grid-image" alt="' . $product_name . '" >';
        }
        $archive_price = apply_filters('archive_price_filter', '', $post);
        $classic_grid_settings = get_classic_grid_settings();
        $row_class = get_row_class($classic_grid_settings);
        $return = '<div class="archive-listing product-' . $post->ID . ' classic-grid ' . $row_class . ' ' . product_class($post->ID) . '">';
        $return .= '<a href="' . get_permalink() . '">';
        //$return .= '<div style="background-image:url(\'' . $url . '\');" class="classic-grid-element"></div>';
        $return .= '<div class="classic-grid-image-wrapper"><div class="pseudo"></div><div class="image">' . $image . '</div></div>';
        $return .= '<h3 class="product-name">' . $product_name . '</h3>' . $archive_price . '</a></div>';
    }
    return $return;
}
 /**
  * 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();
 }
コード例 #27
0
 /**
  * Prints HTML with meta information for the current post-date/time, author, comment count and categories.
  */
 function ultra_posted_on()
 {
     echo '<div class="entry-meta-inner">';
     if (is_sticky() && is_home() && !is_paged()) {
         echo '<span class="featured-post">' . __('Sticky', 'ultra') . '</span>';
     }
     if (is_home() && siteorigin_setting('blog_post_date') || is_archive() && siteorigin_setting('blog_post_date') || is_search() && siteorigin_setting('blog_post_date')) {
         echo '<span class="entry-date"><a href="' . esc_url(get_permalink()) . '" rel="bookmark"><time class="published" datetime="' . esc_attr(get_the_date('c')) . '">' . esc_html(get_the_date('j F Y')) . '</time><time class="updated" datetime="' . esc_attr(get_the_modified_date('c')) . '">' . esc_html(get_the_modified_date()) . '</time></span></a>';
     }
     if (is_single() && siteorigin_setting('blog_post_date')) {
         echo '<span class="entry-date"><time class="published" datetime="' . esc_attr(get_the_date('c')) . '">' . esc_html(get_the_date('j F Y')) . '</time><time class="updated" datetime="' . esc_attr(get_the_modified_date('c')) . '">' . esc_html(get_the_modified_date()) . '</time></span>';
     }
     if (siteorigin_setting('blog_post_author')) {
         echo '<span class="byline"><span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '" rel="author">' . esc_html(get_the_author()) . '</a></span></span>';
     }
     if (comments_open() && siteorigin_setting('blog_post_comment_count')) {
         echo '<span class="comments-link">';
         comments_popup_link(__('Leave a comment', 'ultra'), __('1 Comment', 'ultra'), __('% Comments', 'ultra'));
         echo '</span>';
     }
     echo '</div>';
     if (is_single() && siteorigin_setting('navigation_post_nav')) {
         the_post_navigation($args = array('prev_text' => '', 'next_text' => ''));
     }
 }
コード例 #28
-1
ファイル: post.php プロジェクト: OneTimeUser/retailwire
 /**
  * @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;
 }
コード例 #29
-1
 function test_adding_tutorial_text_to_single()
 {
     //creating admin user and set ut
     $user = new WP_User($this->factory->user->create(array('role' => 'administrator')));
     wp_set_current_user($user->ID);
     //create category
     $cat_id = $this->factory->category->create(array('slug' => rand_str(), 'name' => rand_str(), 'description' => rand_str()));
     //create 3 posts, the $post_ids[1] is the middle one, suppose to have next and prev in the pretext
     $post_ids[] = $this->factory->post->create(array('post_type' => 'post', 'post_status' => 'publish', 'post_title' => 'POST1', 'post_date' => date('Y-m-d H:i:s', time() - 300)));
     $post_ids[] = $this->factory->post->create(array('post_type' => 'post', 'post_status' => 'publish', 'post_title' => 'POST2', 'post_date' => date('Y-m-d H:i:s', time() - 200)));
     $post_ids[] = $this->factory->post->create(array('post_type' => 'post', 'post_status' => 'publish', 'post_title' => 'POST3', 'post_date' => date('Y-m-d H:i:s', time() - 100)));
     //adding them to the category
     foreach ($post_ids as $post_id) {
         $res = wp_set_post_categories($post_id, $cat_id);
     }
     //making the category a tutorial category
     $this->auxClass->set_up_post_data();
     $this->plugin_admin->wp_tutorial_maker_option_update($cat_id);
     //go to tutorial post
     $this->go_to(get_permalink($post_ids[1]));
     $post_content_inside_tutorial = get_echo('the_content');
     //making sure that the tutorial pretext that I want is there
     $this->assertRegExp('/<div class=\'wptm_prev\'><span>Some prev text<\\/span><a href="http:\\/\\/example\\.org\\/\\?p=' . $post_ids[0] . '" rel="prev">POST1<\\/a> <\\/div>/', $post_content_inside_tutorial);
     $this->assertRegExp('/<div class=\'wptm_next\'><span>Some next text<\\/span><a href="http:\\/\\/example\\.org\\/\\?p=' . $post_ids[2] . '" rel="next">POST3<\\/a> <\\/div>/', $post_content_inside_tutorial);
     $this->assertRegExp('/<div id=\'wptm_before_category_link_text\'>Some Category List Header<\\/div>/', $post_content_inside_tutorial);
     $this->assertRegExp('/<div id=\'wptm_before_category_link_text\'>Some Category List Header<\\/div>/', $post_content_inside_tutorial);
     $this->assertRegExp('/<div class=\'wptm_link_to_category\'><a href=\'http:\\/\\/example\\.org\\/\\?cat=' . $cat_id . '\'>Some Name to Category Link<\\/div>/', $post_content_inside_tutorial);
     //making sure that the tutorial pretext is not being added by mistake to some other non Tutorial post
     $non_tutorial_post_id = $this->factory->post->create(array('post_type' => 'post', 'post_status' => 'publish', 'post_title' => 'POST2', 'post_date' => date('Y-m-d H:i:s', time() - 200)));
     $this->go_to(get_permalink($non_tutorial_post_id));
     $post_content_inside_tutorial = get_echo('the_content');
     $this->assertNotRegExp('/wptm/', $post_content_inside_tutorial);
 }
コード例 #30
-7
ファイル: recentposts.php プロジェクト: closings/closings
 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;
 }