Exemplo n.º 1
0
function scoper_log_init_action()
{
    define('INIT_ACTION_DONE_RS', true);
    require_once dirname(__FILE__) . '/db-config_rs.php';
    $func = "require('" . dirname(__FILE__) . "/db-config_rs.php');";
    add_action('switch_blog', create_function('', $func));
    if (is_admin()) {
        scoper_load_textdomain();
    } elseif (defined('XMLRPC_REQUEST')) {
        require_once dirname(__FILE__) . '/xmlrpc_rs.php';
    }
}
 function apply_teaser(&$object, $src_name, $object_type, $args = '')
 {
     $defaults = array('col_excerpt' => '', 'col_content' => '', 'excerpt_teaser' => '', 'col_id' => '', 'teaser_prepend' => '', 'teaser_append' => '', 'teaser_replace' => '', 'more_teaser' => '', 'x_chars_teaser' => '');
     $args = array_merge($defaults, (array) $args);
     extract($args);
     global $scoper;
     if (is_array($object)) {
         $id = $object['ID'];
     } else {
         $id = $object->ID;
     }
     $object->scoper_teaser = true;
     $scoper->teaser_ids['post'][$id] = true;
     if (!empty($object->post_password)) {
         $excerpt_teaser[$object_type] = false;
         $more_teaser[$object_type] = false;
         $x_chars_teaser[$object_type] = false;
     }
     if (!empty($x_chars_teaser[$object_type])) {
         $num_chars = defined('SCOPER_TEASER_NUM_CHARS') ? SCOPER_TEASER_NUM_CHARS : 50;
     }
     // Content replacement mode is applied in the following preference order:
     // 1. Custom excerpt, if available and if selected teaser mode is "excerpt", "excerpt or more", or "excerpt, pre-more or first x chars"
     // 2. Pre-more content, if applicable and if selected teaser mode is "excerpt or more", or "excerpt, pre-more or first x chars"
     // 3. First X Characters (defined by SCOPER_TEASER_NUM_CHARS), if total content is longer than that and selected teaser mode is "excerpt, pre-more or first x chars"
     $teaser_set = false;
     $use_excerpt_suffix = true;
     // optionally, use post excerpt as the hidden content teaser instead of a fixed replacement
     if (!empty($excerpt_teaser[$object_type]) && !empty($object->post_excerpt)) {
         $object->post_content = $object->post_excerpt;
     } elseif (!empty($more_teaser[$object_type]) && ($more_pos = strpos($object->post_content, '<!--more-->'))) {
         $object->post_content = substr($object->post_content, 0, $more_pos + 11);
         $object->post_excerpt = $object->post_content;
         if (is_single() || is_page()) {
             $object->post_content .= '<p class="scoper_more_teaser">' . $teaser_replace[$object_type]['post_content'] . '</p>';
         }
         // since no custom excerpt or more tag is stored, use first X characters as teaser - but only if the total length is more than that
     } elseif (!empty($x_chars_teaser[$object_type]) && !empty($object->post_content) && strlen(strip_tags($object->post_content)) > $num_chars) {
         scoper_load_textdomain();
         // otherwise this is only loaded for wp-admin
         // since we are stripping out img tag, also strip out image caption applied by WP
         $object->post_content = preg_replace("/\\[caption.*\\]/", '', $object->post_content);
         $object->post_content = str_replace("[/caption]", '', $object->post_content);
         $object->post_content = sprintf(_x('%s...', 'teaser suffix', 'scoper'), substr(strip_tags($object->post_content), 0, $num_chars));
         $object->post_excerpt = $object->post_content;
         if (is_single() || is_page()) {
             $object->post_content .= '<p class="scoper_x_chars_teaser">' . $teaser_replace[$object_type]['post_content'] . '</p>';
         }
     } else {
         if (isset($teaser_replace[$object_type]['post_content'])) {
             $object->post_content = $teaser_replace[$object_type]['post_content'];
         } else {
             $object->post_content = '';
         }
         // Replace excerpt with a user-specified fixed teaser message,
         // but only if since no custom excerpt exists or teaser options aren't set to some variation of "use excerpt as teaser"
         if (!empty($teaser_replace[$object_type]['post_excerpt'])) {
             $object->post_excerpt = $teaser_replace[$object_type]['post_excerpt'];
         } else {
             $object->post_excerpt = '';
         }
         // If SCOPER_FORCE_EXCERPT_SUFFIX is defined, use the "content" prefix and suffix only when fully replacing content with a fixed teaser
         $use_excerpt_suffix = false;
     }
     // Deal with ambiguity in teaser settings.  Previously, content prefix/suffix was applied even if RS substitutes the excerpt as displayed content.
     // To avoid confusion with existing installations, only use excerpt prefix/suffix if a value is set or constant is defined.
     if ($use_excerpt_suffix && defined('SCOPER_FORCE_EXCERPT_SUFFIX')) {
         $teaser_prepend[$object_type]['post_content'] = $teaser_prepend[$object_type]['post_excerpt'];
         $teaser_append[$object_type]['post_content'] = $teaser_append[$object_type]['post_excerpt'];
     }
     foreach ($teaser_prepend[$object_type] as $col => $entry) {
         if (isset($object->{$col})) {
             $object->{$col} = $entry . $object->{$col};
         }
     }
     foreach ($teaser_append[$object_type] as $col => $entry) {
         if (isset($object->{$col})) {
             if ($col == 'post_content' && !empty($more_pos)) {
                 // WP will strip off anything after the more comment
                 $object->{$col} = str_replace('<!--more-->', "{$entry}<!--more-->", $object->{$col});
             } else {
                 $object->{$col} .= $entry;
             }
         }
     }
     // no need to display password form if we're blocking content anyway
     if (!empty($object->post_password)) {
         $object->post_password = '';
     }
 }
 function filter_rss($text, $subject = 'content')
 {
     global $post;
     if (!empty($post) && !empty($post->scoper_teaser)) {
         return $text;
     }
     if ($post->post_status == 'private') {
         $feed_privacy = scoper_get_option('rss_private_feed_mode');
     } else {
         $feed_privacy = scoper_get_option('rss_nonprivate_feed_mode');
     }
     switch ($feed_privacy) {
         case RSS_FULL_CONTENT_RS:
             return $text;
         case RSS_EXCERPT_ONLY_RS:
             if ('content' == $subject) {
                 return apply_filters('the_excerpt_rss', get_the_excerpt(true));
             } else {
                 return $text;
             }
         default:
             if ($msg = scoper_get_option('feed_teaser')) {
                 if (defined('SCOPER_TRANSLATE_TEASER')) {
                     scoper_load_textdomain();
                     // otherwise this is only loaded for wp-admin
                     $msg = translate($msg, 'scoper');
                     if (!empty($msg) && !is_null($msg) && is_string($msg)) {
                         $msg = htmlspecialchars_decode($msg);
                     }
                 }
                 return $this->replace_feed_teaser_placeholder($msg);
             }
     }
     // end switch
 }