Support

Account

Home Forums Feature Requests Shortcodes Plugin

Solved

Shortcodes Plugin

  • Hello, I have purchased all of your plugins, and will continue to do so. I would like you to make a WordPress shortcode plugin. We need it most.

    Regards.

  • Hi @iamilkay

    Thanks for the request. I created a plugin called shortcode developer a while back which may be what you are looking for.

    Thanks
    E

  • Hi @iamilkay

    Thanks for the link, but I have no intention to make such a shortcode plugin as I am happy working on ACF.

    Thanks
    E

  • Hello,
    You have misunderstood me. I’m pleased with AFC plugins. What if you make a “shortcode” plugin as AFC like your Custom Field plugin or Options Page plugin. So we can make our own “shortcode”s and add to our theme thanks to this plugin.

  • Hi @iamilkay

    ACF already has a shortcode which you can read about in the docs.
    Are you asking to add a button to the WYSIWYG field, where you can simply insert an ACF shortcode / value?

    Thanks
    E

  • I am actually thinking of working on something similar. A button in the wysiwyg editor that would show you all the custom fields under your options page.

    So you could easily enter global values without having to know your how to write the shortcode.

  • I found this tutorial today and figured I would take a shot at writing what I needed. “http://www.wpactions.com/1028/how-to-create-dropdown-list-button-in-tinymce-toolbar/”

    I was successful in creating a simple dropdown that would allow you to pick from ACF from your options page. I have only tested it with the text field since that’s all I am using it for but I believe it should work for quite a few fields.

    Plugin File (acf-dropdown-shortcode.php)

    <?php
    /*
    Plugin Name: Advanced Custom Fields: Dropdown Shortcode
    Plugin URI: http://www.andresthegiant.com
    Description: Create a dropdown list of Advanced Custom Fields in the tinymce toolbar
    Author: Andres The Gaint
    Version: 0.1
    Author URI: http://www.andresthegiant.com
    */
    
    include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    if ( is_plugin_active( 'advanced-custom-fields/acf.php' ) ) {
    
    	add_action('admin_head', 'my_print_shortcodes_in_js');
    	add_action('admin_head', 'my_add_tinymce');
    	function my_print_shortcodes_in_js(){
    			
    		?>		
    		<script type="text/javascript">			
    			var my_shortcodes = [
    				
    				<?php 
    					$fields = get_fields('option');
    					if( $fields )
    					{
    						foreach( $fields as $field_name => $value )
    						{
    							// get_field_object( $field_name, $post_id, $options )
    							// - $value has already been loaded for us, no point to load it again in the get_field_object function
    							$field = get_field_object($field_name, false, array('load_value' => false));
    					 
    								echo "'" . $field_name . "' , ";
    						}
    					}
    				?>
    			
    			];
    		</script>
    		<?php
    	}
    	
    	
    	function my_add_tinymce() {
    		// global $typenow;
    		// if(!in_array($typenow,array('post','page')))
    		// 	return ;
    		add_filter('mce_external_plugins', 'my_add_tinymce_plugin');
    		add_filter('mce_buttons', 'my_add_tinymce_button');
    	}
    	
    	function my_add_tinymce_plugin($plugin_array) {
    		$plugin_array['acf_drop'] =	plugins_url( 'dropdown-shortcode.js',__FILE__ );
    	
    		return $plugin_array;
    	}
    	
    	function my_add_tinymce_button($buttons) {
    		array_push($buttons, 'acf_drop');
    		return $buttons;
    	}
    }
    
    ?>

    Plugin JS File (dropdown-shortcode.js)

    (function() {
    	
    // Makes ACF names readable 
    function unSlugify(Text)
    {
    	return Text
    		.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();})
    		.replace(/_/g, " ")
    		;
    }	
    	
    tinymce.create('tinymce.plugins.acf_drop', {
     
    init : function(ed, url) {
    },
    createControl : function(n, cm) {
     
    if(n=='acf_drop'){
    var mlb = cm.createListBox('acf_drop', {
    title : 'ACF Options',
    onselect : function(v) {
    if(tinyMCE.activeEditor.selection.getContent() == ''){
    tinyMCE.activeEditor.selection.setContent( v )
    }
    }
    });
     
    for(var i in my_shortcodes)
    mlb.add(unSlugify(my_shortcodes[i]), '[acf field="' + my_shortcodes[i] + '" post_id="option"]');
     
    return mlb;
    }
    return null;
    }
     
     
    });
    tinymce.PluginManager.add('acf_drop', tinymce.plugins.acf_drop);
    })();

    Hope this can help someone else

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Shortcodes Plugin’ is closed to new replies.