本文整理匯總了PHP中is_single函數的典型用法代碼示例。如果您正苦於以下問題:PHP is_single函數的具體用法?PHP is_single怎麽用?PHP is_single使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了is_single函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: base_getBreadcrumbs
function base_getBreadcrumbs()
{
if (is_404()) {
return false;
}
// Hack to fix breadcrumbs when you're viewing the news home
if (is_home()) {
$post = new \Timber\Post(get_option('page_for_posts'));
} else {
global $post;
}
$breadcrumbs = [];
if ($post->post_parent) {
$parent_id = $post->post_parent;
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = new \Timber\Post($page->ID);
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
}
// Add 'Blog Home' to breadcrumbs if you're on a news post or archive
if ((is_single() || is_archive()) && !is_search()) {
$breadcrumbs[] = new \Timber\Post(get_option('page_for_posts'));
}
return $breadcrumbs;
}
示例2: bootstrap_breadcrumbs
/**
* Add breadcrumbs functionality to your WordPress theme
*
* Once you have included the function in your functions.php file
* you can then place the following anywhere in your theme templates
* if(function_exists('bootstrap_breadcrumbs')) bootstrap_breadcrumbs();
*
* credit to: c.bavota - http://bavotasan.com (thanks for the code start)
*/
function bootstrap_breadcrumbs()
{
echo '<ol class="breadcrumb">';
echo '<li><a href="' . home_url('/') . '">Home</a></li>';
// are we at "blog home"?
if (is_home()) {
echo '<li><a href="#">Blogs</a></li>';
}
// where else do we want breadcrumbs
if (!is_page_template('pt-home.php') && !is_home()) {
// check if we're in a commerce plugin
if (function_exists('is_woocommerce') && is_woocommerce()) {
echo '<li><a href="/publications/order/">Shop</a></li>';
$product_cats = wp_get_post_terms(get_the_ID(), 'product_cat');
echo '<li><a href="/publications/order/' . str_replace(" ", "-", $product_cats[0]->name) . '">' . $product_cats[0]->name . '</a></li>';
}
// breadcrumb wordpress structures
if (is_category() || is_single() || is_single('aof')) {
if (get_the_category()) {
$category = get_the_category();
echo '<li><a href="/blog/category/' . str_replace(" ", "-", $category[0]->cat_name) . '">' . $category[0]->cat_name . '</a></li>';
}
if (is_single()) {
echo '<li class="active">';
the_title();
echo '</li>';
}
} elseif (is_page()) {
echo '<li class="active">';
the_title();
echo '</li>';
}
}
echo '</ol>';
}
示例3: tie_register
function tie_register()
{
## Register Main style.css file
wp_register_style('tie-style', get_stylesheet_uri(), array(), '', 'all');
wp_enqueue_style('tie-style');
## Register All Scripts
wp_register_script('tie-scripts', get_template_directory_uri() . '/js/tie-scripts.js', array('jquery'), false, true);
wp_register_script('tie-tabs', get_template_directory_uri() . '/js/tabs.min.js', array('jquery'), false, true);
wp_register_script('tie-cycle', get_template_directory_uri() . '/js/jquery.cycle.all.js', array('jquery'), false, true);
wp_register_script('tie-validation', get_template_directory_uri() . '/js/validation.js', array('jquery'), false, true);
wp_register_script('tie-flexslider', get_template_directory_uri() . '/js/jquery.flexslider-min.js', array('jquery'), false, true);
## Get Global Scripts
wp_enqueue_script('tie-scripts');
## Register WooCommerce css file
wp_register_style('tie-woocommerce', get_template_directory_uri() . '/css/woocommerce.css', array(), '', 'all');
if (class_exists('Woocommerce')) {
wp_enqueue_style('tie-woocommerce');
}
## Get Validation Script
if (tie_get_option('comment_validation') && (is_page() || is_single()) && comments_open()) {
wp_enqueue_script('tie-validation');
}
## For facebook & Google + share
if (is_singular() && tie_get_option('post_og_cards') && (!function_exists('bp_current_component') || function_exists('bp_current_component') && !bp_current_component())) {
tie_og_data();
}
}
示例4: enqueue_scripts
/**
* Register the stylesheets for the public-facing side of the site.
*
* @since 1.0.0
*/
public function enqueue_scripts()
{
global $post, $product;
if (is_object($post) && class_exists('WooCommerce')) {
$is_product_type_variable = 'false';
if (function_exists('wc_get_product')) {
$product = wc_get_product($post);
if ($product) {
if ($product->is_type('variable') && is_single()) {
$is_product_type_variable = 'true';
}
}
}
$attach_id = isset($_SESSION['attach_id']) && !empty($_SESSION['attach_id']) ? $_SESSION['attach_id'] : '';
if (!empty($attach_id)) {
$total_word = get_post_meta($attach_id, 'total_word', true);
} else {
$total_word = '';
}
if (!empty($attach_id)) {
$total_character = get_post_meta($attach_id, 'total_character', true);
} else {
$total_character = '';
}
wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/woocommerce-price-per-word-public.js', array('jquery'), $this->version, false);
if (wp_script_is($this->plugin_name)) {
wp_localize_script($this->plugin_name, 'woocommerce_price_per_word_params', apply_filters('woocommerce_price_per_word_params', array('ajax_url' => admin_url('admin-ajax.php'), 'woocommerce_price_per_word_params_nonce' => wp_create_nonce("woocommerce_price_per_word_params_nonce"), 'total_word' => $total_word, 'total_character' => $total_character, 'is_product_type_variable' => $is_product_type_variable, 'woocommerce_currency_symbol_js' => get_woocommerce_currency_symbol(), 'woocommerce_price_num_decimals' => wc_get_price_decimals(), 'aewcppw_word_character' => $this->wppw_get_product_type(), 'aewcppw_allow_users_to_enter_qty' => $this->aewcppw_allow_users_to_enter_qty())));
}
wp_enqueue_script($this->plugin_name . '-bn', plugin_dir_url(__FILE__) . 'js/woocommerce-price-per-word-bn.js', array('jquery'), $this->version, false);
}
}
開發者ID:angelleye,項目名稱:woocommerce-price-per-word,代碼行數:36,代碼來源:class-woocommerce-price-per-word-public.php
示例5: MyBreadcrumb
function MyBreadcrumb()
{
if (!is_home()) {
echo '<li><a href="';
echo get_option('home');
echo '/">';
echo 'Home';
echo '</a><span class="divider">/</span></li>';
if (is_category() || is_single()) {
echo '<li>';
the_category(', ', '&title_li=');
echo '<span class="divider">/</span></li>';
echo '</li>';
if (is_single()) {
echo '<li class="active">';
// the_title();
echo '</li>';
}
} elseif (is_page()) {
echo '<li class="active">';
the_title();
echo '</li>';
}
}
}
示例6: tography_lite_enqueue_stylesheets
function tography_lite_enqueue_stylesheets()
{
//Bootstrap =======================================================
wp_register_style('bootstrap', TOGRAPHY_LITE_CSS . '/bootstrap.css', array(), '3.1', 'all');
wp_enqueue_style('bootstrap');
//=================================================================
if (is_page_template('page-portfolio-thirds.php') || is_archive()) {
//Isotope ================================================
wp_register_style('isotope', TOGRAPHY_LITE_CSS . '/isotope.css', array(), '1.0', 'all');
wp_enqueue_style('isotope');
//=================================================================
//Photoswipe ======================================================
wp_register_style('photoswipe', TOGRAPHY_LITE_CSS . '/photoswipe.css', array(), '2.0.0', 'all');
wp_enqueue_style('photoswipe');
//=================================================================
//Photoswipe Skin ======================================================
wp_register_style('photoswipe-skin', TOGRAPHY_LITE_CSS . '/default-skin/default-skin.css', array(), '2.0.0', 'all');
wp_enqueue_style('photoswipe-skin');
//=================================================================
}
if (is_single() || is_archive()) {
//Photoswipe ======================================================
wp_register_style('photoswipe', TOGRAPHY_LITE_CSS . '/photoswipe.css', array(), '2.0.0', 'all');
wp_enqueue_style('photoswipe');
//=================================================================
//Photoswipe Skin ======================================================
wp_register_style('photoswipe-skin', TOGRAPHY_LITE_CSS . '/default-skin/default-skin.css', array(), '2.0.0', 'all');
wp_enqueue_style('photoswipe-skin');
//=================================================================
}
//Main Stylesheet =================================================
wp_register_style('main-stylesheet', get_bloginfo('stylesheet_url'), array('bootstrap'), '1.0', 'all');
wp_enqueue_style('main-stylesheet');
//=================================================================
}
示例7: testThemeTemplateIsCorrectForPost
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'));
}
示例8: ninja_forms_get_form_ids_by_post_id
function ninja_forms_get_form_ids_by_post_id($post_id)
{
global $wpdb;
$form_ids = array();
if (is_page($post_id)) {
$form_results = ninja_forms_get_all_forms();
if (is_array($form_results) and !empty($form_results)) {
foreach ($form_results as $form) {
$form_data = $form['data'];
if (isset($form_data['append_page']) and !empty($form_data['append_page'])) {
if ($form_data['append_page'] == $post_id) {
$form_ids[] = $form['id'];
}
}
}
}
$form_id = get_post_meta($post_id, 'ninja_forms_form', true);
if (!empty($form_id)) {
$form_ids[] = $form_id;
}
} else {
if (is_single($post_id)) {
$form_id = get_post_meta($post_id, 'ninja_forms_form', true);
if (!empty($form_id)) {
$form_ids[] = $form_id;
}
}
}
return $form_ids;
}
示例9: alfath_scripts
/**
* Enqueue scripts and stylesheets
*
* Enqueue stylesheets in the following order:
* 1. /theme/assets/css/main.min.css
*
* Enqueue scripts in the following order:
* 1. jquery-1.11.0.min.js via Google CDN
* 2. /theme/assets/js/vendor/modernizr-2.7.2.min.js
* 3. /theme/assets/js/main.min.js (in footer)
*/
function alfath_scripts()
{
wp_enqueue_style('alfath_main', get_template_directory_uri() . '/assets/css/main.min.css', false, '1.0.0');
wp_enqueue_style('alfath_fa-icon', get_template_directory_uri() . '/assets/css/font-awesome.min.css', false, '4.0.3');
wp_enqueue_style('alfath-icon', get_template_directory_uri() . '/assets/css/alfath-icon.min.css', false, '1.0.0');
if (file_exists(get_template_directory() . '/assets/css/custom.css')) {
wp_enqueue_style('alfath_custom', get_template_directory_uri() . '/assets/css/custom.css', array('alfath_main'), filemtime(get_template_directory() . '/assets/css/custom.css'), 'all');
}
// jQuery is loaded using the same method from HTML5 Boilerplate:
// Grab Google CDN's latest jQuery with a protocol relative URL; fallback to local if offline
// It's kept in the header instead of footer to avoid conflicts with plugins.
if (!is_admin() && current_theme_supports('jquery-cdn')) {
wp_deregister_script('jquery');
wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js', false, null, false);
add_filter('script_loader_src', 'alfath_jquery_local_fallback', 10, 2);
}
if (is_single() && comments_open() && get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}
wp_register_script('modernizr', get_template_directory_uri() . '/assets/js/vendor/modernizr-2.7.2.min.js', false, null, false);
wp_register_script('jquery-migrate', get_template_directory_uri() . '/assets/js/vendor/jquery-migrate-1.2.1.min.js', array('jquery'), null, false);
wp_register_script('alfath_scripts', get_template_directory_uri() . '/assets/js/scripts.min.js', false, '1.0.0', true);
wp_enqueue_script('modernizr');
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-migrate');
wp_enqueue_script('alfath_scripts');
}
示例10: hatom_data_in_content_single
function hatom_data_in_content_single($content)
{
if (is_single()) {
$content .= get_hatom_data_single();
}
return $content;
}
示例11: remove_scripts_and_styles
/**
* Remove all scripts and styles from the estimate view and then add those specific to si.
* @return
*/
public static function remove_scripts_and_styles()
{
if (SI_Invoice::is_invoice_query() && is_single()) {
if (apply_filters('si_remove_scripts_styles_on_doc_pages', '__return_true')) {
global $wp_scripts, $wp_styles;
$allowed_scripts = apply_filters('si_allowed_doc_scripts', array('sprout_doc_scripts', 'qtip', 'dropdown'));
$allowed_admin_scripts = apply_filters('si_allowed_admin_doc_scripts', array_merge(array('admin-bar'), $allowed_scripts));
if (current_user_can('edit_sprout_invoices')) {
$wp_scripts->queue = $allowed_admin_scripts;
} else {
$wp_scripts->queue = $allowed_scripts;
}
$allowed_styles = apply_filters('si_allowed_doc_styles', array('sprout_doc_style', 'qtip', 'dropdown'));
$allowed_admin_styles = apply_filters('si_allowed_admin_doc_styles', array_merge(array('admin-bar'), $allowed_styles));
if (current_user_can('edit_sprout_invoices')) {
$wp_styles->queue = $allowed_admin_styles;
} else {
$wp_styles->queue = $allowed_styles;
}
do_action('si_doc_enqueue_filtered');
} else {
// scripts
wp_enqueue_script('sprout_doc_scripts');
wp_enqueue_script('dropdown');
wp_enqueue_script('qtip');
// Styles
wp_enqueue_style('sprout_doc_style');
wp_enqueue_style('dropdown');
wp_enqueue_style('qtip');
}
}
}
示例12: vp_bookmark
/**
* Generate the add/remove a topic to/from bookmark list link.
*
* @since 0.0.1
*/
function vp_bookmark()
{
if (!is_user_logged_in() || !is_single()) {
return;
}
$topic_id = get_the_ID();
$user_id = wp_get_current_user()->ID;
$bookmarked_num = 0;
// Which users already bookmarked this topic
$bookmarked = (array) get_post_meta($topic_id, 'v2press_who_bookmarked_me', true);
if ('' != $bookmarked[0]) {
$bookmarked_num = count($bookmarked);
}
if (in_array($user_id, $bookmarked)) {
$action = 'remove';
$text = __('Remove from Bookmark', 'v2press');
} else {
$action = 'add';
$text = __('Add to Bookmark', 'v2press');
}
$output = '<div class="favorite-topic">';
if (0 < $bookmarked_num) {
$output .= sprintf(_n('%d user bookmarked', '%d users bookmarked', $bookmarked_num, 'v2press'), $bookmarked_num);
}
$output .= '<a class="fav ' . $action . '" href="?bookmark=' . $action . '&topic=' . $topic_id . '" title="' . esc_attr($text) . '">' . $text . '</a>';
$output .= '</div>';
echo $output;
}
示例13: insert_fb_in_head
function insert_fb_in_head()
{
global $post;
if (!is_single()) {
echo '<meta property="fb:app_id" content="964610463630306">';
echo '<meta property="og:title" content="SMS Brandname"/>';
echo '<meta property="og:type" content="website">';
echo '<meta property="og:url" content="' . home_url() . '"/>';
echo '<meta property="og:site_name" content="SMS Brandname"/>';
echo '<meta property="og:description" content="Cam kết giá dịch vụ, Tính năng hữu ích, Khác biệt và tươi mới, Tốc độ và niềm tin, Hổ trợ tuyệt vời">';
echo "";
return;
}
//
$current_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
echo '<meta property="fb:app_id" content="964610463630306">';
echo '<meta property="og:title" content="' . get_the_title() . '"/>';
echo '<meta property="og:type" content="website">';
echo '<meta property="og:url" content="' . $current_url . '"/>';
echo '<meta property="og:site_name" content="SMS Brandname"/>';
echo '<meta property="og:description" content="Cam kết giá dịch vụ, Tính năng hữu ích, Khác biệt và tươi mới, Tốc độ và niềm tin, Hổ trợ tuyệt vời">';
echo "";
if (is_single()) {
$image = get_field('image');
echo '<meta property="og:image" content="' . $image['sizes']['large'] . '"/>';
} else {
$default_image = "http://sms.viet-digital.com/wp-content/uploads/2016/03/logo-top.png";
echo '<meta property="og:image" content="' . $default_image . '"/>';
}
echo "";
}
示例14: enlightenment_glyphicons_author_posts_link_args
function enlightenment_glyphicons_author_posts_link_args($args)
{
if (!is_single() || doing_action('enlightenment_entry_header')) {
$args['format'] = '<span class="glyphicon glyphicon-user"></span> ' . $args['format'];
}
return $args;
}
示例15: getWordPressPageType
/**
* Gets the page type from WordPress.
*
* @return string A string representation of the current page type,
* corresponding to the values used by publisherplugin.google.com.
*/
public static function getWordPressPageType()
{
// is_front_page() returns true if (1) a static front page is set and this
// is that page, or (2) the front page is the blog home page and this
// is the blog home page.
if (is_front_page()) {
return 'front';
}
if (is_home()) {
return 'home';
}
if (is_single()) {
return 'singlePost';
}
if (is_page()) {
return 'page';
}
if (is_category()) {
return 'category';
}
if (is_archive()) {
return 'archive';
}
if (is_search()) {
return 'search';
}
if (is_404()) {
return 'errorPage';
}
return '';
}