black-studio / black-studio-tinymce-widget

Black Studio TinyMCE Widget plugin for WordPress
https://wordpress.org/plugins/black-studio-tinymce-widget/
GNU General Public License v3.0
22 stars 13 forks source link

Allow static assets to be moved #29

Closed cfoellmann closed 9 years ago

cfoellmann commented 9 years ago

Just some idea: If someone would want to load the static assets (js + css) from a different/external location this is what would make this possible easily (in a CDN push scenario - NOT needed for CDN pull):

  1. change assets/ to wporg-assets/ (wp_deploy should support that, right?!)
  2. move css/ and js/ to (now empty) assets/ folder
  3. provide a filter + function to change the "assets urls" (in the main file)
<?php
public function get_url() {
    return esc_url( apply_filters( 'black_studio_tinymce_url', plugins_url( '/', __FILE__ ) ) );
} // End get_url()

public function get_assets_url() {
    return esc_url( apply_filters( 'black_studio_tinymce_assets_url', $this->get_url() . 'assets/' ) );
} // End get_assets_url()
  1. use these functions to generate the urls for enqueuing the files like:
<?php
wp_enqueue_style( $style, . $this->get_assets_url() . 'css/' . $style . $suffix. '.css', array(), self::$version );
marcochiesi commented 9 years ago

The idea is good, but I think that in a CDN push scenario, it would be better to use a WP level filter instead of a plugin level filter. In particular script_loader_src and style_loader_src should do the trick.