Wordpress: using a test theme only for a specific user - php

I'm testing a new template for a wordpress based site, and I'd like to test it directly on the live version instead of making copies. I thought I could create a test user (wordpress is bridged with vbulletin which handles user auth), serve the usual theme to anyone BUT that specific user, who would get the new testing one.
I don't want to install a plugin, I'm looking for the right place to edit to insert this check:
if logged user == test_user_id
serve 'testtheme'
else
serve 'normaltheme'
The userid can be get from $_COOKIE.
I tried hacking the get_template() function in wp-include/theme.php but apparently that was not enough. Any suggestion?

This is the best way to "test" or develop a theme behind the scenes without needing to alter too much of your Wordpress core or make custom changes...
http://digwp.com/2009/12/develop-themes-behind-the-scenes/

Just logging into my old Wordpress.com blog, I see that I can do all the previewing I want from the themes manager already - click around to any page I like, or bring up the frame's URL to see what query string I'd have to append to a URL to get the same preview, e.g.
?preview=1&template=pub/mytheme&stylesheet=pub/mytheme
Any reason that's not enough?

Perhaps you should add a column to your user table, call it "is_beta" and if it's set to 1 then enable beta features/themes. This way you can easily add or remove people from the beta, and when you're beta is ready to launch, you flush the column for everybody and make the features default.

Related

How to update the content of a website using the website itself?

Is it possible to update the content of a website (add Item, remove Item, update Infos, etc...) directly from the webpage?
For example, you have a webpage and you make a new page in it, that only the admin can access. That page should contain some options that allow the admin to change/update contents on the actual website(what people can see) easily.
(Without the admin having to write new HTML or PHP code...)
I heard something about Joomla or Wordpress but I don't really know how they work.
Thank you.
Basicaly, joomla has some fonctionnalities to edit content by the frontoffice. Of course, the user need to be logged and access levels need to be well managed. You should to try it with a basic installation and see if it's coherent with respect to that you looking for.

How to hide WordPress from public view

I have developed a site in PHP which uses WordPress to provide news article content. Both my application and WordPress code bases sit on the same physical box.
The application uses the WordPress loop to pull content from the WordPress back-end and display it within my application.
The content editors for the site require access to the Wordpress back-end to add, edit and remove content as required. WordPress is currently accessible via a sub-domain i.e blog.mydomain.com. However, I do not want to expose WordPress publicly as it is currently, firstly because I want WordPress to behave transparently and secondly I do not want to get penalized for duplicate content when ranking for SEO.
The obvious solution would be to lock down access based on the visitors I.P address, but this is not practical given that the content editors can (and do) access the site from anywhere and not a fixed set of I.P's.
Another solution would be for the content editor to submit a secret parameter in the query string to identify themselves as an administrator i.e &wpadmin=true. However this doesn't seem ideal either.
Is there some other way I could consider architecting the site, or provide some other more suitable access control mechanism for WordPress?
Have you considered simply slapping a htaccess password dialog into WP's root directory? That's close it to the world, and still make it available to who has the right login info.
The only downside would be that your editors would have to log in twice, but the web server login credentials can be easily stored in the browser.

Changinging Joomla template according to the url open in the browser, how?

I am asking if is it possible do the following thing using Joomla
I have 2 different URL, something like: www.stupidname.com and www.seriousname.com
If the user open stupidname.com by his browser will open the website having a stupid template
If the user open seriusname.com by his browser will open the website having a serious template
The website and the content are the same...should only change the template according to the url open in the browser
Do you have some ideas about how to do this thing?
Thanks
Andrea
I've done this before making elements of a template conditional based on the domain name, and that can work well. I suppose you could extend the same logic to change the template.
Perhaps you could add a conditional to both template's index.php to change the template. Perhaps something like...
if ( substr_count( $_SERVER['HTTP_HOST'], "silly") ) {
$GLOBALS["mainframe"]->setTemplate = "silly_template_name";
} else {
$GLOBALS["mainframe"]->setTemplate = "serious_template_name";
}
...I've not tested this, but I think in principle it should work fine, though it might depend on which Joomla version you have.
There are, as saji89 pointed out, plenty of good multi-site extensions and that'd be an ok solution too.
From my personal experience with Joomla I can advise you to use the component Virtual Domains (http://extensions.joomla.org/extensions/core-enhancements/multiple-sites/7557) you can add the domains which you redirect to the main site where Joomla is installed and it this component you assign them the template you want.
I can confirm the functionality on Joomla 2.5 latest update with usage of around 5+ different Virtual Domains on one Joomla installation.
Some possible downsides i want to mention:
SEO links can get sometimes messy, you need to play with some SEO component and its settings
its better to use same structure and components for boths side its easier because otherwise the administration gets messy but its possible
the user which register on one website has automatically account on all of them because its one Joomla

Notify web page about a plugin new version php

I'm developing a web application where users can upload multiple plugins. I want to give an extra value to my app with a feature like wordpress plugin version adviser. I don't know how to deep in this area in order to investigate. I hear someting like "pingtracks", but not sure if this the correct way. Well, that's my doubt, how can I determinate if there is a new plugin version to uptade?
Thanks in advance.
PS: There is a table in my db with all plugins relevent data like url, author, current version, etc.
Each plugin should have a URL for some sort of update manifest. The resource at that URL should contain information such as currently available versions, and the URLs of files that need to be updated. This file could be as simple as static JSON data.
Please remember to use HTTPS, so that it is harder to spoof your update site.
Every time that user uploads a new plugin, check the "current version" in your DB and compare it with the last same-named plugin uploaded. (create another table for saving needed data for example)

Replacing all outbound links to a certain domain in Wordpress

I maintain a Wordpress site for a client of mine. They do all the content, I just keep it running and do the theme work.
A site they've linked to a few hundred times has changed domain and they've (very rudely) not redirected traffic from their old domain, so users clicking on an old link see a 404.
So we're left in the position where we need to fix all the links. The static ones (in theme files) have been easy enough to replace but, as I say, there are hundreds of these blighters littered all over the website in the posts.
Is there a quick method to find-and-replace links like this?
If there's not a Wordpress or PHP method, I'm happy to log in to the database over SSH and fire some SQL off manually... But what SQL do I want?
Running a query is indeed the easiest and cleanest way.
Back up the database of course
According to this blog post (I'm too lazy to look the columns up on a live WP but this looks about right), the right query is
UPDATE wp_posts SET post_content =
REPLACE (post_content,
'http://www.oldsiteurl.com',
'http://www.newsiteurl.com');
There also is a WordPress plugin for that: http://wordpress.org/extend/plugins/search-and-replace/ I have used it when moving my own site and it worked nicely.

Categories