Skip to content

Commit

Permalink
PHP5.2 & WP3.5 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonagnew committed Jul 10, 2015
1 parent 5bf69a1 commit 6beea4d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
14 changes: 11 additions & 3 deletions classes/class-wpcom-liveblog-entry-extend-feature-emojis.php
Expand Up @@ -14,6 +14,13 @@ class WPCOM_Liveblog_Entry_Extend_Feature_Emojis extends WPCOM_Liveblog_Entry_Ex
*/
protected $class_prefix = 'emoji-';

/**
* Path to use with plugins_url
*
* @var string
*/
protected $path;

/**
* The emojis.
*
Expand Down Expand Up @@ -916,12 +923,13 @@ class WPCOM_Liveblog_Entry_Extend_Feature_Emojis extends WPCOM_Liveblog_Entry_Ex
* @return void
*/
public function load() {
$this->path = dirname(__FILE__);
$this->class_prefix = apply_filters( 'liveblog_emoji_class', $this->class_prefix );
$this->emojis = apply_filters( 'liveblog_active_emojis', $this->emojis );

$this->revert_regex = implode( '', array(
preg_quote( '<img src="', '~' ),
preg_quote( plugins_url('../images/emojis/', __FILE__ ), '~' ),
preg_quote( plugins_url('/images/emojis/', $this->path ), '~' ),
'[^"]+',
preg_quote( '" class="liveblog-emoji ', '~' ),
preg_quote( $this->class_prefix, '~' ),
Expand Down Expand Up @@ -952,7 +960,7 @@ public function get_config( $config ) {
'search' => 'key',
'regex' => ':([\w\+\-]*):?$',
'replacement' => ':${key}:',
'template' => '<img src="'.plugins_url( '../images/emojis', __FILE__ ).'/${key}.png" height="20" width="20" /> ${name}',
'template' => '<img src="'.plugins_url( '/images/emojis', $this->path ).'/${key}.png" height="20" width="20" /> ${name}',
) );

return $config;
Expand Down Expand Up @@ -1018,7 +1026,7 @@ public function preg_replace_callback( $match ) {
return $match[0];
}

return '<img src="'.plugins_url( '../images/emojis/'.$match[1].'.png', __FILE__ ).'" class="liveblog-emoji '.$this->class_prefix.$match[1].'" data-emoji="'.$match[1].'">';
return '<img src="'.plugins_url( '/images/emojis/'.$match[1].'.png', $this->path ).'" class="liveblog-emoji '.$this->class_prefix.$match[1].'" data-emoji="'.$match[1].'">';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/class-wpcom-liveblog-entry-extend-feature.php
Expand Up @@ -26,7 +26,7 @@ abstract class WPCOM_Liveblog_Entry_Extend_Feature {
*
* @var array
*/
protected $prefixes = [];
protected $prefixes = array();

/**
* Called by WPCOM_Liveblog_Entry_Extend::load()
Expand Down
9 changes: 5 additions & 4 deletions classes/class-wpcom-liveblog-entry-extend.php
Expand Up @@ -84,10 +84,11 @@ public static function get_autocomplete() {
* Loads in the scripts and styles for autocomplete
*/
public static function enqueue_scripts() {
if ( WPCOM_Liveblog::is_liveblog_editable() ) {
wp_enqueue_style( 'textcomplete-css', plugins_url( '../css/jquery.textcomplete.css', __FILE__ ) );
wp_enqueue_script( 'textcomplete-script', plugins_url( '../js/jquery.textcomplete.min.js', __FILE__ ), false, true );
}
if ( WPCOM_Liveblog::is_liveblog_editable() ) {
$path = dirname(__FILE__);
wp_enqueue_style( 'textcomplete-css', plugins_url( '/css/jquery.textcomplete.css', $path ) );
wp_enqueue_script( 'textcomplete-script', plugins_url( '/js/jquery.textcomplete.min.js', $path ), false, true );
}
}

/**
Expand Down
3 changes: 2 additions & 1 deletion liveblog.php
Expand Up @@ -477,7 +477,8 @@ public static function ajax_crud_entry() {
public static function ajax_preview_entry() {
$entry_content = isset( $_REQUEST['entry_content'] ) ? $_REQUEST['entry_content'] : '';
$entry_content = stripslashes( wp_filter_post_kses( $entry_content ) );
$entry_content = apply_filters( 'liveblog_before_preview_entry', array( 'content' => $entry_content ) )['content'];
$entry_content = apply_filters( 'liveblog_before_preview_entry', array( 'content' => $entry_content ) );
$entry_content = $entry_content['content'];
$entry_content = WPCOM_Liveblog_Entry::render_content( $entry_content );

do_action( 'liveblog_preview_entry', $entry_content );
Expand Down

0 comments on commit 6beea4d

Please sign in to comment.