framework_url() . 'js/colorpicker.js', array( 'jquery' ), '3.6', true ); // Loaded into the footer.
wp_enqueue_script( 'vpthemes-colourpicker' );
// Register the colourpicker CSS.
wp_register_style( 'vpthemes-colorpicker', $this->framework_url() . 'css/colorpicker.css' );
wp_enqueue_style( 'vpthemes-colorpicker' );
// Register the custom CSS styles.
wp_register_style( 'vpthemes-shortcode-generator', $this->framework_url() . 'css/shortcode-generator.css' );
wp_enqueue_style( 'vpthemes-shortcode-generator' );
} // End IF Statement
} // End init()
/*-----------------------------------------------------------------------------------
filter_mce_buttons()
* Add new button to the tinyMCE editor.
-----------------------------------------------------------------------------------*/
function filter_mce_buttons( $buttons ) {
array_push( $buttons, '|', 'vpthemes_shortcodes_button' );
return $buttons;
} // End filter_mce_buttons()
/*-----------------------------------------------------------------------------------
filter_mce_external_plugins()
* Add functionality to the tinyMCE editor as an external plugin.
-----------------------------------------------------------------------------------*/
function filter_mce_external_plugins( $plugins ) {
$plugins['vpthemesShortcodes'] = $this->framework_url() . 'js/shortcode-generator/editor_plugin.js';
return $plugins;
} // End filter_mce_external_plugins()
/*-----------------------------------------------------------------------------------
Utility Functions
* Helper functions for this class.
-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------
framework_url()
-----------------------------------------------------------------------------------*/
function framework_url() {
return trailingslashit( get_template_directory_uri() . '/' . basename( dirname( __FILE__ ) ) );
} // End framework_url()
/*-----------------------------------------------------------------------------------
ajax_action_check_url()
* Checks if a given url (via GET or POST) exists.
* Returns JSON.
*
* NOTE: For users that are not logged in this is not called.
* The client recieves -1 in that case.
-----------------------------------------------------------------------------------*/
function ajax_action_check_url() {
$hadError = true;
$url = isset( $_REQUEST['url'] ) ? $_REQUEST['url'] : '';
if ( strlen( $url ) > 0 && function_exists( 'get_headers' ) ) {
$file_headers = @get_headers( $url );
$exists = $file_headers && $file_headers[0] != 'HTTP/1.1 404 Not Found';
$hadError = false;
}
echo '{ "exists": '. ($exists ? '1' : '0') . ($hadError ? ', "error" : 1 ' : '') . ' }';
die();
} // End ajax_action_check_url()
/*-----------------------------------------------------------------------------------
shortcode_testing()
* Used for testing that the shortcodes are functioning.
-----------------------------------------------------------------------------------*/
function shortcode_testing( $atts, $content = null ) {
if ($content === null) return '';
return 'Working: ' . $content . '' . "\n";
} // End shortcode_testing()
} // End Class
/*-----------------------------------------------------------------------------------
INSTANTIATE CLASS
-----------------------------------------------------------------------------------*/
$wpz_shortcode_generator = new vpthemes_Shortcode_Generator();
?>