Shortcodes-Generator icon indicating copy to clipboard operation
Shortcodes-Generator copied to clipboard

Embed Shortcode Generator plugin in a theme

Open Kamel38 opened this issue 11 years ago • 10 comments

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)

Kamel38 avatar Mar 15 '14 07:03 Kamel38

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

nathanielks avatar Mar 15 '14 16:03 nathanielks

Okay thanks.I look forward !

Kamel38 avatar Mar 15 '14 17:03 Kamel38

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!

nathanielks avatar Mar 15 '14 18:03 nathanielks

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. :)

Kamel38 avatar Mar 15 '14 18:03 Kamel38

aye aye! I'll keep looking into it.

nathanielks avatar Mar 15 '14 18:03 nathanielks

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!

nathanielks avatar Mar 15 '14 19:03 nathanielks

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

Kamel38 avatar Mar 15 '14 19:03 Kamel38

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.

nathanielks avatar Mar 15 '14 19:03 nathanielks

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__ ) );
    }
}

Kamel38 avatar Mar 15 '14 19:03 Kamel38

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

nathanielks avatar Mar 15 '14 20:03 nathanielks