-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed loading of CSS and JS by using wp_enqueue_
Refactor all functions to prevent conflicts, now there're all static method of a class unify method to obtain path of plugin (to get url to assets)
- Loading branch information
Showing
4 changed files
with
108 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,66 +19,79 @@ | |
* | ||
* If not, visit http://gnu.org/licenses/agpl-3.0.html. | ||
* | ||
* @author Ximdex DevTeam <[email protected]> | ||
* @version $Revision$ | ||
* @author Ximdex DevTeam <[email protected]> | ||
* @version $Revision$ | ||
*/ | ||
class XowlClient { | ||
|
||
class XowlClient | ||
{ | ||
|
||
private static $initiated = false; | ||
|
||
public static function init() { | ||
|
||
|
||
public static function init() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* <p>Callback function for 'xowl/enhance' endpoint</p> | ||
* <p>This function calls Ximdex Xowl endpoint to analyze and enhance the content</p> | ||
*/ | ||
function xowl_enhance_content() { | ||
function xowl_enhance_content() | ||
{ | ||
$content = filter_input(INPUT_POST, 'content'); | ||
echo $service->suggest($content); | ||
} | ||
|
||
|
||
private static function init_hooks() { | ||
|
||
|
||
private static function init_hooks() | ||
{ | ||
} | ||
|
||
public static function plugin_activation() { | ||
add_option('xowl_endpoint', 'http://xowl.ximdex.net/api/v1/enhance' , true ); | ||
|
||
public static function plugin_activation() | ||
{ | ||
add_option('xowl_endpoint', 'http://xowl.ximdex.net/api/v1/enhance', true); | ||
add_option('xowl_apikey', '', true); | ||
add_option('xowl_register', 'http://xowl.ximdex.net/register/signup', '', true); | ||
} | ||
|
||
public static function plugin_deactivation() { | ||
} | ||
|
||
public static function xowl_register_tinymce_plugin($plugin_array) { | ||
$plugin_array['xowl_button'] = XOWL_PLUGIN_URL . '/tinymce/xowl_client/editor_plugin.js'; | ||
public static function plugin_deactivation() | ||
{ | ||
} | ||
|
||
public static function xowl_register_tinymce_plugin($plugin_array) | ||
{ | ||
|
||
|
||
$plugin_array['xowl_button'] = XowlClient::urlTo( '/tinymce/xowl_client/editor_plugin.js' ) ; | ||
return $plugin_array; | ||
} | ||
|
||
//Adding the new button to the Tiny's toolbar | ||
public static function xowl_add_tinymce_button($buttons) { | ||
public static function xowl_add_tinymce_button($buttons) | ||
{ | ||
$buttons[] = "xowl_button"; | ||
return $buttons; | ||
} | ||
|
||
//Links in config tab | ||
public static function admin_plugin_settings_link($links) { | ||
public static function admin_plugin_settings_link($links) | ||
{ | ||
$settings_link = '<a href="' . esc_url(self::get_page_url()) . '">' . __('Settings', 'xowl') . '</a>'; | ||
array_unshift($links, $settings_link); | ||
return $links; | ||
} | ||
|
||
private static function get_page_url($page = 'config') { | ||
|
||
private static function get_page_url($page = 'config') | ||
{ | ||
$args = array( | ||
'page' => 'xowl-config' | ||
); | ||
$url = add_query_arg($args, admin_url('options-general.php')); | ||
return $url; | ||
} | ||
|
||
public static function admin_menu() { | ||
|
||
public static function admin_menu() | ||
{ | ||
$hook = add_options_page('Xowl Configuration', 'Xowl Service', 'manage_options', 'xowl-config', array( | ||
'XowlClient', | ||
'display_page' | ||
|
@@ -88,19 +101,26 @@ public static function admin_menu() { | |
'admin_help' | ||
)); | ||
} | ||
|
||
private static function updateVar($name) { | ||
|
||
private static function updateVar($name) | ||
{ | ||
if (!empty($_POST[$name]) && get_option($name) != $_POST[$name]) { | ||
update_option($name, trim( $_POST[$name]) ); | ||
update_option($name, trim($_POST[$name])); | ||
} | ||
} | ||
|
||
public static function display_page() { | ||
|
||
public static function display_page() | ||
{ | ||
wp_enqueue_style('xowl-admin-css', XowlClient::urlTo( 'assets/css/styles.css' ) , "",XOWL_VERSION, "screen" ); | ||
wp_enqueue_script('xowl-admin-js', XowlClient::urlTo( 'assets/js/config-form.js' ) , array( "jquery") , XOWL_VERSION ); | ||
self::updateVar('xowl_endpoint'); | ||
self::updateVar('xowl_apikey'); | ||
require_once ('xowl-config.php'); | ||
require_once('xowl-config.php'); | ||
} | ||
public static function urlTo( $route = '' ) { | ||
return XOWL_PLUGIN_URL . $route ; | ||
} | ||
|
||
public static function admin_help() { | ||
public static function admin_help() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters