コード例 #1
0
ファイル: essential.php プロジェクト: leotaillard/btws2016
 protected function get_rows($metabox, $key)
 {
     $rows = array();
     switch ($metabox . '-' . $key) {
         case 'essential-general':
             $rows[] = '<td></td><td class="subsection top"><h4>' . _x('Site Information', 'metabox title', 'nextgen-facebook') . '</h4></td>';
             $rows[] = $this->p->util->get_th(_x('Default Article Topic', 'option label', 'nextgen-facebook'), null, 'og_art_section') . '<td>' . $this->form->get_select('og_art_section', $this->p->util->get_topics()) . '</td>';
             $rows[] = $this->p->util->get_th(_x('Site Name', 'option label', 'nextgen-facebook'), null, 'og_site_name', array('is_locale' => true)) . '<td>' . $this->form->get_input(SucomUtil::get_locale_key('og_site_name'), null, null, null, get_bloginfo('name', 'display')) . '</td>';
             $rows[] = $this->p->util->get_th(_x('Site Description', 'option label', 'nextgen-facebook'), null, 'og_site_description', array('is_locale' => true)) . '<td>' . $this->form->get_textarea(SucomUtil::get_locale_key('og_site_description'), null, null, null, get_bloginfo('description', 'display')) . '</td>';
             $rows[] = '<td></td><td class="subsection"><h4>' . _x('Facebook / Open Graph', 'metabox title', 'nextgen-facebook') . '</h4></td>';
             $rows[] = $this->p->util->get_th(_x('Facebook Business Page URL', 'option label', 'nextgen-facebook'), null, 'fb_publisher_url') . '<td>' . $this->form->get_input('fb_publisher_url', 'wide') . '</td>';
             $rows[] = $this->p->util->get_th(_x('Facebook Application ID', 'option label', 'nextgen-facebook'), null, 'fb_app_id') . '<td>' . $this->form->get_input('fb_app_id') . '</td>';
             $rows[] = $this->p->util->get_th(_x('or Facebook Admin Username(s)', 'option label', 'nextgen-facebook'), null, 'fb_admins') . '<td>' . $this->form->get_input('fb_admins') . '</td>';
             $rows[] = $this->p->util->get_th(_x('Default Content Language', 'option label', 'nextgen-facebook'), null, 'fb_lang') . '<td>' . $this->form->get_select('fb_lang', SucomUtil::get_pub_lang('facebook')) . '</td>';
             $rows[] = $this->p->util->get_th(_x('Default / Fallback Image ID', 'option label', 'nextgen-facebook'), null, 'og_def_img_id') . '<td>' . $this->form->get_image_upload_input('og_def_img') . '</td>';
             $rows[] = $this->p->util->get_th(_x('or Default / Fallback Image URL', 'option label', 'nextgen-facebook'), null, 'og_def_img_url') . '<td>' . $this->form->get_image_url_input('og_def_img') . '</td>';
             $rows[] = $this->p->util->get_th(_x('Open Graph Image Dimensions', 'option label', 'nextgen-facebook'), null, 'og_img_dimensions') . '<td>' . $this->form->get_image_dimensions_input('og_img', false, false) . '</td>';
             $rows[] = '<td></td><td class="subsection"><h4>' . _x('Google / Schema', 'metabox title', 'nextgen-facebook') . '</h4></td>';
             $rows[] = $this->p->util->get_th(_x('Google+ Business Page URL', 'option label', 'nextgen-facebook'), null, 'google_publisher_url') . '<td>' . $this->form->get_input('seo_publisher_url', 'wide') . '</td>';
             $rows[] = $this->p->util->get_th(_x('Website / Business Logo URL', 'option label', 'nextgen-facebook'), null, 'google_schema_logo_url') . '<td>' . $this->form->get_input('schema_logo_url', 'wide') . '</td>';
             $rows[] = '<td></td><td class="subsection"><h4>' . _x('Pinterest', 'metabox title', 'nextgen-facebook') . '</h4></td>';
             $rows[] = $this->p->util->get_th(_x('Pinterest Company Page URL', 'option label', 'nextgen-facebook'), null, 'rp_publisher_url') . '<td>' . $this->form->get_input('rp_publisher_url', 'wide') . '</td>';
             if (!SucomUtil::get_const('NGFB_RICH_PIN_DISABLE')) {
                 $rows[] = $this->p->util->get_th(_x('Rich Pin Image Dimensions', 'option label', 'nextgen-facebook'), null, 'rp_img_dimensions') . '<td>' . $this->form->get_image_dimensions_input('rp_img') . '</td>';
             }
             $rows[] = '<td></td><td class="subsection"><h4>' . _x('Twitter', 'metabox title', 'nextgen-facebook') . '</h4></td>';
             $rows[] = $this->p->util->get_th(_x('Twitter Business @username', 'option label', 'nextgen-facebook'), null, 'tc_site') . '<td>' . $this->form->get_input('tc_site') . '</td>';
             break;
         case 'essential-advanced':
             $rows['plugin_preserve'] = $this->p->util->get_th(_x('Preserve Settings on Uninstall', 'option label', 'nextgen-facebook'), null, 'plugin_preserve') . '<td>' . $this->form->get_checkbox('plugin_preserve') . '</td>';
             $rows['plugin_debug'] = $this->p->util->get_th(_x('Add Hidden Debug Messages', 'option label', 'nextgen-facebook'), null, 'plugin_debug') . '<td>' . (defined('NGFB_HTML_DEBUG') && NGFB_HTML_DEBUG ? $this->form->get_no_checkbox('plugin_debug') . ' NGFB_HTML_DEBUG constant enabled' : $this->form->get_checkbox('plugin_debug')) . '</td>';
             break;
     }
     return $rows;
 }
コード例 #2
0
ファイル: general.php プロジェクト: coollog/theboola
 protected function get_rows($metabox, $key)
 {
     $rows = array();
     $this->form->user_ids = $this->p->addons['util']['user']->get_display_names();
     $this->form->author_contact_fields = $this->p->addons['util']['user']->get_contact_fields();
     switch ($metabox . '-' . $key) {
         case 'og-general':
             $rows[] = $this->p->util->th('Default Article Topic', 'highlight', 'og_art_section') . '<td>' . $this->form->get_select('og_art_section', $this->p->util->get_topics()) . '</td>';
             $rows[] = $this->p->util->th('Site Name', null, 'og_site_name', array('is_locale' => true)) . '<td>' . $this->form->get_input(SucomUtil::get_locale_key('og_site_name'), null, null, null, get_bloginfo('name', 'display')) . '</td>';
             $rows[] = $this->p->util->th('Site Description', 'highlight', 'og_site_description', array('is_locale' => true)) . '<td>' . $this->form->get_textarea(SucomUtil::get_locale_key('og_site_description'), null, null, null, get_bloginfo('description', 'display')) . '</td>';
             break;
         case 'og-content':
             $rows[] = $this->p->util->th('Title Separator', null, 'og_title_sep') . '<td>' . $this->form->get_input('og_title_sep', 'short') . '</td>';
             break;
         case 'og-images':
             $img_id_pre = array('wp' => 'Media Library');
             if ($this->p->is_avail['media']['ngg'] == true) {
                 $img_id_pre['ngg'] = 'NextGEN Gallery';
             }
             $rows[] = $this->p->util->th('Max Images to Include', null, 'og_img_max') . '<td>' . $this->form->get_select('og_img_max', range(0, $this->p->cf['form']['max_media_items']), 'short', null, true) . '</td>';
             $rows[] = $this->p->util->th('Open Graph Image Dimensions', 'highlight', 'og_img_dimensions') . '<td>Width ' . $this->form->get_input('og_img_width', 'short') . ' x ' . 'Height ' . $this->form->get_input('og_img_height', 'short') . ' &nbsp; ' . 'Crop ' . $this->form->get_checkbox('og_img_crop') . '</td>';
             $rows[] = $this->p->util->th('Default Image ID', 'highlight', 'og_def_img_id') . '<td>' . $this->form->get_input('og_def_img_id', 'short') . '&nbsp;in&nbsp;' . $this->form->get_select('og_def_img_id_pre', $img_id_pre) . '</td>';
             $rows[] = $this->p->util->th('Default Image URL', null, 'og_def_img_url') . '<td>' . (empty($this->p->options['og_def_img_id']) ? $this->form->get_input('og_def_img_url', 'wide') : $this->form->get_no_input('og_def_img_url', 'wide')) . '</td>';
             break;
         case 'og-videos':
             $rows[] = $this->p->util->th('Max Videos to Include', null, 'og_vid_max') . '<td>' . $this->form->get_select('og_vid_max', range(0, $this->p->cf['form']['max_media_items']), 'short', null, true) . '</td>';
             break;
         case 'og-author':
             $rows[] = $this->p->util->th('Article Publisher Page URL', 'highlight', 'og_publisher_url') . '<td>' . $this->form->get_input('og_publisher_url', 'wide') . '</td>';
             break;
         case 'pub-facebook':
             $rows[] = $this->p->util->th('Facebook Admin(s)', 'highlight', 'fb_admins') . '<td>' . $this->form->get_input('fb_admins') . '</td>';
             $rows[] = $this->p->util->th('Facebook Application ID', null, 'fb_app_id') . '<td>' . $this->form->get_input('fb_app_id') . '</td>';
             $rows[] = $this->p->util->th('Default Language', null, 'fb_lang') . '<td>' . $this->form->get_select('fb_lang', SucomUtil::get_pub_lang('facebook')) . '</td>';
             break;
         case 'pub-google':
             $rows[] = $this->p->util->th('Publisher Link URL', 'highlight', 'google_publisher_url') . '<td>' . $this->form->get_input('link_publisher_url', 'wide') . '</td>';
             break;
         case 'pub-pinterest':
             $rows[] = '<td colspan="2" style="padding-bottom:10px;">' . $this->p->msgs->get('info-pub-pinterest') . '</td>';
             $rows[] = $this->p->util->th('Rich Pin Image Dimensions', 'highlight', 'rp_img_dimensions') . '<td>Width ' . $this->form->get_input('rp_img_width', 'short') . ' x ' . 'Height ' . $this->form->get_input('rp_img_height', 'short') . ' &nbsp; ' . 'Crop ' . $this->form->get_checkbox('rp_img_crop') . '</td>';
             break;
     }
     return $rows;
 }
コード例 #3
0
 public function get_site_name($get = 'current')
 {
     // provide options array to allow fallback if locale option does not exist
     $key = SucomUtil::get_locale_key('og_site_name', $this->p->options, $get);
     if (!empty($this->p->options[$key])) {
         return $this->p->options[$key];
     } else {
         return get_bloginfo('name', 'display');
     }
 }
コード例 #4
0
ファイル: opengraph.php プロジェクト: christocmp/bingopaws
 public function get_array(&$og = array(), $use_post = false)
 {
     $obj = $this->p->util->get_post_object($use_post);
     $post_id = empty($obj->ID) || empty($obj->post_type) ? 0 : $obj->ID;
     $post_type = '';
     $has_video_image = false;
     $og_max = $this->p->util->get_max_nums($post_id);
     $og = apply_filters($this->p->cf['lca'] . '_og_seed', $og, $use_post);
     if (!isset($og['fb:admins'])) {
         $og['fb:admins'] = $this->p->options['fb_admins'];
     }
     if (!isset($og['fb:app_id'])) {
         $og['fb:app_id'] = $this->p->options['fb_app_id'];
     }
     if (!isset($og['og:locale'])) {
         // get the current or configured language for og:locale
         $lang = empty($this->p->options['fb_lang']) ? SucomUtil::get_locale($post_id) : $this->p->options['fb_lang'];
         $lang = apply_filters($this->p->cf['lca'] . '_lang', $lang, SucomUtil::get_pub_lang('facebook'), $post_id);
         $og['og:locale'] = $lang;
     }
     if (!isset($og['og:site_name'])) {
         // pass options array to allow fallback if locale option does not exist
         $key = SucomUtil::get_locale_key('og_site_name', $this->p->options, $post_id);
         if (!empty($this->p->options[$key])) {
             $og['og:site_name'] = $this->p->options[$key];
         } else {
             $og['og:site_name'] = get_bloginfo('name', 'display');
         }
     }
     if (!isset($og['og:url'])) {
         $og['og:url'] = $this->p->util->get_sharing_url($use_post, true, $this->p->util->get_source_id('opengraph'));
     }
     if (!isset($og['og:title'])) {
         $og['og:title'] = $this->p->webpage->get_title($this->p->options['og_title_len'], '...', $use_post);
     }
     if (!isset($og['og:description'])) {
         $og['og:description'] = $this->p->webpage->get_description($this->p->options['og_desc_len'], '...', $use_post);
     }
     if (!isset($og['og:type'])) {
         // singular posts / pages are articles by default
         // check post_type for exceptions (like product pages)
         if (is_singular() || $use_post !== false) {
             if (!empty($obj->post_type)) {
                 $post_type = $obj->post_type;
             }
             switch ($post_type) {
                 case 'article':
                 case 'book':
                 case 'music.song':
                 case 'music.album':
                 case 'music.playlist':
                 case 'music.radio_station':
                 case 'product':
                 case 'profile':
                 case 'video.episode':
                 case 'video.movie':
                 case 'video.other':
                 case 'video.tv_show':
                 case 'website':
                     $og['og:type'] = $post_type;
                     break;
                 default:
                     $og['og:type'] = 'article';
                     break;
             }
             // check for default author info on indexes and searches
         } elseif (!(is_singular() || $use_post !== false) && !is_search() && !empty($this->p->options['og_def_author_on_index']) && !empty($this->p->options['og_def_author_id']) || is_search() && !empty($this->p->options['og_def_author_on_search']) && !empty($this->p->options['og_def_author_id'])) {
             $og['og:type'] = 'article';
             if (!isset($og['article:author'])) {
                 $og['article:author'] = $this->p->addons['util']['user']->get_article_author($this->p->options['og_def_author_id']);
             }
             // default for everything else is 'website'
         } else {
             $og['og:type'] = 'website';
         }
         $og['og:type'] = apply_filters($this->p->cf['lca'] . '_og_type', $og['og:type'], $use_post);
     }
     // if the page is an article, then define the other article meta tags
     if (isset($og['og:type']) && $og['og:type'] == 'article') {
         if (!isset($og['article:author'])) {
             if (is_singular() || $use_post !== false) {
                 if (!empty($obj->post_author)) {
                     $og['article:author'] = $this->p->addons['util']['user']->get_article_author($obj->post_author);
                 } elseif (!empty($this->p->options['og_def_author_id'])) {
                     $og['article:author'] = $this->p->addons['util']['user']->get_article_author($this->p->options['og_def_author_id']);
                 }
             }
         }
         if (!isset($og['article:publisher'])) {
             $og['article:publisher'] = $this->p->options['og_publisher_url'];
         }
         if (!isset($og['article:tag'])) {
             $og['article:tag'] = $this->p->webpage->get_tags($post_id);
         }
         if (!isset($og['article:section'])) {
             $og['article:section'] = $this->p->webpage->get_section($post_id);
         }
         if (!isset($og['article:published_time'])) {
             $og['article:published_time'] = trim(get_the_date('c'));
         }
         if (!isset($og['article:modified_time'])) {
             $og['article:modified_time'] = trim(get_the_modified_date('c'));
         }
     }
     // get all videos
     // check first, to add video preview images
     if (!isset($og['og:video'])) {
         if (empty($og_max['og_vid_max'])) {
             $this->p->debug->log('videos disabled: maximum videos = 0');
         } else {
             $og['og:video'] = $this->get_all_videos($og_max['og_vid_max'], $post_id);
             if (is_array($og['og:video'])) {
                 foreach ($og['og:video'] as $val) {
                     if (is_array($val) && !empty($val['og:image'])) {
                         $this->p->debug->log('og:image found in og:video array (no default image required)');
                         $has_video_image = true;
                     }
                 }
             }
         }
     }
     // get all images
     if (!isset($og['og:image'])) {
         if (empty($og_max['og_img_max'])) {
             $this->p->debug->log('images disabled: maximum images = 0');
         } else {
             $og['og:image'] = $this->get_all_images($og_max['og_img_max'], $this->size_name, $post_id);
             // if there's no image, and no video preview image, then add the default image for non-index webpages
             if (empty($og['og:image']) && $has_video_image === false && (is_singular() || $use_post !== false)) {
                 $og['og:image'] = $this->p->media->get_default_image($og_max['og_img_max'], $this->size_name);
             }
         }
     }
     // only a few opengraph meta tags are allowed to be empty
     foreach ($og as $key => $val) {
         switch ($key) {
             case 'og:locale':
             case 'og:site_name':
             case 'og:description':
                 break;
             default:
                 if ($val === '' || is_array($val) && empty($val)) {
                     unset($og[$key]);
                 }
                 break;
         }
     }
     // twitter cards are hooked into this filter to use existing open graph values
     return apply_filters($this->p->cf['lca'] . '_og', $og, $use_post);
 }
コード例 #5
0
 protected function get_rows($metabox, $key)
 {
     $rows = array();
     $this->form->user_ids = $this->p->mods['util']['user']->get_display_names();
     $this->form->author_contact_fields = $this->p->mods['util']['user']->get_contact_fields();
     switch ($metabox . '-' . $key) {
         case 'og-general':
             $rows[] = $this->p->util->get_th('Default Article Topic', 'highlight', 'og_art_section') . '<td>' . $this->form->get_select('og_art_section', $this->p->util->get_topics()) . '</td>';
             $rows[] = $this->p->util->get_th('Site Name', null, 'og_site_name', array('is_locale' => true)) . '<td>' . $this->form->get_input(SucomUtil::get_locale_key('og_site_name'), null, null, null, get_bloginfo('name', 'display')) . '</td>';
             $rows[] = $this->p->util->get_th('Site Description', 'highlight', 'og_site_description', array('is_locale' => true)) . '<td>' . $this->form->get_textarea(SucomUtil::get_locale_key('og_site_description'), null, null, null, get_bloginfo('description', 'display')) . '</td>';
             break;
         case 'og-content':
             $rows[] = $this->p->util->get_th('Title Separator', null, 'og_title_sep') . '<td>' . $this->form->get_input('og_title_sep', 'short') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Title Length', null, 'og_title_len') . '<td>' . $this->form->get_input('og_title_len', 'short') . ' characters or less</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Description Length', null, 'og_desc_len') . '<td>' . $this->form->get_input('og_desc_len', 'short') . ' characters or less</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Content Starts at 1st Paragraph', null, 'og_desc_strip') . '<td>' . $this->form->get_checkbox('og_desc_strip') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Use Image Alt if Content is Empty', null, 'og_desc_alt') . '<td>' . $this->form->get_checkbox('og_desc_alt') . '</td>';
             $rows[] = $this->p->util->get_th('Add Hashtags to Descriptions', null, 'og_desc_hashtags') . '<td>' . $this->form->get_select('og_desc_hashtags', range(0, $this->p->cf['form']['max_hashtags']), 'short', null, true) . ' tag names</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Add Page Title in Tags', null, 'og_page_title_tag') . '<td>' . $this->form->get_checkbox('og_page_title_tag') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Add Page Ancestor Tags', null, 'og_page_parent_tags') . '<td>' . $this->form->get_checkbox('og_page_parent_tags') . '</td>';
             break;
         case 'og-author':
             $rows[] = $this->p->util->get_th('Author Profile URL Field', null, 'og_author_field') . '<td>' . $this->form->get_select('og_author_field', $this->form->author_contact_fields) . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Fallback to Author Index URL', null, 'og_author_fallback') . '<td>' . $this->form->get_checkbox('og_author_fallback') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Default Author when Missing', null, 'og_def_author_id') . '<td>' . $this->form->get_select('og_def_author_id', $this->form->user_ids, null, null, true) . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Force Default Author on Indexes', null, 'og_def_author_on_index') . '<td>' . $this->form->get_checkbox('og_def_author_on_index') . ' defines index / archive webpages as articles</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Default Author on Search Results', null, 'og_def_author_on_search') . '<td>' . $this->form->get_checkbox('og_def_author_on_search') . ' defines search webpages as articles</td>';
             break;
         case 'og-images':
             $rows[] = $this->p->util->get_th('Max Images to Include', null, 'og_img_max') . '<td>' . $this->form->get_select('og_img_max', range(0, $this->p->cf['form']['max_media_items']), 'short', null, true) . (empty($this->form->options['og_vid_prev_img']) ? '' : '&nbsp;&nbsp;<em>video preview images are enabled</em> and (when available) are included first') . '</td>';
             $rows[] = $this->p->util->get_th('Open Graph Image Dimensions', 'highlight', 'og_img_dimensions') . '<td>' . $this->form->get_image_dimensions_input('og_img', false, false) . '</td>';
             $rows[] = $this->p->util->get_th('Default / Fallback Image ID', 'highlight', 'og_def_img_id') . '<td>' . $this->form->get_image_upload_input('og_def_img') . '</td>';
             $rows[] = $this->p->util->get_th('or Default / Fallback Image URL', null, 'og_def_img_url') . '<td>' . $this->form->get_image_url_input('og_def_img') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Force Default Image on Indexes', null, 'og_def_img_on_index') . '<td>' . $this->form->get_checkbox('og_def_img_on_index') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Force Default Image on Author Index', null, 'og_def_img_on_author') . '<td>' . $this->form->get_checkbox('og_def_img_on_author') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Force Default Image on Search Results', null, 'og_def_img_on_search') . '<td>' . $this->form->get_checkbox('og_def_img_on_search') . '</td>';
             if ($this->p->is_avail['media']['ngg'] === true) {
                 $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Add Tags from NGG Featured Image', null, 'og_ngg_tags') . '<td>' . $this->form->get_checkbox('og_ngg_tags') . '</td>';
             }
             break;
         case 'og-videos':
             break;
         case 'pub-facebook':
             $rows[] = $this->p->util->get_th('Facebook Business Page URL', 'highlight', 'fb_publisher_url') . '<td>' . $this->form->get_input('fb_publisher_url', 'wide') . '</td>';
             $rows[] = $this->p->util->get_th('Facebook Admin Username(s)', 'highlight', 'fb_admins') . '<td>' . $this->form->get_input('fb_admins') . '</td>';
             $rows[] = $this->p->util->get_th('Facebook Application ID', null, 'fb_app_id') . '<td>' . $this->form->get_input('fb_app_id') . '</td>';
             $rows[] = $this->p->util->get_th('Default Language', null, 'fb_lang') . '<td>' . $this->form->get_select('fb_lang', SucomUtil::get_pub_lang('facebook')) . '</td>';
             $rows[] = $this->p->util->get_th('Author Name Format', 'highlight', 'google_author_name') . '<td>' . $this->form->get_select('seo_author_name', $this->p->cf['form']['user_name_fields']) . '</td>';
             break;
         case 'pub-google':
             $rows[] = $this->p->util->get_th('Google+ Business Page URL', 'highlight', 'google_publisher_url') . '<td>' . $this->form->get_input('seo_publisher_url', 'wide') . '</td>';
             $rows[] = $this->p->util->get_th('Schema Website / Business Logo URL', null, 'google_schema_logo_url') . '<td>' . $this->form->get_input('schema_logo_url', 'wide') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Schema Meta Description Length', null, 'google_schema_desc_len') . '<td>' . $this->form->get_input('schema_desc_len', 'short') . ' characters or less</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Search / SEO Description Length', null, 'google_seo_desc_len') . '<td>' . $this->form->get_input('seo_desc_len', 'short') . ' characters or less</td>';
             $rows[] = $this->p->util->get_th('Author Link URL Field', null, 'google_author_field') . '<td>' . $this->form->get_select('seo_author_field', $this->form->author_contact_fields) . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Default Author when Missing', null, 'google_def_author_id') . '<td>' . $this->form->get_select('seo_def_author_id', $this->form->user_ids, null, null, true) . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Force Default Author on Indexes', null, 'google_def_author_on_index') . '<td>' . $this->form->get_checkbox('seo_def_author_on_index') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Default Author on Search Results', null, 'google_def_author_on_search') . '<td>' . $this->form->get_checkbox('seo_def_author_on_search') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Add Schema Website JSON-LD', null, 'google_schema_website_json') . '<td>' . $this->form->get_checkbox('schema_website_json') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Add Schema Publisher JSON-LD', null, 'google_schema_publisher_json') . '<td>' . $this->form->get_checkbox('schema_publisher_json') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Add Schema Author JSON-LD', null, 'google_schema_author_json') . '<td>' . $this->form->get_checkbox('schema_author_json') . '</td>';
             break;
         case 'pub-pinterest':
             $rows[] = '<td colspan="2" style="padding-bottom:10px;">' . $this->p->msgs->get('info-pub-pinterest') . '</td>';
             $rows[] = $this->p->util->get_th('Pinterest Company Page URL', null, 'rp_publisher_url') . '<td>' . $this->form->get_input('rp_publisher_url', 'wide') . '</td>';
             $rows[] = $this->p->util->get_th('Rich Pin Image Dimensions', 'highlight', 'rp_img_dimensions') . '<td>' . $this->form->get_image_dimensions_input('rp_img') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Author Name Format', null, 'rp_author_name') . '<td>' . $this->form->get_select('rp_author_name', $this->p->cf['form']['user_name_fields']) . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Website Verification ID', null, 'rp_dom_verify') . '<td>' . $this->form->get_input('rp_dom_verify', 'api_key') . '</td>';
             break;
         case 'pub-twitter':
             $rows[] = $this->p->util->get_th('Twitter Business @username', 'highlight', 'tc_site') . '<td>' . $this->form->get_input('tc_site') . '</td>';
             break;
         case 'pub-other':
             $rows[] = $this->p->util->get_th('Instagram Business URL', null, 'instgram_publisher_url') . '<td>' . $this->form->get_input('instgram_publisher_url', 'wide') . '</td>';
             $rows[] = $this->p->util->get_th('LinkedIn Company Page URL', null, 'linkedin_publisher_url') . '<td>' . $this->form->get_input('linkedin_publisher_url', 'wide') . '</td>';
             $rows[] = $this->p->util->get_th('MySpace Business (Brand) URL', null, 'myspace_publisher_url') . '<td>' . $this->form->get_input('myspace_publisher_url', 'wide') . '</td>';
             break;
     }
     return $rows;
 }
コード例 #6
0
ファイル: general.php プロジェクト: sonvq/passioninvestment
 protected function get_rows($metabox, $key)
 {
     $rows = array();
     $this->form->user_ids = $this->p->mods['util']['user']->get_display_names();
     $this->form->author_contact_fields = $this->p->mods['util']['user']->get_contact_fields();
     switch ($metabox . '-' . $key) {
         case 'og-general':
             $rows[] = $this->p->util->get_th(_x('Default Article Topic', 'option label', 'wpsso'), 'highlight', 'og_art_section') . '<td>' . $this->form->get_select('og_art_section', $this->p->util->get_topics()) . '</td>';
             $rows[] = $this->p->util->get_th(_x('Site Name', 'option label', 'wpsso'), null, 'og_site_name', array('is_locale' => true)) . '<td>' . $this->form->get_input(SucomUtil::get_locale_key('og_site_name'), null, null, null, get_bloginfo('name', 'display')) . '</td>';
             $rows[] = $this->p->util->get_th(_x('Site Description', 'option label', 'wpsso'), 'highlight', 'og_site_description', array('is_locale' => true)) . '<td>' . $this->form->get_textarea(SucomUtil::get_locale_key('og_site_description'), null, null, null, get_bloginfo('description', 'display')) . '</td>';
             break;
         case 'og-content':
             $rows[] = $this->p->util->get_th(_x('Title Separator', 'option label', 'wpsso'), null, 'og_title_sep') . '<td>' . $this->form->get_input('og_title_sep', 'short') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Maximum Title Length', 'option label', 'wpsso'), null, 'og_title_len') . '<td>' . $this->form->get_input('og_title_len', 'short') . ' ' . _x('characters or less', 'option comment', 'wpsso') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Maximum Description Length', 'option label', 'wpsso'), null, 'og_desc_len') . '<td>' . $this->form->get_input('og_desc_len', 'short') . ' ' . _x('characters or less', 'option comment', 'wpsso') . '</td>';
             $rows[] = $this->p->util->get_th(_x('Add Hashtags to Descriptions', 'option label', 'wpsso'), null, 'og_desc_hashtags') . '<td>' . $this->form->get_select('og_desc_hashtags', range(0, $this->p->cf['form']['max_hashtags']), 'short', null, true) . ' ' . _x('tag names', 'option comment') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Add Page Title in Tags / Hashtags', 'option label', 'wpsso'), null, 'og_page_title_tag') . '<td>' . $this->form->get_checkbox('og_page_title_tag') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Add Parent Page Tags / Hashtags', 'option label', 'wpsso'), null, 'og_page_parent_tags') . '<td>' . $this->form->get_checkbox('og_page_parent_tags') . '</td>';
             break;
         case 'og-author':
             $rows[] = $this->p->util->get_th(_x('Author Profile URL Field', 'option label', 'wpsso'), null, 'og_author_field') . '<td>' . $this->form->get_select('og_author_field', $this->form->author_contact_fields) . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Fallback to Author\'s Archive Page', 'option label', 'wpsso'), null, 'og_author_fallback') . '<td>' . $this->form->get_checkbox('og_author_fallback') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Default Author when Missing', 'option label', 'wpsso'), null, 'og_def_author_id') . '<td>' . $this->form->get_select('og_def_author_id', $this->form->user_ids, null, null, true) . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Use Default Author on Indexes', 'option label', 'wpsso'), null, 'og_def_author_on_index') . '<td>' . $this->form->get_checkbox('og_def_author_on_index') . ' defines index / archive webpages as articles</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Use Default Author on Search Results', 'option label', 'wpsso'), null, 'og_def_author_on_search') . '<td>' . $this->form->get_checkbox('og_def_author_on_search') . ' defines search webpages as articles</td>';
             break;
         case 'og-images':
             $rows[] = $this->p->util->get_th(_x('Maximum Images to Include', 'option label', 'wpsso'), null, 'og_img_max') . '<td>' . $this->form->get_select('og_img_max', range(0, $this->p->cf['form']['max_media_items']), 'short', null, true) . (empty($this->form->options['og_vid_prev_img']) ? '' : ' ' . _x('<em>video preview images are enabled</em> and will be included first', 'option comment', 'wpsso')) . '</td>';
             $rows[] = $this->p->util->get_th(_x('Open Graph Image Dimensions', 'option label', 'wpsso'), 'highlight', 'og_img_dimensions') . '<td>' . $this->form->get_image_dimensions_input('og_img', false, false) . '</td>';
             $rows[] = $this->p->util->get_th(_x('Default / Fallback Image ID', 'option label', 'wpsso'), 'highlight', 'og_def_img_id') . '<td>' . $this->form->get_image_upload_input('og_def_img') . '</td>';
             $rows[] = $this->p->util->get_th(_x('or Default / Fallback Image URL', 'option label', 'wpsso'), null, 'og_def_img_url') . '<td>' . $this->form->get_image_url_input('og_def_img') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Use Default Image on Indexes', 'option label', 'wpsso'), null, 'og_def_img_on_index') . '<td>' . $this->form->get_checkbox('og_def_img_on_index') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Use Default Image on Search Results', 'option label', 'wpsso'), null, 'og_def_img_on_search') . '<td>' . $this->form->get_checkbox('og_def_img_on_search') . '</td>';
             if ($this->p->is_avail['media']['ngg'] === true) {
                 $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Add Tags from NGG Featured Image', 'option label', 'wpsso'), null, 'og_ngg_tags') . '<td>' . $this->form->get_checkbox('og_ngg_tags') . '</td>';
             }
             break;
         case 'og-videos':
             break;
         case 'pub-facebook':
             $rows[] = $this->p->util->get_th(_x('Facebook Business Page URL', 'option label', 'wpsso'), 'highlight', 'fb_publisher_url') . '<td>' . $this->form->get_input('fb_publisher_url', 'wide') . '</td>';
             $rows[] = $this->p->util->get_th(_x('Facebook Admin Username(s)', 'option label', 'wpsso'), 'highlight', 'fb_admins') . '<td>' . $this->form->get_input('fb_admins') . '</td>';
             $rows[] = $this->p->util->get_th(_x('Facebook Application ID', 'option label', 'wpsso'), null, 'fb_app_id') . '<td>' . $this->form->get_input('fb_app_id') . '</td>';
             $rows[] = $this->p->util->get_th(_x('Default Language', 'option label', 'wpsso'), null, 'fb_lang') . '<td>' . $this->form->get_select('fb_lang', SucomUtil::get_pub_lang('facebook')) . '</td>';
             $rows[] = $this->p->util->get_th(_x('Author Name Format', 'option label', 'wpsso'), 'highlight', 'google_author_name') . '<td>' . $this->form->get_select('seo_author_name', $this->p->cf['form']['user_name_fields']) . '</td>';
             break;
         case 'pub-google':
             $rows[] = $this->p->util->get_th(_x('Google+ Business Page URL', 'option label', 'wpsso'), 'highlight', 'google_publisher_url') . '<td>' . $this->form->get_input('seo_publisher_url', 'wide') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Search / SEO Description Length', 'option label', 'wpsso'), null, 'google_seo_desc_len') . '<td>' . $this->form->get_input('seo_desc_len', 'short') . ' ' . _x('characters or less', 'option comment', 'wpsso') . '</td>';
             $rows[] = $this->p->util->get_th(_x('Author Link URL Field', 'option label', 'wpsso'), null, 'google_author_field') . '<td>' . $this->form->get_select('seo_author_field', $this->form->author_contact_fields) . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Default Author when Missing', 'option label', 'wpsso'), null, 'google_def_author_id') . '<td>' . $this->form->get_select('seo_def_author_id', $this->form->user_ids, null, null, true) . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Use Default Author on Indexes', 'option label', 'wpsso'), null, 'google_def_author_on_index') . '<td>' . $this->form->get_checkbox('seo_def_author_on_index') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Use Default Author on Search Results', 'option label', 'wpsso'), null, 'google_def_author_on_search') . '<td>' . $this->form->get_checkbox('seo_def_author_on_search') . '</td>';
             $rows[] = '<td colspan="2" class="subsection"><h4>' . _x('Google Structured Data / Schema Markup', 'metabox title', 'wpsso') . '</h4></td>';
             $rows[] = $this->p->util->get_th(_x('Website / Business Logo URL', 'option label', 'wpsso'), null, 'google_schema_logo_url') . '<td>' . $this->form->get_input('schema_logo_url', 'wide') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Maximum Description Length', 'option label', 'wpsso'), null, 'google_schema_desc_len') . '<td>' . $this->form->get_input('schema_desc_len', 'short') . ' ' . _x('characters or less', 'option comment', 'wpsso') . '</td>';
             $schema_select = '';
             $schema_types = apply_filters($this->p->cf['lca'] . '_schema_post_types', $this->p->cf['head']['schema_type']);
             foreach ($this->p->util->get_post_types() as $post_type) {
                 $schema_select .= '<p>' . $this->form->get_select('schema_type_for_' . $post_type->name, $schema_types) . ' for ' . $post_type->label . ' ' . (empty($post_type->description) ? '' : '(' . $post_type->description . ')') . '</p>' . "\n";
             }
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Schema Item Type by Post Type', 'option label', 'wpsso'), null, 'google_schema_post_type') . '<td>' . $schema_select . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Use Meta Property Container(s)', 'option label', 'wpsso'), null, 'google_schema_add_noscript') . '<td>' . $this->form->get_checkbox('schema_add_noscript') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Include Website JSON-LD', 'option label', 'wpsso'), null, 'google_schema_website_json') . '<td>' . $this->form->get_checkbox('schema_website_json') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Include Publisher JSON-LD', 'option label', 'wpsso'), null, 'google_schema_publisher_json') . '<td>' . $this->form->get_checkbox('schema_publisher_json') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Include Author JSON-LD', 'option label', 'wpsso'), null, 'google_schema_author_json') . '<td>' . $this->form->get_checkbox('schema_author_json') . '</td>';
             break;
         case 'pub-pinterest':
             $rows[] = '<td colspan="2" style="padding-bottom:10px;">' . $this->p->msgs->get('info-pub-pinterest') . '</td>';
             $rows[] = $this->p->util->get_th(_x('Pinterest Company Page URL', 'option label', 'wpsso'), null, 'rp_publisher_url') . '<td>' . $this->form->get_input('rp_publisher_url', 'wide') . '</td>';
             if (!SucomUtil::get_const('WPSSO_RICH_PIN_DISABLE')) {
                 $rows[] = $this->p->util->get_th(_x('Rich Pin Image Dimensions', 'option label', 'wpsso'), 'highlight', 'rp_img_dimensions') . '<td>' . $this->form->get_image_dimensions_input('rp_img') . '</td>';
             }
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Author Name Format', 'option label', 'wpsso'), null, 'rp_author_name') . '<td>' . $this->form->get_select('rp_author_name', $this->p->cf['form']['user_name_fields']) . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Pinterest Website Verification ID', 'option label', 'wpsso'), null, 'rp_dom_verify') . '<td>' . $this->form->get_input('rp_dom_verify', 'api_key') . '</td>';
             break;
         case 'pub-twitter':
             $rows[] = '<td colspan="2" style="padding-bottom:10px;">' . $this->p->msgs->get('info-pub-twitter') . '</td>';
             $rows[] = $this->p->util->get_th(_x('Twitter Business @username', 'option label', 'wpsso'), 'highlight', 'tc_site') . '<td>' . $this->form->get_input('tc_site') . '</td>';
             $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Maximum Description Length', 'option label', 'wpsso'), null, 'tc_desc_len') . '<td>' . $this->form->get_input('tc_desc_len', 'short') . ' ' . _x('characters or less', 'option comment', 'wpsso') . '</td>';
             $rows[] = $this->p->util->get_th(_x('<em>Summary</em> Card Image Dimensions', 'option label', 'wpsso'), null, 'tc_sum_dimensions') . '<td>' . $this->form->get_image_dimensions_input('tc_sum', false, false) . '</td>';
             $rows[] = $this->p->util->get_th(_x('<em>Large Image</em> Card Image Dimensions', 'option label', 'wpsso'), null, 'tc_lrgimg_dimensions') . '<td>' . $this->form->get_image_dimensions_input('tc_lrgimg', false, false) . '</td>';
             break;
         case 'pub-other':
             $rows[] = $this->p->util->get_th(_x('Instagram Business URL', 'option label', 'wpsso'), null, 'instgram_publisher_url') . '<td>' . $this->form->get_input('instgram_publisher_url', 'wide') . '</td>';
             $rows[] = $this->p->util->get_th(_x('LinkedIn Company Page URL', 'option label', 'wpsso'), null, 'linkedin_publisher_url') . '<td>' . $this->form->get_input('linkedin_publisher_url', 'wide') . '</td>';
             $rows[] = $this->p->util->get_th(_x('MySpace Business (Brand) URL', 'option label', 'wpsso'), null, 'myspace_publisher_url') . '<td>' . $this->form->get_input('myspace_publisher_url', 'wide') . '</td>';
             break;
     }
     return $rows;
 }
コード例 #7
0
ファイル: webpage.php プロジェクト: kivivuori/jotain
 public function get_description($textlen = 156, $trailing = '', $use_post = false, $use_cache = true, $add_hashtags = true, $encode = true)
 {
     $this->p->debug->args(array('textlen' => $textlen, 'trailing' => $trailing, 'use_post' => $use_post, 'use_cache' => $use_cache, 'add_hashtags' => $add_hashtags, 'encode' => $encode));
     $desc = false;
     $hashtags = '';
     $post_id = 0;
     if (is_singular() || $use_post !== false) {
         if (($obj = $this->p->util->get_post_object($use_post)) === false) {
             $this->p->debug->log('exiting early: invalid object type');
             return $desc;
         }
         $post_id = empty($obj->ID) ? 0 : $obj->ID;
         if (!empty($post_id) && isset($this->p->addons['util']['postmeta'])) {
             $desc = $this->p->addons['util']['postmeta']->get_options($post_id, 'og_desc');
             if (!empty($desc)) {
                 $this->p->debug->log('custom meta description = "' . $desc . '"');
             }
         }
     }
     // get seed if no custom meta description
     if (empty($desc)) {
         $desc = apply_filters($this->p->cf['lca'] . '_description_seed', '', $use_post, $use_cache, $add_hashtags);
         if (!empty($desc)) {
             $this->p->debug->log('description seed = "' . $desc . '"');
         }
     }
     // check for hashtags in meta or seed description, remove and then add again after shorten
     if (preg_match('/(.*)(( #[a-z0-9\\-]+)+)$/U', $desc, $match)) {
         $add_hashtags = true;
         $desc = $match[1];
         $hashtags = trim($match[2]);
     } elseif (is_singular() || $use_post !== false) {
         if ($add_hashtags && !empty($this->p->options['og_desc_hashtags'])) {
             $hashtags = $this->get_hashtags($post_id);
         }
     }
     // if there's no custom description, and no pre-seed,
     // then go ahead and generate the description value
     if (empty($desc)) {
         // $obj and $post_id are defined above, with the same test, so we should be good
         if (is_singular() || $use_post !== false) {
             // use the excerpt, if we have one
             if (has_excerpt($post_id)) {
                 $desc = $obj->post_excerpt;
                 if (!empty($this->p->options['plugin_filter_excerpt'])) {
                     // remove the sharing buttons filter to avoid recursive loops
                     if (!empty($this->p->sharing) && is_object($this->p->sharing)) {
                         $filter_removed = $this->p->sharing->remove_buttons_filter('get_the_excerpt');
                     } else {
                         $filter_removed = false;
                     }
                     $this->p->debug->log('calling apply_filters(\'get_the_excerpt\')');
                     $desc = apply_filters('get_the_excerpt', $desc);
                     if ($filter_removed) {
                         $this->p->sharing->add_buttons_filter('get_the_excerpt');
                     }
                 }
             } else {
                 $this->p->debug->log('no post_excerpt for post_id ' . $post_id);
             }
             // if there's no excerpt, then fallback to the content
             if (empty($desc)) {
                 $desc = $this->get_content($post_id, $use_cache);
             }
             // ignore everything until the first paragraph tag if $this->p->options['og_desc_strip'] is true
             if ($this->p->options['og_desc_strip']) {
                 $desc = preg_replace('/^.*?<p>/i', '', $desc);
             }
             // question mark makes regex un-greedy
         } elseif (is_author()) {
             $author = get_query_var('author_name') ? get_userdata(get_query_var('author')) : get_user_by('slug', get_query_var('author_name'));
             $desc = empty($author->description) ? sprintf('Authored by %s', $author->display_name) : $author->description;
         } elseif (is_tag()) {
             $desc = tag_description();
             if (empty($desc)) {
                 $desc = sprintf('Tagged with %s', single_tag_title('', false));
             }
         } elseif (is_category()) {
             $desc = category_description();
             if (empty($desc)) {
                 $desc = sprintf('%s Category', single_cat_title('', false));
             }
         } elseif (is_tax()) {
             $term = get_queried_object();
             if (!empty($term->description)) {
                 $desc = $term->description;
             }
         } elseif (is_day()) {
             $desc = sprintf('Daily Archives for %s', get_the_date());
         } elseif (is_month()) {
             $desc = sprintf('Monthly Archives for %s', get_the_date('F Y'));
         } elseif (is_year()) {
             $desc = sprintf('Yearly Archives for %s', get_the_date('Y'));
         }
     }
     // if there's still no description, then fallback to a generic version
     if (empty($desc)) {
         if (is_admin() && $obj->post_status == 'auto-draft') {
             $this->p->debug->log('post_status is auto-draft - using empty description');
         } else {
             // pass options array to allow fallback if locale option does not exist
             $key = SucomUtil::get_locale_key('og_site_description', $this->p->options, $post_id);
             if (!empty($this->p->options[$key])) {
                 $this->p->debug->log('description is empty - custom site description (' . $key . ')');
                 $desc = $this->p->options[$key];
             } else {
                 $this->p->debug->log('description is empty - using blog description');
                 $desc = get_bloginfo('description', 'display');
             }
         }
     }
     if ($textlen > 0) {
         if (!empty($hashtags)) {
             $textlen = $textlen - strlen($hashtags) - 1;
         }
         $desc = $this->p->util->limit_text_length($desc, $textlen, '...');
         // runs cleanup_html_tags()
     } else {
         $desc = $this->p->util->cleanup_html_tags($desc);
     }
     if (!empty($hashtags)) {
         $desc .= ' ' . $hashtags;
     }
     if ($encode === true) {
         $desc = htmlentities($desc, ENT_QUOTES, get_bloginfo('charset'), false);
     } else {
         $desc = html_entity_decode($desc, ENT_QUOTES, get_bloginfo('charset'));
     }
     // just in case
     $this->p->debug->log('pre-filter description = "' . $desc . '"');
     return apply_filters($this->p->cf['lca'] . '_description', $desc);
 }
コード例 #8
0
ファイル: webpage.php プロジェクト: leotaillard/btws2016
 public function get_description($textlen = 156, $trailing = '...', $use_post = false, $use_cache = true, $add_hashtags = true, $encode = true, $md_idx = 'og_desc', $src_id = '')
 {
     if ($this->p->debug->enabled) {
         $this->p->debug->mark('render description');
         // start timer
         $this->p->debug->args(array('textlen' => $textlen, 'trailing' => $trailing, 'use_post' => $use_post, 'use_cache' => $use_cache, 'add_hashtags' => $add_hashtags, 'encode' => $encode, 'md_idx' => $md_idx, 'src_id' => $src_id));
     }
     $desc = false;
     $hashtags = '';
     $post_id = 0;
     $page = '';
     if (is_singular() || $use_post !== false) {
         if (($obj = $this->p->util->get_post_object($use_post)) === false) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('exiting early: invalid object type');
             }
             return $desc;
         }
         $post_id = empty($obj->ID) || empty($obj->post_type) ? 0 : $obj->ID;
     }
     // skip if no metadata index / key name
     if (!empty($md_idx)) {
         if (is_singular() || $use_post !== false) {
             if (!empty($post_id)) {
                 $desc = $this->p->util->get_mod_options('post', $post_id, array($md_idx, 'og_desc'));
             }
         } elseif (SucomUtil::is_term_page()) {
             $term = $this->p->util->get_term_object();
             if (!empty($term->term_id)) {
                 $desc = $this->p->util->get_mod_options('taxonomy', $term->term_id, $md_idx);
             }
         } elseif (SucomUtil::is_author_page()) {
             $author = $this->p->util->get_author_object();
             if (!empty($author->ID)) {
                 $desc = $this->p->util->get_mod_options('user', $author->ID, $md_idx);
             }
         }
         if ($this->p->debug->enabled) {
             if (empty($desc)) {
                 $this->p->debug->log('no custom description found');
             } else {
                 $this->p->debug->log('custom description = "' . $desc . '"');
             }
         }
     }
     // get seed if no custom meta description
     if (empty($desc)) {
         $desc = apply_filters($this->p->cf['lca'] . '_description_seed', '', $use_post, $add_hashtags, $md_idx, $src_id);
         if (!empty($desc)) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('description seed = "' . $desc . '"');
             }
         }
     }
     // remove and save trailing hashtags
     if (preg_match('/^(.*)(( *#[a-z][a-z0-9\\-]+)+)$/U', $desc, $match)) {
         $desc = $match[1];
         $hashtags = trim($match[2]);
     } elseif (is_singular() || $use_post !== false) {
         if (!empty($add_hashtags) && !empty($this->p->options['og_desc_hashtags'])) {
             $hashtags = $this->get_hashtags($post_id, $add_hashtags);
         }
     }
     if ($this->p->debug->enabled) {
         $this->p->debug->log('hashtags found = "' . $hashtags . '"');
     }
     // if there's no custom description, and no pre-seed,
     // then go ahead and generate the description value
     if (empty($desc)) {
         // $obj and $post_id are defined above, with the same test, so we should be good
         if (is_singular() || $use_post !== false) {
             // use the excerpt, if we have one
             if (has_excerpt($post_id)) {
                 $desc = $obj->post_excerpt;
                 if (!empty($this->p->options['plugin_filter_excerpt'])) {
                     $filter_removed = apply_filters($this->p->cf['lca'] . '_pre_filter_remove', false, 'get_the_excerpt');
                     if ($this->p->debug->enabled) {
                         $this->p->debug->log('calling apply_filters(\'get_the_excerpt\')');
                     }
                     $desc = apply_filters('get_the_excerpt', $desc);
                     if ($filter_removed) {
                         $filter_added = apply_filters($this->p->cf['lca'] . '_post_filter_add', false, 'get_the_excerpt');
                     }
                 }
             } elseif ($this->p->debug->enabled) {
                 $this->p->debug->log('no post_excerpt for post_id ' . $post_id);
             }
             // if there's no excerpt, then fallback to the content
             if (empty($desc)) {
                 $desc = $this->get_content($post_id, $use_post, $use_cache, $md_idx, $src_id);
             }
             // ignore everything before the first paragraph if true
             if ($this->p->options['plugin_p_strip']) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('removing all text before the first paragraph');
                 }
                 $desc = preg_replace('/^.*?<p>/i', '', $desc);
                 // question mark makes regex un-greedy
             }
         } elseif (SucomUtil::is_term_page()) {
             if (is_tag()) {
                 $desc = tag_description();
                 if (empty($desc)) {
                     $desc = sprintf('Tagged with %s', single_tag_title('', false));
                 }
             } elseif (is_category()) {
                 $desc = category_description();
                 if (empty($desc)) {
                     $desc = sprintf('%s Category', single_cat_title('', false));
                 }
             } else {
                 // other taxonomies
                 $term = $this->p->util->get_term_object();
                 if (!empty($term->description)) {
                     $desc = $term->description;
                 } elseif (!empty($term->name)) {
                     $desc = $term->name . ' Archives';
                 }
             }
         } elseif (SucomUtil::is_author_page()) {
             $author = $this->p->util->get_author_object();
             if (!empty($author->description)) {
                 $desc = $author->description;
             } elseif (!empty($author->display_name)) {
                 $desc = sprintf('Authored by %s', $author->display_name);
             }
         } elseif (is_day()) {
             $desc = sprintf('Daily Archives for %s', get_the_date());
         } elseif (is_month()) {
             $desc = sprintf('Monthly Archives for %s', get_the_date('F Y'));
         } elseif (is_year()) {
             $desc = sprintf('Yearly Archives for %s', get_the_date('Y'));
         }
     }
     // if there's still no description, then fallback to a generic version
     if (empty($desc)) {
         if (is_admin() && !empty($obj->post_status) && $obj->post_status == 'auto-draft') {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('post_status is auto-draft - using empty description');
             }
         } else {
             // pass options array to allow fallback if locale option does not exist
             $key = SucomUtil::get_locale_key('og_site_description', $this->p->options, $post_id);
             if (!empty($this->p->options[$key])) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('description is empty - custom site description (' . $key . ')');
                 }
                 $desc = $this->p->options[$key];
             } else {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('description is empty - using blog description');
                 }
                 $desc = get_bloginfo('description', 'display');
             }
         }
     }
     if ($this->p->debug->enabled) {
         $this->p->debug->log('description strlen before html cleanup ' . strlen($desc));
     }
     $desc = $this->p->util->cleanup_html_tags($desc, true, $this->p->options['plugin_use_img_alt']);
     $desc = apply_filters($this->p->cf['lca'] . '_description_pre_limit', $desc);
     if ($textlen > 0) {
         if (!empty($add_hashtags) && !empty($hashtags)) {
             $textlen = $textlen - strlen($hashtags) - 1;
         }
         if ($this->p->debug->enabled) {
             $this->p->debug->log('description strlen before limit length ' . strlen($desc) . ' (limiting to ' . $textlen . ' chars)');
         }
         $desc = $this->p->util->limit_text_length($desc, $textlen, $trailing, false);
         // don't run cleanup_html_tags()
     } elseif ($this->p->debug->enabled) {
         $this->p->debug->log('description limit text length skipped');
     }
     if (!empty($add_hashtags) && !empty($hashtags)) {
         $desc .= ' ' . $hashtags;
     }
     if ($encode === true) {
         $desc = wp_encode_emoji(htmlentities($desc, ENT_QUOTES, get_bloginfo('charset'), false));
     }
     // double_encode = false
     if ($this->p->debug->enabled) {
         $this->p->debug->mark('render description');
     }
     // stop timer
     return apply_filters($this->p->cf['lca'] . '_description', $desc, $use_post, $add_hashtags, $md_idx, $src_id);
 }
コード例 #9
0
ファイル: general.php プロジェクト: kivivuori/jotain
 protected function get_rows($metabox, $key)
 {
     $rows = array();
     $user_ids = array();
     foreach (get_users() as $user) {
         $user_ids[$user->ID] = $user->display_name;
     }
     $user_ids[0] = 'none';
     switch ($metabox . '-' . $key) {
         case 'og-webpage':
             $rows[] = $this->p->util->th('Article Topic', 'highlight', 'og_art_section') . '<td>' . $this->form->get_select('og_art_section', $this->p->util->get_topics()) . '</td>';
             $rows[] = $this->p->util->th('Site Name', null, 'og_site_name', array('is_locale' => true)) . '<td>' . $this->form->get_input(SucomUtil::get_locale_key('og_site_name'), null, null, null, get_bloginfo('name', 'display')) . '</td>';
             $rows[] = $this->p->util->th('Site Description', 'highlight', 'og_site_description', array('is_locale' => true)) . '<td>' . $this->form->get_textarea(SucomUtil::get_locale_key('og_site_description'), null, null, null, get_bloginfo('description', 'display')) . '</td>';
             $rows[] = $this->p->util->th('Title Separator', null, 'og_title_sep') . '<td>' . $this->form->get_input('og_title_sep', 'short') . '</td>';
             $rows[] = $this->p->util->th('Title Length', null, 'og_title_len') . '<td>' . $this->form->get_input('og_title_len', 'short') . ' characters or less</td>';
             $rows[] = $this->p->util->th('Description Length', null, 'og_desc_len') . '<td>' . $this->form->get_input('og_desc_len', 'short') . ' characters or less</td>';
             $rows[] = $this->p->util->th('Add Page Title in Tags', null, 'og_page_title_tag') . '<td>' . $this->form->get_checkbox('og_page_title_tag') . '</td>';
             $rows[] = $this->p->util->th('Add Page Ancestor Tags', null, 'og_page_parent_tags') . '<td>' . $this->form->get_checkbox('og_page_parent_tags') . '</td>';
             $rows[] = $this->p->util->th('Number of Hashtags to Include', null, 'og_desc_hashtags') . '<td>' . $this->form->get_select('og_desc_hashtags', range(0, $this->p->cf['form']['max_desc_hashtags']), 'short', null, true) . ' tag names</td>';
             $rows[] = $this->p->util->th('Content Begins at First Paragraph', null, 'og_desc_strip') . '<td>' . $this->form->get_checkbox('og_desc_strip') . '</td>';
             break;
         case 'og-images':
             $img_id_pre = array('wp' => 'Media Library');
             if ($this->p->is_avail['media']['ngg'] == true) {
                 $img_id_pre['ngg'] = 'NextGEN Gallery';
             }
             $rows[] = $this->p->util->th('Image Dimensions', 'highlight', 'og_img_dimensions') . '<td>Width ' . $this->form->get_input('og_img_width', 'short') . ' x ' . 'Height ' . $this->form->get_input('og_img_height', 'short') . ' &nbsp; ' . 'Crop ' . $this->form->get_checkbox('og_img_crop') . '</td>';
             $rows[] = $this->p->util->th('Default Image ID', 'highlight', 'og_def_img_id') . '<td>' . $this->form->get_input('og_def_img_id', 'short') . ' in the ' . $this->form->get_select('og_def_img_id_pre', $img_id_pre) . '</td>';
             $rows[] = $this->p->util->th('Default Image URL', null, 'og_def_img_url') . '<td>' . (empty($this->p->options['og_def_img_id']) ? $this->form->get_input('og_def_img_url', 'wide') : $this->form->get_fake_input('og_def_img_url', 'wide')) . '</td>';
             $rows[] = $this->p->util->th('Use Default Image on Indexes', null, 'og_def_img_on_index') . '<td>' . $this->form->get_checkbox('og_def_img_on_index') . '</td>';
             $rows[] = $this->p->util->th('Use Default Image on Search Results', null, 'og_def_img_on_search') . '<td>' . $this->form->get_checkbox('og_def_img_on_search') . '</td>';
             if ($this->p->is_avail['media']['ngg'] === true) {
                 $rows[] = $this->p->util->th('Add Tags from NGG Featured Image', null, 'og_ngg_tags') . (isset($this->p->addons['media']['ngg']) ? '<td>' . $this->form->get_checkbox('og_ngg_tags') . '</td>' : '<td class="blank">' . $this->form->get_fake_checkbox('og_ngg_tags') . '</td>');
             } else {
                 $rows[] = $this->form->get_hidden('og_ngg_tags');
             }
             $rows[] = $this->p->util->th('Maximum Images', null, 'og_img_max') . '<td>' . $this->form->get_select('og_img_max', range(0, $this->p->cf['form']['max_media_items']), 'short', null, true) . '</td>';
             break;
         case 'og-videos':
             $rows[] = $this->p->util->th('Default Video URL', null, 'og_def_vid_url') . '<td>' . $this->form->get_input('og_def_vid_url', 'wide') . '</td>';
             $rows[] = $this->p->util->th('Use Default Video on Indexes', null, 'og_def_vid_on_index') . '<td>' . $this->form->get_checkbox('og_def_vid_on_index') . '</td>';
             $rows[] = $this->p->util->th('Use Default Video on Search Results', null, 'og_def_vid_on_search') . '<td>' . $this->form->get_checkbox('og_def_vid_on_search') . '</td>';
             $rows[] = $this->p->util->th('Maximum Videos', null, 'og_vid_max') . '<td>' . $this->form->get_select('og_vid_max', range(0, $this->p->cf['form']['max_media_items']), 'short', null, true) . '</td>';
             $rows[] = $this->p->util->th('Use HTTPS for Video APIs', null, 'og_vid_https') . '<td>' . $this->form->get_checkbox('og_vid_https') . '</td>';
             break;
         case 'og-author':
             $rows[] = $this->p->util->th('Author Profile URL', null, 'og_author_field') . '<td>' . $this->form->get_select('og_author_field', $this->author_contact_fields()) . '</td>';
             $rows[] = $this->p->util->th('Fallback to Author Index URL', null, 'og_author_fallback') . '<td>' . $this->form->get_checkbox('og_author_fallback') . '</td>';
             $rows[] = $this->p->util->th('Default Author when Missing', null, 'og_def_author_id') . '<td>' . $this->form->get_select('og_def_author_id', $user_ids, null, null, true) . '</td>';
             $rows[] = $this->p->util->th('Use Default Author on Indexes', null, 'og_def_author_on_index') . '<td>' . $this->form->get_checkbox('og_def_author_on_index') . ' defines index webpages as articles</td>';
             $rows[] = $this->p->util->th('Default Author on Search Results', null, 'og_def_author_on_search') . '<td>' . $this->form->get_checkbox('og_def_author_on_search') . ' defines search webpages as articles</td>';
             $rows[] = $this->p->util->th('Article Publisher Page URL', 'highlight', 'og_publisher_url') . '<td>' . $this->form->get_input('og_publisher_url', 'wide') . '</td>';
             break;
         case 'pub-facebook':
             $rows[] = $this->p->util->th('Facebook Admin(s)', 'highlight', 'fb_admins') . '<td>' . $this->form->get_input('fb_admins') . '</td>';
             $rows[] = $this->p->util->th('Facebook Application ID', null, 'fb_app_id') . '<td>' . $this->form->get_input('fb_app_id') . '</td>';
             $rows[] = $this->p->util->th('Default Language', null, 'fb_lang') . '<td>' . $this->form->get_select('fb_lang', SucomUtil::get_pub_lang('facebook')) . '</td>';
             break;
         case 'pub-google':
             $rows[] = $this->p->util->th('Description Length', null, 'google_desc_len') . '<td>' . $this->form->get_input('seo_desc_len', 'short') . ' characters or less</td>';
             $rows[] = $this->p->util->th('Author Name Format', null, 'google_author_name') . '<td>' . $this->form->get_select('seo_author_name', $this->author_name_fields()) . '</td>';
             $rows[] = $this->p->util->th('Author Link URL', null, 'google_author_field') . '<td>' . $this->form->get_select('link_author_field', $this->author_contact_fields()) . '</td>';
             $rows[] = $this->p->util->th('Default Author when Missing', null, 'google_def_author_id') . '<td>' . $this->form->get_select('seo_def_author_id', $user_ids, null, null, true) . '</td>';
             $rows[] = $this->p->util->th('Use Default Author on Indexes', null, 'google_def_author_on_index') . '<td>' . $this->form->get_checkbox('seo_def_author_on_index') . '</td>';
             $rows[] = $this->p->util->th('Default Author on Search Results', null, 'google_def_author_on_search') . '<td>' . $this->form->get_checkbox('seo_def_author_on_search') . '</td>';
             $rows[] = $this->p->util->th('Publisher Link URL', 'highlight', 'google_publisher_url') . '<td>' . $this->form->get_input('link_publisher_url', 'wide') . '</td>';
             break;
         case 'pub-pinterest':
             $rows[] = '<td colspan="2" style="padding-bottom:10px;">' . $this->p->msgs->get('pub-pinterest-info') . '</td>';
             $rows[] = $this->p->util->th('Author Name Format', null, 'rp_author_name') . '<td>' . $this->form->get_select('rp_author_name', $this->author_name_fields()) . '</td>';
             break;
     }
     return $rows;
 }