Skip to content

Instantly share code, notes, and snippets.

@max-kk
Last active February 13, 2017 09:30
Show Gist options
  • Save max-kk/c12e1a858486f22e7f1e5d0054a2ae4c to your computer and use it in GitHub Desktop.
Save max-kk/c12e1a858486f22e7f1e5d0054a2ae4c to your computer and use it in GitHub Desktop.
Добавление тизера Sape в виджеты Wordpress (шорткод)
<?php
/*
Plugin Name: Sape Teaser for WordPress
Plugin URI: #
Description: Шорткод тизера Sape [sape_teaser block_id="564132" _SAPE_USER="13163sdfr4489fjf"]
Version: 1.0
Author: Max K
Author URI: http://maxim-kaminsky.com/ru/
*/
// Enable shortcodes in text widgets
add_filter('widget_text','do_shortcode');
add_shortcode('sape_teaser', 'render_sape_teaser564563');
function render_sape_teaser564563( $args ) {
if ( empty($args['block_id']) || empty($args['_SAPE_USER']) ) {
return;
}
defined('_SAPE_USER') || define('_SAPE_USER', $args['_SAPE_USER']);
require_once(ABSPATH .'/' ._SAPE_USER . '/sape.php');
//замените 'UTF-8' на 'windows-1251' если основная кодировка сайт windows-1251
$sape = new SAPE_client(array('charset' => 'UTF-8'));
return $sape->return_teasers_block( $args['block_id'] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment