nathanielks / Shortcodes-Generator

A plugin to generate shortcodes and a corresponding button in the WordPress visual editor. Wicked!
16 stars 9 forks source link

Embed Shortcode Generator plugin in a theme #3

Open Kamel38 opened 10 years ago

Kamel38 commented 10 years ago

Hi ! I was wondering if i can embed the plugin in my theme. Is it possible ? If yes, I tried different way to do this, for exemple : I put the plugin in root of my theme and I include the "cur-shortcodes-generator.php" file. But the plugin doesn't works. However, If I put it in the plugin directory, it works. Can you give me a way to include the plugin in my theme ? Thanks to answer quickly :)

(Sorry if my English is bad, I'm French and I just do with what I've learned at school)

nathanielks commented 10 years ago

Sure thing, Kamel! I'm out and about right now, but I'll have an answer for you soon.

Kamel38 commented 10 years ago

Okay thanks.I look forward !

nathanielks commented 10 years ago

Question for you @Kamel38: have you heard of TGM Plugin Activation? It's a way of declaring plugin dependencies in a theme without bundling those plugins with it. Personally, I'd recommend going that route rather than bundling together. If you don't want to go that route, I'd be happy to look into this further!

Kamel38 commented 10 years ago

Yes, I know and I'm actually using it for many Plugins such as Contact form, Layer slider, Woo sidebar... I can't add more plugins : it's been a lot. I was advised to use it only for big plugins, and for small, it is best to include them. :)

nathanielks commented 10 years ago

aye aye! I'll keep looking into it.

nathanielks commented 10 years ago

Alrighty my good man. The plugin has been updated to 1.2.1 and here are the instructions to follow:

To do that, move the plugin file into your theme and include this code in your functions.php file:

add_action( 'after_setup_theme', 'cur_shortcodes_theme_setup');
function cur_shortcodes_theme_setup(){

    // We're assuming the plugin directory is located in
    // /wp-content/themes/themename/shortcodes-generator/
    define( 'CSG_URI', get_template_directory_uri() . '/shortcodes-generator/' );

    require_once 'shortcodes-generator/cur-shortcodes-generator.php';

    $csg = Cur_Shortcodes_Generator::get_instance();
}

It'll take care of the rest!

Kamel38 commented 10 years ago

Oh, thank you very much, it works !! Just one thing : the image of the button is not displayed :/ http://evolutiongraph.fr/chevereto/images/2014/03/15/t1e9S.jpg

nathanielks commented 10 years ago

Aye, double check the url it's feeding into it. Open up your dev tools and it should show the error and the url it's trying to load.

Kamel38 commented 10 years ago

Apparently, the stylesheet is not loaded : I see with the dev' tools "http://127.0.0.1/wordpress/wp-content/plugins/C:/wamp/www/wordpress/wp-content/themes/Creation_Theme/non-plugins/Shortcodes-Generator-master/assets/css/shortcodes.css?ver=3.8" instead of "C:/wamp/www/wordpress/wp-content/themes/Creation_Theme/non-plugins/Shortcodes-Generator-master/assets/css/shortcodes.css?ver=3.8"

I think it's somewhere here : function shortcodes_button_css() {

    $css_path = apply_filters('cur_shortcodes_css_location', '/shortcodes/shortcodes.css');

    if ( file_exists( get_template_directory() . $css_path ) ){ 
        wp_enqueue_style( 'cur_shortcodes_button_css', get_template_directory_uri() . $css_path );
    } else {
        wp_enqueue_style( 'cur_shortcodes_button_css', plugins_url('/assets/css/shortcodes.css', __FILE__ ) );
    }
}
nathanielks commented 10 years ago

Aye, it is. That's the old version. Have you updated to 1.2.1?