• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wpml_get_language_information函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wpml_get_language_information函数的典型用法代码示例。如果您正苦于以下问题:PHP wpml_get_language_information函数的具体用法?PHP wpml_get_language_information怎么用?PHP wpml_get_language_information使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wpml_get_language_information函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: get_post_language_code_from_db

 /**
  * Returns a post language code reading it from WPML tables.
  *
  * @param int $post_id
  *
  * @return bool|string Either the language code string (e.g. `en`) or `false` on failure.
  */
 private function get_post_language_code_from_db($post_id)
 {
     $language_information = wpml_get_language_information(null, $post_id);
     if (empty($language_information) || empty($language_information['language_code'])) {
         return false;
     }
     return $language_information['language_code'];
 }
开发者ID:TakenCdosG,项目名称:chefs,代码行数:15,代码来源:Translations.php


示例2: wpml_jetpack_widget_get_top_posts

 function wpml_jetpack_widget_get_top_posts($posts, $post_ids, $count)
 {
     global $sitepress;
     foreach ($posts as $k => $post) {
         $lang_information = wpml_get_language_information($post['post_id']);
         $post_language = substr($lang_information['locale'], 0, 2);
         if ($post_language !== $sitepress->get_current_language()) {
             unset($posts[$k]);
         }
     }
     return $posts;
 }
开发者ID:shazadmaved,项目名称:vizblog,代码行数:12,代码来源:wpml.php


示例3: filter_tribe_events_linked_post_create

 /**
  * Assign linked posts managed by The Events Calendar a language.
  *
  * We use the filter as an action to assign linked posts a language.
  * WPML will not "see" posts that have not a language assigned: here we make sure that linked posts like
  * venues and organizers will be assigned the language of the event they are being linked to.
  *
  * @param int    $id               The linked post ID; this would be `null` by default but we know TEC is inserting
  *                                 the post at priority 10.
  * @param array  $data             Unused, an array of data representing the linked post submission.
  * @param string $linked_post_type The linked post type, e.g. `tribe_venue` or `tribe_organizer`.
  * @param string $post_status      Unused, the linked post type post status.
  * @param int    $event_id         The post ID of the event this post is linked to; this will be null for newly created events.
  *
  * @return int The untouched linked post ID.
  */
 public function filter_tribe_events_linked_post_create($id, $data, $linked_post_type, $post_status, $event_id)
 {
     if (empty($id) || empty($event_id)) {
         return $id;
     }
     $event_language_info = wpml_get_language_information($event_id);
     $language_code = !empty($event_language_info['language_code']) ? $event_language_info['language_code'] : ICL_LANGUAGE_CODE;
     $added = wpml_add_translatable_content('post_' . $linked_post_type, $id, $language_code);
     if (WPML_API_ERROR === $added) {
         $log = new Tribe__Log();
         $entry = "Could not set language for linked post type '{$linked_post_type}' with id '{$id}' to '{$language_code}'";
         $log->log_error($entry, __CLASS__);
     }
     return $id;
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:31,代码来源:Linked_Posts.php


示例4: jig_init_shortcode


//.........这里部分代码省略.........
                        if (strtolower(substr($recents_date_range, 11)) !== 'today') {
                            $recents_date_range_before['year'] = substr($recents_date_range, 11, 4);
                            $recents_date_range_before['month'] = ltrim(substr($recents_date_range, 16, 2), '0');
                            $recents_date_range_before['day'] = ltrim(substr($recents_date_range, 19, 2), '0');
                        } else {
                            $recents_date_range_today = getdate();
                            $recents_date_range_before['year'] = $recents_date_range_today['year'];
                            $recents_date_range_before['month'] = $recents_date_range_today['mon'];
                            $recents_date_range_before['day'] = $recents_date_range_today['mday'];
                        }
                        $args['date_query'] = array(array('after' => $recents_date_range_after, 'before' => $recents_date_range_before), 'inclusive' => true);
                    }
                    if ($recents_last_x_days !== '') {
                        $recents_last_x_days_today = getdate();
                        $recents_last_x_days_other_day = getdate(date('U') - (int) $recents_last_x_days * 86400);
                        $args['date_query'] = array(array('after' => array('year' => $recents_last_x_days_other_day['year'], 'month' => $recents_last_x_days_other_day['mon'], 'day' => $recents_last_x_days_other_day['mday'], 'hour' => $recents_last_x_days_other_day['hours'], 'minute' => $recents_last_x_days_other_day['minutes'], 'second' => $recents_last_x_days_other_day['seconds']), 'before' => array('year' => $recents_last_x_days_today['year'], 'month' => $recents_last_x_days_today['mon'], 'day' => $recents_last_x_days_today['mday'], 'hour' => $recents_last_x_days_today['hours'], 'minute' => $recents_last_x_days_today['minutes'], 'second' => $recents_last_x_days_today['seconds'])), 'inclusive' => true);
                    }
                    if ($orderby == 'menu_order' && $recents_post_type == 'page') {
                        $args['suppress_filters'] = false;
                        add_filter('posts_orderby', array($this, 'add_secondary_order_to_pages'));
                    }
                    if ($recents_parent_id === '') {
                        $posts = get_posts($args);
                    } else {
                        $args['post_parent'] = $recents_parent_id;
                        $posts = $this->get_recents_recursive($args, $recents_tree_depth, 0);
                    }
                    if ($orderby == 'menu_order' && $recents_post_type == 'page') {
                        remove_filter('posts_orderby', array($this, 'add_secondary_order_to_pages'));
                    } elseif ($orderby == 'rand') {
                        $posts = (array) $posts;
                        shuffle($posts);
                    }
                    $is_wpml = defined('ICL_SITEPRESS_VERSION') || function_exists('wpml_get_language_information');
                    if ($posts) {
                        // If there are images attached to the post
                        $this->images = $url_hash_list = array();
                        // Create a new array for the images
                        foreach ($posts as &$post) {
                            // Loop through each
                            if ($is_wpml === true) {
                                if (version_compare(ICL_SITEPRESS_VERSION, '3.2', '>=')) {
                                    //Code for the new version greater than or equal to 3.2
                                    $post_language = apply_filters('wpml_post_language_details', NULL, $post->ID);
                                } else {
                                    //support for older WPML versions
                                    $post_language = wpml_get_language_information($post->ID);
                                }
                                if ($post_language['different_language'] == true) {
                                    $post->jig_image_src = 'skip';
                                    continue;
                                }
                            }
                            $post->post_thumbnail_id = get_post_thumbnail_id($post->ID);
                            $image = $this->jig_wp_get_attachment_image_src($post->post_thumbnail_id, $lightbox_max_size);
                            if ($image == false && !empty($post->post_thumbnail_id) && class_exists('nggdb')) {
                                global $wpdb;
                                $nggID = substr($post->post_thumbnail_id, 4);
                                if ($nggID !== false) {
                                    $nggImage = $this->jig_ng_find_images($nggID, true);
                                    if (!empty($nggImage)) {
                                        $image = array();
                                        $image[0] = $nggImage->imageURL;
                                        $image[1] = $nggImage->meta_data['width'];
                                        $image[2] = $nggImage->meta_data['height'];
                                    }
开发者ID:sabdev1,项目名称:ljcdevsab,代码行数:67,代码来源:justified-image-grid.php


示例5: shortcode_post_cycle

    function shortcode_post_cycle($atts, $content = null)
    {
        extract(shortcode_atts(array('num' => '5', 'type' => 'post', 'meta' => '', 'effect' => 'slide', 'thumb' => 'true', 'thumb_width' => '200', 'thumb_height' => '180', 'more_text_single' => theme_locals('read_more'), 'category' => '', 'custom_category' => '', 'excerpt_count' => '15', 'pagination' => 'true', 'navigation' => 'true', 'custom_class' => ''), $atts));
        $type_post = $type;
        $slider_pagination = $pagination;
        $slider_navigation = $navigation;
        $random = gener_random(10);
        $i = 0;
        $rand = rand();
        $output = '<script type="text/javascript">
						jQuery(window).load(function() {
							jQuery("#flexslider_' . $random . '").flexslider({
								animation: "' . $effect . '",
								smoothHeight : true,
								directionNav: ' . $slider_navigation . ',
								controlNav: ' . $slider_pagination . '
							});
						});';
        $output .= '</script>';
        $output .= '<div id="flexslider_' . $random . '" class="flexslider no-bg ' . $custom_class . '">';
        $output .= '<ul class="slides">';
        global $post;
        global $my_string_limit_words;
        // WPML filter
        $suppress_filters = get_option('suppress_filters');
        $args = array('post_type' => $type_post, 'category_name' => $category, $type_post . '_category' => $custom_category, 'numberposts' => $num, 'orderby' => 'post_date', 'order' => 'DESC', 'suppress_filters' => $suppress_filters);
        $latest = get_posts($args);
        foreach ($latest as $key => $post) {
            // Unset not translated posts
            if (function_exists('wpml_get_language_information')) {
                global $sitepress;
                $check = wpml_get_language_information($post->ID);
                $language_code = substr($check['locale'], 0, 2);
                if ($language_code != $sitepress->get_current_language()) {
                    unset($latest[$key]);
                }
                // Post ID is different in a second language Solution
                if (function_exists('icl_object_id')) {
                    $post = get_post(icl_object_id($post->ID, $type_post, true));
                }
            }
            setup_postdata($post);
            $excerpt = get_the_excerpt();
            $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
            $url = $attachment_url['0'];
            $image = aq_resize($url, $thumb_width, $thumb_height, true);
            $output .= '<li>';
            if ($thumb == 'true') {
                if (has_post_thumbnail($post->ID)) {
                    $output .= '<figure class="thumbnail featured-thumbnail"><a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">';
                    $output .= '<img  src="' . $image . '" alt="' . get_the_title($post->ID) . '" />';
                    $output .= '</a></figure>';
                } else {
                    $thumbid = 0;
                    $thumbid = get_post_thumbnail_id($post->ID);
                    $images = get_children(array('orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => -1));
                    if ($images) {
                        $k = 0;
                        //looping through the images
                        foreach ($images as $attachment_id => $attachment) {
                            // $prettyType = "prettyPhoto-".$rand ."[gallery".$i."]";
                            //if( $attachment->ID == $thumbid ) continue;
                            $image_attributes = wp_get_attachment_image_src($attachment_id, 'full');
                            // returns an array
                            $img = aq_resize($image_attributes[0], $thumb_width, $thumb_height, true);
                            //resize & crop img
                            $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                            $image_title = $attachment->post_title;
                            if ($k == 0) {
                                $output .= '<figure class="featured-thumbnail">';
                                $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">';
                                $output .= '<img  src="' . $img . '" alt="' . get_the_title($post->ID) . '" />';
                                $output .= '</a></figure>';
                            }
                            break;
                            $k++;
                        }
                    }
                }
            }
            $output .= '<h5><a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">';
            $output .= get_the_title($post->ID);
            $output .= '</a></h5>';
            if ($meta == 'true') {
                $output .= '<span class="meta">';
                $output .= '<span class="post-date">';
                $output .= get_the_date();
                $output .= '</span>';
                $output .= '<span class="post-comments">' . theme_locals('comments') . ": ";
                $output .= '<a href="' . get_comments_link($post->ID) . '">';
                $output .= get_comments_number($post->ID);
                $output .= '</a>';
                $output .= '</span>';
                $output .= '</span>';
            }
            //display post options
            $output .= '<div class="post_options">';
            switch ($type_post) {
                case "team":
                    $teampos = get_post_meta($post->ID, 'my_team_pos', true) ? get_post_meta($post->ID, 'my_team_pos', true) : "";
//.........这里部分代码省略.........
开发者ID:poolieweb,项目名称:LawStaticAthena,代码行数:101,代码来源:post_cycle.php


示例6: get_product_from_post


//.........这里部分代码省略.........
                 }
             }
         }
     } catch (Exception $e) {
     }
     $send_product = array('product_id' => $product->id, 'currency' => get_woocommerce_currency(), 'price' => $product->get_price(), 'url' => get_permalink($product->id), 'thumbnail_url' => $thumbnail, 'action' => 'insert', 'description' => $product->get_post_data()->post_content, 'short_description' => $product->get_post_data()->post_excerpt, 'name' => $product->get_title(), 'sku' => $product->get_sku(), 'categories' => $product->get_categories(), 'tag' => $product_tags, 'store_id' => get_current_blog_id(), 'identifier' => (string) $product->id, 'product_brand' => $product_brands, 'taxonomies' => $taxonomies, 'acf_fields' => $acf_fields, 'sellable' => $product->is_purchasable(), 'visibility' => $product->is_visible(), 'stock_quantity' => $product->get_stock_quantity(), 'is_managing_stock' => $product->managing_stock(), 'is_backorders_allowed' => $product->backorders_allowed(), 'is_purchasable' => $product->is_purchasable(), 'is_in_stock' => $product->is_in_stock(), 'product_status' => get_post_status($post_id));
     try {
         $variable = new WC_Product_Variable($post_id);
         $variations = $variable->get_available_variations();
         $variations_sku = '';
         if (!empty($variations)) {
             foreach ($variations as $variation) {
                 if ($product->get_sku() != $variation['sku']) {
                     $variations_sku .= $variation['sku'] . ' ';
                 }
             }
         }
         $send_product['variations_sku'] = $variations_sku;
         $all_attributes = $product->get_attributes();
         $attributes = array();
         if (!empty($all_attributes)) {
             foreach ($all_attributes as $attr_mame => $value) {
                 if ($all_attributes[$attr_mame]['is_taxonomy']) {
                     if (!$woocommerce_ver_below_2_1) {
                         $attributes[$attr_mame] = wc_get_product_terms($post_id, $attr_mame, array('fields' => 'names'));
                     } else {
                         $attributes[$attr_mame] = woocommerce_get_product_terms($post_id, $attr_mame, 'names');
                     }
                 } else {
                     $attributes[$attr_mame] = $product->get_attribute($attr_mame);
                 }
             }
         }
         $send_product['attributes'] = $attributes;
         $send_product['total_variable_stock'] = $variable->get_total_stock();
         try {
             if (version_compare(WOOCOMMERCE_VERSION, '2.2', '>=')) {
                 if (function_exists('wc_get_product')) {
                     $original_product = wc_get_product($product->id);
                     if (is_object($original_product)) {
                         $send_product['visibility'] = $original_product->is_visible();
                         $send_product['product_type'] = $original_product->product_type;
                     }
                 }
             } else {
                 if (function_exists('get_product')) {
                     $original_product = get_product($product->id);
                     if (is_object($original_product)) {
                         $send_product['visibility'] = $original_product->is_visible();
                         $send_product['product_type'] = $original_product->product_type;
                     }
                 }
             }
         } catch (Exception $e) {
         }
     } catch (Exception $e) {
         $err_msg = "exception raised in attributes";
         self::send_error_report($err_msg);
     }
     if (!$woocommerce_ver_below_2_1) {
         try {
             $send_product['price_compare_at_price'] = $product->get_regular_price();
             $send_product['price_min'] = $variable->get_variation_price('min');
             $send_product['price_max'] = $variable->get_variation_price('max');
             $send_product['price_min_compare_at_price'] = $variable->get_variation_regular_price('min');
             $send_product['price_max_compare_at_price'] = $variable->get_variation_regular_price('max');
         } catch (Exception $e) {
             $send_product['price_compare_at_price'] = null;
             $send_product['price_min'] = null;
             $send_product['price_max'] = null;
             $send_product['price_min_compare_at_price'] = null;
             $send_product['price_max_compare_at_price'] = null;
         }
     } else {
         $send_product['price_compare_at_price'] = null;
         $send_product['price_min'] = null;
         $send_product['price_max'] = null;
         $send_product['price_min_compare_at_price'] = null;
         $send_product['price_max_compare_at_price'] = null;
     }
     $send_product['description'] = self::content_filter_shortcode_with_content($send_product['description']);
     $send_product['short_description'] = self::content_filter_shortcode_with_content($send_product['short_description']);
     $send_product['description'] = self::content_filter_shortcode($send_product['description']);
     $send_product['short_description'] = self::content_filter_shortcode($send_product['short_description']);
     try {
         if (defined('ICL_SITEPRESS_VERSION') && is_plugin_active('woocommerce-multilingual/wpml-woocommerce.php') && function_exists('wpml_get_language_information')) {
             if (version_compare(ICL_SITEPRESS_VERSION, '3.2', '>=')) {
                 $language_info = apply_filters('wpml_post_language_details', NULL, $post_id);
             } else {
                 $language_info = wpml_get_language_information($post_id);
             }
             if ($language_info && is_array($language_info) && array_key_exists('locale', $language_info)) {
                 // WP_Error could be returned from wpml_get_language_information(...)
                 $send_product['lang'] = $language_info['locale'];
             }
         }
     } catch (Exception $e) {
     }
     return $send_product;
 }
开发者ID:booklein,项目名称:wpbookle,代码行数:101,代码来源:wcis_plugin.php


示例7: _fw_insert_all_event_children_data

 /**
  * For even datetime range row create custom 'fw-events-tags' post. Also save search query tags as meta values.
  *
  * @param int $post_id
  *
  * @return bool
  */
 private function _fw_insert_all_event_children_data($post_id)
 {
     $options_values = fw_get_db_post_option($post_id);
     if (is_array($options_values) === false) {
         return false;
     }
     $container_id = $this->parent->get_event_option_id();
     $meta_rows_data = fw_akg($container_id . '/event_children', $options_values);
     $all_day_event = fw_akg($container_id . '/all_day', $options_values);
     if (is_array($meta_rows_data) && count($meta_rows_data) > 0) {
         foreach ($meta_rows_data as $meta_row) {
             $start_date = fw_akg('event_date_range/from', $meta_row);
             $end_date = fw_akg('event_date_range/to', $meta_row);
             $from_timestamp = strtotime($start_date);
             $to_timestamp = strtotime($end_date);
             if (!$from_timestamp || !$to_timestamp || -1 === $from_timestamp || -1 === $to_timestamp) {
                 continue;
             }
             $terms = wp_get_post_terms($post_id, $this->parent->get_taxonomy_name(), array('fields' => 'ids'));
             $event_post_tag_id = wp_insert_post(array('post_parent' => $post_id, 'post_type' => $this->post_type, 'post_status' => 'publish', 'tax_input' => array($this->parent->get_taxonomy_name() => $terms)), true);
             if ($event_post_tag_id == 0 || $event_post_tag_id instanceof WP_Error) {
                 return false;
             }
             add_post_meta($event_post_tag_id, $this->from_date, $from_timestamp - (date('H', $from_timestamp) * 3600 + date('i', $from_timestamp) * 60));
             add_post_meta($event_post_tag_id, $this->to_date, $to_timestamp - (date('H', $to_timestamp) * 3600 + date('i', $to_timestamp) * 60));
             add_post_meta($event_post_tag_id, $this->from_time, date('H', $from_timestamp) * 3600 + date('i', $from_timestamp) * 60);
             add_post_meta($event_post_tag_id, $this->to_time, date('H', $to_timestamp) * 3600 + date('i', $to_timestamp) * 60);
             add_post_meta($event_post_tag_id, $this->all_day, $all_day_event);
             if (function_exists('wpml_get_language_information') && function_exists('wpml_add_translatable_content')) {
                 $lang = wpml_get_language_information($post_id);
                 $language = substr(fw_akg('locale', $lang), 0, 2);
                 if (!empty($language)) {
                     wpml_add_translatable_content('post_' . $this->post_type, $event_post_tag_id, $language);
                 }
             }
             $users = fw_akg('event-user', $meta_row);
             if (is_array($users) && count($users) > 0) {
                 foreach ($users as $user) {
                     add_post_meta($event_post_tag_id, 'event-user', $user);
                 }
             }
         }
     }
     return true;
 }
开发者ID:northpen,项目名称:project_11,代码行数:52,代码来源:class-fw-extension-events-tags.php


示例8: posts_list_shortcode

 function posts_list_shortcode($atts, $content = null, $shortcodename = '')
 {
     extract(shortcode_atts(array('type' => 'post', 'thumbs' => '', 'thumb_width' => '', 'thumb_height' => '', 'post_content' => '', 'numb' => '5', 'order_by' => '', 'order' => '', 'link' => '', 'link_text' => __('Read more', CHERRY_PLUGIN_DOMAIN), 'tag' => '', 'tags' => '', 'custom_class' => ''), $atts));
     // check what order by method user selected
     switch ($order_by) {
         case 'date':
             $order_by = 'post_date';
             break;
         case 'title':
             $order_by = 'title';
             break;
         case 'popular':
             $order_by = 'comment_count';
             break;
         case 'random':
             $order_by = 'rand';
             break;
     }
     // check what order method user selected (DESC or ASC)
     switch ($order) {
         case 'DESC':
             $order = 'DESC';
             break;
         case 'ASC':
             $order = 'ASC';
             break;
     }
     global $post;
     global $my_string_limit_words;
     global $_wp_additional_image_sizes;
     // WPML filter
     $suppress_filters = get_option('suppress_filters');
     $args = array('post_type' => $type, 'tag' => $tag, 'numberposts' => $numb, 'orderby' => $order_by, 'order' => $order, 'suppress_filters' => $suppress_filters);
     $posts = get_posts($args);
     $i = 0;
     // thumbnail size
     $thumb_x = 0;
     $thumb_y = 0;
     if ($thumbs == 'large') {
         $thumb_x = 620;
         $thumb_y = 300;
     } else {
         $thumb_x = $_wp_additional_image_sizes['post-thumbnail']['width'];
         $thumb_y = $_wp_additional_image_sizes['post-thumbnail']['height'];
     }
     // thumbnail class
     $thumbs_class = '';
     if ($thumbs == 'large') {
         $thumbs_class = 'large';
     }
     $output = '<div class="posts-list ' . $custom_class . '">';
     foreach ($posts as $key => $post) {
         // Unset not translated posts
         if (function_exists('wpml_get_language_information')) {
             global $sitepress;
             $check = wpml_get_language_information($post->ID);
             $language_code = substr($check['locale'], 0, 2);
             if ($language_code != $sitepress->get_current_language()) {
                 unset($posts[$key]);
             }
             // Post ID is different in a second language Solution
             if (function_exists('icl_object_id')) {
                 $post = get_post(icl_object_id($post->ID, $type, true));
             }
         }
         setup_postdata($post);
         $excerpt = get_the_excerpt();
         $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
         $url = $attachment_url['0'];
         if ($thumb_width != '' && $thumb_height != '') {
             $image = aq_resize($url, $thumb_width, $thumb_height, true);
         } else {
             $image = aq_resize($url, $thumb_x, $thumb_y, true);
         }
         $mediaType = get_post_meta($post->ID, 'tz_portfolio_type', true);
         $format = get_post_format();
         $output .= '<div class="row-fluid list-item-' . $i . '">';
         $output .= '<article class="span12 post__holder">';
         //post header
         $output .= '<header class="post-header">';
         $output .= '<h2 class="post-title"><a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">';
         $output .= get_the_title($post->ID);
         $output .= '</a></h2>';
         // post meta
         $output .= '<div class="post_meta">';
         // post category
         $output .= '<span class="post_category">';
         if ($type != '' && $type != 'post') {
             $terms = get_the_terms($post->ID, $type . '_category');
             if ($terms && !is_wp_error($terms)) {
                 $out = array();
                 $output .= __('Posted in', CHERRY_PLUGIN_DOMAIN) . ' ';
                 foreach ($terms as $term) {
                     $out[] = '<a href="' . get_term_link($term->slug, $type . '_category') . '">' . $term->name . '</a>';
                 }
                 $output .= join(', ', $out);
             }
         } else {
             $categories = get_the_category();
             if ($categories) {
//.........这里部分代码省略.........
开发者ID:drupalninja,项目名称:schome_org,代码行数:101,代码来源:posts-list.php


示例9: insertTokensToDB

 /**
  * Generates the query based on the post and the toke array and inserts into DB
  *
  * @param object $the_post the post
  * @param array $tokens tokens array
  *
  * @return bool
  */
 private function insertTokensToDB($the_post, $tokens)
 {
     global $wpdb;
     $asp_index_table = $this->asp_index_table;
     $args = $this->args;
     $values = array();
     $lang = '';
     if (count($tokens) <= 0) {
         return false;
     }
     foreach ($tokens as $term => $d) {
         // If it's numeric, delete the leading space
         $term = trim($term);
         if (function_exists('wpml_get_language_information')) {
             $lang_info = wpml_get_language_information($the_post->ID);
             $lang_arr = explode('_', $lang_info['locale']);
             $lang = $lang_arr[0];
         }
         $value = $wpdb->prepare("(%d, %s, REVERSE(%s), %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %s, %d, %s)", $the_post->ID, $term, $term, $args['blog_id'], $d['content'], $d['title'], $d['comment'], $d['tag'], $d['link'], $d['author'], $d['category'], $d['excerpt'], $d['taxonomy'], $d['customfield'], $the_post->post_type, 0, $lang);
         $values[] = $value;
     }
     if (count($values) > 0) {
         $values = implode(', ', $values);
         $query = "INSERT INTO {$asp_index_table}\n\t\t\t\t(`doc`, `term`, `term_reverse`, `blogid`, `content`, `title`, `comment`, `tag`, `link`, `author`,\n\t\t\t\t `category`, `excerpt`, `taxonomy`, `customfield`, `post_type`, `item`, `lang`)\n\t\t\t\tVALUES {$values}";
         $wpdb->query($query);
         $this->keywords_found += count($tokens);
     }
     return true;
 }
开发者ID:Juni4567,项目名称:meritscholarship,代码行数:37,代码来源:indextable.class.php


示例10: shortcode_roundabout

    function shortcode_roundabout($atts, $content = null)
    {
        extract(shortcode_atts(array('title' => '', 'num' => '3', 'type' => '', 'thumb_width' => '375', 'thumb_height' => '250', 'category' => '', 'custom_category' => '', 'more_button_text' => '', 'more_button_link' => '', 'custom_class' => ''), $atts));
        wp_enqueue_script('roundabout_script', CHERRY_PLUGIN_URL . 'includes/assets/js/jquery.roundabout.min.js', array('jquery'));
        wp_enqueue_script('roundabout_shape', CHERRY_PLUGIN_URL . 'includes/assets/js/jquery.roundabout-shapes.min.js', array('jquery'));
        $ra_id = uniqid();
        // check what type of post user selected
        switch ($type) {
            case 'blog':
                $type_post = 'post';
                break;
            case 'portfolio':
                $type_post = 'portfolio';
                break;
            case 'testimonial':
                $type_post = 'testi';
                break;
            case 'our team':
                $type_post = 'team';
                break;
            default:
                $type_post = 'post';
                break;
        }
        $output = '<div class="roundabout-holder ' . $custom_class . '">';
        if ($title != '') {
            $output .= '<h2>' . $title . '</h2>';
        }
        $output .= '<ul id="roundabout-list-' . $ra_id . '" class="unstyled">';
        global $post;
        // WPML filter
        $suppress_filters = get_option('suppress_filters');
        $args = array('post_type' => $type_post, 'category_name' => $category, $type_post . '_category' => $custom_category, 'posts_per_page' => -1, 'orderby' => 'post_date', 'order' => 'DESC', 'suppress_filters' => $suppress_filters);
        $posts = get_posts($args);
        $i = 1;
        foreach ($posts as $key => $post) {
            // Unset not translated posts
            if (function_exists('wpml_get_language_information')) {
                global $sitepress;
                $check = wpml_get_language_information($post->ID);
                $language_code = substr($check['locale'], 0, 2);
                if ($language_code != $sitepress->get_current_language()) {
                    unset($posts[$key]);
                }
                // Post ID is different in a second language Solution
                if (function_exists('icl_object_id')) {
                    $post = get_post(icl_object_id($post->ID, $type_post, true));
                }
            }
            setup_postdata($post);
            if ($num == -1) {
                $num = count($posts);
            }
            if ($num >= $i) {
                if (has_post_thumbnail($post->ID)) {
                    $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
                    $url = $attachment_url['0'];
                    $image = aq_resize($url, $thumb_width, $thumb_height, true);
                    $output .= '<li>';
                    $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">';
                    $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />';
                    $output .= '</a>';
                    $output .= '</li>';
                    $i++;
                }
            }
        }
        wp_reset_postdata();
        // restore the global $post variable
        $output .= '</ul>';
        if ($more_button_text != '' && $more_button_link != '') {
            $output .= '<a class="btn btn-primary" href="' . $more_button_link . '">' . $more_button_text . '</a>';
        }
        $output .= '<script>
				jQuery(document).ready(function() {
					jQuery("#roundabout-list-' . $ra_id . '").roundabout({
						minOpacity: 1,
						minScale: 0.6,
						minZ: 0,
						shape: "square",
						responsive: true
					});
				});
				jQuery(window).bind("resize", function() {
					jQuery("#roundabout-list-' . $ra_id . ' li").removeAttr("style");
					jQuery("#roundabout-list-' . $ra_id . '").roundabout({
						minOpacity: 1,
						minScale: 0.6,
						responsive: false
					});
				});';
        $output .= '</script>';
        $output .= '</div>';
        return $output;
    }
开发者ID:rafaelfranco,项目名称:gruporota_portal,代码行数:95,代码来源:roundabout.php


示例11: theme_locals

					<h3 class="archive_h"><?php 
        echo theme_locals("last_posts");
        ?>
</h3>
					<div class="list styled check-list">
						<ul>
							<?php 
        // WPML filter
        $suppress_filters = get_option('suppress_filters');
        $archive_args = array('numberposts' => 30, 'suppress_filters' => $suppress_filters);
        $archive_30 = get_posts($archive_args);
        foreach ($archive_30 as $key => $post) {
            // Unset not translated posts
            if (function_exists('wpml_get_language_information')) {
                global $sitepress;
                $check = wpml_get_language_information($post->ID);
                $language_code = substr($check['locale'], 0, 2);
                if ($language_code != $sitepress->get_current_language()) {
                    unset($posts[$key]);
                }
                // Post ID is different in a second language Solution
                if (function_exists('icl_object_id')) {
                    $post = get_post(icl_object_id($post->ID, $type, true));
                }
            }
            ?>

									<li><a href="<?php 
            the_permalink();
            ?>
"><?php 
开发者ID:robbuh,项目名称:CherryFramework,代码行数:31,代码来源:loop-archives.php


示例12: shortcode_recenttesti

function shortcode_recenttesti($atts, $content = null)
{
    extract(shortcode_atts(array('num' => '5', 'thumb' => 'true', 'excerpt_count' => '30', 'custom_class' => ''), $atts));
    // WPML filter
    $suppress_filters = get_option('suppress_filters');
    $args = array('post_type' => 'testi', 'numberposts' => $num, 'orderby' => 'post_date', 'suppress_filters' => $suppress_filters);
    $testi = get_posts($args);
    $output = '<div class="testimonials ' . $custom_class . '">';
    global $post;
    global $my_string_limit_words;
    foreach ($testi as $k => $post) {
        // Unset not translated posts
        if (function_exists('wpml_get_language_information')) {
            global $sitepress;
            $check = wpml_get_language_information($post->ID);
            $language_code = substr($check['locale'], 0, 2);
            if ($language_code != $sitepress->get_current_language()) {
                unset($testi[$k]);
            }
            // Post ID is different in a second language Solution
            if (function_exists('icl_object_id')) {
                $post = get_post(icl_object_id($post->ID, 'testi', true));
            }
        }
        setup_postdata($post);
        $excerpt = get_the_excerpt();
        $testiname = get_post_meta(get_the_ID(), 'my_testi_caption', true);
        $testiurl = get_post_meta(get_the_ID(), 'my_testi_url', true);
        $testiinfo = get_post_meta(get_the_ID(), 'my_testi_info', true);
        $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
        $url = $attachment_url['0'];
        $image = aq_resize($url, 280, 240, true);
        $output .= '<div class="testi-item">';
        $output .= '<div class="testi-meta">';
        if (isset($testiname)) {
            $output .= '<div class="user">';
            $output .= $testiname;
            $output .= '</div>';
        }
        if (isset($testiinfo)) {
            $output .= '<div class="info">(';
            $output .= $testiinfo;
            $output .= ')</div>';
        }
        $output .= '</div>';
        $output .= '<blockquote class="testi-item_blockquote">';
        if ($thumb == 'true') {
            if (has_post_thumbnail($post->ID)) {
                $output .= '<figure class="featured-thumbnail">';
                $output .= '<img src="' . $image . '" alt="" />';
                $output .= '</figure>';
            }
        }
        $output .= '<a href="' . get_permalink($post->ID) . '">';
        $output .= my_string_limit_words($excerpt, $excerpt_count);
        $output .= '</a><span class="close_quote"></span><div class="clear"></div>';
        $output .= '</blockquote>';
        $output .= '</div>';
    }
    wp_reset_postdata();
    // restore the global $post variable
    $output .= '</div>';
    return $output;
}
开发者ID:rafaelfranco,项目名称:gruporota_portal,代码行数:64,代码来源:my_function.php


示例13: posts_grid_shortcode

 function posts_grid_shortcode($atts, $content = null)
 {
     extract(shortcode_atts(array('type' => 'post', 'category' => '', 'custom_category' => '', 'columns' => '3', 'rows' => '3', 'order_by' => 'date', 'order' => 'DESC', 'thumb_width' => '370', 'thumb_height' => '250', 'meta' => '', 'excerpt_count' => '15', 'link' => 'yes', 'link_text' => __('Read more', CHERRY_PLUGIN_DOMAIN), 'custom_class' => ''), $atts));
     $spans = $columns;
     $rand = rand();
     // columns
     switch ($spans) {
         case '1':
             $spans = 'span12';
             break;
         case '2':
             $spans = 'span6';
             break;
         case '3':
             $spans = 'span4';
             break;
         case '4':
             $spans = 'span3';
             break;
         case '6':
             $spans = 'span2';
             break;
     }
     // check what order by method user selected
     switch ($order_by) {
         case 'date':
             $order_by = 'post_date';
             break;
         case 'title':
             $order_by = 'title';
             break;
         case 'popular':
             $order_by = 'comment_count';
             break;
         case 'random':
             $order_by = 'rand';
             break;
     }
     // check what order method user selected (DESC or ASC)
     switch ($order) {
         case 'DESC':
             $order = 'DESC';
             break;
         case 'ASC':
             $order = 'ASC';
             break;
     }
     // show link after posts?
     switch ($link) {
         case 'yes':
             $link = true;
             break;
         case 'no':
             $link = false;
             break;
     }
     global $post;
     global $my_string_limit_words;
     $numb = $columns * $rows;
     // WPML filter
     $suppress_filters = get_option('suppress_filters');
     $args = array('post_type' => $type, 'category_name' => $category, $type . '_category' => $custom_category, 'numberposts' => $numb, 'orderby' => $order_by, 'order' => $order, 'suppress_filters' => $suppress_filters);
     $posts = get_posts($args);
     $i = 0;
     $count = 1;
     $output_end = '';
     if ($numb > count($posts)) {
         $output_end = '</ul>';
     }
     $output = '<ul class="posts-grid row-fluid unstyled ' . $custom_class . '">';
     for ($j = 0; $j < count($posts); $j++) {
         // Unset not translated posts
         if (function_exists('wpml_get_language_information')) {
             global $sitepress;
             $check = wpml_get_language_information($posts[$j]->ID);
             $language_code = substr($check['locale'], 0, 2);
             if ($language_code != $sitepress->get_current_language()) {
                 unset($posts[$j]);
             }
             // Post ID is different in a second language Solution
             if (function_exists('icl_object_id')) {
                 $posts[$j] = get_post(icl_object_id($posts[$j]->ID, $type, true));
             }
         }
         $post_id = $posts[$j]->ID;
         setup_postdata($posts[$j]);
         $excerpt = get_the_excerpt();
         $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full');
         $url = $attachment_url['0'];
         $image = aq_resize($url, $thumb_width, $thumb_height, true);
         $mediaType = get_post_meta($post_id, 'tz_portfolio_type', true);
         $prettyType = 0;
         if ($count > $columns) {
             $count = 1;
             $output .= '<ul class="posts-grid row-fluid unstyled ' . $custom_class . '">';
         }
         $output .= '<li class="' . $spans . '">';
         if (has_post_thumbnail($post_id) && $mediaType == 'Image') {
             $prettyType = 'prettyPhoto-' . $rand;
             $output .= '<figure class="featured-thumbnail thumbnail">';
//.........这里部分代码省略.........
开发者ID:rafaelfranco,项目名称:gruporota_portal,代码行数:101,代码来源:posts_grid.php


示例14: st_get_setup_post_slider_data

/**
* @return return the slider data for dunction st_slider
*/
function st_get_setup_post_slider_data($get_posts_args = array())
{
    if (empty($get_posts_args)) {
        return array();
    }
    $r = wp_parse_args($get_posts_args, array('cats' => '', 'numpost' => 5, 'exclude' => '', 'orderby' => 'ID', 'order' => 'DESC'));
    extract($r);
    if ($numpost <= 0) {
        $numpost = 5;
    }
    if (!is_array($cats)) {
        $cats = explode(',', $cats);
    }
    /**
     * @Since ver 1.3
     */
    $args = array('posts_per_page' => $numpost);
    if ($exclude != '') {
        $exclude = explode(',', $exclude);
        $args['post__not_in'] = $exclude;
    }
    if ($cats) {
        $args['category__in'] = $cats;
    }
    $args['meta_key'] = '_thumbnail_id';
    $args['meta_query'] = array(array('key' => '_thumbnail_id', 'value' => 0, 'type' => 'numeric', 'compare' => '>'));
    $args['orderby'] = $orderby;
    $args['order'] = $order;
    $args['post_status'] = 'publish';
    if (st_is_wpml()) {
        if (is_admin()) {
            // this function calling in admin page
            global $post;
            $lang_data = wpml_get_language_information($post->ID);
            //  echo var_dump($lang_data,$post->ID); die();
            $args['la 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wpml_get_language_input_field函数代码示例发布时间:2022-05-23
下一篇:
PHP wpmem_inc_regmessage函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap