OthelloBloke
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Error with an old plugin using count() functionThat nailed it. Thank you.
Forum: Fixing WordPress
In reply to: Error with an old plugin using count() functionRyan’s Useful Options.
I took an old plugin called is_child and integrated into a plugin that I use on some client sites because I was sick and tired of copying and pasting. Figured I’d make a plugin.
Forum: Fixing WordPress
In reply to: Force User Email ChangeHi… cheers. I don’t want to change the passwords. I want to force people to change their email addresses.
Ryan
Forum: Developing with WordPress
In reply to: Help using a variable in a function parameterI fixed it. I was using the ID, and just used the page slug and everything worked perfectly.
Legit appreciate your help mate.
Forum: Developing with WordPress
In reply to: Help using a variable in a function parameterIt said there was another function because when you told me to try that, I didn’t erase all of the other code that initially defined it.
Thanks for your help anyway 🙂
Forum: Developing with WordPress
In reply to: Help using a variable in a function parameterI did that. It showed me a bunch of errors about other random plugins, but not a single error about is_child.
I even deleted ALL of that code from the plugin, and is_child then gave me an undefined function error.
Forum: Developing with WordPress
In reply to: Help using a variable in a function parameterI just went through the ENTIRE plugin, and the ONLY place is_child is used or mentioned is here:
<?php if( !function_exists( "is_child" ) ) { function is_child( $ofParent, $doRecursive = true ) { global $wpdb; $allCats = array(); // Turn title or slug into ID if needed. if( !is_int( $ofParent ) ) { if( is_page() ) # Different handling for Pages $getID = $wpdb->get_results(" SELECT ID as cat_ID FROM {$wpdb->posts} WHERE post_title = '{$ofParent}' OR post_name = '{$ofParent}' LIMIT 0,1 "); else # Get catID $getID = $wpdb->get_results(" SELECT cat_ID FROM {$wpdb->terms} // FROM {$wpdb->categories} WHERE cat_name = '{$ofParent}' OR category_nicename = '{$ofParent}' LIMIT 0,1 "); if( !$getID ) # Not found. return false; else { # Found. $ofParent = $getID[0]->cat_ID; unset( $getID ); } } // Everyone's a sub zero. if( $ofParent == 0 && $doRecursive ) return true; // Now let's break it down to categories (or pages). if( is_page() ) { global $post; $allCats[] = $post->ID; } elseif( is_single() ) { $getCats = get_the_category(); foreach( $getCats as $getCat ) $allCats[] = $getCat->cat_ID; unset( $getCats ); } elseif( is_category ) { global $cat; $allCats[] = $cat; } // Already a match? Would save processing time. if( in_array( $ofParent, $allCats ) ) return true; // Post without recursive search ends here. if( ( is_single() ) && !$doRecursive ) return false; // Otherwise, let's do some genealogy. while( count( $allCats ) != 0 ) { if( in_array( $ofParent, $allCats ) ) return true; else $allCats = is_child_getParents( $allCats ); } // Still here? Then nothing has been found. return false; } } if( !function_exists( "is_child_getParents" ) ) { function is_child_getParents( $fromChilds ) { // As there's only get_category_parents which isn't useful // for fetching parental data, we'll have to query this // directly to the DB. global $wpdb; $fromChilds = implode( ", ", $fromChilds ); if( !$fromChilds ) return array(); $getParents = ( is_page() ) ? # Pages $wpdb->get_results(" SELECT post_parent AS category_parent FROM {$wpdb->posts} WHERE ID IN ({$fromChilds}) ") : # Posts / Categories $wpdb->get_results(" SELECT category_parent // FROM {$wpdb->categories} FROM {$wpdb->terms} WHERE cat_ID IN ({$fromChilds}) "); foreach( $getParents as $getParent ) if( $getParent->category_parent != 0 ) $allParents[] = $getParent->category_parent; return $allParents; } }and then when I try to use it. I’m really stuck.
Forum: Developing with WordPress
In reply to: Help using a variable in a function parameterSo why does it work if I replace my original code with:
if( !is_user_logged_in() && is_child(232) ) { auth_redirect(); }
Forum: Developing with WordPress
In reply to: Help using a variable in a function parameterNo I mean it’s only defined in one place in the plugin… and then I use the is_child function later on in the plugin in a difference place.
Forum: Developing with WordPress
In reply to: Help using a variable in a function parameterYeah it’s being defined in the same plugin.
Forum: Developing with WordPress
In reply to: Help using a variable in a function parameteris_child already exists.
Forum: Developing with WordPress
In reply to: Help using a variable in a function parameterIt’s not echoing anything 🙁 I’m stuck. Here’s the is_child function:
<?php if( !function_exists( "is_child" ) ) { function is_child( $ofParent, $doRecursive = true ) { global $wpdb; $allCats = array(); // Turn title or slug into ID if needed. if( !is_int( $ofParent ) ) { if( is_page() ) # Different handling for Pages $getID = $wpdb->get_results(" SELECT ID as cat_ID FROM {$wpdb->posts} WHERE post_title = '{$ofParent}' OR post_name = '{$ofParent}' LIMIT 0,1 "); else # Get catID $getID = $wpdb->get_results(" SELECT cat_ID FROM {$wpdb->terms} // FROM {$wpdb->categories} WHERE cat_name = '{$ofParent}' OR category_nicename = '{$ofParent}' LIMIT 0,1 "); if( !$getID ) # Not found. return false; else { # Found. $ofParent = $getID[0]->cat_ID; unset( $getID ); } } // Everyone's a sub zero. if( $ofParent == 0 && $doRecursive ) return true; // Now let's break it down to categories (or pages). if( is_page() ) { global $post; $allCats[] = $post->ID; } elseif( is_single() ) { $getCats = get_the_category(); foreach( $getCats as $getCat ) $allCats[] = $getCat->cat_ID; unset( $getCats ); } elseif( is_category ) { global $cat; $allCats[] = $cat; } // Already a match? Would save processing time. if( in_array( $ofParent, $allCats ) ) return true; // Post without recursive search ends here. if( ( is_single() ) && !$doRecursive ) return false; // Otherwise, let's do some genealogy. while( count( $allCats ) != 0 ) { if( in_array( $ofParent, $allCats ) ) return true; else $allCats = is_child_getParents( $allCats ); } // Still here? Then nothing has been found. return false; } } if( !function_exists( "is_child_getParents" ) ) { function is_child_getParents( $fromChilds ) { // As there's only get_category_parents which isn't useful // for fetching parental data, we'll have to query this // directly to the DB. global $wpdb; $fromChilds = implode( ", ", $fromChilds ); if( !$fromChilds ) return array(); $getParents = ( is_page() ) ? # Pages $wpdb->get_results(" SELECT post_parent AS category_parent FROM {$wpdb->posts} WHERE ID IN ({$fromChilds}) ") : # Posts / Categories $wpdb->get_results(" SELECT category_parent // FROM {$wpdb->categories} FROM {$wpdb->terms} WHERE cat_ID IN ({$fromChilds}) "); foreach( $getParents as $getParent ) if( $getParent->category_parent != 0 ) $allParents[] = $getParent->category_parent; return $allParents; } }Forum: Developing with WordPress
In reply to: Help using a variable in a function parameterI already did that. It’s echoing the page ID number that it’s supposed to.
But it doesn’t work when I put the variable as the parameter 🙁
Forum: Fixing WordPress
In reply to: Custom Plugin Settings Screen – Saving HTMLAnyone?
Forum: Plugins
In reply to: [Contact Form 7] wpcf7_add_shortcode is deprecatedI’m not using wpcf7_add_shortcode anywhere.
I just installed the plugin, and added
[contact-form-7 id="50" title="Contact form 1"]to my page.That post doesn’t show me how to fix the error.