PASTEBIN
| #1 paste tool since 2002
create new paste
tools
api
archive
faq
PASTEBIN
create new paste
trending pastes
sign up
login
my alerts
my settings
my profile
Don't like ads?
PRO users
don't see any ads ;-)
Public Pastes
Untitled
2 sec ago
Untitled
4 sec ago
Untitled
8 sec ago
Untitled
12 sec ago
Untitled
35 sec ago
Untitled
13 sec ago
Untitled
14 sec ago
Untitled
14 sec ago
New Paste
<?php /** * @package YD_feedwordpress_content_filter * @author Yann Dubois * @version 0.2.0 */ /* Plugin Name: YD Feedwordpress content filter Plugin URI: http://www.yann.com/en/wp-plugins/yd-feedwordpress-content-filter Description: Automatically filters the content of syndicated posts. | Funded by <a href="http://www.abc.fr">ABC.fr</a> Version: 0.2.0 Author: Yann Dubois Author URI: http://www.yann.com/ License: GPL2 */ /** * @copyright 2010 Yann Dubois ( email : yann _at_ abc.fr ) * * Original development of this plugin was kindly funded by http://www.abc.fr * * Additional developments kindly provided by Alessandro Nuzzo ( http://www.e-one.it ) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * 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 */ /** Revision 0.1.0: - Original beta release Revision 0.2.0: - Refactored using the YD Plugins Framework - Added some options - Added image attachment hack contributed by Alessandro Nuzzo - Added redirected URL resolution - Got rid of unused code - Small bug fixes */ include_once( 'inc/yd-widget-framework.inc.php' ); $junk = new YD_Plugin( array( 'name' => 'YD Feedwordpress Content Filter', 'version' => '0.2.0', 'has_option_page' => true, 'has_shortcode' => false, 'has_widget' => false, 'widget_class' => '', 'has_cron' => false, 'crontab' => array( 'daily' => array( 'yd_fwp_filter', 'daily_update' ), 'hourly' => array( 'yd_fwp_filter', 'hourly_update' ) ), 'has_stylesheet' => false, 'stylesheet_file' => 'css/yd.css', 'has_translation' => false, 'translation_domain'=> '', // must be copied in the widget class!!! 'translations' => array( array( 'English', 'Yann Dubois', 'http://www.yann.com/' ) ), 'initial_funding' => array( 'Yann.com', 'http://www.yann.com' ), 'additional_funding'=> array(), 'form_blocks' => array( 'Main options' => array( 'google_filter' => 'bool', 'yahoo_filter' => 'bool', 'wikio_filter' => 'bool', 'local_images' => 'bool', 'fix_attach' => 'bool', 'fix_first' => 'bool', 'fix_redirect' => 'bool', 'hash_to_tags' => 'bool' // Hashtag ) ), 'option_field_labels'=>array( 'google_filter' => 'Apply Google News item filter', 'yahoo_filter' => 'Apply Yahoo News item filter', 'wikio_filter' => 'Apply Wikio News item filter', 'local_images' => 'Import images as local attachments', 'fix_attach' => 'Fix attachment IDs', 'fix_first' => 'Fix repeated title on first line', 'fix_redirect' => 'Resolve redirected source URL', 'hash_to_tags' => 'Twitter Hashtags to tags' // Hashtag ), 'option_defaults' => array( 'google_filter' => 1, 'yahoo_filter' => 1, 'wikio_filter' => 1, 'local_images' => 1, 'fix_attach' => 1, 'fix_first' => 1, 'fix_redirect' => 1, 'hash_to_tags' => 1, // Hashtag ), 'form_add_actions' => array( // no custom actions ), 'has_cache' => false, 'option_page_text' => '', 'backlinkware_text' => 'Featuring YD Feedwordpress Content Filter Plugin', 'plugin_file' => __FILE__ ) ); class yd_fwp_filter { const option_key = 'yd-feedwordpress-content-filter'; function __construct() { $this->yd_fwp_filter(); } function yd_fwp_filter() { $options = get_option( self::option_key ); add_action( 'syndicated_post', array( &$this, 'filter' ), 10, 1 ); if( $options['fix_attach'] ) { add_action( 'post_syndicated_item', array( &$this, 'fixAttach' ), 20, 1 ); add_action( 'update_syndicated_item', array( &$this, 'fixAttach' ), 20, 1 ); } } function filter( $post ) { if( !$post ) return $post; $options = get_option( self::option_key ); $content = $post['post_content']; $title = $post['post_title']; $stripped_content = strip_tags( $content, '<i><sup><sub><strong><u><br><p><img>' ); //<b><em> $stripped_content = preg_replace( '|^(<[^>]*>)*(<br\s*\/?>)+|i', "$1", $stripped_content ); // no <br> at beginning (Google) $stripped_content = preg_replace( '|<img[^src]+>|i', '', $stripped_content ); // no sourceless <img> (Google) $stripped_content = preg_replace( '|(<p\s*>)*\s*et plus encore »\s*(</p\s*>)*|ims', '', $stripped_content ); // Hashtag if( $options['hash_to_tags'] ) { // find hashtags preg_match_all( '/\B#(\w*[a-zA-Z-]+\w*)/', $content, $matches ); $hashtags = $matches[0]; // #bleh $tags = $matches[1]; // bleh unset( $matches ); global $id; wp_set_post_tags( $id, implode( ', ', $tags ) ); } // i nice try ^^
Optional Paste Settings
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
HTML 5
Java
JavaScript
Lua
None
Objective C
Perl
PHP
Python
Rails
-------------
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
ActionScript
ActionScript 3
Ada
ALGOL 68
Apache Log
AppleScript
APT Sources
ARM
ASM (NASM)
ASP
Asymptote
autoconf
Autohotkey
AutoIt
Avisynth
Awk
BASCOM AVR
Bash
Basic4GL
BibTeX
Blitz Basic
BNF
BOO
BrainFuck
C
C for Macs
C Intermediate Language
C#
C++
C++ (with QT extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
ChaiScript
Clojure
Clone C
Clone C++
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
DCL
DCPU-16
DCS
Delphi
Delphi Prism (Oxygene)
Diff
DIV
DOS
DOT
E
ECMAScript
Eiffel
Email
EPC
Erlang
F#
Falcon
FO Language
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
Game Maker
GDB
Genero
Genie
GetText
Go
Groovy
GwBasic
Haskell
Haxe
HicEst
HQ9 Plus
HTML
HTML 5
Icon
IDL
INI file
Inno Script
INTERCAL
IO
J
Java
Java 5
JavaScript
jQuery
KiXtart
Latex
LDIF
Liberty BASIC
Linden Scripting
Lisp
LLVM
Loco Basic
Logtalk
LOL Code
Lotus Formulas
Lotus Script
LScript
Lua
M68000 Assembler
MagikSF
Make
MapBasic
MatLab
mIRC
MIX Assembler
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MPASM
MXML
MySQL
Nagios
newLISP
None
NullSoft Installer
Oberon 2
Objeck Programming Langua
Objective C
OCalm Brief
OCaml
Octave
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
ParaSail
PARI/GP
Pascal
PAWN
PCRE
Per
Perl
Perl 6
PHP
PHP Brief
Pic 16
Pike
Pixel Bender
PL/SQL
PostgreSQL
POV-Ray
Power Shell
PowerBuilder
ProFTPd
Progress
Prolog
Properties
ProvideX
PureBasic
PyCon
Python
Python for S60
q/kdb+
QBasic
R
Rails
REBOL
REG
Rexx
Robots
RPM Spec
Ruby
Ruby Gnuplot
SAS
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
SPARK
SPARQL
SQL
StoneScript
SystemVerilog
T-SQL
TCL
Tera Term
thinBasic
TypoScript
Unicon
UnrealScript
UPC
Urbi
Vala
VB.NET
Vedit
VeriLog
VHDL
VIM
Visual Pro Log
VisualBasic
VisualFoxPro
WhiteSpace
WHOIS
Winbatch
XBasic
XML
Xorg Config
XPP
YAML
Z80 Assembler
ZXBasic
Paste Expiration:
Never
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
Paste Exposure:
Public
Unlisted
Private (members only)
Paste Name / Title:
Hello
Guest
Sign Up
or
Login
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login