Support » Plugin: AWPCP - Classifieds Plugin » [Plugin: Another WordPress Classifieds Plugin] Add support for wp_enqueue_scripts for styles too

  • Resolved ahuggins


    I also see this being helpful for those that want to control which pages scripts and stylesheets are loaded on.

    Here’s the code that needs to be changed, I left in the old function so you could see what needs to be changed:

    function awpcp_addcss() {
    	//echo "\n".'<!--[if lte IE 6]><style type="text/css" media="screen">@import "'.AWPCP_URL.'css/'.$awpcpstylesheetie6.'";</style><![endif]-->
    	//		 ';
    	// load custom stylesheet if one exists in the wp-content/plugins directory:
    //	if (file_exists(WP_PLUGIN_DIR.'/awpcp_custom_stylesheet.css')) {
    //	    echo "\n".'<link rel="stylesheet" type="text/css" media="screen" href="'.WP_PLUGIN_URL.'/awpcp_custom_stylesheet.css" />';
    //	}
    function awpcp_enqueue_style(){
    	wp_register_style('awpcp_styles', AWPCP_URL.'css/awpcpstyle.css');
    	global $is_IE;
    	if( $is_IE ) {
    		wp_register_style('awpcp_ie6_styles', AWPCP_URL.'css/awpcpstyle-ie-6.css');
    	if (file_exists(WP_PLUGIN_DIR.'/awpcp_custom_stylesheet.css')) {
    		wp_register_style('awpcp_custom_styles', WP_PLUGIN_DIR.'/awpcp_custom_stylesheet.css');
    	    //echo "\n".'<link rel="stylesheet" type="text/css" media="screen" href="'.WP_PLUGIN_URL.'/awpcp_custom_stylesheet.css" />';
    add_action('wp_enqueue_scripts', 'awpcp_enqueue_style');

    This conditionally loads the IE styles for IE, a little more work would be needed to load only for IE6, but it shouldn’t be too bad. It also enqueues the styles for custom_styles and does it conditionally, so only for those that have that file.

    Let me know if you run into any issues. Would appreciate if you could make these changes.

Viewing 1 replies (of 1 total)
  • Plugin Author awpcp


    We’ll try it out and if there are no conflicts, we’ll go for it. IE6 is evil. 🙂 We’re trying to phase it out.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Another WordPress Classifieds Plugin] Add support for wp_enqueue_scripts for styles too’ is closed to new replies.