Wordpress: How does a plugin generate a page? - php

Could someone please solve a beginner's crisis for me? I simply CANNOT figure out how a plugin generates a page or even multiple pages without making a page template in the dashboard. I have read Google results and even talked to the author of this plugin I am reading through to get an idea but the way he explained it was too complex for me to understand. Here is a link in case you want to see his explanation. But I just want to understand...If a plugin is ONE PHP script, then whatever function calls the HTML template for the page must include() it right? At least that's how this plugin does it. But then why is it that when I click on one of the pages for the plugin I see this in the URL: http://www.efficientmind.org/?page_id=73. What does the ?page_id=73 mean? And how does query_vars play a part in all this? I'm so confused...Could someone maybe explain it in layman's terms and then also in a more technical so I can compare and contrast??

Related

Function in button

So I'm working on a wordpress theme and it's really twisted. The problem is I'm comfortable just with html and css, as I'm a code noob, so I would really appreciate your help here.
The problem here is that I want to put a tracking script and a redirect on a specific button. I'd now how to do this if I'd find the button's html form.
But when I go to the code in the page where the button is, this is the only thing showing regarding the button
<?php BookYourTravel_Theme_Utils::render_submit_button("primary-btn",
"submit-accommodation-booking", esc_html__('TRIMITE REZERVAREA',
'bookyourtravel')); ?>
BookYourTravel is the theme
I know you should maybe see all the files to know what to do, as this doesn't seem as enough info.
But I also have a functions.php file. Should I look there? Do you have any idea where should I go?
Thank you a lot. Really stuck here.
Are you writing the theme yourself or are you working with someone else's theme? If you're working on someone else's theme, I would reccommend looking into building a child theme so if you change some code, the OG theme is still there in it's entirety and if they update the theme, your code wont get destroyed in the update. There are tons of tutorials on how to set up a child theme and theres a plugin that will make it for you called Child Theme Configurator if you're not too keen on doing it yourself.
You should be super careful when you're editing functions in your theme(especially if you're new to PHP), but that's where this html is being generated. One of those functions is the thing that's generating your html. If you find where the function is held, you could probably change it so it echos the extra code you're looking to implement but it would be on every button that this function generates throughout your site.
You didn't really give enough information for us to do anything. So if you are really pulling your hair on this one just replace the old button with a new button that you wrote. I can help you out on that end if you don't know javascript.

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.

Facebook link inspector

I'm building a website and am looking for a way to implement a certain feature that Facebook has. The feature that am looking for is the link inspector. I am not sure that is what it is called, or what its called for that matter. It's best I give you an example so you know exactly what I am looking for.
When you post a link on Facebook, for example a link to a youtube video (or any other website for that matter), Facebook automatically inspects the page that it leads you and imports information like page title, favicon, and some other images, and then adds them to your post as a way of giving (what i think is) a brief preview of the page to anyone reading that post.
I already have a feature that allows users to share a link (or URLs). What I want is to do something useful with the url, to display something other than just a plain link to a webpage, to give someone viewing a shared link (in the form if a post) some useful insight into the page that the url leads to.
What I'm looking for is a script, or tutorial, or at the very least someone to point me in the right direction, so that it can help me accomplish this (using PHP preferably).
I've tried googling it but I don't know exactly what such a feature would be called and google isn't helpful when you don't exactly know what you're looking for.
I figure someone out there, in this vast knowledge basket called stackoverflow, can help me with this. Can anyone help me?
You would first scan the page for URLs using regex, then you would parse the pages those links reference with a php DOMDocument. You could use the parsed document to obtain any information you need from the webpage.
DOMDocument:
http://php.net/manual/en/class.domdocument.php
DOMDocument->load (loads a file, aka a webpage):
http://php.net/manual/en/domdocument.load.php
the link goes through http://www.facebook.com/l.php
You pass a URL to this and facebook filters it.

Prestashop - custom template link

I'm starting with "PrestaShop" and I just can't figure out, how to put a link in template to custom page I created in CMS module... I thought, there might be some easy way, as there is in WordPress, like "get_permalink(ID)", but there's nothing like this and I can't find anything about this anywhere and it just drives me mad.
So, here's the deal, I've got a custom template, and there are some top links, like "About Us". I've created this page in CMS and it has ID "6".
How do I make this bloody "PrestaShop" to generate a link to this page in my template file?
About
I think you're looking for SMARTY template tags and custom variables defined for Prestashop specifically. The one the you probably need is {$base_dir} which will be translated to http://www.yoursite.com/ obviously with appropriate protocol (non-secure HTTP or secured HTTPS).
After that, you only need to include page URL, which you can get from Admin->Tools->CMS section.
If I find any specific tags that you can use to call the content, I will update my post here.
Your Text
the "WHAT goes here" is just the url you want your link drives the client to when clicking on that link.
You need to understand a little minimum of HTML for this I guess. Check html tag a meaning .
Prestashop has a fairly good and extensive documentation. Two and half seconds googling drives me here, just like answering your question it looks like.

do not reload sidebar.php within single.php

In my Wordpress-powered website (http://onomadesign.com/wordpress/identity-design/usx-corporation/ for example) I want the sidebar.php, the thumbnail navigation on the right, NOT to reload when people click another project. So that they not get lost in navigation.
Now, I have looked at iframes, jQuery cookies, 'AHAH-method', php sessions.. but I can't find an easy way to do this.
I am defenitely not a programming expert, could someone give me an easy solution for this?
Thanks a lot in advance!
IFrames or AJAX are the only two options you have. (I suppose unless you did full screen flash) Everything else is going to reload the page. Ahh those other technologies you mentioned do not address the problem of reloading the main page (except iframes)
It isn't really going to be "straight-forward", but what you're trying to do isn't straight forward. I really recommend you take a look at jQuery and how AJAX works, it's probably the better of the options all things considered.
There are a few Wordpress plugins that attempt to implement this functionality. I haven't used any, so I'm not sure if they completely avoid reloading the sidebar, but it's worth a shot. One in particular that seems fairly well scored would be http://ajaxedwp.com/ I found this plugin by going to the "Add New" plugins page in the Wordpress Admin panel and searching for "AJAX Page Load".

Categories