Aangemaakte reacties

2 reacties aan het bekijken - 1 tot 2 (van in totaal 2)
  • Thread starter Nukeface

    (@nukeface)

    Extra informatie:
    Wanneer de site ‘nl_NL’ gedefinieerd heeft staan voor de taal dan werkt het dashboard niet, zonder ‘nl_NL’, dus ” voor Engels, dan werkt het dashboard zonder probleem.

    Zien jullie misschien ook iets mis met deze code? Ik probeer style en script bestanden te registreren binnen een plugin. Er is een print_r en/of echo op uit te voeren na de registratie, dus de syntax iig klopt. Maar ik krijg ze niet terug te zien. Ik ben nog vrij nieuw aan het WP programmeren en al helemaal wat plugins aan gaat.

    function load_script_files(){
    	$pluginURL = plugin_root();
    
    	//CASCADING STYLE SHEETS
    	//make an array of stylesheets to be added automatically on admin dashboard load
    	$styleArray[] = array( 'handle' => 'dummy', 'src' => $pluginURL . '', 'path' => WP_PLUGIN_DIR ); //unknown why, first add_action does not work using foreach
    	$styleArray[] = array( 'handle' => 'maxe_dashboard_css', 	'src' => $pluginURL . 'php/maxe_dashboard.css',			'path' => WP_PLUGIN_DIR . '/max-event/php/maxe_dashboard.css' );
    	$styleArray[] = array( 'handle' => 'maxe_page_calender_css', 		'src' => $pluginURL . 'php/maxe_page_calender.css',		'path' => WP_PLUGIN_DIR . '/max-event/php/maxe_page_calender.css' );
    	$styleArray[] = array( 'handle' => 'maxe_widget_css', 		'src' => $pluginURL . 'widget/maxe_widget.css', 	'path' => WP_PLUGIN_DIR . '/max-event/widget/maxe_widget.css' );
    
    	//loop through stylesheet array to create and call action to have them added, one at a time
    	foreach( $styleArray as $style ){
    		do_action( 'wp_print_styles', $style );
    		add_action( 'wp_print_styles', 'add_stylesheet', 10, $style );
    	}
    }
    
    //add stylesheets to the page to be loaded, $style to consist of: $handle, $src, $path
    function add_stylesheet( $style ){
    	$src = 		$style[ 'src' ];
    	$handle = 	$style[ 'handle' ];
    	$path = 	$style[ 'path' ];
    	printr($style);
    	//check if the file path exists, then register the file and add to list to be generated
    	if( file_exists( $path )){
    		wp_deregister_style( $handle );
    		wp_register_style( $handle, $src );
    		wp_enqueue_style( $handle );
    	}
    }

    Resultaat (URL’s kloppen):
    Array
    (
    [handle] => maxe_page_calender_css
    [src] => http://URL/wp-content/plugins/max-event/php/maxe_page_calender.css
    [path] => /URL/wp-content/plugins/max-event/php/maxe_page_calender.css
    )

    Tevens is er het gekke probleem dat in de foreach bij de eerste array waarde, [0], de registratie functie niet wordt aangeroepen.

    Veel meer dan dit wordt er nog niet gedaan door de plugin.

    Alvast bedankt voor de hulp!!!
    Nukeface

2 reacties aan het bekijken - 1 tot 2 (van in totaal 2)