• Hi Radoslav,

    Thanks for the plugin. Can you tell me what is the correct way of embedding this plugin in my custom plugin.

    I am using WordPress Plugin Boilerplate. So I placed your plugin inside “includes” folder and I loaded the plugin as below.

    require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/ultimate-fields/ultimate-fields.php';

    This includes the plugin and everything works fine, but I don’t think the CSS, JS files and fonts, images are working fine.

    Do I need to set any Constant to set the path for CSS, JS, fonts, images etc.,? Like setting UF_URL, UF_DIR help loading the css and js properly?

    The url to CSS and JS are like this:

    http://mailchimp.wp:8888/wp-content/plugins/ultimate-fields/templates/css/jquery-ui/jquery-ui.css

    But the path should have been

    http://mailchimp.wp:8888/wp-content/plugins/MY-PLUGIN-NAME/INCLUDES/ultimate-fields/templates/css/jquery-ui/jquery-ui.css

    The same applies for js and other assets as well.

    PS: Will this plugin be under constant development? I am planning to use this for all my future projects.

    Thanks!

    https://wordpress.org/plugins/ultimate-fields/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Dragon Heart

    (@sudheerranga)

    I solved it by setting the UF_URL constant.

    define( 'UF_URL', plugins_url() . '/My-PLUGIN-NAME/INCLUDES/ultimate-fields/');

    Let me know if this is the correct way.

    Thread Starter Dragon Heart

    (@sudheerranga)

    Is there a github repo to submit a pull request?

    The tabs functionality is broken. Quote is missing. Please fix.

    this.tabNav.removeClass( 'nav-tab-active' ).filter( '[href="#' + id + '"]' ).addClass( 'nav-tab-active' );

    Plugin Author Radoslav Georgiev

    (@radogeorgiev)

    Hi Dragon Heart,

    this is not the correct way to do it, because in the plugin, I am not checking if the constant is already defined or not, which means that you will be getting a PHP notice. If you enable the WP_DEBUG constant, which you should definitely do, you will see it.

    Checking the code in https://plugins.trac.wordpress.org/browser/ultimate-fields/trunk/common/startup.php , the plugin should automatically work even when within another plugin, but right now I don’t have the time to check what the bug is.

    However, as you see in the uf_start() function, there is a filter called “uf_startup_vars”. You can use it in the following way, assuming that you apply the filter in your root plugin file:

    <?php
    add_filter( 'uf_startup_vars', 'my_plugin_uf_startup_vars' );
    function my_plugin_uf_startup_vars( $vars ) {
    	$vars[ 'url' ] = plugins_url( 'includes/ultimate-fields/', __FILE__ );
    	return $vars;
    }

    For the tabs: Note taken. I had this fixed somewhere, but I’ve obviously broken it again 🙂

    And lastly, the answer to the PS:
    The plugin is under constant development, but not in the version you see here. I am nearly ready with version 2 (at least functionality-wise, there could be a few bugs) and am working on the website and documentation for it.

    If you really like the plugin and are determined to use it within yours, I strongly suggest that you try the beta, which you can find at https://github.com/RadoslavGeorgiev/ultimate-fields . As this would pretty much be beta testing, I would be glad to help you with any issues/bugs, arising during your work, as fast as I can.

    Best regards,
    Rado

    Thread Starter Dragon Heart

    (@sudheerranga)

    Thanks a lot for getting back. I will change my code.

    I will definitely give 2.0 a try and see if I can use for my plugin and theme development. Will post the bugs/issues on github so that it will be helpful for others as well.

    I wanted to know if how this scenario can be achieved.

    I am working on an API key based plugin and when the user enters the Key, I validate and if everything is fine, I need to populate a dropdown (select2) based on the json response. Can this be achieved with some hack using Ultimate Fields?

    For eg: Say user enters a Github username in the textbox. I will do an ajax call and form the json response from github, I want to display the repositories in the dropdown. Is this possible? or any other approach to achieve this?

    Let me know.

    Thanks.

    Plugin Author Radoslav Georgiev

    (@radogeorgiev)

    Hi again,

    currently this cannot be achieved neither through Ultimate Fields 1, nor 2. At least not without, as you said, hacking the plugin, which of course is not recommended.

    To achieve this you would need:

    1. A custom field type, although technically you’d be able to achieve it through hacking of the select field
    2. Some additional JavaScript because currently fields live within an enclosure, which does not allow them to know what other fields exist nor their values.

    However, you got me interested, so I will check if I can figure out something sleek within the next day and share it with you, as I have the feeling that this functionality will be requested for many situations.

    In this particular case, I feel the need for some core functionality that’s why I am giving it a try. Otherwise you would have to create the field on your own, which will include some code and if the sole purpose of including UF within your plugin is to have those two fields, it would simply be too much overhead.

    I am not aware if you need this for a post type or as an options page, so I cannot immediately point you in a particular direction, but if you share some more details, I would be glad to.

    Bye for now,
    Rado

    Plugin Author Radoslav Georgiev

    (@radogeorgiev)

    Hi again,

    I played a bit and you can now check the updated version of v.2 in GitHub and the field at https://github.com/RadoslavGeorgiev/ultimate-fields-value-injection-demo

    Currently it’s hard-coded to work with the “github_username” field, but I guess you would get the idea code-wise.

    Tomorrow I’ll work on an interface field that would allow people to select the fields, whose values would be injected and update the code.

    Till then,
    Rado

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Embedding Ultimate Fields into Custom Plugin’ is closed to new replies.