Save last login date in global before change it?
Don’t use global variables. You can do it like this without global variable: global $current_user; echo get_user_meta( $current_user->ID, ‘last-login’, true );
Don’t use global variables. You can do it like this without global variable: global $current_user; echo get_user_meta( $current_user->ID, ‘last-login’, true );
global $wp_meta_boxes returns NULL
I think the best way to do it is to index all the posts and search through them in database. This method should be the fastest when you perform a search because you can filter posts, create the pagination etc. Check this tutorial https://rudrastyh.com/wordpress/search-across-wp-multisite.html Another way is to to something with switch_to_blog() function – I … Read more
I’m afraid you can’t do what you are after – without AJAX, that is. The problem lies with the fact that all/most of the meta boxes are added in an admin-specific context. The add_meta_boxes action hook, for instance, is the most common (and appropriate) place to add custom meta boxes. And this very hook is … Read more
You can encapsulate the logic in a class: class NameSwitch { private $state = false; private $string; public function __construct( $string ) { $this->string = $string; } public function change_state() { $this->state = ! $this->state; return $this->state; } public function replace( $output, $show = NULL ) { if ( ‘name’ !== $show ) return $output; … Read more
Remove that filter/function and apply your markup in the PHP template/page file. If you need help post where you output the title. CLASS Here is how I might set this up using a class: if ( ! class_exists( ‘ThemeCustomizations’ ) ) { class ThemeCustomizations { static $inBody = false; public static function set_in_body_true() { static::$inBody … Read more
A Must Use plugin could do the work. This is just an outline and has to be fully tested: add_shortcode( ‘global_form’, ‘shortcode_wpse_87634’ ); function shortcode_wpse_87634() { // Main site, ID=1, that has the form switch_to_blog( 1 ); // Do your stuff $my_stuff = something(); // maybe do_shortcode // Back to original site restore_current_blog(); // Return … Read more
OK, got it. I just dug around in wp core a bit and found the function they use to grab autodetcts. WP uses the php preg_replace_callback function within the WP autoembed function. Here is the code, as seen in wp-includes/class-wp-embed.php: /** * Passes any unlinked URLs that are on their own line to {@link WP_Embed::shortcode()} … Read more
I would stay stick to the function. PHP caches functions for speed and efficiency. In some situations, using a function is faster then using a variable. There are other benefits too – imagine if you changed the name of your variable – you would have to go and update every piece of code where it’s … Read more
get_query_var() is a wrapper for $wp_query->get($var);. But the global $wp_query is not always identical to the one set up during the request. That’s the main problem with query_posts(). And other plugins can overwrite these variables unintentionally too. I have seen plugins putting $i into the global namespace … And the return values are different: $GLOBALS[‘missing_var’] … Read more