WordPress.org

Plugin Directory

Changeset 497772


Ignore:
Timestamp:
01/31/12 03:52:09 (2 years ago)
Author:
coffee2code
Message:
  • Fix bug where special characters were being double-escaped prior to use in regex
  • Update plugin framework to 034
  • Minor readme.txt formatting tweaks
Location:
text-replace
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • text-replace/trunk/c2c-plugin.php

    r475516 r497772  
    33 * @package C2C_Plugins 
    44 * @author Scott Reilly 
    5  * @version 032 
     5 * @version 034 
    66 */ 
    77/* 
     
    1818 
    1919/* 
    20 Copyright (c) 2010-2011 by Scott Reilly (aka coffee2code) 
     20Copyright (c) 2010-2012 by Scott Reilly (aka coffee2code) 
    2121 
    2222Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 
     
    3333*/ 
    3434 
    35 if ( ! class_exists( 'C2C_Plugin_032' ) ) : 
    36  
    37 abstract class C2C_Plugin_032 { 
     35if ( ! class_exists( 'C2C_Plugin_034' ) ) : 
     36 
     37abstract class C2C_Plugin_034 { 
    3838    protected $plugin_css_version = '008'; 
    3939    protected $options            = array(); 
     
    171171            add_action( 'admin_menu', array( &$this, 'admin_menu' ) ); 
    172172            if ( ! $this->disable_contextual_help ) { 
    173                 add_filter( 'contextual_help', array( &$this, 'contextual_help' ), 10, 3 ); 
     173                if ( version_compare( $GLOBALS['wp_version'], '3.3', '<' ) ) 
     174                    add_filter( 'contextual_help', array( &$this, 'contextual_help' ), 10, 3 ); 
    174175                if ( $this->is_plugin_admin_page() ) 
    175176                    add_thickbox(); 
     
    284285     * @return void 
    285286     */ 
    286     protected function options_page_description( $localized_heading_text = '' ) { 
     287    public function options_page_description( $localized_heading_text = '' ) { 
     288        if ( ! is_string( $localized_heading_text ) ) 
     289            $localized_heading_text = ''; 
     290 
    287291        if ( empty( $localized_heading_text ) ) 
    288292            $localized_heading_text = $this->name; 
     
    461465        $help_url = admin_url( "plugin-install.php?tab=plugin-information&amp;plugin={$this->id_base}&amp;TB_iframe=true&amp;width=640&amp;height=656" ); 
    462466 
    463         $help = '<p class="more-help">'; 
     467        $help = '<h3>More Plugin Help</h3>'; 
     468        $help .= '<p class="more-help">'; 
    464469        $help .= '<a title="' . esc_attr( sprintf( __( 'More information about %1$s %2$s', $this->textdomain ), $this->name, $this->version ) ) . 
    465470            '" class="thickbox" href="' . $help_url . '">' . __( 'Click for more help on this plugin', $this->textdomain ) . '</a>' . 
     
    542547        } 
    543548        $menu_func = 'add_' . $func_root . '_page'; 
    544         if ( function_exists( $menu_func ) ) 
     549        if ( function_exists( $menu_func ) ) { 
    545550            $this->options_page = call_user_func( $menu_func, $this->name, $this->menu_name, 'manage_options', $this->plugin_basename, array( &$this, 'options_page' ) ); 
     551            add_action( 'load-' . $this->options_page, array( &$this, 'help_tabs' ) ); 
     552        } 
     553    } 
     554 
     555    /** 
     556     * Initialize help tabs. 
     557     * 
     558     * @since 034 
     559     * @return void 
     560     */ 
     561    public function help_tabs() { 
     562        if ( ! class_exists( 'WP_Screen' ) ) 
     563            return; 
     564 
     565        $screen = get_current_screen(); 
     566 
     567        if ( $screen->id != $this->options_page ) 
     568            return; 
     569 
     570        $this->help_tabs_content( $screen ); 
     571    } 
     572 
     573    /** 
     574     * Configures help tabs content. 
     575     * 
     576     * This should be overridden by inheriting class if it needs help content. 
     577     * 
     578     * @since 034 
     579     * 
     580     * @return void 
     581     */ 
     582    public function help_tabs_content( $screen ) { 
     583        $screen->add_help_tab( array( 
     584            'id'      => 'c2c-more-help-' . $this->id_base, 
     585            'title'   => __( 'More Help', $this->textdomain ), 
     586            'content' => self::contextual_help( '', $this->options_page ) 
     587        ) ); 
    546588    } 
    547589 
     
    808850        do_action( $this->get_hook( 'before_settings_form' ), $this ); 
    809851 
    810         echo "<form action='options.php' method='post' class='c2c-form'>\n"; 
     852        echo "<form action='" . admin_url( 'options.php' ) . "' method='post' class='c2c-form'>\n"; 
    811853 
    812854        settings_fields( $this->admin_options_name ); 
  • text-replace/trunk/readme.txt

    r475516 r497772  
    44Tags: text, replace, shortcut, shortcuts, post, post content, coffee2code 
    55Requires at least: 3.1 
    6 Tested up to: 3.3 
    7 Stable tag: 3.2.1 
    8 Version: 3.2.1 
     6Tested up to: 3.3.1 
     7Stable tag: 3.2.2 
     8Version: 3.2.2 
    99 
    1010Replace text with other text. Handy for creating shortcuts to common, lengthy, or frequently changing text/HTML, or for smilies. 
     
    1818* Your best bet with defining shortcuts is to define something that would never otherwise appear in your text.  For instance, bookend the shortcut with colons: 
    1919 
    20     `:wp: => <a href='http://wordpress.org'>WordPress</a>` 
    21     `:aol: => <a href='http://www.aol.com'>America Online, Inc.</a>` 
     20` 
     21:wp: => <a href='http://wordpress.org'>WordPress</a> 
     22:aol: => <a href='http://www.aol.com'>America Online, Inc.</a> 
     23 
     24` 
     25 
    2226Otherwise, you risk proper but undesired replacements: 
    23     `Hi => Hello` 
     27 
     28`Hi => Hello` 
    2429 
    2530Would have the effect of changing "His majesty" to "Hellos majesty". 
     
    156161 
    157162== Changelog == 
     163 
     164= 3.2.2 = 
     165* Fix bug where special characters were being double-escaped prior to use in regex 
     166* Update plugin framework to 034 
     167* Minor readme.txt formatting tweaks 
    158168 
    159169= 3.2.1 = 
     
    281291== Upgrade Notice == 
    282292 
     293= 3.2.2 = 
     294Minor bugfix release: fixed bug where special characters were being double-escaped; updated plugin framework. 
     295 
    283296= 3.2.1 = 
    284297Recommended bugfix release: fixed bug when $x (where x is a number) would not display when used in replacement string; fix to properly escape shortcut keys prior to internal use; and updated plugin framework. 
  • text-replace/trunk/text-replace.php

    r475516 r497772  
    33 * @package Text_Replace 
    44 * @author Scott Reilly 
    5  * @version 3.2.1 
     5 * @version 3.2.2 
    66 */ 
    77/* 
    88Plugin Name: Text Replace 
    9 Version: 3.2.1 
     9Version: 3.2.2 
    1010Plugin URI: http://coffee2code.com/wp-plugins/text-replace/ 
    1111Author: Scott Reilly 
    12 Author URI: http://coffee2code.com 
     12Author URI: http://coffee2code.com/ 
    1313Text Domain: text-replace 
    1414Domain Path: /lang/ 
     
    4848require_once( 'c2c-plugin.php' ); 
    4949 
    50 class c2c_TextReplace extends C2C_Plugin_032 { 
     50class c2c_TextReplace extends C2C_Plugin_034 { 
    5151 
    5252    public static $instance; 
     
    6666            return; 
    6767 
    68         parent::__construct( '3.2.1', 'text-replace', 'c2c', __FILE__, array() ); 
     68        parent::__construct( '3.2.2', 'text-replace', 'c2c', __FILE__, array() ); 
    6969        register_activation_hook( __FILE__, array( __CLASS__, 'activation' ) ); 
    7070        self::$instance = $this; 
     
    181181        echo '</li><li>'; 
    182182        echo __( 'HTML is allowed.', $this->textdomain ); 
     183        echo '</li><li>'; 
    183184        echo __( 'Only use quotes it they are actual part of the original or replacement strings.', $this->textdomain ); 
    184185        echo '</li><li><strong><em>'; 
     
    196197     */ 
    197198    public function text_replace( $text ) { 
    198         $oldchars = array( "(", ")", "[", "]", "?", ".", ",", "|", "\$", "*", "+", "^", "{", "}" ); 
    199         $newchars = array( "\(", "\)", "\[", "\]", "\?", "\.", "\,", "\|", "\\\$", "\*", "\+", "\^", "\{", "\}" ); 
    200199        $options = $this->get_options(); 
    201200        $text_to_replace = apply_filters( 'c2c_text_replace', $options['text_to_replace'] ); 
     
    208207                    $text = str_replace( $old_text, $new_text, $text ); 
    209208                } else { 
    210                     $old_text = preg_quote( str_replace( $oldchars, $newchars, $old_text ) ); 
     209                    $old_text = preg_quote( $old_text, '|' ); 
    211210                    $text = preg_replace( "|(?!<.*?)$old_text(?![^<>]*?>)|$preg_flags", addcslashes( $new_text, '\\$' ), $text ); 
    212211                } 
Note: See TracChangeset for help on using the changeset viewer.