Initial
<?php | ||
/* | ||
* Plugin Name: Muraselon Currency ShortCode | ||
* Description: Injects a small javascript snippet by way of shortcode [muraseloncurrency] | ||
* Version: 1.0 | ||
* Author: Danny Froberg <[email protected]> | ||
* Author URI: https://www.froberg.org | ||
* GitLab Plugin URL: https://gitlab.froberg.org/plugins/muraselon-currency-shortcode.git | ||
*/ | ||
add_action('admin_head', 'daf_add_shortcode_muraseloncurrency_button'); | ||
function daf_add_shortcode_muraseloncurrency_button() { | ||
global $typenow; | ||
if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) { | ||
return; | ||
} | ||
if( ! in_array( $typenow, array( 'post', 'page' ) ) ) | ||
return; | ||
if ( get_user_option('rich_editing') == 'true') { | ||
add_filter('mce_external_plugins', 'daf_muraseloncurrency_add_tinymce_plugin'); | ||
add_filter('mce_buttons', 'daf_muraseloncurrency_register_tinymce_plugin'); | ||
} | ||
} | ||
function daf_muraseloncurrency_add_tinymce_plugin($plugin_array) { | ||
$plugin_array['muraseloncurrency_shortcode_button'] = plugin_dir_url( __FILE__ ) . '/js/editor-muraseloncurrency-button.js'; | ||
return $plugin_array; | ||
} | ||
function daf_muraseloncurrency_register_tinymce_plugin($buttons) { | ||
array_push($buttons, "muraseloncurrency_shortcode_button"); | ||
return $buttons; | ||
} | ||
function daf_muraselon_currency(){ | ||
return <<<ENDOFSNIPPET | ||
<script type="text/javascript" src="https://sp-today.com/spwidget.php?city=damas&fields=USD%2CEUR%2CTRY"></script> | ||
ENDOFSNIPPET; | ||
} | ||
add_shortcode('muraseloncurrency', 'daf_muraselon_currency'); |
Please register or sign in to comment