Ready to get started?Download WordPress


Developer's Custom Fields
A way to include this in your theme (1 post)

  1. bjones1985
    Posted 10 months ago #

    This is how you can add this plugin included in your theme if you want. You must change the slt-cf-init.php file and change the plug_url to get_template_directory_uri() . '/folder-name/developers-custom-fields/js/slt-cf-admin.js' ); for each of the files it requires to load. I have been using this and it works fine. This is way I included it. I am not saying that it will never break or that this is the perfect way for including it in your theme so be advised. When I have time I will look into editing this a bit so that it can be included in a better way. Plugin is great though and I really like it.

    So remember change the plugin_url because plugin_url is how you would include it in plugin form. So to included it in template form you have to change this. Here is a full example but I put mine in my inc folder. You do not have to included it in this folder. This was how I preferred to include mine.

    /* Initialize
    // Global initialization
    function slt_cf_init() {
    	global $slt_custom_fields;
    	// Globals still to initialize (ones that use core functions with filters that aren't exposed if run earlier)
    	$slt_custom_fields['ui_css_url'] = ( get_template_directory_uri() . '/inc/developers-custom-fields/js/jquery-ui/smoothness/jquery-ui-1.8.16.custom.css' );
    	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG )
    		$slt_custom_fields['css_url'] = ( get_template_directory_uri() . '/inc/developers-custom-fields/css/slt-cf-admin.css' );
    		$slt_custom_fields['css_url'] = ( get_template_directory_uri() . '/inc/developers-custom-fields/css/slt-cf-admin.min.css' );
    	// Register scripts and styles
    	wp_register_style( 'slt-cf-styles', $slt_custom_fields['css_url'] );
    	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
    		$slt_js_admin = ( get_template_directory_uri() . '/inc/developers-custom-fields/js/slt-cf-admin.js' );
    		$slt_js_file_select = ( get_template_directory_uri() . '/inc/developers-custom-fields/js/slt-cf-file-select.js' );
    		$slt_js_gmaps = ( get_template_directory_uri() . '/inc/developers-custom-fields/js/slt-cf-gmaps.js' );
    	} else {
    		$slt_js_admin = ( get_template_directory_uri() . '/inc/developers-custom-fields/js/slt-cf-admin.min.js' );
    		$slt_js_file_select = ( get_template_directory_uri() . '/inc/developers-custom-fields/js/slt-cf-file-select.min.js' );
    		$slt_js_gmaps = ( get_template_directory_uri() . '/inc/developers-custom-fields/js/slt-cf-gmaps.min.js' );
    	wp_register_script( 'slt-cf-scripts', $slt_js_admin, array( 'jquery' ), SLT_CF_VERSION );
    	if ( ! SLT_CF_WP_IS_GTE_3_3 ) {
    		// Register jQuery UI Datepicker for below WP 3.3
    		wp_register_script( 'jquery-ui-datepicker', ( get_template_directory_uri() . '/inc/developers-custom-fields/js/jquery-ui/jquery-ui-1.8.16.custom.min.js' ), array( 'jquery-ui-core' ), '1.8.16', true );

    in your text editor line 3 to 32 of the code is all you change.



You must log in to post.

About this Plugin

About this Topic


No tags yet.