Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Dan

    (@danscott1121)

    Hi,

    Thanks for the reply, sorry for my broad request.

    Well, in general, to be able to (better and more ‘neatly’) build on the functionality that a plugin provides, without having to request features and wait for them to (maybe) be implemented in a later version. Also to be able to answer some of my own questions, without having to post a question and wait for a reply (e.g. what JS events and methods does your plugin provide?).

    Whilst I love plugin and think your plugin is one of the better cookie control ones available as a WP plugin, it still doesn’t do everything I need.

    A couple specific things:

    I don’t want the popup to close on clicking outside of the popup.

    I need JS events to be fired on enabling/disabling the various types of cookie (passing relevant information to hooks), and on enabling all, and on saving changes. (there may already be such events in your plugin’s JS, but its not easy to figure it out with the minified version only).

    I need to be able to tell your plugin’s JS to enable/disable cookies, on a per category basis, from my own JS code.

    Thanks

    Thread Starter Dan

    (@danscott1121)

    Hi,

    I did figure it out… Sorry, I should have posted at the time, but here it is now my solution:

    I found the function (in pmpro register helper plugin) which outputs custom checkoutboxes:

    pmprorh_pmpro_checkout_boxes();

    I ‘overrode’ this ^^ function with my own function. My function is a copy-n-paste of pmprorh_pmpro_checkout_boxes(), I just changed the format of the HTML to match the structure of the existing table-based checkout boxes.

    My function is that below, which I added to the pmpro_checkout_boxes hook.

    NOTE: the function below is not in my theme’s functions.php, but in a custom plugin. PMPRO recommends making customization this way (read this).

    You need to remove the old action for the same hook. I ended up doing this in my theme’s functions.php. I tried doing it in the customisations plugin, but it wasn’t working for some reason.

    ‘remove_action(“pmpro_checkout_boxes”, “pmprorh_pmpro_checkout_boxes”);’

    function my_pmprorh_pmpro_checkout_boxes()
    {
    	global $pmprorh_registration_fields, $pmprorh_checkout_boxes;
    
    	foreach($pmprorh_checkout_boxes as $cb)
    	{
    		//how many fields to show at checkout?
    		$n = 0;
    		if(!empty($pmprorh_registration_fields[$cb->name]))
    			foreach($pmprorh_registration_fields[$cb->name] as $field)
    				if(pmprorh_checkFieldForLevel($field) && (!isset($field->profile) || (isset($field->profile) && $field->profile !== "only" && $field->profile !== "only_admin")))		$n++;
    
    		if($n > 0)
    		{
    			?>
    			<table id="pmpro_checkout_box-<?php echo $cb->name; ?>" class="pmpro_checkout">
    				<thead>
    				<tr>
    					<th>
    						<h2 class="sectionHeading"><?php echo $cb->label;?></h2>
    
    						<div class="underline clear"></div>
    						<span class="pmpro_thead-msg"> <a href=""></a></span>
    					</th>
    				</tr>
    				</thead>
    				<tbody>
    				<tr>
    					<td>
    						<?php
    						foreach($pmprorh_registration_fields[$cb->name] as $field)
    						{
    							if(pmprorh_checkFieldForLevel($field) && (!isset($field->profile) || (isset($field->profile) && $field->profile !== "only" && $field->profile !== "only_admin")))
    								$field->displayAtCheckout();
    						}
    						?>
    					</td> <!-- end pmpro_checkout-fields -->
    				</tr>
    				</tbody>
    			</table> <!-- end pmpro_checkout_box-name -->
    			<?php
    		}
    	}
    }
    
    add_action("pmpro_checkout_boxes", "my_pmprorh_pmpro_checkout_boxes");
    Dan

    (@danscott1121)

    I found this tip in another thread…

    Someone found that the loading of one particular css file was causing their pmpro powered site to be very slow (a print CSS file).

    This solution was posted:

    //don't load PMPro print CSS
    function init_dont_load_pmpro_print_css()
    {
        wp_dequeue_style('pmpro_print');
    }
    add_action('init', 'init_dont_load_pmpro_print_css', 20);

    (add to your theme’s functions.php).

    It seems silly that one css file could be causing such performance problems, but I added the above code (to remove the css file) and my site suddenly started to perform like an averagely fast site (compared to super, slow before).

    Give it a go.

Viewing 3 replies - 1 through 3 (of 3 total)