daphatmac
Forum Replies Created
-
Forum: Plugins
In reply to: [Secure Custom Fields] Had to downgrade to 3.5.4There’s definitely an issue with the JS / jQuery – I’ve had similar issues with conditional logic since the 3.5.5 update.
I could go through the code and fix it, but like everyone else here, it’s just quicker to downgrade until the bugs are fixed.
Forum: Plugins
In reply to: [Secure Custom Fields] Is conditional logic broken / changed in 3.5.5?That’s interesting – it must be a change in one of the JavaScript files then – oh, by the way, I found this today for the exact same reason!
Let’s hope it’s not a major bug – it doesn’t seem to be, but it would be nice to be fixed soon ??
Forum: Plugins
In reply to: [Secure Custom Fields] Is conditional logic broken / changed in 3.5.5?I’ve changed the code for the conditional logic script generation to use .on() instead of .live() and it seems to work for me now. The only issue I have is that validation is still performed on fields that have been hidden by conditional logic. I would prefer if a field is hidden by conditional logic that any validation for that field is ignored (i.e., is_required etc).
Here’s the code I’m using at the moment – although I’m hoping there’ll be a fix in the next update – this is around line 796 in
acf.php
.// conditional logic // - isset is needed for the edit field group page where fields are created without many parameters if (isset($field['conditional_logic']['status']) && $field['conditional_logic']['status']) { $join = ' && '; if ($field['conditional_logic']['allorany'] == "any") { $join = ' || '; } $if = array(); foreach ($field['conditional_logic']['rules'] as $rule) { $if[] = 'acf.conditional_logic.calculate({ field : "'. $field['key'] .'", toggle : "' . $rule['field'] . '", operator : "' . $rule['operator'] .'", value : "' . $rule['value'] . '"})' ; } //do script echo '<script type="text/javascript">'; echo ' (function($) {'; echo ' var conditionalFN = function() {'; echo ' var field = $(".field-'.$field['key'].'");'; echo ' if('.implode($join, $if).') {'; echo ' field.show();'; echo ' } else {'; echo ' field.hide();'; echo ' }'; echo ' };'; foreach($field['conditional_logic']['rules'] as $rule ) { echo ' $(".field-'.$rule['field'].' *[name]").on("change", function(){'; echo ' conditionalFN();'; echo ' });'; } echo ' conditionalFN();'; echo ' })(jQuery);'; echo '</script>'; }
Forum: Plugins
In reply to: [Secure Custom Fields] Is conditional logic broken / changed in 3.5.5?Looks like
acf.conditional_logic.calculate
isn’t being called for some reason. I’ll keep investigating & update this if I find a solution.Wondering if it’s something to do with the update to jQuery 1.8 in WP 3.5 and the deprecation of the .live() event handler.
Yeah, it seems that $acf is only partly instantiated by the time I need it in functions.php. If I global it, I can get to it, but it’s clearly not initialized in full yet. I hadn’t noticed it before because I had some fallback code in case of an empty return from the get_field(), which was covering for it.
I’ve done some searching and apparently plugins are loaded and init’ed before the functions.php file, so I should have access to the ACF methods in full. Is there any way to make sure the fields are registered and the plugin is fully available, or is this just a limitation of WP?
Thanks again!
Hmmm. I’ve rolled back to 3.2.0 and a previous version of my DB and I’m still having similar issues. Let me check it out some more and I’ll get back to you.
Thanks & great plugin BTW!
Forum: Plugins
In reply to: [CaPa Protect] [Plugin: CaPa Protect] CaPa issue with search..Hey Freediver,
Not sure if this will help you, but I came across a similar issue – I thought about hacking the plugin, but I ended up using a custom query – here’s my code with a bit tacked on for pagination.
//setup pagination $paged = 1; if(isset($_GET['paged'])) { if($_GET['paged'] != '') { $paged = $_GET['paged']; } } $args['paged'] = $paged; //get custom protection categories from CAPA $CAPA_settings = get_option('capa_protect_cat_user_'.$current_user->ID, ''); if(is_array($CAPA_settings)) { foreach($CAPA_settings as $category=>$value) { $allowed_categories[] = $category; } $args['category__in'] = $allowed_categories; } //setup custom query $args['s'] = $search_term; query_posts($args);
So I basically pull the CAPA defined permissions for the current user, based on their ID (if you get an error about the user ID, you may need to bring the $current_user variable into the page from the global scope by adding
global $current_user;
to the beginning of this snippet.This seems to work OK for me so far, and it might give you a headstart in the right direction ??
Hey Michael,
Sorry if I was a little confusing – I actually added that line to the WP Require Auth plugin that was causing the problem. Your plugin worked beautifully without any changes, so kudos to your uberness! If I do ever come up with any improvements to your plugin that you might find useful, I’ll probably PM you and we can work out a fork if need be, but I doubt I can improve what you’ve made.
Thanks for taking the time to follow up with me on this – take it easy mate!
Ooooohkay, I’m a bit of an idiot.
Only when I output the results of the crontabb’ed wget to terminal, instead of /dev/null, did I notice that the wget wasn’t even making it to wp-cron.php.
I was wondering why, when I realised that because this is an internal company site, with staff only access, I’m forcing authentication with the WP Require Auth plugin and of course the wget was literally getting trapped it into a “must login first” state because of the plugin.
So, to fix it, I’ve just added this line to the plugin (fortunately it’s not a complicated plugin):
&& (strpos($_SERVER['PHP_SELF'], 'wp-cron.php') === false
This basically includes the wp-cron.php file as one of files that are excepted from authentication checking in the plugin. It looks like you can add exceptions to any page here and I know it’s a pain if there’s an upgrade to the plugin that overwrites this change, but at least I know where I’m going wrong.
Needless to say, it’s all working now – thanks for taking the time to be my programming teddy bear!
Hopefully this helps someone out in the future anyway – thanks again for your help and the excellent plugin ??
Hey again – seems like it hasn’t made any difference ??
I’ve been testing wp-cron with scheduled posts – and all I’m getting is “missed schedule”.
Interestingly enough, it doesn’t seem to work if I try the internal wp-cron, OR disable it and use the Linux crontab to execute a bash script.
I’ve tried using the crontab of several users including root. I’ve tried using wget, curl AND PHP CLI in the bash script to trigger the wp-cron.php and all I get it a generic “you’re not logged in page”.
I’ll keep going and if I make a breakthrough, I’ll send you an update ??
OK, it doesn’t look like wp-cron is actually running, so I’ve made some changes according to instructions here.
I’ll let it run overnight and check in the AM to update you.
Cheers mate!
That’s no worries – I’ll check that tonight and get back to you.
Thanks!