Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #995505

    Hi,

    i stumbled upon this code: https://kriesi.at/support/topic/custom-avia-shortcodes/
    While it works for a child theme, it seems not to work for a plugin:

    $plugins_url = plugin_dir_url( __FILE__ );
    
    add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
    function avia_include_shortcode_template($paths)
    {
        	array_unshift($paths, $plugins_url.'shortcodes/');
    
    	return $paths;
    }

    Pathes are accordingly changed for plugin – but i cannot see them in the layout builder.

    #995510

    I also tried the setup after the theme – doesnt work either, any help appreciated

    $plugins_url = plugin_dir_url( __FILE__ );
    
    add_action( 'after_setup_theme', 'loadPlugin' );
    
    function loadPlugin() {	
    
    	add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
    	
    }
    
    function avia_include_shortcode_template($paths)
    {
    	array_unshift($paths, $plugins_url.'shortcodes/');
    	return $paths;
    }
    • This reply was modified 6 years, 3 months ago by rup.
    #995670

    Hi,

    I think your code won’t work because $plugins_url is not defined as global var. You can try this code instead:

    
    function avia_include_shortcode_template($paths)
    {
    	global $plugins_url;
    	array_unshift($paths, $plugins_url.'shortcodes/');
    	return $paths;
    }
    

    or you define the $plugins_url var inside the function like:

    
    function avia_include_shortcode_template($paths)
    {
    	$plugins_url = plugin_dir_url( __FILE__ );
    	array_unshift($paths, $plugins_url.'shortcodes/');
    	return $paths;
    }
    

    Best regards,
    Dude

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.