コード例 #1
0
/**
 * fix home_url
 * @param $url
 * @param $what
 * @return mixed|string
 */
function hw_menu_qtrans_convertHomeURL($url, $what)
{
    if (function_exists('qtrans_convertURL') && $what == '/') {
        return qtrans_convertURL($url);
    }
    return $url;
}
コード例 #2
0
 function qtrans_convertHomeURL($url, $what)
 {
     if ($what == '/') {
         return qtrans_convertURL($url);
     }
     return $url;
 }
コード例 #3
0
function qt_permalink($qt, $permalink, $post_content, $modified_time, $change_freq, $priority, &$sitemap)
{
    if ($qt["enabled"]) {
        // Get modified time
        if ($modified_time != 0) {
            $modified_time = $sitemap->GetTimestampFromMySql($modified_time);
        }
        // Get a list of languages
        if ($post_content) {
            // Get available languages form post
            $languages = qtrans_getAvailableLanguages($post_content);
        } else {
            // Get all available languages
            $languages = $qt["enabled_languages"];
        }
        // Add an extra permalink url for every non-default qTranslate language
        foreach ($languages as $language) {
            if ($qt["hide_default_language"] == 1 && $qt["default_language"] == $language) {
                $sitemap->AddUrl($permalink, $modified_time, $change_freq, $priority);
            } else {
                $sitemap->AddUrl(qtrans_convertURL($permalink, $language, true), $modified_time, $change_freq, $priority);
            }
        }
    }
}
コード例 #4
0
function qtranslate_menu_item($menu_item)
{
    if (stripos($menu_item->url, get_site_url()) !== false) {
        $menu_item->url = qtrans_convertURL($menu_item->url);
        //echo $menu_item->url;
    }
    return $menu_item;
}
コード例 #5
0
 /**
  * Template for Converting Home link in Custom Menu
  *
  * To override this in a child theme
  * simply create your own catchbase_menuitem(), and that function will be used instead.
  *
  * @since Catch Base Pro 3.0
  */
 function catchbase_menuitem($menu_item)
 {
     // convert local URLs in custom menu items
     if ($menu_item->type == 'custom' && stripos($menu_item->url, get_site_url()) !== false) {
         $menu_item->url = qtrans_convertURL($menu_item->url);
     }
     return $menu_item;
 }
コード例 #6
0
 public function convertURL($url, $lang = '')
 {
     if (function_exists('qtranxf_convertURL')) {
         return qtranxf_convertURL($url, $lang);
     } else {
         return qtrans_convertURL($url, $lang);
     }
 }
コード例 #7
0
 /**
  * Template for Homepage Headline
  *
  * To override this in a child theme
  * simply create your own adventurous_homepage_headline(), and that function will be used instead.
  *
  * @uses adventurous_before_main action to add it in the header
  * @since Adventurous 1.0
  */
 function adventurous_homepage_headline()
 {
     //delete_transient( 'adventurous_homepage_headline' );
     global $post, $wp_query, $adventurous_options_settings;
     $options = $adventurous_options_settings;
     // Getting data from Theme Options
     $disable_headline = $options['disable_homepage_headline'];
     $disable_subheadline = $options['disable_homepage_subheadline'];
     $disable_button = $options['disable_homepage_button'];
     $homepage_headline = $options['homepage_headline'];
     $homepage_subheadline = $options['homepage_subheadline'];
     $homepage_headline_button = $options['homepage_headline_button'];
     $homepage_headline_target = $options['homepage_headline_target'];
     //support qTranslate plugin
     if (function_exists('qtrans_convertURL')) {
         $homepage_headline_url = qtrans_convertURL($options['homepage_headline_url']);
     } else {
         $homepage_headline_url = $options['homepage_headline_url'];
     }
     // Front page displays in Reading Settings
     $page_on_front = get_option('page_on_front');
     $page_for_posts = get_option('page_for_posts');
     // Get Page ID outside Loop
     $page_id = $wp_query->get_queried_object_id();
     if (empty($disable_headline) || empty($disable_subheadline) || empty($disable_button)) {
         if (!($adventurous_homepage_headline = get_transient('adventurous_homepage_headline'))) {
             echo '<!-- refreshing cache -->';
             $adventurous_homepage_headline = '<div id="homepage-message"><div class="container"><div class="left-section">';
             if ($disable_headline == "0") {
                 $adventurous_homepage_headline .= '<h2>' . $homepage_headline . '</h2>';
             }
             if ($disable_subheadline == "0") {
                 $adventurous_homepage_headline .= '<p>' . $homepage_subheadline . '</p>';
             }
             $adventurous_homepage_headline .= '</div><!-- .left-section -->';
             if (!empty($homepage_headline_url) && $disable_button == "0") {
                 if (!empty($homepage_headline_target)) {
                     $headlinetarget = '_blank';
                 } else {
                     $headlinetarget = '_self';
                 }
                 $adventurous_homepage_headline .= '<div class="right-section"><a href="' . $homepage_headline_url . '" target="' . $headlinetarget . '">' . $homepage_headline_button . '</a></div><!-- .right-section -->';
             }
             $adventurous_homepage_headline .= '</div><!-- .container --></div><!-- #homepage-message -->';
             set_transient('adventurous_homepage_headline', $adventurous_homepage_headline, 86940);
         }
         echo $adventurous_homepage_headline;
     }
 }
コード例 #8
0
ファイル: lang.php プロジェクト: slavic18/cats
 /**
  * Показывает переключатель языков в виде ненумерованного списка
  *
  * @param        $ulClasses
  * @param string $linkActiveClass
  * @param bool   $echo
  *
  * @return string
  */
 public function showLangSwitcher($ulClasses, $linkActiveClass = 'active', $echo = TRUE)
 {
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $result = '<ul class="' . $ulClasses . '">';
     foreach (qtrans_getSortedLanguages() as $lang) {
         $isActive = $lang == $GLOBALS['q_config']['language'] ? ' class="' . $linkActiveClass . '" ' : '';
         $result .= '<li><a href="' . qtrans_convertURL($url, $lang) . '" ' . $isActive . '>' . $lang . '</a></li>';
     }
     $result .= '</ul>';
     if ($echo) {
         echo $result;
         return;
     }
     return $result;
 }
コード例 #9
0
 function get_post_knews($reply, $id, $type, $lang)
 {
     if (is_array($reply) && isset($reply['skip'])) {
         return $reply;
     }
     global $post, $Knews_plugin, $knewsOptions;
     $post = get_post($id);
     $permalink = get_permalink();
     if (KNEWS_MULTILANGUAGE && $knewsOptions['multilanguage_knews'] == 'qt' && function_exists('qtrans_convertURL')) {
         $post = qtrans_use($lang, $post, false);
         $permalink = qtrans_convertURL($permalink, $lang, true);
     }
     setup_postdata($post);
     $excerpt_length = apply_filters('excerpt_length', 55);
     $excerpt = (string) get_the_excerpt();
     $content = (string) get_the_content();
     if ($knewsOptions['apply_filters_on'] == '1') {
         $content = apply_filters('the_content', $content);
     }
     $content = strip_shortcodes($content);
     $content = knews_iterative_extract_code('<script', '</script>', $content, true);
     $content = knews_iterative_extract_code('<fb:like', '</fb:like>', $content, true);
     $content = str_replace(']]>', ']]>', $content);
     $content = strip_tags($content);
     if ($excerpt == '') {
         $excerpt = $content;
     }
     $words = explode(' ', $content, $excerpt_length + 1);
     if (count($words) > $excerpt_length) {
         array_pop($words);
         //array_push($words, '[...]');
         $excerpt = implode(' ', $words) . '...';
     }
     $content = nl2br($content);
     $words = explode(' ', $excerpt, $excerpt_length + 1);
     if (count($words) > $excerpt_length) {
         array_pop($words);
         //array_push($words, '[...]');
         $excerpt = implode(' ', $words) . '...';
     }
     $featimg = '';
     if ($Knews_plugin->im_pro()) {
         if (has_post_thumbnail($post->ID)) {
             $featimg = knews_get_image_path();
         }
     }
     return array('title' => get_the_title(), 'excerpt' => $excerpt, 'content' => $content, 'permalink' => $permalink, 'image' => $featimg);
 }
コード例 #10
0
 public static function qtranslate($input)
 {
     global $q_config;
     if (is_array($input)) {
         // got an array? return one!
         foreach ($input as $url) {
             foreach ($q_config['enabled_languages'] as $language) {
                 $return[] = qtrans_convertURL($url, $language);
             }
         }
     } else {
         $return = qtrans_convertURL($input);
         // not an array? just convert the string.
     }
     return $return;
 }
コード例 #11
0
function qtrans_getLanguageLinks($style = '', $id = '')
{
    if (function_exists('qtrans_init')) {
        global $q_config;
        if ($style == '') {
            $style = 'text';
        }
        if (is_bool($style) && $style) {
            $style = 'image';
        }
        if (is_404()) {
            $url = get_option('home');
        } else {
            $url = '';
        }
        if ($id == '') {
            $id = 'qtranslate';
        }
        $id .= '-chooser';
        switch ($style) {
            case 'image':
            case 'text':
            case 'dropdown':
                echo '<ul class="qtrans_language_chooser" id="' . $id . '">';
                foreach (qtrans_getSortedLanguages() as $language) {
                    echo '<li';
                    if ($language == $q_config['language']) {
                        echo ' class="active"';
                    }
                    echo '><a href="' . qtrans_convertURL($url, $language) . '"';
                    // set hreflang
                    echo ' hreflang="' . $language . '" title="' . $q_config['language_name'][$language] . '"';
                    echo '><span';
                    echo '>' . $q_config['language_name'][$language] . '</span></a></li>';
                }
                echo "</ul><div class=\"qtrans_widget_end\"></div>";
        }
    }
}
コード例 #12
0
ファイル: Function.php プロジェクト: ycms/theme-evo
/**
 * Language list Code for non-Widget users
 *
 * @global array $q_config
 * @param string $sep
 */
function qtrans_generate_language_list($sep = " | ")
{
    global $q_config;
    $languages = qtrans_getSortedLanguages();
    $num_langs = count($languages);
    $id = 'qtranslate-chooser';
    $url = is_404() ? get_option('home') : '';
    echo '<div class="qtrans_language_chooser" id="' . $id . '">';
    foreach ($languages as $language) {
        $classes = array('lang-' . $language);
        if ($language == $q_config['language']) {
            $classes[] = 'active';
        }
        echo '<span class="' . implode(' ', $classes) . '"><a href="' . qtrans_convertURL($url, $language) . '"';
        echo ' hreflang="' . $language . '" title="' . $q_config['language_name'][$language] . '"';
        echo '>' . $q_config['language_name'][$language] . '</a></span>';
        if (--$num_langs > 0) {
            echo '<span class="qtrans_separator">' . $sep . '</span>';
        }
    }
    echo "</div>";
}
コード例 #13
0
function qtrans_header()
{
    global $q_config;
    echo "\n<meta http-equiv=\"Content-Language\" content=\"" . $q_config['locale'][$q_config['language']] . "\" />\n";
    $css = "<style type=\"text/css\" media=\"screen\">\n";
    $css .= ".qtrans_flag span { display:none }\n";
    $css .= ".qtrans_flag { height:12px; width:18px; display:block }\n";
    $css .= ".qtrans_flag_and_text { padding-left:20px }\n";
    foreach ($q_config['enabled_languages'] as $language) {
        $css .= ".qtrans_flag_" . $language . " { background:url(" . WP_CONTENT_URL . '/' . $q_config['flag_location'] . $q_config['flag'][$language] . ") no-repeat }\n";
    }
    $css .= "</style>\n";
    echo apply_filters('qtranslate_header_css', $css);
    // skip the rest if 404
    if (is_404()) {
        return;
    }
    // set links to translations of current page
    foreach ($q_config['enabled_languages'] as $language) {
        if ($language != qtrans_getLanguage()) {
            echo '<link hreflang="' . $language . '" href="' . qtrans_convertURL('', $language) . '" rel="alternate" rev="alternate" />' . "\n";
        }
    }
}
コード例 #14
0
            </div><!-- end of .widget-wrapper -->
            <div class="widget-wrapper">

                <div class="widget-title-home"></div>
                <div class="textwidget">
                    
                    <?php 
$options = get_option('responsive_theme_options');
echo '<ul class="social-icons-custom">';
if (!empty($options['twitter_uid'])) {
    echo '<li class="twitter-icon-custom social-icon"><a target="_blank" href="' . $options['twitter_uid'] . '">' . '<img src="' . get_stylesheet_directory_uri() . '/icons/twitter.png" width="24" height="24" alt="Twitter">' . '</a></li>';
}
if (!empty($options['facebook_uid'])) {
    echo '<li class="facebook-icon-custom social-icon"><a target="_blank" href="' . $options['facebook_uid'] . '">' . '<img src="' . get_stylesheet_directory_uri() . '/icons/facebook.png" width="24" height="24" alt="Facebook">' . '</a></li>';
}
echo '<li class="rss-icon-custom social-icon"><a target="_blank" href="' . qtrans_convertURL(get_bloginfo('rss2_url', 'display')) . '">' . '<img src="' . get_stylesheet_directory_uri() . '/icons/rss.png" width="24" height="24" alt="RSS">' . '</a></li>';
echo '</ul><!-- end of .social-icons -->';
?>
                    
                </div>

            </div><!-- end of .widget-wrapper -->
            
             
            
            <?php 
if (!dynamic_sidebar('home-widget-3')) {
    ?>
                <div class="widget-wrapper">

                    <div class="widget-title-home"><h4><?php 
コード例 #15
0
 function tc_url_lang($url) {
   return ( function_exists( 'qtrans_convertURL' ) ) ? qtrans_convertURL($url) : $url;
 }
コード例 #16
0
function qtrans_checkCanonical($redirect_url, $requested_url)
{
    // fix canonical conflicts with language urls
    if (qtrans_convertURL($redirect_url) == qtrans_convertURL($requested_url)) {
        return false;
    }
    return $redirect_url;
}
コード例 #17
0
 /**
  * Retrieve the home url for a given site.
  *
  * @param  int $blog_id   (optional) Blog ID. Defaults to current blog.
  * @param  string $path   (optional) Path relative to the home url.
  * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https'.
  * @return string Home url link with optional path appended.
  *
  * @since 1.0
  */
 public function home_url($url, $path, $scheme, $blog_id)
 {
     if (!in_array($scheme, array('http', 'https'))) {
         $scheme = is_ssl() && !is_admin() ? 'https' : 'http';
     }
     if (empty($blog_id) || !is_multisite()) {
         $url = get_option('home');
     } else {
         $url = get_blog_option($blog_id, 'home');
     }
     if ('http' != $scheme) {
         $url = str_replace('http://', "{$scheme}://", $url);
     }
     $ignore_caller = $this->ignore_rewrite_caller();
     if (!empty($path) && is_string($path) && strpos($path, '..') === false) {
         $url .= '/' . ltrim($path, '/');
     }
     if (!$ignore_caller) {
         $url = qtrans_convertURL($url, $this->get_lang(), true);
     }
     return $url;
 }
コード例 #18
0
 /**
  * Returns the URL of the management page as a shortcode
  */
 public function subscribe_url_shortcode()
 {
     global $post;
     $user_link = get_bloginfo('url') . get_option('subscribe_reloaded_manager_page', '');
     if (function_exists('qtrans_convertURL')) {
         $user_link = qtrans_convertURL($user_link);
     }
     if (strpos($user_link, '?') !== false) {
         return "{$user_link}&amp;srp={$post->ID}&amp;sra=s";
     } else {
         return "{$user_link}?srp={$post->ID}&amp;sra=s";
     }
 }
コード例 #19
0
 /**
  * Template for Featured Header Image from Post and Page
  *
  * To override this in a child theme
  * simply create your own catchbase_featured_imaage_pagepost(), and that function will be used instead.
  *
  * @since Catch Base 1.0
  */
 function catchbase_featured_page_post_image()
 {
     global $post, $wp_query;
     // Get Page ID outside Loop
     $page_id = $wp_query->get_queried_object_id();
     $page_for_posts = get_option('page_for_posts');
     if (is_home() && $page_for_posts == $page_id) {
         $header_page_id = $page_id;
     } else {
         $header_page_id = $post->ID;
     }
     if (has_post_thumbnail($header_page_id)) {
         $options = catchbase_get_theme_options();
         $featured_header_image_url = $options['featured_header_image_url'];
         $featured_header_image_base = $options['featured_header_image_base'];
         if ('' != $featured_header_image_url) {
             //support for qtranslate custom link
             if (function_exists('qtrans_convertURL')) {
                 $link = qtrans_convertURL($featured_header_image_url);
             } else {
                 $link = esc_url($featured_header_image_url);
             }
             //Checking Link Target
             if ('1' == $featured_header_image_base) {
                 $target = '_blank';
             } else {
                 $target = '_self';
             }
         } else {
             $link = '';
             $target = '';
         }
         $featured_header_image_alt = $options['featured_header_image_alt'];
         // Header Image Title/Alt
         if ('' != $featured_header_image_alt) {
             $title = esc_attr($featured_header_image_alt);
         } else {
             $title = '';
         }
         $featured_image_size = $options['featured_image_size'];
         if ('slider' == $featured_image_size) {
             $feat_image = get_the_post_thumbnail($post->ID, 'catchbase-slider', array('id' => 'main-feat-img'));
         } else {
             if ('full' == $featured_image_size) {
                 $feat_image = get_the_post_thumbnail($post->ID, 'full', array('id' => 'main-feat-img'));
             } else {
                 $feat_image = get_the_post_thumbnail($post->ID, 'catchbase-large', array('id' => 'main-feat-img'));
             }
         }
         $catchbase_featured_image = '<div id="header-featured-image" class =' . $featured_image_size . '>';
         // Header Image Link
         if ('' != $featured_header_image_url) {
             $catchbase_featured_image .= '<a title="' . esc_attr($title) . '" href="' . esc_url($link) . '" target="' . $target . '">' . $feat_image . '</a>';
         } else {
             // if empty featured_header_image on theme options, display default
             $catchbase_featured_image .= $feat_image;
         }
         $catchbase_featured_image .= '</div><!-- #header-featured-image -->';
         echo $catchbase_featured_image;
     } else {
         catchbase_featured_image();
     }
 }
コード例 #20
0
 if (!$Knews_plugin->initialized) {
     $Knews_plugin->init();
 }
 $url_home = '';
 if (KNEWS_MULTILANGUAGE) {
     if ($knewsOptions['multilanguage_knews'] == 'wpml') {
         global $sitepress;
         if (method_exists($sitepress, 'language_url')) {
             $user_lang = $Knews_plugin->get_user_lang($Knews_plugin->get_safe('e'));
             $url_home = $sitepress->language_url($user_lang);
         }
     }
     if ($knewsOptions['multilanguage_knews'] == 'qt') {
         if (function_exists('qtrans_convertURL')) {
             $user_lang = $Knews_plugin->get_user_lang($Knews_plugin->get_safe('e'));
             $url_home = qtrans_convertURL(get_bloginfo('url'), $user_lang);
         }
     }
 }
 if ($url_home == '') {
     $url_home = get_bloginfo('url');
 }
 if (strpos($url_home, '?') === false) {
     $url_home .= '?unsubscribe=';
 } else {
     $url_home .= '&unsubscribe=';
 }
 if ($Knews_plugin->block_user_self()) {
     $url_home .= 'ok';
 } else {
     $url_home .= 'error';
コード例 #21
0
function qtrans_use($lang, $text, $show_available = false)
{
    global $q_config;
    // return full string if language is not enabled
    if (!qtrans_isEnabled($lang)) {
        return $text;
    }
    if (is_array($text)) {
        // handle arrays recursively
        foreach ($text as $key => $t) {
            $text[$key] = qtrans_use($lang, $text[$key], $show_available);
        }
        return $text;
    }
    if (is_object($text) || @get_class($text) == '__PHP_Incomplete_Class') {
        foreach (get_object_vars($text) as $key => $t) {
            $text->{$key} = qtrans_use($lang, $text->{$key}, $show_available);
        }
        return $text;
    }
    // prevent filtering weird data types and save some resources
    if (!is_string($text) || $text == '') {
        return $text;
    }
    // get content
    $content = qtrans_split($text);
    // find available languages
    $available_languages = array();
    foreach ($content as $language => $lang_text) {
        $lang_text = trim($lang_text);
        if (!empty($lang_text)) {
            $available_languages[] = $language;
        }
    }
    // if no languages available show full text
    if (sizeof($available_languages) == 0) {
        return $text;
    }
    // if content is available show the content in the requested language
    if (!empty($content[$lang])) {
        return $content[$lang];
    }
    // content not available in requested language (bad!!) what now?
    if (!$show_available) {
        // check if content is available in default language, if not return first language found. (prevent empty result)
        if ($lang != $q_config['default_language']) {
            return "(" . $q_config['language_name'][$q_config['default_language']] . ") " . qtrans_use($q_config['default_language'], $text, $show_available);
        }
        foreach ($content as $language => $lang_text) {
            $lang_text = trim($lang_text);
            if (!empty($lang_text)) {
                return "(" . $q_config['language_name'][$language] . ") " . $lang_text;
            }
        }
    }
    // display selection for available languages
    $available_languages = array_unique($available_languages);
    $language_list = "";
    if (preg_match('/%LANG:([^:]*):([^%]*)%/', $q_config['not_available'][$lang], $match)) {
        $normal_seperator = $match[1];
        $end_seperator = $match[2];
        // build available languages string backward
        $i = 0;
        foreach ($available_languages as $language) {
            if ($i == 1) {
                $language_list = $end_seperator . $language_list;
            }
            if ($i > 1) {
                $language_list = $normal_seperator . $language_list;
            }
            $language_list = "<a href=\"" . qtrans_convertURL('', $language) . "\">" . $q_config['language_name'][$language] . "</a>" . $language_list;
            $i++;
        }
    }
    return "<p>" . preg_replace('/%LANG:([^:]*):([^%]*)%/', $language_list, $q_config['not_available'][$lang]) . "</p>";
}
コード例 #22
0
 /**
  * Displays the checkbox to allow visitors to subscribe
  */
 function subscribe_reloaded_show()
 {
     global $post, $wp_subscribe_reloaded;
     $checkbox_subscription_type = null;
     $_comment_ID = null;
     // Enable JS scripts.
     $wp_subscribe_reloaded->stcr->utils->add_plugin_js_scripts();
     wp_enqueue_style('stcr-plugin-style');
     $is_disabled = get_post_meta($post->ID, 'stcr_disable_subscriptions', true);
     if (!empty($is_disabled)) {
         return $_comment_ID;
     }
     $show_subscription_box = true;
     $html_to_show = '';
     $user_link = get_bloginfo('url') . get_option('subscribe_reloaded_manager_page', '');
     if (function_exists('qtrans_convertURL')) {
         $user_link = qtrans_convertURL($user_link);
     }
     $manager_link = strpos($user_link, '?') !== false ? "{$user_link}&amp;srp={$post->ID}&amp;srk=" . get_option('subscribe_reloaded_unique_key') : "{$user_link}?srp={$post->ID}&amp;srk=" . get_option('subscribe_reloaded_unique_key');
     if ($wp_subscribe_reloaded->stcr->is_user_subscribed($post->ID, '', 'C')) {
         $html_to_show = str_replace('[manager_link]', $user_link, __(html_entity_decode(stripslashes(get_option('subscribe_reloaded_subscribed_waiting_label', "Your subscription to this post needs to be confirmed. <a href='[manager_link]'>Manage your subscriptions</a>.")), ENT_QUOTES, 'UTF-8'), 'subscribe-reloaded'));
         $show_subscription_box = false;
     } elseif ($wp_subscribe_reloaded->stcr->is_user_subscribed($post->ID, '')) {
         $html_to_show = str_replace('[manager_link]', $user_link, __(html_entity_decode(stripslashes(get_option('subscribe_reloaded_subscribed_label', "You are subscribed to this post. <a href='[manager_link]'>Manage</a> your subscriptions.")), ENT_QUOTES, 'UTF-8'), 'subscribe-reloaded'));
         $show_subscription_box = false;
     }
     if ($wp_subscribe_reloaded->stcr->is_author($post->post_author)) {
         // when the second parameter is empty, cookie value will be used
         if (get_option('subscribe_reloaded_admin_subscribe', 'no') == 'no') {
             $show_subscription_box = false;
         }
         $html_to_show .= str_replace('[manager_link]', $manager_link, __(html_entity_decode(stripslashes(get_option('subscribe_reloaded_author_label', "You can <a href='[manager_link]'>manage the subscriptions</a> of this post.")), ENT_QUOTES, 'UTF-8'), 'subscribe-reloaded'));
     }
     if ($show_subscription_box) {
         $checkbox_label = str_replace('[subscribe_link]', "{$manager_link}&amp;sra=s", __(html_entity_decode(stripslashes(get_option('subscribe_reloaded_checkbox_label', "Notify me of followup comments via e-mail. You can also <a href='[subscribe_link]'>subscribe</a> without commenting.")), ENT_QUOTES, 'UTF-8'), 'subscribe-reloaded'));
         $checkbox_inline_style = get_option('subscribe_reloaded_checkbox_inline_style', 'width:30px');
         if (!empty($checkbox_inline_style)) {
             $checkbox_inline_style = " style='{$checkbox_inline_style}'";
         }
         $checkbox_html_wrap = html_entity_decode(stripslashes(get_option('subscribe_reloaded_checkbox_html', '')), ENT_QUOTES, 'UTF-8');
         if (get_option('subscribe_reloaded_enable_advanced_subscriptions', 'no') == 'no') {
             switch (get_option('subscribe_reloaded_checked_by_default_value')) {
                 case '0':
                     $checkbox_subscription_type = 'yes';
                     break;
                 case '1':
                     $checkbox_subscription_type = 'replies';
                     break;
             }
             $checkbox_field = "<input{$checkbox_inline_style} type='checkbox' name='subscribe-reloaded' id='subscribe-reloaded' value='{$checkbox_subscription_type}'" . (get_option('subscribe_reloaded_checked_by_default', 'no') == 'yes' ? " checked='checked'" : '') . " />";
         } else {
             $checkbox_field = "<select name='subscribe-reloaded' id='subscribe-reloaded'>\n\t\t\t\t\t\t\t\t\t<option value='none' " . (get_option('subscribe_reloaded_default_subscription_type') === '0' ? "selected='selected'" : '') . ">" . __("Don't subscribe", 'subscribe-reloaded') . "</option>\n\t\t\t\t\t\t\t\t\t<option value='yes' " . (get_option('subscribe_reloaded_default_subscription_type') === '1' ? "selected='selected'" : '') . ">" . __("All", 'subscribe-reloaded') . "</option>\n\t\t\t\t\t\t\t\t\t<option value='replies' " . (get_option('subscribe_reloaded_default_subscription_type') === '2' ? "selected='selected'" : '') . ">" . __("Replies to my comments", 'subscribe-reloaded') . "</option>\n\t\t\t\t\t\t\t\t</select>";
         }
         if (empty($checkbox_html_wrap)) {
             $html_to_show = "{$checkbox_field} <label for='subscribe-reloaded'>{$checkbox_label}</label>" . $html_to_show;
         } else {
             $checkbox_html_wrap = str_replace('[checkbox_field]', $checkbox_field, $checkbox_html_wrap);
             $html_to_show = str_replace('[checkbox_label]', $checkbox_label, $checkbox_html_wrap) . $html_to_show;
         }
     }
     if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
         $html_to_show = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($html_to_show);
     }
     // Check for the Comment Form location
     if (get_option('subscribe_reloaded_commentbox_place') == 'yes') {
         echo "<div class='stcr-form hidden'>";
         echo "<!-- Subscribe to Comments Reloaded version" . $wp_subscribe_reloaded->stcr->current_version . " -->";
         echo "<!-- BEGIN: subscribe to comments reloaded -->" . $html_to_show . "<!-- END: subscribe to comments reloaded -->";
         echo "</div>";
     } else {
         echo "<!-- Subscribe to Comments Reloaded version" . $wp_subscribe_reloaded->stcr->current_version . " -->";
         echo "<!-- BEGIN: subscribe to comments reloaded -->" . $html_to_show . "<!-- END: subscribe to comments reloaded -->";
     }
 }
コード例 #23
0
ファイル: i18n.php プロジェクト: EliasGoldberg/troop-sim
/**
 * Get all translated path of a specific post with ID.
 *
 * @since	2.4
 *
 * @param 	int 	$post_id	Post ID
 * @param 	string 	$post_type 	Post Type
 * @param 	string 	$regex 		Regex to include at the end
 * @return 	array	$urls
 */
function get_rocket_i18n_translated_post_urls($post_id, $post_type = 'page', $regex = null)
{
    $urls = array();
    $path = parse_url(get_permalink($post_id), PHP_URL_PATH);
    $langs = get_rocket_i18n_code();
    if (empty($path)) {
        return $urls;
    }
    // WPML
    if (rocket_is_plugin_active('sitepress-multilingual-cms/sitepress.php')) {
        foreach ($langs as $lang) {
            $urls[] = parse_url(get_permalink(icl_object_id($post_id, $post_type, true, $lang)), PHP_URL_PATH) . $regex;
        }
    }
    // qTranslate
    if (rocket_is_plugin_active('qtranslate/qtranslate.php')) {
        $langs = $GLOBALS['q_config']['enabled_languages'];
        $langs = array_diff($langs, array($GLOBALS['q_config']['default_language']));
        $url = get_permalink($post_id);
        $urls[] = parse_url(get_permalink($post_id), PHP_URL_PATH) . $regex;
        foreach ($langs as $lang) {
            $urls[] = parse_url(qtrans_convertURL($url, $lang, true), PHP_URL_PATH) . $regex;
        }
    }
    // Polylang
    if (rocket_is_plugin_active('polylang/polylang.php') && is_object($GLOBALS['polylang']->model) && ($translations = $GLOBALS['polylang']->model->get_translations('page', $post_id))) {
        foreach ($translations as $post_id) {
            $urls[] = parse_url(get_permalink($post_id), PHP_URL_PATH) . $regex;
        }
    }
    if (trim($path, '/') != '') {
        $urls[] = $path . $regex;
    }
    $urls = array_unique($urls);
    return $urls;
}
コード例 #24
0
    /**
     * Template for Promotion Headline
     *
     * To override this in a child theme
     * simply create your own catchresponsive_promotion_headline(), and that function will be used instead.
     *
     * @uses catchresponsive_before_main action to add it in the header
     * @since Catch Responsive 1.0
     */
    function catchresponsive_promotion_headline()
    {
        //delete_transient( 'catchresponsive_promotion_headline' );
        global $post, $wp_query;
        $options = catchresponsive_get_theme_options();
        $promotion_headline = $options['promotion_headline'];
        $promotion_subheadline = $options['promotion_subheadline'];
        $promotion_headline_button = $options['promotion_headline_button'];
        $promotion_headline_target = $options['promotion_headline_target'];
        $enablepromotion = $options['promotion_headline_option'];
        //support qTranslate plugin
        if (function_exists('qtrans_convertURL')) {
            $promotion_headline_url = qtrans_convertURL($options['promotion_headline_url']);
        } else {
            $promotion_headline_url = $options['promotion_headline_url'];
        }
        // Front page displays in Reading Settings
        $page_on_front = get_option('page_on_front');
        $page_for_posts = get_option('page_for_posts');
        // Get Page ID outside Loop
        $page_id = $wp_query->get_queried_object_id();
        if (("" != $promotion_headline || "" != $promotion_subheadline || "" != $promotion_headline_url) && ($enablepromotion == 'entire-site' || (is_front_page() || is_home() && $page_for_posts != $page_id) && $enablepromotion == 'homepage')) {
            if (!($catchresponsive_promotion_headline = get_transient('catchresponsive_promotion_headline'))) {
                echo '<!-- refreshing cache -->';
                $catchresponsive_promotion_headline = '
				<div id="promotion-message">
					<div class="wrapper">
						<div class="section left">';
                if ("" != $promotion_headline) {
                    $catchresponsive_promotion_headline .= '<h2>' . $promotion_headline . '</h2>';
                }
                if ("" != $promotion_subheadline) {
                    $catchresponsive_promotion_headline .= '<p>' . $promotion_subheadline . '</p>';
                }
                $catchresponsive_promotion_headline .= '
						</div><!-- .section.left -->';
                if ("" != $promotion_headline_url) {
                    if ("1" == $promotion_headline_target) {
                        $headlinetarget = '_blank';
                    } else {
                        $headlinetarget = '_self';
                    }
                    $catchresponsive_promotion_headline .= '
							<div class="section right">
								<a class="promotion-button" href="' . esc_url($promotion_headline_url) . '" target="' . $headlinetarget . '">' . esc_attr($promotion_headline_button) . '
								</a>
							</div><!-- .section.right -->';
                }
                $catchresponsive_promotion_headline .= '
					</div><!-- .wrapper -->
				</div><!-- #promotion-message -->';
                set_transient('catchresponsive_promotion_headline', $catchresponsive_promotion_headline, 86940);
            }
            echo $catchresponsive_promotion_headline;
        }
    }
コード例 #25
0
 /**
  * Builds the sitemap and writes it into a xml file.
  * 
  * ATTENTION PLUGIN DEVELOPERS! DONT CALL THIS METHOD DIRECTLY!
  * The method is probably not available, since it is only loaded when needed.
  * Use do_action("sm_rebuild"); if you want to rebuild the sitemap.
  * Please refer to the documentation.txt for more details.
  *
  * @since 3.0
  * @access public
  * @author Arne Brachhold <himself [at] arnebrachhold [dot] de>
  * @return array An array with messages such as failed writes etc.
  */
 function BuildSitemap()
 {
     global $wpdb, $posts, $wp_version;
     $this->Initate();
     if ($this->GetOption("b_memory") != '') {
         @ini_set("memory_limit", $this->GetOption("b_memory"));
     }
     if ($this->GetOption("b_time") != -1) {
         @set_time_limit($this->GetOption("b_time"));
     }
     //This object saves the status information of the script directly to the database
     $status = new GoogleSitemapGeneratorStatus();
     //Other plugins can detect if the building process is active
     $this->_isActive = true;
     //$this->AddElement(new GoogleSitemapGeneratorXmlEntry());
     //Debug mode?
     $debug = $this->GetOption("b_debug");
     if ($this->GetOption("b_xml")) {
         $fileName = $this->GetXmlPath();
         $status->StartXml($this->GetXmlPath(), $this->GetXmlUrl());
         if ($this->IsFileWritable($fileName)) {
             $this->_fileHandle = fopen($fileName, "w");
             if (!$this->_fileHandle) {
                 $status->EndXml(false, "Not openable");
             }
         } else {
             $status->EndXml(false, "not writable");
         }
     }
     //Write gzipped sitemap file
     if ($this->IsGzipEnabled()) {
         $fileName = $this->GetZipPath();
         $status->StartZip($this->GetZipPath(), $this->GetZipUrl());
         if ($this->IsFileWritable($fileName)) {
             $this->_fileZipHandle = gzopen($fileName, "w1");
             if (!$this->_fileZipHandle) {
                 $status->EndZip(false, "Not openable");
             }
         } else {
             $status->EndZip(false, "not writable");
         }
     }
     if (!$this->_fileHandle && !$this->_fileZipHandle) {
         $status->End();
         return;
     }
     //Content of the XML file
     $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<?xml version="1.0" encoding="UTF-8"' . '?' . '>'));
     $styleSheet = $this->GetDefaultStyle() && $this->GetOption('b_style_default') === true ? $this->GetDefaultStyle() : $this->GetOption('b_style');
     if (!empty($styleSheet)) {
         $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<' . '?xml-stylesheet type="text/xsl" href="' . $styleSheet . '"?' . '>'));
     }
     $this->AddElement(new GoogleSitemapGeneratorDebugEntry("generator=\"wordpress/" . get_bloginfo('version') . "\""));
     $this->AddElement(new GoogleSitemapGeneratorDebugEntry("sitemap-generator-url=\"http://www.arnebrachhold.de\" sitemap-generator-version=\"" . $this->GetVersion() . "\""));
     $this->AddElement(new GoogleSitemapGeneratorDebugEntry("generated-on=\"" . date(get_option("date_format") . " " . get_option("time_format")) . "\""));
     //All comments as an asso. Array (postID=>commentCount)
     $comments = $this->GetOption("b_prio_provider") != "" ? $this->GetComments() : array();
     //Full number of comments
     $commentCount = count($comments) > 0 ? $this->GetCommentCount($comments) : 0;
     if ($debug && $this->GetOption("b_prio_provider") != "") {
         $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Total comment count: " . $commentCount));
     }
     //Go XML!
     $this->AddElement(new GoogleSitemapGeneratorXmlEntry('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'));
     $home = get_bloginfo('url');
     $homePid = 0;
     //Add the home page (WITH a slash!)
     if ($this->GetOption("in_home")) {
         if ('page' == get_option('show_on_front') && get_option('page_on_front')) {
             $pageOnFront = get_option('page_on_front');
             $p = get_page($pageOnFront);
             if ($p) {
                 $homePid = $p->ID;
                 $this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql($p->post_modified_gmt && $p->post_modified_gmt != '0000-00-00 00:00:00' ? $p->post_modified_gmt : $p->post_date_gmt), $this->GetOption("cf_home"), $this->GetOption("pr_home"));
             }
         } else {
             $this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql(get_lastpostmodified('GMT')), $this->GetOption("cf_home"), $this->GetOption("pr_home"));
         }
     }
     //Add the posts
     if ($this->GetOption("in_posts") || $this->GetOption("in_pages")) {
         if ($debug) {
             $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Postings"));
         }
         //Pre 2.1 compatibility. 2.1 introduced 'future' as post_status so we don't need to check post_date
         $wpCompat = floatval($wp_version) < 2.1;
         $useQTransLate = false;
         //function_exists('qtrans_convertURL') && function_exists('qtrans_getEnabledLanguages'); Not really working yet
         $excludes = $this->GetOption('b_exclude');
         //Excluded posts and pages (user enetered ID)
         $exclCats = $this->GetOption("b_exclude_cats");
         // Excluded cats
         if ($exclCats && count($exclCats) > 0 && $this->IsTaxonomySupported()) {
             $excludedCatPosts = get_objects_in_term($exclCats, "category");
             // Get all posts in excl. cats. Unforttunately this also gives us pages, revisions and so on...
             //Remove the pages, revisions etc from the exclude by category list, because they are always in the uncategorized one.
             if (count($excludedCatPosts) > 0) {
                 $exclPages = $wpdb->get_col("SELECT ID FROM `" . $wpdb->posts . "` WHERE post_type!='post' AND ID IN ('" . implode("','", $excludedCatPosts) . "')");
                 $exclPages = array_map('intval', $exclPages);
                 //Remove the pages from the exlusion list before
                 if (count($exclPages) > 0) {
                     $excludedCatPosts = array_diff($excludedCatPosts, $exclPages);
                 }
                 //Merge the category exclusion list with the users one
                 if (count($excludedCatPosts) > 0) {
                     $excludes = array_merge($excludes, $excludedCatPosts);
                 }
             }
         }
         $contentStmt = '';
         if ($useQTransLate) {
             $contentStmt .= ', post_content ';
         }
         $postPageStmt = '';
         $inSubPages = $this->GetOption('in_posts_sub') === true;
         if ($inSubPages && $this->GetOption('in_posts') === true) {
             $pageDivider = '<!--nextpage-->';
             $postPageStmt = ", (character_length(`post_content`)  - character_length(REPLACE(`post_content`, '{$pageDivider}', ''))) / " . strlen($pageDivider) . " as postPages";
         }
         $sql = "SELECT `ID`, `post_author`, `post_date`, `post_date_gmt`, `post_status`, `post_name`, `post_modified`, `post_modified_gmt`, `post_parent`, `post_type` {$postPageStmt} {$contentStmt} FROM `" . $wpdb->posts . "` WHERE ";
         $where = '(';
         if ($this->GetOption('in_posts')) {
             //WP < 2.1: posts are post_status = publish
             //WP >= 2.1: post_type must be 'post', no date check required because future posts are post_status='future'
             if ($wpCompat) {
                 $where .= "(post_status = 'publish' AND post_date_gmt <= '" . gmdate('Y-m-d H:i:59') . "')";
             } else {
                 $where .= " (post_status = 'publish' AND (post_type = 'post' OR post_type = '')) ";
             }
         }
         if ($this->GetOption('in_pages')) {
             if ($this->GetOption('in_posts')) {
                 $where .= " OR ";
             }
             if ($wpCompat) {
                 //WP < 2.1: posts have post_status = published, pages have post_status = static
                 $where .= " post_status='static' ";
             } else {
                 //WP >= 2.1: posts have post_type = 'post' and pages have post_type = 'page'. Both must be published.
                 $where .= " (post_status = 'publish' AND post_type = 'page') ";
             }
         }
         $where .= ") ";
         if (is_array($excludes) && count($excludes) > 0) {
             $where .= " AND ID NOT IN ('" . implode("','", $excludes) . "')";
         }
         $where .= " AND post_password='' ORDER BY post_modified DESC";
         $sql .= $where;
         if ($this->GetOption("b_max_posts") > 0) {
             $sql .= " LIMIT 0," . $this->GetOption("b_max_posts");
         }
         $postCount = intval($wpdb->get_var("SELECT COUNT(*) AS cnt FROM `" . $wpdb->posts . "` WHERE " . $where, 0, 0));
         //Create a new connection because we are using mysql_unbuffered_query and don't want to disturb the WP connection
         //Safe Mode for other plugins which use mysql_query() without a connection handler and will destroy our resultset :(
         $con = $postRes = null;
         //In 2.2, a bug which prevented additional DB connections was fixed
         if (floatval($wp_version) < 2.2) {
             $this->SetOption("b_safemode", true);
         }
         if ($this->GetOption("b_safemode") === true) {
             $postRes = mysql_query($sql, $wpdb->dbh);
             if (!$postRes) {
                 trigger_error("MySQL query failed: " . mysql_error(), E_USER_NOTICE);
                 //E_USER_NOTICE will be displayed on our debug mode
                 return;
             }
         } else {
             $con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, true);
             if (!$con) {
                 trigger_error("MySQL Connection failed: " . mysql_error(), E_USER_NOTICE);
                 return;
             }
             if (!mysql_select_db(DB_NAME, $con)) {
                 trigger_error("MySQL DB Select failed: " . mysql_error(), E_USER_NOTICE);
                 return;
             }
             $postRes = mysql_unbuffered_query($sql, $con);
             if (!$postRes) {
                 trigger_error("MySQL unbuffered query failed: " . mysql_error(), E_USER_NOTICE);
                 return;
             }
         }
         if ($postRes) {
             //#type $prioProvider GoogleSitemapGeneratorPrioProviderBase
             $prioProvider = NULL;
             if ($this->GetOption("b_prio_provider") != '') {
                 $providerClass = $this->GetOption('b_prio_provider');
                 $prioProvider = new $providerClass($commentCount, $postCount);
             }
             //$posts is used by Alex King's Popularity Contest plugin
             //if($posts == null || !is_array($posts)) {
             //	$posts = &$postRes;
             //}
             $z = 1;
             $zz = 1;
             //Default priorities
             $default_prio_posts = $this->GetOption('pr_posts');
             $default_prio_pages = $this->GetOption('pr_pages');
             //Change frequencies
             $cf_pages = $this->GetOption('cf_pages');
             $cf_posts = $this->GetOption('cf_posts');
             $minPrio = $this->GetOption('pr_posts_min');
             //Cycle through all posts and add them
             while ($post = mysql_fetch_object($postRes)) {
                 //Fill the cache with our DB result. Since it's incomplete (no text-content for example), we will clean it later.
                 $cache = array(&$post);
                 update_post_cache($cache);
                 //Set the current working post for other plugins which depend on "the loop"
                 $GLOBALS['post'] =& $post;
                 $permalink = get_permalink($post->ID);
                 if ($permalink != $home && $post->ID != $homePid) {
                     $isPage = false;
                     if ($wpCompat) {
                         $isPage = $post->post_status == 'static';
                     } else {
                         $isPage = $post->post_type == 'page';
                     }
                     //Default Priority if auto calc is disabled
                     $prio = 0;
                     if ($isPage) {
                         //Priority for static pages
                         $prio = $default_prio_pages;
                     } else {
                         //Priority for normal posts
                         $prio = $default_prio_posts;
                     }
                     //If priority calc. is enabled, calculate (but only for posts, not pages)!
                     if ($prioProvider !== null && !$isPage) {
                         //Comment count for this post
                         $cmtcnt = isset($comments[$post->ID]) ? $comments[$post->ID] : 0;
                         $prio = $prioProvider->GetPostPriority($post->ID, $cmtcnt, $post);
                         if ($debug) {
                             $this->AddElement(new GoogleSitemapGeneratorDebugEntry('Debug: Priority report of postID ' . $post->ID . ': Comments: ' . $cmtcnt . ' of ' . $commentCount . ' = ' . $prio . ' points'));
                         }
                     }
                     if (!$isPage && $minPrio > 0 && $prio < $minPrio) {
                         $prio = $minPrio;
                     }
                     //Add it
                     $this->AddUrl($permalink, $this->GetTimestampFromMySql($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt), $isPage ? $cf_pages : $cf_posts, $prio);
                     if ($inSubPages) {
                         $subPage = '';
                         for ($p = 1; $p <= $post->postPages; $p++) {
                             if (get_option('permalink_structure') == '') {
                                 $subPage = $permalink . '&amp;page=' . ($p + 1);
                             } else {
                                 $subPage = trailingslashit($permalink) . user_trailingslashit($p + 1, 'single_paged');
                             }
                             $this->AddUrl($subPage, $this->GetTimestampFromMySql($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt), $isPage ? $cf_pages : $cf_posts, $prio);
                         }
                     }
                     // Multilingual Support with qTranslate, thanks to Qian Qin
                     if ($useQTransLate) {
                         global $q_config;
                         foreach (qtrans_getEnabledLanguages($post->post_content) as $language) {
                             if ($language != $q_config['default_language']) {
                                 $this->AddUrl(qtrans_convertURL($permalink, $language), $this->GetTimestampFromMySql($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt), $isPage ? $cf_pages : $cf_posts, $prio);
                             }
                         }
                     }
                 }
                 //Update the status every 100 posts and at the end.
                 //If the script breaks because of memory or time limit,
                 //we have a "last reponded" value which can be compared to the server settings
                 if ($zz == 100 || $z == $postCount) {
                     $status->SaveStep($z);
                     $zz = 0;
                 } else {
                     $zz++;
                 }
                 $z++;
                 //Clean cache because it's incomplete
                 if (version_compare($wp_version, "2.5", ">=")) {
                     //WP 2.5 makes a mysql query for every clean_post_cache to clear the child cache
                     //so I've copied the function here until a patch arrives...
                     wp_cache_delete($post->ID, 'posts');
                     wp_cache_delete($post->ID, 'post_meta');
                     clean_object_term_cache($post->ID, 'post');
                 } else {
                     clean_post_cache($post->ID);
                 }
             }
             unset($postRes);
             unset($prioProvider);
             if ($this->GetOption("b_safemode") !== true && $con) {
                 mysql_close($con);
             }
         }
         if ($debug) {
             $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Postings"));
         }
     }
     //Add the cats
     if ($this->GetOption("in_cats")) {
         if ($debug) {
             $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Cats"));
         }
         $exclCats = $this->GetOption("b_exclude_cats");
         // Excluded cats
         if ($exclCats == null) {
             $exclCats = array();
         }
         if (!$this->IsTaxonomySupported()) {
             $catsRes = $wpdb->get_results("\n\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\tc.cat_ID AS ID,\n\t\t\t\t\t\t\t\tMAX(p.post_modified_gmt) AS last_mod\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t`" . $wpdb->categories . "` c,\n\t\t\t\t\t\t\t\t`" . $wpdb->post2cat . "` pc,\n\t\t\t\t\t\t\t\t`" . $wpdb->posts . "` p\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tpc.category_id = c.cat_ID\n\t\t\t\t\t\t\t\tAND p.ID = pc.post_id\n\t\t\t\t\t\t\t\tAND p.post_status = 'publish'\n\t\t\t\t\t\t\t\tAND p.post_type='post'\n\t\t\t\t\t\t\tGROUP\n\t\t\t\t\t\t\t\tBY c.cat_id\n\t\t\t\t\t\t\t");
             if ($catsRes) {
                 foreach ($catsRes as $cat) {
                     if ($cat && $cat->ID && $cat->ID > 0 && !in_array($cat->ID, $exclCats)) {
                         if ($debug) {
                             if ($debug) {
                                 $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Cat-ID:" . $cat->ID));
                             }
                         }
                         $this->AddUrl(get_category_link($cat->ID), $this->GetTimestampFromMySql($cat->last_mod), $this->GetOption("cf_cats"), $this->GetOption("pr_cats"));
                     }
                 }
             }
         } else {
             $cats = get_terms("category", array("hide_empty" => true, "hierarchical" => false));
             if ($cats && is_array($cats) && count($cats) > 0) {
                 foreach ($cats as $cat) {
                     if (!in_array($cat->term_id, $exclCats)) {
                         $this->AddUrl(get_category_link($cat->term_id), 0, $this->GetOption("cf_cats"), $this->GetOption("pr_cats"));
                     }
                 }
             }
         }
         if ($debug) {
             $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Cats"));
         }
     }
     //Add the archives
     if ($this->GetOption("in_arch")) {
         if ($debug) {
             $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Archive"));
         }
         $now = current_time('mysql');
         //WP2.1 introduced post_status='future', for earlier WP versions we need to check the post_date_gmt
         $arcresults = $wpdb->get_results("\n\t\t\t\t\t\tSELECT DISTINCT\n\t\t\t\t\t\t\tYEAR(post_date_gmt) AS `year`,\n\t\t\t\t\t\t\tMONTH(post_date_gmt) AS `month`,\n\t\t\t\t\t\t\tMAX(post_date_gmt) as last_mod,\n\t\t\t\t\t\t\tcount(ID) as posts\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t{$wpdb->posts}\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tpost_date < '{$now}'\n\t\t\t\t\t\t\tAND post_status = 'publish'\n\t\t\t\t\t\t\tAND post_type = 'post'\n\t\t\t\t\t\t\t" . (floatval($wp_version) < 2.1 ? "AND {$wpdb->posts}.post_date_gmt <= '" . gmdate('Y-m-d H:i:59') . "'" : "") . "\n\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\tYEAR(post_date_gmt),\n\t\t\t\t\t\t\tMONTH(post_date_gmt)\n\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\tpost_date_gmt DESC");
         if ($arcresults) {
             foreach ($arcresults as $arcresult) {
                 $url = get_month_link($arcresult->year, $arcresult->month);
                 $changeFreq = "";
                 //Archive is the current one
                 if ($arcresult->month == date("n") && $arcresult->year == date("Y")) {
                     $changeFreq = $this->GetOption("cf_arch_curr");
                 } else {
                     // Archive is older
                     $changeFreq = $this->GetOption("cf_arch_old");
                 }
                 $this->AddUrl($url, $this->GetTimestampFromMySql($arcresult->last_mod), $changeFreq, $this->GetOption("pr_arch"));
             }
         }
         if ($debug) {
             $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Archive"));
         }
     }
     //Add the author pages
     if ($this->GetOption("in_auth")) {
         if ($debug) {
             $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Author pages"));
         }
         $linkFunc = null;
         //get_author_link is deprecated in WP 2.1, try to use get_author_posts_url first.
         if (function_exists('get_author_posts_url')) {
             $linkFunc = 'get_author_posts_url';
         } else {
             if (function_exists('get_author_link')) {
                 $linkFunc = 'get_author_link';
             }
         }
         //Who knows what happens in later WP versions, so check again if it worked
         if ($linkFunc !== null) {
             //Unfortunately there is no API function to get all authors, so we have to do it the dirty way...
             //We retrieve only users with published and not password protected posts (and not pages)
             //WP2.1 introduced post_status='future', for earlier WP versions we need to check the post_date_gmt
             $sql = "SELECT DISTINCT\n\t\t\t\t\t\t\tp.ID,\n\t\t\t\t\t\t\tu.user_nicename,\n\t\t\t\t\t\t\tMAX(p.post_modified_gmt) AS last_post\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t{$wpdb->users} u,\n\t\t\t\t\t\t\t{$wpdb->posts} p\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tp.post_author = u.ID\n\t\t\t\t\t\t\tAND p.post_status = 'publish'\n\t\t\t\t\t\t\tAND p.post_type = 'post'\n\t\t\t\t\t\t\tAND p.post_password = ''\n\t\t\t\t\t\t\t" . (floatval($wp_version) < 2.1 ? "AND p.post_date_gmt <= '" . gmdate('Y-m-d H:i:59') . "'" : "") . "\n\t\t\t\t\t\tGROUP BY\n\t\t\t\t\t\t\tu.ID,\n\t\t\t\t\t\t\tu.user_nicename";
             $authors = $wpdb->get_results($sql);
             if ($authors && is_array($authors)) {
                 foreach ($authors as $author) {
                     if ($debug) {
                         if ($debug) {
                             $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Author-ID:" . $author->ID));
                         }
                     }
                     $url = $linkFunc == 'get_author_posts_url' ? get_author_posts_url($author->ID, $author->user_nicename) : get_author_link(false, $author->ID, $author->user_nicename);
                     $this->AddUrl($url, $this->GetTimestampFromMySql($author->last_post), $this->GetOption("cf_auth"), $this->GetOption("pr_auth"));
                 }
             }
         } else {
             //Too bad, no author pages for you :(
             if ($debug) {
                 $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: No valid author link function found"));
             }
         }
         if ($debug) {
             $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Author pages"));
         }
     }
     //Add tag pages
     if ($this->GetOption("in_tags") && $this->IsTaxonomySupported()) {
         if ($debug) {
             $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Tags"));
         }
         $tags = get_terms("post_tag", array("hide_empty" => true, "hierarchical" => false));
         if ($tags && is_array($tags) && count($tags) > 0) {
             foreach ($tags as $tag) {
                 $this->AddUrl(get_tag_link($tag->term_id), 0, $this->GetOption("cf_tags"), $this->GetOption("pr_tags"));
             }
         }
         if ($debug) {
             $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Tags"));
         }
     }
     //Add custom taxonomy pages
     if ($this->GetOption("in_tax") && $this->IsTaxonomySupported()) {
         if ($debug) {
             $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start custom taxonomies"));
         }
         $enabledTaxonomies = $this->GetOption("in_tax");
         $taxList = array();
         foreach ($enabledTaxonomies as $taxName) {
             $taxonomy = get_taxonomy($taxName);
             if ($taxonomy) {
                 $taxList[] = $wpdb->escape($taxonomy->name);
             }
         }
         if (count($taxList) > 0) {
             //We're selecting all term information (t.*) plus some additional fields
             //like the last mod date and the taxonomy name, so WP doesnt need to make
             //additional queries to build the permalink structure.
             //This does NOT work for categories and tags yet, because WP uses get_category_link
             //and get_tag_link internally and that would cause one additional query per term!
             $sql = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tt.*,\n\t\t\t\t\t\ttt.taxonomy AS _taxonomy,\n\t\t\t\t\t\tUNIX_TIMESTAMP(MAX(post_date_gmt)) as _mod_date\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$wpdb->posts} p ,\n\t\t\t\t\t\t{$wpdb->term_relationships} r,\n\t\t\t\t\t\t{$wpdb->terms} t,\n\t\t\t\t\t\t{$wpdb->term_taxonomy} tt\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tp.ID = r.object_id\n\t\t\t\t\t\tAND p.post_status = 'publish'\n\t\t\t\t\t\tAND p.post_type = 'post'\n\t\t\t\t\t\tAND p.post_password = ''\n\t\t\t\t\t\tAND r.term_taxonomy_id = t.term_id\n\t\t\t\t\t\tAND t.term_id = tt.term_id\n\t\t\t\t\t\tAND tt.count > 0\n\t\t\t\t\t\tAND tt.taxonomy IN ('" . implode("','", $taxList) . "')\n\t\t\t\t\tGROUP BY\n\t\t\t\t\t\tt.term_id";
             $termInfo = $wpdb->get_results($sql);
             foreach ($termInfo as $term) {
                 $this->AddUrl(get_term_link($term, $term->_taxonomy), $term->_mod_date, $this->GetOption("cf_tags"), $this->GetOption("pr_tags"));
             }
         }
         if ($debug) {
             $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End custom taxonomies"));
         }
     }
     //Add the custom pages
     if ($debug) {
         $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start Custom Pages"));
     }
     if ($this->_pages && is_array($this->_pages) && count($this->_pages) > 0) {
         //#type $page GoogleSitemapGeneratorPage
         foreach ($this->_pages as $page) {
             $this->AddUrl($page->GetUrl(), $page->getLastMod(), $page->getChangeFreq(), $page->getPriority());
         }
     }
     if ($debug) {
         $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End Custom Pages"));
     }
     if ($debug) {
         $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: Start additional URLs"));
     }
     do_action('sm_buildmap');
     if ($debug) {
         $this->AddElement(new GoogleSitemapGeneratorDebugEntry("Debug: End additional URLs"));
     }
     $this->AddElement(new GoogleSitemapGeneratorXmlEntry("</urlset>"));
     $pingUrl = '';
     if ($this->GetOption("b_xml")) {
         if ($this->_fileHandle && fclose($this->_fileHandle)) {
             $this->_fileHandle = null;
             $status->EndXml(true);
             $pingUrl = $this->GetXmlUrl();
         } else {
             $status->EndXml(false, "Could not close the sitemap file.");
         }
     }
     if ($this->IsGzipEnabled()) {
         if ($this->_fileZipHandle && fclose($this->_fileZipHandle)) {
             $this->_fileZipHandle = null;
             $status->EndZip(true);
             $pingUrl = $this->GetZipUrl();
         } else {
             $status->EndZip(false, "Could not close the zipped sitemap file");
         }
     }
     //Ping Google
     if ($this->GetOption("b_ping") && !empty($pingUrl)) {
         $sPingUrl = "http://www.google.com/webmasters/sitemaps/ping?sitemap=" . urlencode($pingUrl);
         $status->StartGooglePing($sPingUrl);
         $pingres = $this->RemoteOpen($sPingUrl);
         if ($pingres == NULL || $pingres === false) {
             $status->EndGooglePing(false, $this->_lastError);
             trigger_error("Failed to ping Google: " . htmlspecialchars(strip_tags($pingres)), E_USER_NOTICE);
         } else {
             $status->EndGooglePing(true);
         }
     }
     //Ping Ask.com
     if ($this->GetOption("b_pingask") && !empty($pingUrl)) {
         $sPingUrl = "http://submissions.ask.com/ping?sitemap=" . urlencode($pingUrl);
         $status->StartAskPing($sPingUrl);
         $pingres = $this->RemoteOpen($sPingUrl);
         if ($pingres == NULL || $pingres === false || strpos($pingres, "successfully received and added") === false) {
             //Ask.com returns 200 OK even if there was an error, so we need to check the content.
             $status->EndAskPing(false, $this->_lastError);
             trigger_error("Failed to ping Ask.com: " . htmlspecialchars(strip_tags($pingres)), E_USER_NOTICE);
         } else {
             $status->EndAskPing(true);
         }
     }
     //Ping YAHOO
     if ($this->GetOption("b_pingyahoo") === true && $this->GetOption("b_yahookey") != "" && !empty($pingUrl)) {
         $sPingUrl = "http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=" . $this->GetOption("b_yahookey") . "&url=" . urlencode($pingUrl);
         $status->StartYahooPing($sPingUrl);
         $pingres = $this->RemoteOpen($sPingUrl);
         if ($pingres == NULL || $pingres === false || strpos(strtolower($pingres), "success") === false) {
             trigger_error("Failed to ping YAHOO: " . htmlspecialchars(strip_tags($pingres)), E_USER_NOTICE);
             $status->EndYahooPing(false, $this->_lastError);
         } else {
             $status->EndYahooPing(true);
         }
     }
     //Ping Bing
     if ($this->GetOption("b_pingmsn") && !empty($pingUrl)) {
         $sPingUrl = "http://www.bing.com/webmaster/ping.aspx?siteMap=" . urlencode($pingUrl);
         $status->StartMsnPing($sPingUrl);
         $pingres = $this->RemoteOpen($sPingUrl);
         if ($pingres == NULL || $pingres === false || strpos($pingres, "Thanks for submitting your sitemap") === false) {
             trigger_error("Failed to ping Bing: " . htmlspecialchars(strip_tags($pingres)), E_USER_NOTICE);
             $status->EndMsnPing(false, $this->_lastError);
         } else {
             $status->EndMsnPing(true);
         }
     }
     $status->End();
     $this->_isActive = false;
     //done...
     return $status;
 }
コード例 #26
0
    exit;
}
require_once WP_PLUGIN_DIR . '/subscribe-to-comments-reloaded/classes/helper.class.php';
$helper = new subscribeToCommentsHelper();
ob_start();
if (!empty($email)) {
    global $wp_subscribe_reloaded;
    // Send management link
    $from_name = stripslashes(get_option('subscribe_reloaded_from_name', 'admin'));
    $from_email = get_option('subscribe_reloaded_from_email', get_bloginfo('admin_email'));
    $subject = html_entity_decode(stripslashes(get_option('subscribe_reloaded_management_subject', 'Manage your subscriptions on [blog_name]')), ENT_COMPAT, 'UTF-8');
    $message = html_entity_decode(stripslashes(get_option('subscribe_reloaded_management_content', '')), ENT_COMPAT, 'UTF-8');
    $manager_link = get_bloginfo('url') . get_option('subscribe_reloaded_manager_page', '/comment-subscriptions/');
    $one_click_unsubscribe_link = $manager_link;
    if (function_exists('qtrans_convertURL')) {
        $manager_link = qtrans_convertURL($manager_link);
    }
    $clean_email = $wp_subscribe_reloaded->stcr->utils->clean_email($email);
    $subscriber_salt = $wp_subscribe_reloaded->stcr->utils->generate_temp_key($clean_email);
    $headers = "MIME-Version: 1.0\n";
    $headers .= "From: {$from_name} <{$from_email}>\n";
    $content_type = get_option('subscribe_reloaded_enable_html_emails', 'no') == 'yes' ? 'text/html' : 'text/plain';
    $headers .= "Content-Type: {$content_type}; charset=" . get_bloginfo('charset');
    $manager_link .= strpos($manager_link, '?') !== false ? '&' : '?';
    $manager_link .= "sre=" . $wp_subscribe_reloaded->stcr->utils->get_subscriber_key($clean_email) . "&srk={$subscriber_salt}";
    $one_click_unsubscribe_link .= strpos($one_click_unsubscribe_link, '?') !== false ? '&' : '?';
    $one_click_unsubscribe_link .= (strpos($one_click_unsubscribe_link, '?') !== false ? '&' : '?') . "sre=" . $this->utils->get_subscriber_key($clean_email) . "&srk={$subscriber_salt}" . "&sra=u" . "&srp=";
    // Replace tags with their actual values
    $subject = str_replace('[blog_name]', get_bloginfo('name'), $subject);
    $message = str_replace('[blog_name]', get_bloginfo('name'), $message);
    $page_message = str_replace('[blog_name]', get_bloginfo('name'), $message);
コード例 #27
0
 static function get_form_action_url()
 {
     // returns the URL for the WP page the form was on
     if (function_exists('qtrans_convertURL')) {
         // compatible with qtranslate plugin
         // In case of multi-lingual pages, the /de/ /en/ language url is used.
         $form_action_url = qtrans_convertURL(strip_tags($_SERVER['REQUEST_URI']));
     } else {
         $form_action_url = 'http://' . strip_tags($_SERVER['HTTP_HOST']) . strip_tags($_SERVER['REQUEST_URI']);
     }
     // set the type of request (SSL or not)
     if (is_ssl()) {
         $form_action_url = preg_replace('|http://|', 'https://', $form_action_url);
     }
     //filter hook for form action URL
     return apply_filters('si_contact_form_action_url', $form_action_url, self::$form_id_num);
 }
コード例 #28
0
    /**
     * This function to display featured posts content
     *
     * @get the data value from theme options
     * @displays on the index
     *
     * @useage Featured Image, Title and Excerpt of Post
     *
     * @uses set_transient
     *
     * @since Catch Base 1.0v
     */
    function catchbase_image_content($options)
    {
        $quantity = $options['featured_content_number'];
        $more_link_text = $options['excerpt_more_text'];
        $show_content = isset($options['featured_content_show']) ? $options['featured_content_show'] : 'excerpt';
        $catchbase_image_content = '';
        for ($i = 1; $i <= $quantity; $i++) {
            if (!empty($options['featured_content_target_' . $i])) {
                $target = '_blank';
            } else {
                $target = '_self';
            }
            //Checking Link
            if (!empty($options['featured_content_link_' . $i])) {
                //support qTranslate plugin
                if (function_exists('qtrans_convertURL')) {
                    $link = qtrans_convertURL($options['featured_content_link_' . $i]);
                } else {
                    $link = esc_url($options['featured_content_link_' . $i]);
                }
            } else {
                $link = '#';
            }
            //Checking Title
            if (!empty($options['featured_content_title_' . $i])) {
                $title = esc_attr($options['featured_content_title_' . $i]);
            } else {
                $title = '';
            }
            //Checking Content
            if (!empty($options['featured_content_content_' . $i])) {
                $content = $options['featured_content_content_' . $i];
            } else {
                $content = '';
            }
            $catchbase_image_content .= '
		<article id="featured-post-' . $i . '" class="post hentry featured-image-content">';
            if (!empty($options['featured_content_image_' . $i])) {
                $catchbase_image_content .= '
				<figure class="featured-homepage-image">
					<a title="' . $title . '" href="' . $link . '" target="' . $target . '">
						<img src="' . $options['featured_content_image_' . $i] . '" class="wp-post-image" alt="' . $title . '" title="' . $title . '">
					</a>
				</figure>';
            }
            if ($title != '' || $content != '') {
                $catchbase_image_content .= '
				<div class="entry-container">';
                if ($title != '') {
                    $catchbase_image_content .= '
						<header class="entry-header">
							<h1 class="entry-title">
								<a href="' . $link . '" rel="bookmark" target="' . $target . '">' . $title . '</a>
							</h1>
						</header>';
                }
                if ('hide-content' != $show_content) {
                    if ('' != $content) {
                        $catchbase_image_content .= '
							<div class="entry-content"><p>
								' . $content . '
							</p></div>';
                    }
                }
                $catchbase_image_content .= '
				</div><!-- .entry-container -->';
            }
            $catchbase_image_content .= '			
		</article><!-- .featured-post-' . $i . ' -->';
        }
        return $catchbase_image_content;
    }
コード例 #29
0
function qtrans_generateLanguageSelectCode($style = '', $id = '')
{
    global $q_config;
    if ($style == '') {
        $style = 'text';
    }
    if (is_bool($style) && $style) {
        $style = 'image';
    }
    if (is_404()) {
        $url = get_option('home');
    } else {
        $url = '';
    }
    if ($id == '') {
        $id = 'qtranslate';
    }
    $id .= '-chooser';
    switch ($style) {
        case 'image':
        case 'text':
        case 'dropdown':
            echo '<ul class="qtrans_language_chooser" id="' . $id . '">';
            foreach (qtrans_getSortedLanguages() as $language) {
                $classes = array('lang-' . $language);
                if ($language == $q_config['language']) {
                    $classes[] = 'active';
                }
                echo '<li class="' . implode(' ', $classes) . '"><a href="' . qtrans_convertURL($url, $language) . '"';
                // set hreflang
                echo ' hreflang="' . $language . '" title="' . $q_config['language_name'][$language] . '"';
                if ($style == 'image') {
                    echo ' class="qtrans_flag qtrans_flag_' . $language . '"';
                }
                echo '><span';
                if ($style == 'image') {
                    echo ' style="display:none"';
                }
                echo '>' . $q_config['language_name'][$language] . '</span></a></li>';
            }
            echo "</ul>";
            if ($style == 'dropdown') {
                echo "<script type=\"text/javascript\">\n// <![CDATA[\r\n";
                echo "var lc = document.getElementById('" . $id . "');\n";
                echo "var s = document.createElement('select');\n";
                echo "s.id = 'qtrans_select_" . $id . "';\n";
                echo "lc.parentNode.insertBefore(s,lc);";
                // create dropdown fields for each language
                foreach (qtrans_getSortedLanguages() as $language) {
                    echo qtrans_insertDropDownElement($language, qtrans_convertURL($url, $language), $id);
                }
                // hide html language chooser text
                echo "s.onchange = function() { document.location.href = this.value;}\n";
                echo "lc.style.display='none';\n";
                echo "// ]]>\n</script>\n";
            }
            break;
        case 'both':
            echo '<ul class="qtrans_language_chooser" id="' . $id . '">';
            foreach (qtrans_getSortedLanguages() as $language) {
                echo '<li';
                if ($language == $q_config['language']) {
                    echo ' class="active"';
                }
                echo '><a href="' . qtrans_convertURL($url, $language) . '"';
                echo ' class="qtrans_flag_' . $language . ' qtrans_flag_and_text" title="' . $q_config['language_name'][$language] . '"';
                echo '><span>' . $q_config['language_name'][$language] . '</span></a></li>';
            }
            echo "</ul><div class=\"qtrans_widget_end\"></div>";
            break;
    }
}
コード例 #30
0
function afg_display_gallery($atts)
{
    global $size_heading_map, $afg_text_color_map, $pf;
    if (!get_option('afg_pagination')) {
        update_option('afg_pagination', 'on');
    }
    extract(shortcode_atts(array('id' => '0'), $atts));
    $cur_page = 1;
    $cur_page_url = afg_get_cur_url();
    preg_match("/afg{$id}_page_id=(?P<page_id>\\d+)/", $cur_page_url, $matches);
    if ($matches) {
        $cur_page = $matches['page_id'];
        $match_pos = strpos($cur_page_url, "afg{$id}_page_id={$cur_page}") - 1;
        $cur_page_url = substr($cur_page_url, 0, $match_pos);
        if (function_exists('qtrans_convertURL')) {
            $cur_page_url = qtrans_convertURL($cur_page_url);
        }
    }
    if (strpos($cur_page_url, '?') === false) {
        $url_separator = '?';
    } else {
        $url_separator = '&';
    }
    $galleries = get_option('afg_galleries');
    if (!isset($galleries) || array_key_exists($id, $galleries) == false) {
        return afg_error("Gallery ID {$id} has been either deleted or not configured.");
    }
    $gallery = $galleries[$id];
    $api_key = get_option('afg_api_key');
    $user_id = get_option('afg_user_id');
    $disable_slideshow = get_afg_option($gallery, 'slideshow_option') == 'disable';
    $slideshow_option = get_afg_option($gallery, 'slideshow_option');
    $per_page = get_afg_option($gallery, 'per_page');
    $sort_order = get_afg_option($gallery, 'sort_order');
    $photo_size = get_afg_option($gallery, 'photo_size');
    $photo_title = get_afg_option($gallery, 'captions');
    $photo_descr = get_afg_option($gallery, 'descr');
    $bg_color = get_afg_option($gallery, 'bg_color');
    $columns = get_afg_option($gallery, 'columns');
    $credit_note = get_afg_option($gallery, 'credit_note');
    $gallery_width = get_afg_option($gallery, 'width');
    $pagination = get_afg_option($gallery, 'pagination');
    $cache_refresh_interval = get_afg_option($gallery, 'cache_refresh_interval');
    if ($photo_size == 'custom') {
        $custom_size = get_afg_option($gallery, 'custom_size');
        $custom_size_square = get_afg_option($gallery, 'custom_size_square');
        if ($custom_size <= 70) {
            $photo_size = '_s';
        } else {
            if ($custom_size <= 90) {
                $photo_size = '_t';
            } else {
                if ($custom_size <= 220) {
                    $photo_size = '_m';
                } else {
                    if ($custom_size <= 500) {
                        $photo_size = 'NULL';
                    }
                }
            }
        }
    } else {
        $custom_size = 0;
        $custom_size_square = 'false';
    }
    $photoset_id = NULL;
    $gallery_id = NULL;
    $group_id = NULL;
    $tags = NULL;
    $popular = false;
    if (!isset($gallery['photo_source'])) {
        $gallery['photo_source'] = 'photostream';
    }
    if ($gallery['photo_source'] == 'photoset') {
        $photoset_id = $gallery['photoset_id'];
    } else {
        if ($gallery['photo_source'] == 'gallery') {
            $gallery_id = $gallery['gallery_id'];
        } else {
            if ($gallery['photo_source'] == 'group') {
                $group_id = $gallery['group_id'];
            } else {
                if ($gallery['photo_source'] == 'tags') {
                    $tags = $gallery['tags'];
                } else {
                    if ($gallery['photo_source'] == 'popular') {
                        $popular = true;
                    }
                }
            }
        }
    }
    $extras = 'url_l, description, date_upload, date_taken, owner_name';
    if (!DEBUG) {
        $photos = get_transient('afg_id_' . $id);
    }
    if ($photos === false) {
        $photos = array();
        if (isset($photoset_id) && $photoset_id) {
            $rsp_obj = $pf->photosets_getInfo($photoset_id);
            if ($pf->error_code) {
                return afg_error($pf->error_msg);
            }
            $total_photos = $rsp_obj['photos'];
        } else {
            if (isset($gallery_id) && $gallery_id) {
                $rsp_obj = $pf->galleries_getInfo($gallery_id);
                if ($pf->error_code) {
                    return afg_error($pf->error_msg);
                }
                $total_photos = $rsp_obj['gallery']['count_photos']['_content'];
            } else {
                if (isset($group_id) && $group_id) {
                    $rsp_obj = $pf->groups_pools_getPhotos($group_id, NULL, NULL, NULL, NULL, 1, 1);
                    if ($pf->error_code) {
                        return afg_error($pf->error_msg);
                    }
                    $total_photos = $rsp_obj['photos']['total'];
                    if ($total_photos > 500) {
                        $total_photos = 500;
                    }
                } else {
                    if (isset($tags) && $tags) {
                        $rsp_obj = $pf->photos_search(array('user_id' => $user_id, 'tags' => $tags, 'extras' => $extras, 'per_page' => 1));
                        if ($pf->error_code) {
                            return afg_error($pf->error_msg);
                        }
                        $total_photos = $rsp_obj['photos']['total'];
                    } else {
                        if (isset($popular) && $popular) {
                            $rsp_obj = $pf->photos_search(array('user_id' => $user_id, 'sort' => 'interestingness-desc', 'extras' => $extras, 'per_page' => 1));
                            if ($pf->error_code) {
                                return afg_error($pf->error_msg);
                            }
                            $total_photos = $rsp_obj['photos']['total'];
                        } else {
                            $rsp_obj = $pf->people_getInfo($user_id);
                            if ($pf->error_code) {
                                return afg_error($pf->error_msg);
                            }
                            $total_photos = $rsp_obj['photos']['count']['_content'];
                        }
                    }
                }
            }
        }
        for ($i = 1; $i < $total_photos / 500 + 1; $i++) {
            if ($photoset_id) {
                $flickr_api = 'photoset';
                $rsp_obj_total = $pf->photosets_getPhotos($photoset_id, $extras, NULL, 500, $i);
                if ($pf->error_code) {
                    return afg_error($pf->error_msg);
                }
            } else {
                if ($gallery_id) {
                    $flickr_api = 'photos';
                    $rsp_obj_total = $pf->galleries_getPhotos($gallery_id, $extras, 500, $i);
                    if ($pf->error_code) {
                        return afg_error($pf->error_msg);
                    }
                } else {
                    if ($group_id) {
                        $flickr_api = 'photos';
                        $rsp_obj_total = $pf->groups_pools_getPhotos($group_id, NULL, NULL, NULL, $extras, 500, $i);
                        if ($pf->error_code) {
                            return afg_error($pf->error_msg);
                        }
                    } else {
                        if ($tags) {
                            $flickr_api = 'photos';
                            $rsp_obj_total = $pf->photos_search(array('user_id' => $user_id, 'tags' => $tags, 'extras' => $extras, 'per_page' => 500, 'page' => $i));
                            if ($pf->error_code) {
                                return afg_error($pf->error_msg);
                            }
                        } else {
                            if ($popular) {
                                $flickr_api = 'photos';
                                $rsp_obj_total = $pf->photos_search(array('user_id' => $user_id, 'sort' => 'interestingness-desc', 'extras' => $extras, 'per_page' => 500, 'page' => $i));
                                if ($pf->error_code) {
                                    return afg_error($pf->error_msg);
                                }
                            } else {
                                $flickr_api = 'photos';
                                if (get_option('afg_flickr_token')) {
                                    $rsp_obj_total = $pf->people_getPhotos($user_id, array('extras' => $extras, 'per_page' => 500, 'page' => $i));
                                } else {
                                    $rsp_obj_total = $pf->people_getPublicPhotos($user_id, NULL, $extras, 500, $i);
                                }
                                if ($pf->error_code) {
                                    return afg_error($pf->error_msg);
                                }
                            }
                        }
                    }
                }
            }
            $photos = array_merge($photos, $rsp_obj_total[$flickr_api]['photo']);
        }
        if (!DEBUG) {
            set_transient('afg_id_' . $id, $photos, afg_get_cache_refresh_interval_secs($cache_refresh_interval));
        }
    } else {
        $total_photos = count($photos);
    }
    if ($total_photos % $per_page == 0) {
        $total_pages = (int) ($total_photos / $per_page);
    } else {
        $total_pages = (int) ($total_photos / $per_page) + 1;
    }
    if ($gallery_width == 'auto') {
        $gallery_width = 100;
    }
    $text_color = isset($afg_text_color_map[$bg_color]) ? $afg_text_color_map[$bg_color] : '';
    $disp_gallery .= "<div class='afg-gallery' id='afg-{$id}'>";
    if ($slideshow_option == 'highslide') {
        $photo_count = 1;
    }
    if (!$popular && $sort_order != 'flickr') {
        if ($sort_order == 'random') {
            shuffle($photos);
        } else {
            usort($photos, $sort_order);
        }
    }
    if ($disable_slideshow) {
        $class = '';
        $rel = '';
        $click_event = '';
    } else {
        if ($slideshow_option == 'colorbox') {
            $class = "class='afgcolorbox'";
            $rel = "rel='example4{$id}'";
            $click_event = "";
        } else {
            if ($slideshow_option == 'highslide') {
                $class = "class='highslide'";
                $rel = "";
                $click_event = "onclick='return hs.expand(this, {slideshowGroup: {$id} })'";
            } else {
                if ($slideshow_option == 'flickr') {
                    $class = "";
                    $rel = "";
                    $click_event = "target='_blank'";
                }
            }
        }
    }
    if ($photo_size == '_s') {
        $photo_width = "width='75'";
        $photo_height = "height='75'";
    } else {
        $photo_width = '';
        $photo_height = '';
    }
    foreach ($photos as $pid => $photo) {
        $p_title = esc_attr($photo['title']);
        $p_description = esc_attr($photo['description']['_content']);
        $p_description = preg_replace("/\n/", "<br />", $p_description);
        $photo_url = afg_get_photo_url($photo['farm'], $photo['server'], $photo['id'], $photo['secret'], $photo_size);
        if ($slideshow_option != 'none') {
            if (isset($photo['url_l']) ? $photo['url_l'] : '') {
                $photo_page_url = $photo['url_l'];
            } else {
                $photo_page_url = afg_get_photo_url($photo['farm'], $photo['server'], $photo['id'], $photo['secret'], '_z');
            }
            if ($photoset_id) {
                $photo['owner'] = $user_id;
            }
            $photo_title_text = $p_title;
            if ($slideshow_option == 'highslide' && $p_description) {
                $photo_title_text .= '<br /><span>' . $p_description . '</span>';
            }
            $photo_title_text .= ' • <a href="https://www.flickr.com/photos/' . $photo['owner'] . '/' . $photo['id'] . '/" target="_blank">View on Flickr</a>';
            $photo_title_text = esc_attr($photo_title_text);
            if ($slideshow_option == 'flickr') {
                $photo_page_url = "https://www.flickr.com/photos/" . $photo['owner'] . "/" . $photo['id'];
            }
        }
        if ($photo_count <= $per_page * $cur_page && $photo_count > $per_page * ($cur_page - 1)) {
            $pid_len = strlen($photo['id']);
            if ($slideshow_option != 'none') {
                $disp_gallery .= "<a {$class} {$rel} {$click_event} href='{$photo_page_url}' title='{$photo['title']}'>";
            }
            if ($custom_size) {
                $timthumb_script = BASE_URL . "/afg_img_rsz.php?src=";
                if ($photo['width_l'] > $photo['height_l']) {
                    $timthumb_params = "&q=100&w={$custom_size}";
                    if ($custom_size_square == 'true') {
                        $timthumb_params .= "&h={$custom_size}";
                    }
                } else {
                    $timthumb_params = "&q=100&h={$custom_size}";
                    if ($custom_size_square == 'true') {
                        $timthumb_params .= "&w={$custom_size}";
                    }
                }
            } else {
                $timthumb_script = "";
                $timthumb_params = "";
            }
            $disp_gallery .= "<img title='{$photo['title']}' src='{$timthumb_script}{$photo_url}{$timthumb_params}' alt='{$photo_title_text}'/>";
            if ($slideshow_option != 'none') {
                $disp_gallery .= "</a>";
            }
            if ($size_heading_map[$photo_size] && $photo_title == 'on') {
                if ($group_id || $gallery_id) {
                    $owner_title = "- by <a href='https://www.flickr.com/photos/{$photo['owner']}/' target='_blank'>{$photo['ownername']}</a>";
                } else {
                    $owner_title = '';
                }
                $disp_gallery .= "<div class='afg-title'>{$p_title} {$owner_title}</div>";
            }
            if ($photo_descr == 'on' && $photo_size != '_s' && $photo_size != '_t') {
                $disp_gallery .= "<div class='afg-description'>" . $photo['description']['_content'] . "</div>";
            }
        } else {
            if ($pagination == 'on' && $slideshow_option != 'none') {
                if ($slideshow_option == 'highslide') {
                    $photo_url = afg_get_photo_url($photo['farm'], $photo['server'], $photo['id'], $photo['secret'], '_s');
                } else {
                    $photo_url = '';
                }
                if ($slideshow_option == 'highslide') {
                    $photo_src_text = "src='{$photo_url}'";
                } else {
                    $photo_src_text = "";
                }
                $disp_gallery .= "<a style='display:none' {$class} {$rel} {$click_event} href='{$photo_page_url}'" . " title='{$photo['title']}'>" . " <img class='afg-img' alt='{$photo_title_text}' {$photo_src_text} width='75' height='75'></a> ";
            }
        }
        $photo_count += 1;
    }
    // Pagination
    if ($pagination == 'on' && $total_pages > 1) {
        $disp_gallery .= "<div class='afg-pagination'>";
        if ($cur_page == 1) {
            $disp_gallery .= "<span>&#171; prev </span>";
            $disp_gallery .= "<span class='afg-cur-page'> 1 </span>";
        } else {
            $prev_page = $cur_page - 1;
            $disp_gallery .= "<a href='{$cur_page_url}{$url_separator}afg{$id}_page_id={$prev_page}#afg-{$id}' title='Prev Page'>&nbsp;&#171; prev </a>&nbsp;&nbsp;&nbsp;&nbsp;";
            $disp_gallery .= "<a href='{$cur_page_url}{$url_separator}afg{$id}_page_id=1#afg-{$id}' title='Page 1'> 1 </a>&nbsp;";
        }
        if ($cur_page - 2 > 2) {
            $start_page = $cur_page - 2;
            $end_page = $cur_page + 2;
            $disp_gallery .= " ... ";
        } else {
            $start_page = 2;
            $end_page = 6;
        }
        for ($count = $start_page; $count <= $end_page; $count += 1) {
            if ($count > $total_pages) {
                break;
            }
            if ($cur_page == $count) {
                $disp_gallery .= "<span>{$count}</span>";
            } else {
                $disp_gallery .= "<a href='{$cur_page_url}{$url_separator}afg{$id}_page_id={$count}#afg-{$id}' title='Page {$count}'>&nbsp;{$count} </a>&nbsp;";
            }
        }
        if ($count < $total_pages) {
            $disp_gallery .= " ... ";
        }
        if ($count <= $total_pages) {
            $disp_gallery .= "<a href='{$cur_page_url}{$url_separator}afg{$id}_page_id={$total_pages}#afg-{$id}' title='Page {$total_pages}'>&nbsp;{$total_pages} </a>";
        }
        if ($cur_page == $total_pages) {
            $disp_gallery .= "<span>next &#187;</span>";
        } else {
            $next_page = $cur_page + 1;
            $disp_gallery .= "<a class='afg-page' href='{$cur_page_url}{$url_separator}afg{$id}_page_id={$next_page}#afg-{$id}' title='Next Page'> next &#187; </a>";
        }
        $disp_gallery .= "<br />({$total_photos} Photos)";
        $disp_gallery .= "</div>";
    }
    if ($credit_note == 'on') {
        $disp_gallery .= "<div class='afg-credit'>Powered by " . "<a href='http://www.ronakg.com/projects/awesome-flickr-gallery-wordpress-plugin'" . "title='Awesome Flickr Gallery by Ronak Gandhi'/>AFG</a>";
        $disp_gallery .= "</div>";
    }
    $disp_gallery .= "</div>";
    return $disp_gallery;
}