Commit 0b565912 authored by Danny Froberg's avatar Danny Froberg 💬
Browse files

Initial

parent 9f566432
# muraselon-currency-shortcode
#Muraselon Currency ShortCode
* Description: Injects a small javascript snippet by way of shortcode [muraseloncurrency]
(function() {
tinymce.PluginManager.add('muraseloncurrency_shortcode_button', function( editor, url ) {
editor.addButton( 'muraseloncurrency_shortcode_button', {
text: '[MUSCUR]',
icon: false,
onclick: function() {
editor.insertContent('[muraseloncurrency]');
}
});
});
})();
<?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');
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment