Skip to content

Instantly share code, notes, and snippets.

@roboter
Created September 4, 2013 13:29
Show Gist options
  • Save roboter/6436961 to your computer and use it in GitHub Desktop.
Save roboter/6436961 to your computer and use it in GitHub Desktop.
sape.php wordpress plugin widget
<?php
/*
Plugin Name: SapeFeed
Plugin URI:
Description: sape plugin
Version: 1.1.0
Author: RobbyRoboter
Author URI: http://www.begemotik.ee
*/
add_action('init', sape_widget_register);
// укажите ваш номер в сапе
$sape_user = 'Your SAPE ID HERE';
// укажите кодировку вашего блога
$sape_parameters['charset'] = 'UTF-8';
if (!defined('_SAPE_USER')){
define('_SAPE_USER', $sape_user);
}
require_once($_SERVER['DOCUMENT_ROOT'].'/'._SAPE_USER.'/sape.php');
function sape_widget_register()
{
//register_sidebar_widget('Sape Feed', 'sape_widget');
if ( function_exists( 'wp_register_sidebar_widget') )
wp_register_sidebar_widget( 'sape', 'Sape Feed', 'sape_widget' );
}
function sape_widget($args)
{
global $wpdb,$sape;
extract($args);
echo $before_widget;
echo $before_title;
echo 'друзья:';
echo $after_title;
echo '<ul><li>';
//$o['force_show_code'] = true; /// нужно передать параметром new SAPE_client($o);
$o['charset'] = 'UTF-8';
$o['force_show_code'] = true;
$o['verbose'] = true;
$sape = new SAPE_client($o);
echo $sape->return_links();
echo '</li></ul>';
echo $after_widget;
}
remove_filter('the_content', 'wptexturize');
add_filter('the_content', 'maxsite_sape_replace');
remove_filter('the_excerpt', 'wptexturize');
add_filter('the_excerpt', 'maxsite_sape_replace');
global $sape_user, $sape_context;
if ( !isset($sape_context) ) $sape_context = new SAPE_context($sape_parameters);
unset($sape_charset);
function maxsite_sape_replace($content) {
global $sape_context;
$content = $sape_context->replace_in_text_segment($content);
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment