Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating custom extension through Plugin #394

Closed
akshaya-rane opened this issue Mar 24, 2015 · 17 comments
Closed

Creating custom extension through Plugin #394

akshaya-rane opened this issue Mar 24, 2015 · 17 comments

Comments

@akshaya-rane
Copy link

Hi,

I have created plugin with following structure,

<plugin_folder_name>/framework-customizations/extensions/<extension_name>

I have added below code in main plugin file,

function _wdm_filter_my_plugin_extensions($locations) {
$locations[dirname(__FILE__) . '/framework-customizations/extensions/'] = plugin_dir_url( __FILE__ ) . 'framework-customizations/extensions/';
    return $locations;
}
add_filter('fw_extensions_locations', '_wdm_filter_my_plugin_extensions');

If I add extension, in theme 'extensions' folder, it worked well.

Can you please give a step by step approach for creating extension via a plugin?

@ghost
Copy link

ghost commented Mar 24, 2015

Create directory <plugin_folder_name>/extensions

function _wdm_filter_my_plugin_extensions($locations) {
    $locations[dirname(__FILE__) . '/extensions'] 
    =
    plugin_dir_url( __FILE__ ) . 'extensions';

    return $locations;
}
add_filter('fw_extensions_locations', '_wdm_filter_my_plugin_extensions');

@ghost ghost self-assigned this Mar 24, 2015
@akshaya-rane
Copy link
Author

Thank you. This works well.

I have one doubt. If I add extension through plugin, will it be visible in Unyson 'Available' / 'Active' extension list.

Currently, it is not visible. If plugin is active, it gets activated automatically.

I have added following properties,

$manifest['display'] = true;

$manifest['standalone'] = true;

in manifest file.

@ghost
Copy link

ghost commented Mar 24, 2015

If I add extension through plugin, will it be visible in Unyson 'Available' / 'Active' extension list.

Sorry, at the moment no (I forgot about that). I am fixing this right now.

@ghost ghost closed this as completed in 9dfb7c8 Mar 24, 2015
@ghost
Copy link

ghost commented Mar 24, 2015

Please download the latest Unyson dev version, extract in plugins/unyson/ and let me know if plugin extensions are visibile on the Unyson Extensions page.

@ghost
Copy link

ghost commented Mar 24, 2015

P.S. To set extension image, add this in manifest

$manifest['thumbnail'] = '//placehold.it/256x256&text=hello';

@dylan-ngo11
Copy link

Hi @moldcraft
I followed above step to create extension from plugin folder.
It worked well but it had problem with other extension function for example: fw_ext_feedback_stars_get_post_rating().

It showed:

Fatal error: Call to undefined function fw_ext_feedback_stars_get_post_rating() in /plugins/ht-recipes/extensions/recipes/views/single.php on line 124

Any suggestions?

@ghost
Copy link

ghost commented Mar 26, 2015

Fatal error: Call to undefined function fw_ext_feedback_stars_get_post_rating() in /plugins/ht-recipes/extensions/recipes/views/single.php on line 124

Before calling any extension function, first you need to check if it is enabled/exists

if (fw_ext('extension_name')) {
   fw_ext_extension_name_whaterver_function();
}

@dylan-ngo11
Copy link

Thanks for your help!

@akshaya-rane
Copy link
Author

Hi,

Sorry for the delay.

I checked with new version, it works well. Great !!

@martinburdon
Copy link
Contributor

Hi, I'm just about to implement this so my shortcodes are in a plugin rather than the framework-customizations folder.

When I submit my theme to ThemeForest would I just include the plugin with the theme and let the user install my plugin when setting up the theme or must the plugin be hosted with WordPress.org in their plugin directory?

Thanks

@ghost
Copy link

ghost commented Apr 26, 2015

Included

@martinburdon
Copy link
Contributor

Thanks

@martinburdon
Copy link
Contributor

Is there anyway I can have more than one plugin with shortcodes? I'm wanting to have one plugin which contains core shortcodes which I'm going to reuse on each theme. I then want another plugin with theme specific shortcodes tailored to the themes genre.

As far as I'm aware I can't use the fw_extensions_locations filter on more than one plugin.

Is there a way I can achieve this?

@ghost
Copy link

ghost commented Apr 26, 2015

You can use the filter how much you want, in any plugin you want (No limits/restrictions)


For e.g. you can have multiple directories with extensions in the same plugin:

function _filter_{plugin-id}_extensions($locations) {
    $locations[ dirname(__FILE__) . '/core-extensions' ]
    = plugin_dir_url( __FILE__ ) . 'core-extensions';

    $locations[ dirname(__FILE__) . '/theme-extensions' ]
    = plugin_dir_url( __FILE__ ) . 'theme-extensions';

    return $locations;
}
add_filter('fw_extensions_locations', '_filter_{plugin-id}_extensions');

@QuantaTec
Copy link

Hi,

It seems we can only declare shortcodes in one extension at a time, if loaded from the plugins.

Example:

we have a plugin which loads one extension name 'our-core' and also shortcodes ( 'our-core-shorcode' )

Now lets create another plugin and load another extension name 'our-core-secondary' and also shortcodes ( 'our-core-secondary-shortcode' )

Both extensions are being loaded via two different plugins but only one will support shortcodes. not both? Unless the extension name is the same.

How can we have multiple plugins with its own extensions and its own shortcodes, as it seems only one plugin can support shortcodes at a time, the second is simply ignored for shorcodes.

Any help is appreciated @moldcraft

@ghost
Copy link

ghost commented Nov 23, 2016

@Shahab2905 I created 2 plugins with one shortcode in each, everything works fine

1479893110764

You can test the plugins on your side
Download

@QuantaTec
Copy link

@moldcraft Thank you, Indeed its is working.

I will look into my code again and see whats been done wrong.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants