Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #12 from vokiel/master
Browse files Browse the repository at this point in the history
Resolving captioned image in wpgalery plugin, better paths resolving, reformat code
  • Loading branch information
wwalc committed Sep 2, 2015
2 parents 0ff8f93 + 56df916 commit 4111653
Show file tree
Hide file tree
Showing 10 changed files with 308 additions and 309 deletions.
525 changes: 266 additions & 259 deletions ckeditor_class.php

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions ckeditor_wordpress.php
@@ -1,4 +1,4 @@
<?php
<?php if ( !defined('ABSPATH')){ exit; } // Exit if accessed directly

/*
Plugin Name: CKEditor for WordPress
Expand All @@ -13,8 +13,7 @@

function ckeditor_init(){
global $ckeditor_wordpress;
require_once 'ckeditor_class.php';
require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once dirname(__FILE__) . '/ckeditor_class.php';

if (is_admin()){
add_action('admin_menu', array(&$ckeditor_wordpress, 'add_option_page'));
Expand Down Expand Up @@ -46,10 +45,9 @@ function ckeditor_init(){
add_filter( 'ckeditor_buttons', array(&$ckeditor_wordpress, 'wppoll_buttons') );

/** temporary for ngggallery **/
include_once(dirname(__FILE__) . '/plugins/nggallery/ckeditor.php');
include_once dirname(__FILE__) . '/plugins/nggallery/ckeditor.php';

/** temporary for gd-star-rating **/
add_filter( 'ckeditor_external_plugins', array(&$ckeditor_wordpress, 'starrating_external_plugin') );
add_filter( 'ckeditor_buttons', array(&$ckeditor_wordpress, 'starrating_buttons') );
}
?>
22 changes: 21 additions & 1 deletion ckfinder/ckfinder_config.php
Expand Up @@ -15,7 +15,27 @@
$error_reporting = error_reporting();
error_reporting($error_reporting & ~E_STRICT);

require_once(dirname(__FILE__). '/../../../../wp-config.php');
function findWpConfigRecursively($dir){
do {
if( file_exists($dir."/wp-config.php") ) {
return $dir;
}
} while( $dir = realpath("$dir/..") );
return null;
}

if ( !defined('ABSPATH')) {
// Go out from ckfinder/core/connector/php/ into plugins directory
$pluginsRoot = dirname(dirname(dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME']))))));
$wpRoot = dirname(dirname($pluginsRoot));
if ( file_exists( $wpRoot. '/wp-config.php' ) ) {
require_once $wpRoot . '/wp-config.php';
}
else {
$wpRoot = findWpConfigRecursively($pluginsRoot);
require_once $wpRoot . '/wp-config.php';
}
}
require_once(dirname(__FILE__). '/../ckeditor_class.php');

/**
Expand Down
42 changes: 8 additions & 34 deletions includes/advanced.php
@@ -1,4 +1,4 @@
<?php
<?php if ( !defined('ABSPATH')){ exit; } // Exit if accessed directly
/*
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license
Expand Down Expand Up @@ -69,14 +69,7 @@
</table>
<h3><?php _e('Advanced Options', 'ckeditor_wordpress') ?></h3>
<table class="form-table">
<?php
if (isset($this->options['advanced']['acf']))
{
$acf = $this->options['advanced']['acf'];
} else {
$acf = 'f';
}
?>
<?php $acf = isset($this->options['advanced']['acf']) ? $this->options['advanced']['acf'] : 'f'; ?>
<tr valign="top">
<th scope="row"><?php _e('Advanced Content Filter', 'ckeditor_wordpress')?></th>
<td>
Expand Down Expand Up @@ -116,7 +109,9 @@
$pluginNames = array('scayt' => 'Spell Check As You Type (SCAYT)', 'wsc' => 'WebSpellChecker (WSC)');

foreach ($plugins as $plugin){
if ($plugin == "wpgallery" || $plugin == "wpeditimage") continue;
if ($plugin == "wpgallery" || $plugin == "wpeditimage") {
continue;
}
if (!isset($this->options['plugins'][$plugin])){
$this->options['plugins'][$plugin] = 't';
}
Expand All @@ -132,14 +127,7 @@
<tr valign="top">
<th scope="row"><?php _e('Language', 'ckeditor_wordpress')?></th>
<td>
<?php
if (isset($this->options['advanced']['language']))
{
$selected = $this->options['advanced']['language'];
}else{
$selected = (get_locale())? get_locale() : 'en';
}
?>
<?php $selected = isset($this->options['advanced']['language']) ? $this->options['advanced']['language'] : (get_locale()? get_locale() : 'en'); ?>
<select name="options[advanced][language]">
<?php foreach ($langs AS $key => $lang): ?>
<option value="<?php echo $key?>" <?php if ($key == $selected):?>selected="selected"<?php endif;?>><?php echo $lang ?></option>
Expand All @@ -149,14 +137,7 @@
<?php if (isset($message['advanced_language'])): ?><span class="error"><?php echo $message['advanced_language'] ?></span><?php endif; ?>
</td>
</tr>
<?php
if (isset($this->options['advanced']['detect_language_auto']))
{
$auto = $this->options['advanced']['detect_language_auto'];
} else {
$auto = 't';
}
?>
<?php $auto = isset($this->options['advanced']['detect_language_auto']) ? $this->options['advanced']['detect_language_auto'] : 't'; ?>
<tr valign="top">
<th scope="row"><?php _e('Auto-detect language', 'ckeditor_wordpress')?></th>
<td>
Expand All @@ -169,14 +150,7 @@
<tr valign="top">
<th scope="row"><?php _e('Language direction ', 'ckeditor_wordpress')?></th>
<td>
<?php
if (isset($this->options['advanced']['language_direction']))
{
$selected = $this->options['advanced']['language_direction'];
}else{
$selected = 'default';
}
?>
<?php $selected = isset($this->options['advanced']['language_direction']) ? $this->options['advanced']['language_direction']: 'default'; ?>
<select name="options[advanced][language_direction]">
<option value="default" <?php if ($selected == 'default'):?>selected="selected"<?php endif;?>>Get from current locale (default)</option>
<option value="ltr" <?php if ($selected == 'ltr'):?>selected="selected"<?php endif;?>>Left-To-Right</option>
Expand Down
2 changes: 1 addition & 1 deletion includes/basic.php
@@ -1,4 +1,4 @@
<?php
<?php if ( !defined('ABSPATH')){ exit; } // Exit if accessed directly
/*
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license
Expand Down
2 changes: 1 addition & 1 deletion includes/file_editor.php
@@ -1,4 +1,4 @@
<?php
<?php if ( !defined('ABSPATH')){ exit; } // Exit if accessed directly
/*
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license
Expand Down
4 changes: 2 additions & 2 deletions includes/overview.php
@@ -1,4 +1,4 @@
<?php
<?php if ( !defined('ABSPATH')){ exit; } // Exit if accessed directly
/*
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license
Expand Down Expand Up @@ -204,6 +204,7 @@ function ckeditor_overview_configuration() {
</div>
<?php
}

function ckeditor_reset_settings() {
?>
<div>
Expand Down Expand Up @@ -252,4 +253,3 @@ function ckeditor_overview_help() {
add_meta_box('dashboard_reset_settings', __('Reset Plugin Settings', 'ckeditor_wordpress'), 'ckeditor_reset_settings', 'ckeditor_overview', 'left', 'core');

ckeditor_admin_overview();
?>
2 changes: 1 addition & 1 deletion includes/upload.php
@@ -1,4 +1,4 @@
<?php
<?php if ( !defined('ABSPATH')){ exit; } // Exit if accessed directly
/*
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license
Expand Down
4 changes: 2 additions & 2 deletions plugins/wpeditimage/js/editimage.js
Expand Up @@ -227,7 +227,7 @@ wpImage = {
d = t.I('img_demo'), dom = tinyMCEPopup.dom, DL, caption = '', dlc, pa, tmp, url, pattern, match;
if (el.getName() != 'img')
return;
if(el.getAttribute('src').indexOf('../wp-content') != -1 )
if(el.getAttribute('src').indexOf('../') != -1 )
{
tmp = window.parent.document.location.pathname.split('/');
url = window.parent.document.location.protocol + '//' + window.parent.document.location.host + '/' + tmp[1] + '/' + el.getAttribute('src').replace(/\.\.\//, '');
Expand Down Expand Up @@ -278,7 +278,7 @@ wpImage = {
t.updateStyle('vspace');
pa = el.getParent() ;
if ( pa.getName()== 'a' ) {
if(pa.getAttribute('href').indexOf('../wp-content') != -1 )
if(pa.getAttribute('href').indexOf('../') != -1 )
{
tmp = window.parent.document.location.pathname.split('/');
url = window.parent.document.location.protocol + '//' + window.parent.document.location.host + '/' + tmp[1] + '/' + pa.getAttribute('href').replace(/\.\.\//, '');
Expand Down
6 changes: 3 additions & 3 deletions plugins/wpgallery/plugin.js
Expand Up @@ -246,14 +246,14 @@ var image_attributes = {};
{
return function( data )
{
data = data.replace( /\[caption(.*?)\]([^>]+?>)(.*?)\[\/caption\]/mig, function(match, captionAttr, imgTag, captionText)
data = data.replace( /\[caption(.*?)\].*?(<img.*?\/?>).*?[^>]+?>(.*?)\[\/caption\]/mig, function(match, captionAttr, imgTag, captionText)
{
var pattern = /wp-image-([0-9]+)/i;
var match = pattern.exec(imgTag);
if (match[1]) {
if (match && match[1]) {
image_attributes['wp-image-' + match[1]] = {
'data-cke-caption' : captionAttr.replace(/^ /, ''),
'data-cke-caption-text' : captionText
'data-cke-caption-text' : captionText.replace(/^ /, '')
};
return imgTag;
}
Expand Down

0 comments on commit 4111653

Please sign in to comment.