Determine the current page in PHP within a wordpress plug-in - php

This issue has been driving me up a wall.
I've been working on a mobile website for a friend who uses wordpress. I'm attempting to modify a wordpress plugin that "rethemes" each page for mobile users. I want the plugin to do it's normal thing ("retheme" the page) iff the user is on the blog page, otherwise (if the user visits a different page, he will be redirected to a different address (the address of the mobile website).
In order to do this, I have to be able to detect whether I'm on the blog page, or a different page when the functions in the plugin are run.
I tried condtionals like is_home, is_page(id), ect., but none of them work. I also tried parsing the url and attempting to determine the page that way, but I can't.
I'm just getting my feet wet with PHP, so I'm really not sure what to try next.
To restate my question: How can I determine whether I'm on a certain page within a wordpress plugin function?
The plugin, for the record, is "Wordpress PDA & iPhoned" (http://imthi.com/wp-pda/)
Here's the relevant code:
function PDAPlugin() {
if(true) {
header("Location: http://adavidcreation.com/mobile");
exit;
}
...
}
This works, but I want to change the if statement to only be true if it's NOT the blog.
Any help would be greatly appreciated!

Try using this, which should retrieve the page id: $id = get_option('page_for_posts');
If this doesnt work -> https://wordpress.stackexchange.com/

Related

Wordpress redirect from URL with BuddyPress

I am using the plugin BuddyPress on my WordPress site and when the user clicks on their profile they are redirected to the URL "/members/USERNAME/profile/home/". However, I do not want this page to be there and so I would like the profile 'landing' page to be the URL "/members/USERNAME/activity/".
I am not experienced with WordPress or PHP but I attempted to code a redirect for this when the user ends up on the 'home' page which is placed within my BuddyPress members/single/home.php file within my child theme:
$redirect_url_home = get_home_url();
$redirect_url_home_tt = $redirect_url_home;
$username_redirect_tt = wp_get_current_user();
$new_redirect_slug = "'/members/'.$username_redirect_tt->user_login.'/activity/'";
$redirect_url_home_tt. = $new_redirect_slug;
echo($redirect_url_home_tt);
wp_safe_redirect( $redirect_url_home_tt );
This code doesn't work but that was my thinking of how to solve my problem and I'm sure there is an easier/nicer way to do what I would like, maybe even without a coded redirect and within BuddyPress itself? I have tried using their forum/documentation for answers but haven't had a reply or found anything useful.
As I say I have no experience with this sort of stuff so any help would be greatly appreciated! Also, to add, I cannot link the site as it is currently on a localhost.
Thanks!
This question was originally posted on StackExchange here (https://wordpress.stackexchange.com/questions/386414/wordpress-redirect-from-url-with-buddypress) but I have had no reply as of yet and I would really like one so hopefully, this reaches someone that can help!

Wordpress - changing logo when on an imember360 page

A client is using iMember360 on his website, and doesn't want to give me access to the infusionsoft login so I can't ask this in their support forums, so hoping someone here will know a solution.
When you are viewing pages that are for a specific membership role only, he wants the website to have a different logo.
IE . if you are a profit.Ology member/subscriber, show a profit.Ology logo.
I was hoping when you are logged in, it would add some sort of body class to the tune of 'Profit.ology-Membership', so I could use that to change the logo, but nothing like that happens.
I know I can add a class using body_class('$myclass'); - but my issue is I don't know how to grab a variable for which of these was clicked (if that makes sense).
Has anyone done this before? Any ideas?
Cookies...
You will probably need to use the shortcodes provided by the iMember360 Wordpress plugin. See here for a reference. Even though it's not the original intent, you can use a shortcode as a php function (getting a value in return) by doing the following:
$variable = do_shortcode('[shortcode-name]');
So for example, if you used the ran the following code:
$i4w_users = do_shortcode('[i4w_user_levels sep="|"]');
Then take a look at what information is contained in the $i4w_users variable. You might be able to use that to parse out different user types/levels. If that shortcode doesn't do what you're looking for, you might need to look at some of the other shortcodes they provide on that reference page.

How to redirect a search query from a wordpress search bar to another website?

I am working on a wordpress website where i want to redirect my search from my wordpress site to another website and display the results of that search on that website , with the contents of that website
Assuming you're using the standard WordPress search form, you could hook into the get_search_form filter, and change the action attribute for the form. So something like:
add_filter('get_search_form', 'so_change_search_form_action', 10, 1);
function so_change_search_form_action($form) {
return preg_replace('#action="[^"]*"#','action="http://www.example.com/search"',$form);
}
That's completely untested code, but hopefully it'll get you started (I assume you have code on the destination server to handle the request).

Hide Javascript file from Analytics

I apologize ahead of time for the non descriptive title, as I wasn't really sure how to word this.
I've currently switched some of my Wordpress sites that have a responsive design that implement a slider over to WooSlider. Works super well, and I love it. However, there is something stopping me from switching all of my sites over. And I understand this is not a WooSlider only fault, but it's something I cannot Google and find out.
This is happening on every page view, even those without a slider.
In Google Analytics it shows domain.com/?wooslider-javascript=load&t=1352743207&ver=1.0.0 as a page view. For every single page. I obviously don't want this, but I don't know how to get rid of it.
Another example of this happening is using Gravity Forms with a referrer info plugin that shows page views, search query, browser, etc.
When the form is sent, the following is sent via email.
Page visited 1: domain.com/?wooslider-javascript=load&t=1352743207&ver=1.0.0 (http://domain.com/?wooslider-javascript=load&t=1352743207&ver=1.0.0)
Page visited 2: domain.com/about (http://domain.com/contact/about/
Page visited 3: domain.com/?wooslider-javascript=load&t=1352751787&ver=1.0.0 (http://domain.com/?wooslider-javascript=load&t=1352751787&ver=1.0.0)
Page visited 4: domain.com/contact/ (http://domain.com/contact/)
So obviously I don't want that js file to show up as a page view. How can I remedy this?
Thanks!
Google Analytics Configuration Mistake #2: Query String Variables
wooslider-javascript,t,ver

How does WP Greet Box work?

I have noticed some blogs using what looks like a wordpress plugin to detect if the website visitor came from google search. how is this done?
http://omninoggin.com/projects/wordpress-plugins/wp-greet-box-wordpress-plugin/
The plugin checks the $_SERVER['HTTP_REFERRER'] value (since it is written in PHP) which holds the referrer of the loaded page, then parses it to check what site the user came from to welcome them accordingly.

Categories