Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: DK RSS Digest
- Plugin URI: http://dmkim1.bget.ru/
- Description: Plugin for RSS aggregation and autoposting
- Version: 4.44
- Author: Dmitriy Kim
- Author URI: http://dmkim1.bget.ru/
- License: GPL2
- Copyright 2013. Dmitriy Kim (email : dmkim1979@gmail.com)
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License, version 2, as
- published by the Free Software Foundation.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
- //------------------------------------ error handler
- function pubHandler($number, $message, $file, $line) {
- if (($number!=E_USER_ERROR) && ($number!=E_USER_WARNING))
- return;
- ob_start();
- echo '<h2>error occured</h2>';
- echo '<p>'.str_pad('error number: ',30,' ',STR_PAD_RIGHT).$number.'</p>';
- echo '<p>'.str_pad('error message: ',30,' ',STR_PAD_RIGHT).$message.'</p>';
- echo '<p>'.str_pad('error in file: ',30,' ',STR_PAD_RIGHT).$file.'</p>';
- echo '<p>'.str_pad('error in line: ',30,' ',STR_PAD_RIGHT).$line.'</p>';
- $s = ob_get_clean();
- $logfile = dirname(__FILE__).'/cronlog.txt';
- if (file_exists($logfile))
- $fh = fopen($logfile,'a');
- else
- $fh = fopen($logfile,'w');
- fwrite($fh, date('d.m.Y H:i:s ').$s);
- fclose($fh);
- };
- class Debugger {
- private static $_prepared = false;
- private static $_debugFile ='';
- private static $_buffer ='';
- //---------------------------------
- private static function isDebugFile() {
- return (bool)self::$_debugFile;
- }
- //---------------------------------
- private static function prepared() {
- if (self::$_prepared)
- return true;
- return false;
- }
- //--------------------------------- prepare file
- private static function prepare_file() {
- if (!file_exists(ROOT.DS.'logs'))
- mkdir (ROOT.DS.'logs');
- self::$_debugFile = ROOT.DS.'logs'.DS.'debugz.html';
- }
- //------------------------------------ output buffer
- private static function outputBuffer() {
- if (self::isDebugFile()) {
- if (!file_exists(self::$_debugFile))
- $f = fopen (self::$_debugFile,'w');
- else
- $f = fopen (self::$_debugFile,'w');
- fwrite($f, self::$_buffer);
- fclose($f);
- } else
- echo '<h2>debug information</h2><div style="font-family:courier new">'.self::$_buffer.'</div>';
- }
- //------------------------------------ error handler
- public static function errorHandler($number, $message, $file, $line) {
- if (($number!=E_USER_ERROR) && ($number!=E_USER_WARNING))
- return;
- ob_start();
- echo '<h2>error occured</h2>';
- echo '<p>'.str_pad('error number: ',30,' ',STR_PAD_RIGHT).$number.'</p>';
- echo '<p>'.str_pad('error message: ',30,' ',STR_PAD_RIGHT).$message.'</p>';
- echo '<p>'.str_pad('error in file: ',30,' ',STR_PAD_RIGHT).$file.'</p>';
- echo '<p>'.str_pad('error in line: ',30,' ',STR_PAD_RIGHT).$line.'</p>';
- $s = ob_get_clean();
- self::$_buffer .= nl2br($s);
- self::outputBuffer();
- }
- //----------------------------------- exception handler
- public static function exceptionHandler($exception) {
- ob_start();
- echo '<h2>exception occured</h2>';
- echo '<p>'.str_pad('exception code: ',30,' ',STR_PAD_RIGHT).$exception->getCode().'</p>';
- echo '<p>'.str_pad('exception message: ',30).$exception->getMessage().'</p>';
- echo '<p>'.str_pad('exception in file: ',30).$exception->getFile().'</p>';
- echo '<p>'.str_pad('exception in line: ',30).$exception->getLine().'</p>';
- //echo '<h3>exception trace</h3>';
- //echo '<pre>'.print_r($exception->getTrace(),true).'</pre>';
- $s = ob_get_clean();
- self::$_buffer .= nl2br($s);
- self::outputBuffer();
- }
- //----------------------------------- shutdown handler
- public static function shutdownHandler() {
- ob_start();
- $error = error_get_last();
- echo '<h2>script finished</h2>';
- echo 'error: <pre>'.print_r($error,true).'</pre>';
- $s = ob_get_clean();
- self::$_buffer .= nl2br($s);
- self::outputBuffer();
- }
- //--------------------------------- prepare debugger
- public static function prepare() {
- if (!defined('DEBUG_MODE') || (!DEBUG_MODE))
- return;
- if (self::prepared())
- return;
- error_reporting(E_ERROR | E_WARNING);
- ini_set('display_errors','On');
- set_error_handler (array('Debugger','errorHandler'));
- set_exception_handler (array('Debugger','exceptionHandler'));
- register_shutdown_function (array('Debugger','shutdownHandler'));
- if (defined('DEBUG_FILE') && (DEBUG_FILE==true))
- self::prepare_file();
- self::$_buffer = '';
- self::$_prepared = true;
- }
- //--------------------------------- handle & write info
- public static function writeInfo($info, $className, $method) {
- if (!defined('DEBUG_MODE') || (!DEBUG_MODE))
- return;
- self::prepare();
- $s = str_repeat('-',50)."\r\n";
- $s .= date('d.m.Y H:i:s').' class: '.$className.' method: '.$method. "\r\n";
- $s .= str_repeat('-',50)."\r\n";
- $inf = array();
- if (!is_array($info)) {
- $inf[] = $info;
- } else
- $inf = $info;
- $s .= '<pre>'.print_r($inf, true).'</pre>';
- self::$_buffer .= nl2br($s);
- }
- }
- //--------------------------------------------------------
- define ('DS',DIRECTORY_SEPARATOR);
- define ('ROOT', dirname(__FILE__));
- //define ('DEBUG_MODE', true);
- //define ('DEBUG_FILE', true);
- Debugger::prepare();
- //--------------------------------------------------------
- class DKRSSDigest {
- private $wp_url;
- private $wp_dir;
- private $plugin_url;
- private $plugin_dir;
- private $template_url;
- private $template_dir;
- private $stylesheet_url;
- private $stylesheet_dir;
- private $upload_url;
- private $upload_dir;
- private $wp_charset;
- private $wp_version;
- private $ajax_url;
- private $_options;
- //---------------------------- debug information
- protected function _w($info, $method) {
- $className = get_class($this);
- Debugger::writeInfo($info, $className, $method);
- }
- //------------------------------------
- public function __construct() {
- $this->_options = get_option('dk_rss_digest_options');
- //register_activation_hook(__FILE__, array(&$this, 'install'));
- add_action('activate_dk_rss_digest/dk_rss_digest.php', array(&$this,'install'));
- register_deactivation_hook(__FILE__, array(&$this, 'uninstall'));
- add_action ('init', array(&$this,'dk_redir'));
- if ($this->_options['pub_register_custom_post']==1)
- add_action ('init', array(&$this,'dk_posttype'));
- add_action ('admin_init', array(&$this, 'dk_init'));
- add_action('plugins_loaded', array(&$this,'dk_plugins_loaded'));
- add_action ('admin_menu', array(&$this,'dk_register_admin_menu'));
- add_action('wp_ajax_rss-management',array(&$this,'dk_ajax_rss_management'));
- add_action('wp_ajax_post_types', array(&$this,'dk_ajax_post_types'));
- add_action('wp_ajax_taxz', array(&$this,'dk_ajax_taxz'));
- add_action('wp_ajax_catz', array(&$this,'dk_ajax_catz'));
- //add_filter('cron_schedules', array(&$this,'dk_schedule_intervals'));
- add_action('sc_check_feeds', array(&$this,'check_feeds'));
- //add_action('sc_check_feeds', array(&$this,'publish_posts'));
- }
- //------------------------------------------------------
- // cron_schedules
- //------------------------------------------------------
- public function dk_schedule_intervals($schedules) {
- $periods = $this->_options['pub_schedule_periods'];
- foreach ($periods as $period) {
- $schedules[$period.'days'] = array(
- 'interval' => 3600*24*$period,
- 'display' => __( $period.' days' )
- );
- }
- return $schedules;
- }
- //------------------------------------------------------
- // Plugin Activation
- //------------------------------------------------------
- public function install() {
- require_once(dirname(__FILE__).'/inc/rss.inc.php');
- $rss = new Rss();
- $rss->mk_tables();
- $default_options = array (
- 'pub_post_type' => 'post',
- 'pub_taxonomy' => 'category',
- 'pub_category' => 0,
- 'pub_register_custom_post'=> 0,
- 'pub_schedule_hooks'=>array()
- );
- add_option('dk_rss_digest_options', $default_options);
- wp_schedule_event( time(), 'hourly', 'sc_check_feeds');
- }
- //------------------------------------------------------
- // Plugin Deactivation
- //------------------------------------------------------
- public function uninstall() {
- wp_clear_scheduled_hook('sc_check_feeds');
- delete_option('dk_rss_digest_options');
- }
- //------------------------------------------------------
- // scheduled event [sc_check_feeds]
- //------------------------------------------------------
- public function check_feeds() {
- $prevh = set_error_handler("pubHandler");
- require_once(dirname(__FILE__).'/inc/rss.inc.php');
- $logfile = dirname(__FILE__).'/cronlog.txt';
- if (file_exists($logfile))
- $fh = fopen($logfile,'a');
- else
- $fh = fopen($logfile,'w');
- $rss = new Rss;
- $res = $rss->get_rsslines();
- foreach ($res as $line) {
- try {
- $s = $rss->update_rssline($line);
- fwrite ($fh,date('d.m.Y H:i:s ').$s."\r\n");
- } catch
- (Exception $e) {
- fwrite ($fh,date('d.m.Y H:i:s ').$e->getMessage()."\r\n");
- }
- }
- fclose ($fh);
- $this-> publish_posts();
- }
- //------------------------------------------
- // publich scheduled posts
- //------------------------------------------
- public function publish_posts() {
- $logfile = dirname(__FILE__).'/cronlog.txt';
- if (file_exists($logfile))
- $fh = fopen($logfile,'a');
- else
- $fh = fopen($logfile,'w');
- require_once(dirname(__FILE__).'/inc/base.inc.php');
- require (dirname(__FILE__).'/inc/classmap.php');
- foreach ($classmap as $incfile) {
- if (file_exists(dirname(__FILE__).'/inc/'.$incfile))
- require_once(dirname(__FILE__).'/inc/'.$incfile);
- }
- require_once (dirname(__FILE__).'/inc/app/digest.inc.php');
- require_once (dirname(__FILE__).'/inc/app/digestelement.inc.php');
- $injector = new Injector();
- $dbconn = new DBConn();
- $injector->set($dbconn);
- $dbmodel = new DBModel($injector);
- $injector->set($dbmodel);
- $model = new Digest($injector);
- //------------------------------------
- $hooks = $this->_options['pub_schedule_hooks'];
- foreach ($hooks as $key=>$value) {
- $inf = $model->getSingle($key);
- $period = $inf['digest_schedule_period'];
- fwrite ($fh, date('d.m.Y H:i:s ').'post '.$inf['digest_title'].' scheduled '.date('d.m.Y H:i',$hooks[$key])."\r\n");
- if (($value-time()<60*15) || (5==5)) {
- $model->publish($key);
- $hooks[$key] = strtotime("+".$period." days", $value);
- fwrite ($fh, date('d.m.Y H:i:s ').'post '.$inf['digest_title'].' published ');
- fwrite ($fh, ' next scheduled time: '. date('d.m.Y H:i',$hooks[$key])."\r\n");
- }
- }
- $this->_options['pub_schedule_hooks'] = $hooks;
- update_option('dk_rss_digest_options', $this->_options);
- fclose ($fh);
- }
- //------------------------------------------------------
- // init
- //------------------------------------------------------
- public function dk_redir() {
- $this->_w('hook triggered', __METHOD__);
- if( preg_match('/\/about\/?$/',$_SERVER['REQUEST_URI'])){
- $af = (dirname(__FILE__)).'/about.php';
- if (file_exists($af)) {
- include $af;
- exit;
- }
- }
- }
- //------------------------------------------------------
- // init
- //------------------------------------------------------
- public function dk_posttype() {
- $args = array( 'public' => true,
- 'labels' => array(
- 'name' => __( 'Digests' ),
- 'singular_name' => __( 'Digest' )
- ),
- 'has_archive' => true,
- 'supports'=> array('title','editor','author','excerpt','comments','thumbnail'),
- 'rewrite' => array('slug' => 'digest') );
- register_post_type( 'digest', $args );
- register_taxonomy(
- 'direction',
- 'digest',
- array(
- 'label' => __( 'Direction' ),
- 'rewrite' => array( 'slug' => 'direction' ),
- 'hierarchical' => true
- )
- );
- //flush_rewrite_rules();
- }
- //------------------------------------------------------
- // admin_init
- //------------------------------------------------------
- public function dk_init() {
- //global $pagenow, $current_screen;
- $this->_w('hook triggered', __METHOD__);
- $this->wp_url = home_url();
- $this->wp_dir = ABSPATH;
- $this->plugin_url = trailingslashit (WP_PLUGIN_URL .'/'.dirname(plugin_basename(__FILE__)));
- $this->plugin_dir = trailingslashit (WP_PLUGIN_DIR .'/'.dirname(plugin_basename(__FILE__)));
- $this->template_url = trailingslashit (get_template_directory_uri());
- $this->template_dir = trailingslashit (get_template_directory());
- $this->stylesheet_url = trailingslashit (get_stylesheet_directory_uri());
- $this->stylesheet_dir = trailingslashit (get_stylesheet_directory());
- $tmp = wp_upload_dir();
- $this->upload_url = trailingslashit ($tmp['baseurl']);
- $this->upload_dir = trailingslashit ($tmp['basedir']);
- $this->wp_charset = get_bloginfo('charset');
- $this->wp_version = get_bloginfo('version');
- $this->ajax_url = admin_url('admin-ajax.php', (is_ssl() ? 'https' : 'http'));
- //-------------------------------------------------
- add_settings_section('main_section',__('General settings'), array($this,'main_settings_section'),'dk-main-menu');
- add_settings_field('pub_post_type',__('Post type for publications'),array($this,'pub_post_type_setting'),
- 'dk-main-menu','main_section');
- add_settings_field('pub_taxonomy',__(''),array($this,'pub_taxonomy_setting'),'dk-main-menu','main_section');
- add_settings_field('pub_category',__('Category for publications'),array($this,'pub_category_setting'),
- 'dk-main-menu','main_section');
- add_settings_field('pub_register_custom_post',
- __('Register custom post type (Digests) for publications ?'),array($this,'pub_custom_post_setting'),
- 'dk-main-menu','main_section');
- register_setting('dk_rss_digest_options','dk_rss_digest_options', array($this,'validate_options'));
- //-------------------------------------------------
- if (isset($_GET['page']) && ($_GET['page']=='dk-rss-management')) {
- //wp_deregister_script('jquery');
- //wp_register_script('jquery',$this->plugin_url.'inc/jquery.min.js', false);
- //add_action('admin_print_scripts', array(&$this,'dk_inline_script'));
- add_action('admin_enqueue_scripts', array(&$this,'dk_scripts'));
- add_action('admin_print_styles', array(&$this,'dk_inline_style'));
- add_action('admin_head', array(&$this,'dk_inline_script'));
- }
- if (isset($_GET['page']) && ($_GET['page']=='dk-digest-management')) {
- add_action('admin_enqueue_scripts', array(&$this,'dk_scripts'));
- add_action('admin_print_styles', array(&$this,'dk_inline_style4'));
- add_action('admin_head', array(&$this,'dk_inline_script4'));
- }
- if (isset($_GET['page']) && ($_GET['page']=='dk-main-menu')) {
- add_action('admin_enqueue_scripts', array(&$this,'dk_scripts'));
- add_action('admin_head', array(&$this,'dk_inline_script5'));
- }
- }
- //------------------------------------------------------
- // plugins_loaded
- //------------------------------------------------------
- public function dk_plugins_loaded() {
- $this->_w('hook triggered', __METHOD__);
- if (is_admin()) {
- //load_plugin_textdomain('dk_rss', $this->plugin_dir.'lang/');
- }
- }
- //------------------------------------------------------
- // admin_enqueue_scripts
- //------------------------------------------------------
- public function dk_scripts() {
- $this->_w('hook triggered', __METHOD__);
- wp_enqueue_script('jquery');
- }
- //------------------------------------------------------
- // admin_head (dk-rss-management)
- //------------------------------------------------------
- public function dk_inline_script() {
- $this->_w('hook triggered', __METHOD__);
- $ajax_nonce = wp_create_nonce('rss-test88');
- ?>
- <script type="text/javascript">
- jQuery(document).ready(init);
- ajax_get='';
- ajax_post='';
- //------------------------------------------
- function init() {
- //-------------------
- jQuery('#dkrss_container a[rel^="_"], #dkrss_container input:button[rel^="_"]').unbind('click').click ( function(ev) {
- var ev = ev || event;
- if (jQuery(this).get(0).tagName=='A')
- if (jQuery(this).get(0).hasAttribute("rel")) {
- jQuery(this).prev().attr('checked','checked');
- }
- //--------------------------------
- if (this.hasAttribute('lnname'))
- var line_name = this.getAttribute('lnname');
- else
- var line_name = '';
- //--------------------------------
- if (this.hasAttribute('pg'))
- var page_id = this.getAttribute('pg');
- else
- var page_id = 'z';
- //--------------------------------
- if (!ajax_get)
- ajax_get = new Ajax_get();
- ajax_get.query(jQuery(this).attr('rel').slice(1), line_name, page_id);
- if (ev.preventDefault)
- ev.preventDefault();
- else
- ev.returnValue = false;
- });
- //-------------------
- jQuery('#dkrss_container form').filter(
- function(index) {
- return (this.hasAttribute('rel')) && (jQuery(this).attr('rel').substr(0,1)=='_');})
- .unbind('submit')
- .submit( function(ev) {
- var ev = ev || event;
- if (!ajax_post)
- ajax_post = new Ajax_post();
- var data8 = {};
- jQuery(this).find('input[name]').each (
- function(i) {
- data8[this.name]=this.value;
- }
- );
- jQuery.when (ajax_post.query(jQuery(this).attr('rel').slice(1), data8))
- .done(function(){updateState();});
- if (ev.preventDefault)
- ev.preventDefault();
- else
- ev.returnValue = false;
- });
- //----------------------------------
- jQuery('#dkrss_contentheader').unbind().ajaxStart(
- function() {
- jQuery(this).html('ajax request started...');
- }
- );
- //----------------------------------
- jQuery('#dkrss_contentheader').unbind().ajaxStop(
- function() {
- jQuery(this).html('ajax request finished');
- }
- );
- //----------------------------------
- };
- //------------------------------------------
- Ajax_get = function () {
- var _self = this;
- //----------------------
- this.onSuccess = function(inf, status, xhr) {
- jQuery('#dkrss_ajaxblock').empty().html(inf);
- init();
- }
- //----------------------
- this.onError = function(xhr, status, exception) {
- var inf = [];
- inf.push ('ajaxResponse: <pre>'+xhr.responseText+'</pre>');
- inf.push ('status: '+xhr.status);
- inf.push ('ready state: '+xhr.readyState);
- inf.push ('text status: '+status);
- inf.push ('exception: '+exception);
- s = inf.join('<br/>');
- jQuery('#dkrss_ajaxblock').empty().html(s);
- }
- //----------------------
- this.query = function (action, line_name, page_id) {
- var line_name = line_name || jQuery('#lineform input:radio:checked').val();
- var data = {
- action: 'rss-management',
- security: '<?php echo $ajax_nonce; ?>',
- action4: action,
- line_name: line_name
- };
- if (!isNaN(page_id)) {
- data['page'] = page_id
- }
- return jQuery.ajax ( {
- type: 'GET',
- url: "<?php echo $this->ajax_url; ?>",
- data: data,
- success: _self.onSuccess,
- error: _self.onError
- })
- }
- };
- //------------------------------------------
- Ajax_post = function () {
- var _self = this;
- //----------------------
- this.onSuccess = function (inf, status, xhr) {
- jQuery('#dkrss_ajaxblock').empty().html(inf);
- }
- //----------------------
- this.onError = function (xhr, status, exception) {
- var inf = [];
- inf.push ('ajaxResponse: <pre>'+xhr.responseText+'</pre>');
- inf.push ('exception: '+exception);
- s = inf.join('<br/>');
- jQuery('#dkrss_ajaxblock').empty().html(s);
- }
- //----------------------
- this.query = function (action, data) {
- return jQuery.ajax ( {
- type: 'POST',
- url: "<?php echo $this->ajax_url; ?>" +'?action=rss-management&action4='+action+
- '&security=<?php echo $ajax_nonce; ?>',
- data : data,
- success: _self.onSuccess,
- error: _self.onError
- });
- }
- }
- //-------------------------------------------------
- function updateState() {
- var addr = '<?php echo $this->ajax_url; ?>';
- jQuery.when (jQuery.get( addr, {action:'rss-management',action4: 'show_rsslines',
- security: '<?php echo $ajax_nonce ?>'})).done(
- function(tx) {
- jQuery('#dkrss_twitlines').empty().html(tx);
- init();
- }
- )
- }
- </script>
- <?php
- }
- //------------------------------------------------------
- // admin_head (dk-digest-management)
- //------------------------------------------------------
- public function dk_inline_script4() {
- $ajax_url8 = $this->plugin_url.'inc/ajax_ind4.php';
- $ajax_nonce = wp_create_nonce('digest-test88');
- ?>
- <script type="text/javascript">
- var gl_current_digest = 0;
- //-----------------------------------------
- function init() {
- jQuery('#all_ajax_status').ajaxStart( function() {
- jQuery(this).html('Request started, Please wait...');
- });
- //--------------------
- jQuery('#all_ajax_status').ajaxStop( function() {
- jQuery(this).html('Request finished.');
- });
- //--------------------
- jQuery('#all_ajax_status').ajaxSend( function (ev, xhr, options) {
- jQuery(this).html('Request sent, status:'+xhr.status);
- });
- //--------------------
- jQuery('#all_ajax_status').ajaxSuccess (function( ev, xhr, options) {
- jQuery(this).html('Request success, status:'+xhr.status+', readystate:'+xhr.readyState);
- jQuery(options.statusblock).html('');
- });
- //--------------------
- jQuery('#all_ajax_status').ajaxError( function( ev, xhr, options, err) {
- jQuery(this).html('Error occured: '+err+', status:'+xhr.status);
- jQuery(options.statusblock).html('error occured :'+err);
- jQuery(options.targetblock).html('response: '+xhr.responseText+'<br/>'+
- ' xhr status:'+xhr.status+'<br/>xhr ready state:'+xhr.readyState+'<br/>');
- });
- //--------------------
- jQuery('#all_ajax_status').ajaxComplete( function( ev, xhr, options) {
- });
- }
- //-----------------------------------------
- function ajaxBeforeSend (xhr, options) {
- jQuery(options.statusblock).html('request started, please wait...');
- }
- //-----------------------------------------
- function ajaxSuccess (target_block) {
- return function(inf, status, xhr) {
- jQuery(target_block).html(inf);
- redir_links(target_block);
- if (target_block=='#digests_ajax')
- master_detail_events(target_block);
- }
- }
- //-----------------------------------------
- function ajaxError (xhr, status, err) {
- }
- //-----------------------------------------
- function ajaxComplete (xhr, status) {
- }
- //-----------------------------------------
- function master_detail_events(target_block) {
- jQuery('.entrytitle a',jQuery(target_block)).unbind('click').click(
- function() {
- var re = /digest_id=(\d+)/;
- var zid = re.exec(this.href);
- gl_current_digest = zid[1];
- ajax_request('#digests_details_ajax_info',
- '#digests_details_ajax', "<?php echo $ajax_url8; ?>?controller=digestelements&filterdigestelements="+
- encodeURIComponent('digest_id='+gl_current_digest));
- return false;
- }
- )
- jQuery('.entrytitle a',jQuery(target_block)).eq(0).trigger('click');
- }
- //-----------------------------------------
- function redir_links(target_block) {
- jQuery('a',target_block).click( function() {
- var route = jQuery(this).attr('href')
- if (target_block=='#digests_details_ajax')
- route += "&filterdigestelements="+encodeURIComponent('digest_id='+gl_current_digest);
- if (this.innerHTML=='publish') {
- var dt = new Date();
- var defstr = dt.getFullYear()+'-'+(dt.getMonth()+1)+'-'+dt.getDate();
- var s = prompt("Enter publishing date", defstr );
- if ((s==null) || (s=="")) {
- s =defstr;
- }
- route +='&pubdate='+s;
- }
- ajax_request(target_block+'_info', target_block, route );
- return false;
- });
- jQuery('input:hidden[name=digest_id]').attr('value', gl_current_digest);
- var frm =jQuery('form',target_block);
- if (frm.length>0) {
- var events = frm.data("events");
- var fnz = events.submit[0]['handler'];
- frm.unbind('submit', events.submit[0]);
- }
- jQuery('form',target_block).bind('submit', function() {
- if (fnz.call(this)==false)
- return false;
- var data = {};
- jQuery(this).find('input[name],select[name],textarea[name]').each(
- function(ind, el4) {
- data[el4.name] = el4.value;
- })
- if (target_block=='#digests_details_ajax')
- this.action += "&filterdigestelements="+encodeURIComponent('digest_id='+gl_current_digest);
- ajax_request(target_block+'_info', target_block, this.action, 'POST', data);
- return false;
- });
- jQuery('input:button[name="cancel"]',target_block).attr('onclick','').click( function() {
- var route = jQuery(this).parent().find('input:hidden[name="cancelroute"]').attr('value');
- if (target_block=='#digests_details_ajax')
- route += "&filterdigestelements="+encodeURIComponent('digest_id='+gl_current_digest);
- ajax_request(target_block+'_info', target_block, route);
- return false;
- });
- }
- //-----------------------------------------
- function ajax_request(status_block, target_block, inurl, intype, indata) {
- var intype = intype || 'GET';
- var indata = indata || {};
- indata['security']='<?php echo $ajax_nonce; ?>';
- jQuery.ajax ( {
- url: inurl,
- type: intype,
- data: indata,
- dataType: 'html',
- statusblock: status_block,
- targetblock: target_block,
- beforeSend: ajaxBeforeSend,
- success: ajaxSuccess(target_block),
- error: ajaxError,
- complete: ajaxComplete
- })
- }
- //-----------------------------------------
- jQuery(document).ready ( function() {
- init();
- ajax_request('#digests_ajax_info', '#digests_ajax', "<?php echo $ajax_url8; ?>?controller=digests");
- });
- </script>
- <?php
- }
- //------------------------------------------------------
- // admin_head (dk-main-menu)
- //------------------------------------------------------
- public function dk_inline_script5() {
- ?>
- <script type="text/javascript">
- jQuery(document).ready (
- function() {
- //----------------------------------
- var handler = function() {
- var value4 = jQuery(this).val();
- jQuery.ajax ( {
- url: "<?php echo $this->ajax_url;?>", type: 'POST', dataType: 'html',
- data: {action: 'taxz', ptype: value4 },
- success: function(inf) {
- jQuery('#tax_sel_inp').replaceWith(inf);
- }});
- jQuery('#cat_sel_inp').attr('disabled',true);
- jQuery.ajax ( {
- url: "<?php echo $this->ajax_url;?>", type: 'POST', dataType: 'html',
- data: {action: 'catz', ptype: value4 },
- success: function(inf) {
- jQuery('#cat_sel_inp').replaceWith(inf);
- }});
- }
- //----------------------------------
- jQuery('input[name="dk_rss_digest_options[pub_register_custom_post]"]').change(
- function() {
- var value4 = jQuery(this).val();
- jQuery.ajax ( {
- url: "<?php echo $this->ajax_url;?>", type: 'POST', dataType: 'html',
- data: {action: 'post_types', reg_post: value4 },
- success: function(inf) {
- //var events = jQuery(this).data("events");
- //jQuery('#post_type_sel_inp').unbind('change', events.change[0]);
- jQuery('#post_type_sel_inp').replaceWith(inf);
- jQuery('#post_type_sel_inp').bind('change', handler);
- jQuery('#post_type_sel_inp').trigger('change');
- }});
- });
- //----------------------------------
- jQuery('#post_type_sel_inp').bind('change', handler);
- //----------------------------------
- })
- </script>
- <?php
- }
- //------------------------------------------------------
- // admin_print_styles (dk-rss-management)
- //------------------------------------------------------
- public function dk_inline_style() {
- $this->_w('hook triggered', __METHOD__);
- ?>
- <style type="text/css">
- #dkrss_container ul {
- list-style-type: none;
- }
- #dkrss_container a {
- color:inherit;
- }
- #dkrss_container {
- width: 90%;
- margin: 0 auto;
- font-family: verdana, helvetica, sans-serif;
- font-size: 1em;
- }
- #dkrss_header {
- height: 200px;
- /*background: #800;
- color: white;*/
- position:relative;
- }
- #dkrss_sidebar {
- float:left;
- width: 300px;
- padding: 20px 0 0 0;
- }
- #dkrss_twitlines li {
- height: 1.5em;
- line-height:1.5em;
- border-bottom: dotted 1px;
- }
- #dkrss_twitlines input[type=radio] {
- width:50px;
- }
- #dkrss_twitlines li a {
- text-decoration: none;
- }
- #dkrss_container .controls {
- overflow: auto;
- margin: 10px 0 0 0;
- padding: 0 0 20px 0;
- }
- #dkrss_container .controls li {
- float:left;
- margin-top: 5px;
- margin-right:10px;
- border: solid 1px #500;
- border-radius: 10px;
- background: #ffe;
- padding: 5px 10px;
- /*font-size: 0.75em;*/
- }
- #dkrss_container .controls li a {
- text-decoration: none;
- }
- #dkrss_container .controls li a:hover {
- text-decoration: underline;
- }
- #dkrss_content {
- margin-left: 320px;
- }
- #dkrss_contentheader {
- height: 0px;
- /*background: #400;*/
- color: white;
- }
- #dkrss_ajaxblock {
- border: dotted 1px #888;
- }
- #dkrss_footer {
- height: 50px;
- background: #444;
- clear:left;
- }
- /*-------------------------*/
- #dkrss_container .twitfeed {
- font-size: 0.75em;
- }
- #dkrss_container .twitfeed li {
- overflow: auto;
- margin-top: 5px;
- position: relative;
- border-bottom: dotted 1px #888;
- padding-bottom: 3px;
- padding-right: 160px;
- }
- #dkrss_container .twitfeed li a {
- text-decoration: none;
- color: #800;
- }
- #dkrss_container .twitid {
- display:none;
- }
- #dkrss_container .twittitle {
- line-height:1.5;
- }
- #dkrss_container .twitdesc {
- width:60%;
- float:left;
- margin-right:5px;
- }
- #dkrss_container .twitlink {
- float: left;
- font-size: 10px;
- width: 39%;
- word-wrap: break-word;
- }
- li .twitlink a {
- color: #999;
- }
- #dkrss_container .twitpubdate {
- position:absolute;
- right:0;
- bottom:0;
- background: #ffe;
- border: solid 1px #f5f5f5;
- color: #555;
- padding: 0 10px;
- width: 130px;
- border-radius: 5px;
- -moz-border-radius: 5px;
- -webkit-border-radius: 5px;
- }
- #dkrss_container .pager {
- overflow: auto;
- padding: 10px 0 15px 0;
- }
- #dkrss_container .pager li {
- float:left;
- margin: 0 5px 4px 0;
- border: solid 1px #500;
- border-radius: 10px;
- -moz-border-radius: 10px;
- -webkit-border-radius: 10px;
- background: #ffe;
- font-size:0.75em;
- overflow:hidden;
- }
- #dkrss_container .pager li a {
- display:block;
- height: 100%;
- padding: 0.5em 10px;
- text-decoration: none;
- }
- #dkrss_container .pager li a:hover {
- background: #444;
- color: white;
- }
- /*-------------------------*/
- #dkrss_container form {
- overflow: auto;
- padding: 5px;
- margin:5px;
- }
- #dkrss_container form p {
- }
- #dkrss_container form input[type=text] {
- margin-left:20px;
- }
- #dkrss_container form input[type=button],
- #dkrss_container form input[type=submit],
- #dkrss_container form input[type=reset] {
- display:block;
- float: left;
- margin: 5px 5px 0 0;
- padding: 5px 8px;
- background: #f0f0f0;
- cursor:pointer;
- border: solid 1px #444;
- border-radius: 10px;
- -moz-border-radius: 10px;
- -webkit-border-radius: 10px;
- }
- #dkrss_container form input[type=submit] {
- clear: left;
- }
- </style>
- <?php
- }
- //------------------------------------------------------
- // admin_print_styles (dk-digest-management)
- //------------------------------------------------------
- public function dk_inline_style4() {
- ?>
- <style type="text/css">
- #dkdigest_container {
- font-family: verdana, sans-serif;
- font-size:100%;
- }
- #dkdigest_container #container {
- width:1000px;
- margin:0 auto;
- }
- #dkdigest_container .header {
- display: none;
- }
- #dkdigest_container .content {
- float:left;
- width:1100px;
- margin-bottom: 5px;
- margin-top: 20px;
- }
- #dkdigest_container .page {
- float:left;
- }
- #dkdigest_container .page>div {
- float:left;
- margin:0 0 0;
- height: 30px;
- width: 130px;
- padding: 4px 10px;
- border: solid 1px #aaa;
- border-left: none;
- font-size: 12px;
- }
- #dkdigest_container div.entrytitle {
- margin-top: 0;
- font-size:1.2em;
- font-weight:bold;
- width:200px;
- height:30px;
- line-height:30px;
- text-align:center;
- background: #eee;
- border-radius:10px;
- -moz-border-radius:10px;
- -webkit-border-radius:10px;
- float: left;
- clear:left;
- padding: 4px 50px;
- }
- #dkdigest_container .page>div.caption {
- border-bottom: none;
- }
- #dkdigest_container div.caption:first-child {
- width: 200px;
- padding: 4px 50px;
- }
- #dkdigest_container .entrytitle a {
- color:#999;
- text-decoration: none;
- }
- #dkdigest_container .entrytitle a:hover {
- color:#555;
- }
- #dkdigest_container .entryeditpanel {
- margin-top:10px;
- overflow:hidden;
- /*position: relative;*/
- top: -40px;
- height: 80px!important;
- }
- #dkdigest_container .entryeditpanel>div {
- margin-top:4px;
- }
- #dkdigest_container .editpanel {
- overflow:hidden;
- }
- #dkdigest_container .editbutton,
- #dkdigest_container .deletebutton,
- #dkdigest_container .addbutton,
- #dkdigest_container .backtolistbutton {
- background:#ff9;
- font-weight:bold;
- font-size: 12px;
- text-align:center;
- padding:1px 10px;
- margin-right:5px;
- border: solid 2px #800;
- -moz-border-radius: 8px;
- -webkit-border-radius: 8px;
- border-radius: 8px;
- float:left;
- }
- #dkdigest_container .editbutton a,
- #dkdigest_container .deletebutton a,
- #dkdigest_container .addbutton a,
- #dkdigest_container .backtolistbutton a{
- color:#c00;
- text-decoration: none;
- }
- #dkdigest_container .sidebar {
- display:none;
- }
- #dkdigest_container .footer {
- clear:both;
- background: #f0f0f0;
- padding:0;
- margin-bottom:20px;
- }
- #dkdigest_container div.clearfix {
- clear: left;
- width:0;
- height:0;
- padding:0;
- border:none;
- }
- #dkdigest_container .navigation {
- margin-top:4px;
- overflow: hidden;
- }
- #dkdigest_container .navigation ul {
- list-style-type:none;
- }
- #dkdigest_container .navigation li {
- float:left;
- margin-right: 5px;
- text-align:center;
- height:40px;
- line-height:40px;
- background: white;
- font-weight: bold;
- width: 40px;
- border: solid 1px #555;
- -moz-border-radius:4px;
- -webkit-border-radius:4px;
- }
- #dkdigest_container .navigation li a,
- #dkdigest_container .navigation li a:visited {
- text-decoration:none;
- color: #800;
- }
- #dkdigest_container .navigation li a:hover {
- text-decoration: underline;
- }
- #dkdigest_container form {
- padding:20px 40px 10px 20px;
- }
- #dkdigest_container fieldset {
- padding-top:10px;
- }
- #dkdigest_container legend {
- display: none;
- }
- #dkdigest_container label {
- display:block;
- float:left;
- clear:left;
- width:200px;
- margin-right:10px;
- margin-top: 5px;
- }
- #dkdigest_container input,
- #dkdigest_container select {
- display: block;
- border: solid 1px #aaa;
- border-radius: 4px;
- -moz-border-radius: 4px;
- -webkit-border-radius: 4px;
- padding:2px 5px;
- margin-top:5px;
- }
- #dkdigest_container input[type=text] {
- width:400px;
- }
- #dkdigest_container input[type=submit],
- #dkdigest_container input[type=button] {
- background:#ffa;
- float:left;
- border:solid 2px #a00;
- border-radius 8px;
- -moz-border-radius 8px;
- -webkit-border-radius 8px;
- color:#b00;
- cursor:pointer;
- padding:4px 20px;
- font-size:1em;
- margin-right:10px;
- margin-top:10px;
- }
- #dkdigest_container #all_ajax_status {
- display: none;
- }
- </style>
- <?php
- }
- //------------------------------------------------------
- // admin_menu
- //------------------------------------------------------
- public function dk_register_admin_menu() {
- $this->_w('hook triggered', __METHOD__);
- add_menu_page(__('DK RSS Digest Settings'), __('DK RSS Digest Settings'),
- 'activate_plugins','dk-main-menu', array(&$this,'dk_menu_page'));
- add_submenu_page('dk-main-menu', __('RSS setup'), __('RSS setup'),
- 'activate_plugins', 'dk-rss-management', array(&$this,'dk_rss_page'));
- add_submenu_page('dk-main-menu', __('Publishing'),__('Publishing'),
- 'activate_plugins', 'dk-digest-management', array(&$this,'dk_digest_page'));
- add_submenu_page('dk-main-menu', __('Help'),__('Help'),
- 'activate_plugins', 'dk-help', array(&$this,'dk_help'));
- }
- //------------------------------------------------------
- // settings_section [main_section]
- //------------------------------------------------------
- public function main_settings_section() {
- echo '<h3>'.__('DK RSS Digest Settings').'</h3>';
- }
- //------------------------------------------------------
- // settings_field [pub_post_type]
- //------------------------------------------------------
- public function pub_post_type_setting() {
- $excl = array('page','attachment','revision','nav_menu_item');
- if (isset($_POST['reg_post'])) {
- if ($_POST['reg_post']==1) {
- $this->dk_posttype();
- }
- else {
- array_push($excl, 'digest');
- }
- }
- $inf = get_post_types();
- $inf = array_diff($inf, $excl);
- echo '<select id="post_type_sel_inp" name="dk_rss_digest_options[pub_post_type]">';
- foreach ($inf as $ptype) {
- echo '<option value="'.$ptype.
- '" '.selected($this->_options['pub_post_type'],$ptype,false).' >'.$ptype.'</option>';
- }
- echo '</select>';
- }
- //------------------------------------------------------
- // settings_field [pub_taxonomy]
- //------------------------------------------------------
- public function pub_taxonomy_setting() {
- if (isset($_POST['ptype'])) {
- $this->dk_posttype();
- $ptype = $_POST['ptype'];
- $args = array('object_type'=>array($ptype));
- $output = 'names';
- $operator = 'and';
- $taxz = get_taxonomies($args, $output, $operator);
- $tax = reset($taxz);
- }
- else {
- $tax = $this->_options['pub_taxonomy'];
- }
- echo '<input id="tax_sel_inp" type="hidden" '.
- 'name="dk_rss_digest_options[pub_taxonomy]" value="'.
- $tax.'" />';
- }
- //------------------------------------------------------
- // settings_field [pub_category]
- //------------------------------------------------------
- public function pub_category_setting() {
- if (isset($_POST['ptype'])) {
- $this->dk_posttype();
- $ptype = $_POST['ptype'];
- $args = array('object_type'=>array($ptype));
- $output = 'names';
- $operator = 'and';
- $taxz = get_taxonomies($args, $output, $operator);
- $tax = reset($taxz);
- } else {
- $ptype = $this->_options['pub_post_type'];
- $tax = $this->_options['pub_taxonomy'];
- }
- $cats = get_categories('taxonomy='.$tax.'&type='.$ptype.'&hide_empty=0');
- echo '<select id="cat_sel_inp" name="dk_rss_digest_options[pub_category]">';
- foreach ($cats as $cat) {
- echo '<option value="'.$cat->term_id.
- '" '.selected($this->_options['pub_category'],$cat->term_id,false).' >'.$cat->name.'</option>';
- }
- echo '</select></div>';
- }
- //------------------------------------------------------
- // settings_field [pub_register_custom_post]
- //------------------------------------------------------
- public function pub_custom_post_setting() {
- echo '<input id="reg_custom_post" type="radio"
- name="dk_rss_digest_options[pub_register_custom_post]"
- value="1" '.checked($this->_options["pub_register_custom_post"],1,false).' /> Yes<br/>';
- echo '<input id="unreg_custom_post" type="radio"
- name="dk_rss_digest_options[pub_register_custom_post]"
- value="0" '.checked($this->_options["pub_register_custom_post"],0,false).' /> No<br/>';
- }
- //-----------------------------------------------------------------
- // main-settings-group [dk_rss_digest_options] validate
- //-----------------------------------------------------------------
- public function validate_options($input) {
- return $input;
- }
- //------------------------------------------------------
- // Menu Page [dk-main-menu]
- //------------------------------------------------------
- public function dk_menu_page() {
- $this->_w('hook triggered', __METHOD__);
- echo '<h3>DK RSS Digest</h3>';
- echo '<ul><li><a href="'.admin_url('admin.php?page=dk-rss-management').'">'.__('RSS management').'</a></li>';
- echo '<li><a href="'.admin_url('admin.php?page=dk-digest-management').'">'.__('Publishing management').'</a></li>';
- echo '<li><a href="'.admin_url('admin.php?page=dk-help').'">'.__('Help').'</a></li>';
- echo '</ul>';
- ?>
- <form action="options.php" method="post">
- <?php settings_fields( 'dk_rss_digest_options' ); ?>
- <?php do_settings_sections('dk-main-menu'); ?>
- <p class="submit">
- <input name="Submit" type="submit" value="<?php echo __('Save Changes'); ?>" />
- </p>
- </form>
- <?php
- }
- //------------------------------------------------------
- // Menu Page [dk-rss-management]
- //------------------------------------------------------
- public function dk_rss_page() {
- $this->_w('hook triggered', __METHOD__);
- require_once($this->plugin_dir.'inc/rss.inc.php');
- $rss = new Rss();
- //-----------
- ?>
- <div id="dkrss_container">
- <div id="dkrss_header">
- Here you can register RSS feeds you want use to create aggregations<br/>
- <ul><li> Click "add rss feed" and in appeared form fill the name and address of RSS feed
- (the "name" is the alias you will use later to relate to this feed). Submit the form</li>
- <li>If you want to retrieve RSS content immediately click "update RSS feed"
- then click the link with the name of feed at the left. You will see the latest retrieved content of the feed</li>
- <li>After you registered RSS feed its content will be retrieved automatically every hour and saved into WordPress database </li>
- <li>If you want to alter name or address of RSS feed select the feed you want to change at the left
- and click "edit rss feed". Make changes and submit the form</li>
- <li>To delete all retrieved content of RSS feed from WordPress database select the feed and click "clear rss feed" </li>
- <li>To delete RSS feed from the list of registered feeds select the feed and click "delete RSS feed"</li>
- </ul>
- </div>
- <div id="dkrss_sidebar">
- <div id="dkrss_twitlines">
- <?php try {echo $rss->show_rsslines();} catch (Exception $e) {echo $e->getMessage();} ?>
- </div>
- <div id="dkrss_controls">
- <?php try {echo $rss->show_controls();} catch( Exception $e) {echo $e->getMessage();} ?>
- </div>
- </div>
- <div id="dkrss_content">
- <div id="dkrss_contentheader">
- </div>
- <div id="dkrss_ajaxblock">
- </div>
- </div>
- <div id="dkrss_footer">
- </div>
- </div>
- <?php
- //-----------
- }
- //------------------------------------------------------
- // wp_ajax_rss-management
- //------------------------------------------------------
- public function dk_ajax_rss_management() {
- $this->_w('hook triggered', __METHOD__);
- if (!check_ajax_referer('rss-test88','security',false)) {
- _e('Failed to verify referer');
- exit();
- }
- require_once($this->plugin_dir.'inc/rss.inc.php');
- $action= (isset($_GET['action4'])) ? $_GET['action4'] : '';
- $line_name =(isset($_GET['line_name'])) ? $_GET['line_name'] : '';
- $rss = new Rss();
- if ($action) {
- echo $rss->$action($line_name);
- exit();
- }
- }
- //------------------------------------------------------
- // wp_ajax_post_types
- //------------------------------------------------------
- public function dk_ajax_post_types() {
- $this->pub_post_type_setting();
- exit();
- }
- //------------------------------------------------------
- // wp_ajax_taxz
- //------------------------------------------------------
- public function dk_ajax_taxz() {
- $this->pub_taxonomy_setting();
- exit();
- }
- //------------------------------------------------------
- // wp_ajax_catz
- //------------------------------------------------------
- public function dk_ajax_catz() {
- $this->pub_category_setting();
- exit();
- }
- //------------------------------------------------------
- // Menu Page [dk-digest-management]
- //------------------------------------------------------
- public function dk_digest_page() {
- @ini_set('display_errors',true);
- if (!empty($_POST['test_s']) && ($_POST['test_s']=="inf")) {
- $this->publish_posts();
- }
- else
- if (!empty($_POST['do_update'])) {
- check_admin_referer('add-test88');
- require_once($this->plugin_dir.'inc/base.inc.php');
- require ($this->plugin_dir.'inc/classmap.php');
- foreach ($classmap as $incfile) {
- if (file_exists($this->plugin_dir.'inc/'.$incfile))
- require_once($this->plugin_dir.'inc/'.$incfile);
- }
- require_once ($this->plugin_dir.'inc/app/digest.inc.php');
- $injector = new Injector();
- $dbconn = new DBConn();
- $injector->set($dbconn);
- $dbmodel = new DBModel($injector);
- $injector->set($dbmodel);
- $model = new Digest($injector);
- //------------------------------------
- $els = $model->getAll();
- //------------------------------------
- $hooks = array();
- echo '<h3>Elements scheduled for automatic publishing</h3>';
- echo '<ul>';
- foreach ($els as $el) {
- if ($el['digest_is_active']==1) {
- $tm = strtotime($el['digest_schedule_time']);
- if ($tm<time())
- $tm = strtotime("+1 days", $tm);
- $hooks[$el['digest_id']] = $tm;
- echo '<li>'.$el['digest_title'].' next publishing: '.date('d.m.Y H:i',$tm).'</li>';
- }
- }
- echo '</ul>';
- //------------------------------------
- $this->_options['pub_schedule_hooks']=$hooks;
- update_option('dk_rss_digest_options', $this->_options);
- }
- ?>
- <div id="dkdigest_container">
- <h3>List of schedules</h3>
- <div id="all_ajax_status"></div>
- <div id="digests_ajax_info"></div>
- <div id="digests_ajax"></div>
- <h3 id="current_digest">Schedule details</h3>
- <div id="digests_details_ajax_info"></div>
- <div id="digests_details_ajax"></div>
- <form name="savef" action="<?php echo admin_url('admin.php?page=dk-digest-management');?>" method="POST">
- <?php wp_nonce_field('add-test88'); ?>
- <input type="checkbox" name="test_s" value="inf" /> Test schedule<br/>
- <input type="submit" name="do_update" value="update schedule" />
- </form>
- </div>
- <?php
- }
- //------------------------------------------------------
- // Menu Page [dk-help]
- //------------------------------------------------------
- public function dk_help() {
- ?>
- <p>The plugin is contrived as tool for filling the WordPress blog automatically, using the content of various sites, provided through RSS feeds. Final output supposed to be some mixture of this information and plugin provides tools for gathering information, combining it in different ways and setting up the schedule for automatic publishings. For example it might be information about certain subject from the various news sites combined with comments about it from blogs or social networks supplemented with photos from somewhere else. Or you can setup the daily or weekly announcements about updates at number of interesting sites. By now the plugin is in an experimental stage and my objective here is to provide maximum flexibility in combining information so it could be used for wide range of tasks concerning aggregation. Any suggestions about improvements are welcome.</p>
- <p>After activating the plugin you will see two additional pages in WordPress admin menu. First named "RSS setup" allows you to register RSS feeds you are going to use. Each registered feed will be automatically scheduled for checks for updates. Checks for updates will be conducted each hour and retrieved information will be stored in your WordPress database. (This procedure will prevent you from missing some information in cases when the feed updates are much more frequent then your scheduled post updates. For example you publish some post every week and want to include into it the content of the feed for this period. Likely that the actual feed at this moment will not contain all information for such a long period especially if it has frequent or massive updates. Therefore plugin takes information saved beforehead into WordPress database instead)</p>
- <p>
- The second menu named "Publishing" purposed for assembling initial information from RSS feeds into form in which it will appear in WordPress posts and for scheduling automatic publishing. </p>
- <p>
- The setup of automatic publishing includes three steps.</p>
- <p>
- First you should register RSS feeds you want to get the content from. On the page "RSS setup" click link "add new feed". In the appeared form fill the name and address of the feed. The "name" is the alias which you will be using futher while assembling feeds for publishing. (It is only allowed to use alphanumeric characters or underscore in the "name") In the "address" field place actual url address of the feed. After submitting the form the RSS feed will be scheduled for checks for updates as mentioned above. Repeat the procedure for all feeds you want to use.
- </p>
- <img src="<?php echo $this->plugin_url.'help/1.png';?>" /><br/>
- <ul>
- <li>If you want to retrieve RSS content immediately click "update RSS feed"
- then click the link with the name of feed at the left. You will see the latest retrieved content of the feed</li>
- <li>After you registered RSS feed its content will be retrieved automatically every hour and saved into WordPress database </li>
- <li>If you want to alter name or address of RSS feed select the feed you want to change at the left
- and click "edit rss feed". Make changes and submit the form</li>
- <li>To delete all retrieved content of RSS feed from WordPress database select the feed and click "clear rss feed" </li>
- <li>To delete RSS feed from the list of registered feeds select the feed and click "delete RSS feed"</li>
- </ul>
- <p>
- At the second step you create the publishing schedule. Suppose you want to publish once a month content of certain photo blogs . Click the "Publishing". In the opened page you will see two tables. Upper table, containing schedule items, and lower, which contains the details for each schedule item, including information about what feeds will be included into post, in what order, the period of time for which the information will be retrieved for each feed, the html template for each feed.
- </p>
- <br/>
- <p>
- Click the "add" button below the upper table and in appeared form specify the name of schedule item and period of publishing. In our example these will be Publication title: "Photo Blogs" , Publishing period (days) : 30. You can also specify the time of day for publications
- and post type and category in which these publications will be posted.
- </p>
- <img src="<?php echo $this->plugin_url.'help/5.png';?>" /><br/>
- When you activate schedule element
- (you can do it during creation by assigning "Active" for "Is publication active field" or later by clicking "Activate" button)
- this element will be automatically scheduled for publishing according to its settings.<br/>
- Below the element you will see exact time when next publication will occur<br/>
- <img src="<?php echo $this->plugin_url.'help/3.png';?>" /><br/>
- <p>
- At the next step you will determine how the RSS content will be combined for publishing. <br/>
- In lower table "schedule details" you should create element for each RSS feed whose content you want include in the post.<br/>
- For each element you should specify the name of RSS feed (which you assigned while registering the feed)<br/>
- Specify the order ("Element order") in which content of this feed will be printed in post<br/>
- In field "Request period in days" specify the period for which feed content would be retrieved
- (starting back from the day of publication)<br/><br/>
- Specify the PHP template for processing the content. <br/>
- This template will be processed for each feed item.
- Using PHP will give you ability to perform complex operations on feed content.
- (For example you can retrieve images from rss description as in the example below )
- The template maintains conditional tags %title%, %description%, %link%, %pubdate%<br/>
- While processing the template these tags are replaced with PHP variables containing corresponding values of feed<br/>
- To create the output use "echo"<br/><br/>
- Also specify "html template before elements", which will be printed before output of RSS items and
- "html template after elements", which will be printed after output of RSS items<br/>
- (these are html templates)<br/>
- </p>
- <img src="<?php echo $this->plugin_url.'help/6.png';?>" /><br/>
- Repeat the procedure for each RSS feed you want include in the post<br/><br/>
- <img src="<?php echo $this->plugin_url.'help/4.png';?>" /><br/>
- Tip: if you want content of some RSS feeds mixed together
- just specify for these feeds equal value in "Element order" field.<br/><br/>
- Note: In this version of plugin RSS items always ordered by date
- <?php
- }
- }
- $digest = new DKRSSDigest();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement