コード例 #1
0
ファイル: about_us.php プロジェクト: pavel24071988/pconstant
 $page = $db->query('SELECT * FROM about_us WHERE url = \'' . $URI[2] . '\'')->fetch();
 $path_to_image = file_exists($_SERVER['DOCUMENT_ROOT'] . '/images/' . $URI[1] . '/' . $URI[2] . '.jpg') ? '/images/' . $URI[1] . '/' . $URI[2] . '.jpg' : '/images/main_theme.jpg';
 // поделим текст пополам - так как у нас двух колоночная страница должна быть
 $text = $page['description'];
 $count_words = mb_strlen($text, 'UTF-8');
 $count_words_one = ceil($count_words / 2);
 $first_column = mb_substr($text, 0, $count_words_one, 'UTF-8');
 $second_column = mb_substr($text, $count_words_one, $count_words, 'UTF-8');
 echo '
     <div itemscope itemtype="http://schema.org/ScholarlyArticle">
         <div class="services" style="padding-bottom: 0;">
             <h1 class="tipical-h1-headline black">
                 <span>' . $page['title'] . '</span>
             </h1>
         </div>
         <meta itemprop="articleSection" content="' . get_article_section($URI[1]) . '">
         <div class="content_text">
             <div style="text-align: center;"><img itemprop="image" src="' . $path_to_image . '" alt="' . $page['title'] . '"/></div>
             <br />
             <div><a href="/' . $URI[1] . '">назад</a></div>
             <br />
             <div itemprop="articleBody">
                 <div class="services-promo-text clearfix">
                 <div class="services-promo-text-item">
                 ' . $first_column . ' -
                 </div>
                 <div class="services-promo-text-item">
                 ' . $second_column . '
                 </div>
                 </div>
             </div>
コード例 #2
0
 /**
  * Replaces variables with WordPress content
  *
  * @since 1.0.0
  *
  * @param int $id User ID
  */
 function issuem_replacements_args($string, $post)
 {
     $issuem_settings = get_issuem_settings();
     if (!empty($issuem_settings['use_wp_taxonomies'])) {
         $tags = 'post_tag';
         $cats = 'category';
     } else {
         $tags = 'issuem_issue_tags';
         $cats = 'issuem_issue_categories';
     }
     /* HAS added for Easst */
     $string = str_ireplace('%SECTION%', get_article_section($post->ID), $string);
     $string = str_ireplace('%TITLE%', get_the_title(), $string);
     $string = str_ireplace('%URL%', apply_filters('issuem_article_url', get_permalink($post->ID), $post->ID), $string);
     if (preg_match('/%CATEGORY\\[?(\\d*)\\]?%/i', $string, $matches)) {
         $post_cats = get_the_terms($post->ID, $cats);
         $categories = '';
         if ($post_cats && !is_wp_error($post_cats)) {
             if (!empty($matches[1])) {
                 $max_cats = $matches[1];
             } else {
                 $max_cats = 0;
             }
             $cat_array = array();
             $count = 1;
             foreach ($post_cats as $post_cat) {
                 $cat_array[] = $post_cat->name;
                 if (0 != $max_cats && $max_cats <= $count) {
                     break;
                 }
                 $count++;
             }
             $categories = join(", ", $cat_array);
         }
         $string = preg_replace('/%CATEGORY\\[?(\\d*)\\]?%/i', $categories, $string);
     }
     if (preg_match('/%TAG\\[?(\\d*)\\]?%/i', $string, $matches)) {
         $post_tags = get_the_terms($post->ID, $tags);
         $tag_string = '';
         if ($post_tags && !is_wp_error($post_tags)) {
             if (!empty($matches[1])) {
                 $max_tags = $matches[1];
             } else {
                 $max_tags = 0;
             }
             $cat_array = array();
             $count = 1;
             foreach ($post_tags as $post_tag) {
                 $cat_array[] = $post_tag->name;
                 if (0 != $max_tags && $max_tags <= $count) {
                     break;
                 }
                 $count++;
             }
             $tag_string = join(", ", $cat_array);
         }
         $string = preg_replace('/%TAG\\[?(\\d*)\\]?%/i', $tag_string, $string);
     }
     if (preg_match('/%TEASER%/i', $string, $matches)) {
         if ($teaser = get_post_meta($post->ID, '_teaser_text', true)) {
             $string = preg_replace('/%TEASER%/i', $teaser, $string);
         } else {
             $string = preg_replace('/%TEASER%/i', '%EXCERPT%', $string);
         }
         // If no Teaser Text exists, try to get an excerpt
     }
     if (preg_match('/%EXCERPT\\[?(\\d*)\\]?%/i', $string, $matches)) {
         if (!empty($matches[1])) {
             $excerpt_length = $matches[1];
         } else {
             $excerpt_length = 0;
         }
         if (empty($post->post_excerpt)) {
             $excerpt = $excerpt_length === 0 ? '' : get_the_content();
         } else {
             $excerpt = $post->post_excerpt;
         }
         $excerpt = strip_shortcodes($excerpt);
         $excerpt = apply_filters('the_content', $excerpt);
         $excerpt = str_replace(']]>', ']]&gt;', $excerpt);
         if ($excerpt_length !== 0 && empty($post->post_excerpt)) {
             $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
             $excerpt = wp_trim_words($excerpt, $excerpt_length, $excerpt_more);
         }
         $string = preg_replace('/%EXCERPT\\[?(\\d*)\\]?%/i', $excerpt, $string);
     }
     if (preg_match('/%CONTENT%/i', $string, $matches)) {
         $content = get_the_content();
         $content = apply_filters('the_content', $content);
         $content = str_replace(']]>', ']]&gt;', $content);
         $string = preg_replace('/%CONTENT%/i', $content, $string);
     }
     if (preg_match('/%FEATURE_IMAGE%/i', $string, $matches)) {
         $image = get_the_post_thumbnail($post->ID);
         $string = preg_replace('/%FEATURE_IMAGE%/i', $image, $string);
     }
     if (preg_match('/%ISSUEM_FEATURE_THUMB%/i', $string, $matches)) {
         $image = get_the_post_thumbnail($post->ID, 'issuem-featured-thumb-image');
         $string = preg_replace('/%ISSUEM_FEATURE_THUMB%/i', $image, $string);
     }
     if (preg_match('/%BYLINE%/i', $string, $matches)) {
         $author_name = get_issuem_author_name($post);
         if (strlen(trim($author_name)) > 0) {
             $byline = sprintf(__('by %s', 'issuem'), apply_filters('issuem_author_name', $author_name, $post->ID));
         } else {
             $byline = '';
         }
         $string = preg_replace('/%BYLINE%/i', $byline, $string);
     }
     if (preg_match('/%DATE%/i', $string, $matches)) {
         $post_date = get_the_date('', $post->ID);
         $string = preg_replace('/%DATE%/i', $post_date, $string);
     }
     $string = apply_filters('issuem_custom_replacement_args', $string, $post);
     return stripcslashes($string);
 }