Is there any substantial difference between the Pluign options or Theme options for admin ?
I can find a lot of good theme related tutorials (for options pages) - but not so much (or not so clear) plugins option page .
Does following the themes related tutorials will be substantial the same ?
(considering only activation / deactivation hooks would be different ? )
Edit I - just to clarify:
my question was more specifically, whether I could follow the "themes" tutorials for the settings, even if I need it for "plugins" - and if so, what exactly are the points which I would need to change / pay attention to ..
This weekend I wrote my first plugin after being a WP theme developer since 2007 and I was confronted with the same problems as you.
It turns out that the theme page basically just a simplified version of what you would do to create a plugin page. This often means that functions take lesser arguments and you have less to think about. But it's a double-edged sword since it gives you less freedom about what you wanna do.
E.g: Instead of add_theme_page() you would call add_menu_page() or add_submenu_page() depending on where you want your menu to appear. Comparing the arguments:
add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function);
add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
Same goes for add_options_page() wich is a wrapper function add_submenu_page().
The second thing I noticed is the Settings API. As long as you follow the Codex you and your plugin are save since it takes away all of the actual settings form layout creation. This is what many tutorials out there spend their most energy in: creating hundreds of lines of code to layout forms. Settings API is kind of like a framework for that.
I checked all top google tutorial results for "wordpress theme options page" and only two of them used the Settings API (this and that one). So I recommend you do not follow most of the tutorials unless they use the Settings API.
That's it really. Creating a plugin settings in WordPress is nothing more than registering the menu item and rendering the settings via Settings API.
In WordPress the way the options are handled are quite similar for both themes and Plugins.
Also if you choose to put a particular option inside theme, then it will be active only as long as that particular theme is activated, the same applies for the Plugin as well.
If you want the functionality to be available only when the theme is activated, then you might have to place them inside theme and if you want it to be active across multiple themes, then you might want to put them inside a Plugin.
The other difference is that, themes might have some special hooks which may not be available for the Plugin.
Also the option/setting page for themes and Plugins are different.
This is depending on how a theme or plugin develop. Options are usually stored on the wp_options database. Both of them can benefit from it and substantially the same. But on other case, like a very large plugin, a developer would likely choose to create a TABLE and store the options there.
Related
I would like to know if there was any methodologies to inherit or extend a plugin files to theme directory as woocommerce did and customize them without touching the base/core files. please share any links or thoughts
Thanks
You're looking for WordPress's add_action() and do_action() functions. WooCommerce, for example, makes use of these functions by using hooks and filters for templates and functions.
For example, WooCommerce does things like do_action( 'woocommerce_before_main_content' );. This means that you can "add and action", override functionality, remove actions, and generally customize things how you see fit.
Not all plugins and themes ship with this functionality; but browsing the source code can often reveal instances of this. It's more of a courtesy by developers.
I understanding we may not have a plug-in that would fit in to our requirements in all respects. I am planning to use theme-my-login plug-in. However, it requires fair amount of customization in terms of adding more/custom fields for registering into site. There are some page redirections that I had to insert conditionally.
Can I tweak the code with-in plug-in files?
Should I be extending this through themes files/folders, withough tweaking in the plug-in file structure?
Thanks in advance
It all depends on what you want to change / add, and what the target plugin allows you to do. In general, you can customise some of what other plugins are doing by making use of available filters, actions, CSS, templates, and brute-force WordPress filter/action hooks if that's appropriate.
The Theme My Login, which you reference, presents its various views through templates that you can override either by dropping a customised copy of its template into your theme, or through a filter "tml_template". If what you want to change is the appearance, then you have lots of control through those two avenues. I notice that the plugin has various other filters you can hook, allowing you to customise many aspects of the plugin.
I suggest you start off by reading the plugin's FAQ which points you in the right directions already.
You can tweak the code with anything in Wordpress, but with caution.
If you are customizing wordpress themes, when the themes are updated by wordpress, any customizations are lost.
That is why Child themes are created.
You may find this link useful:
http://codex.wordpress.org/Child_Themes
I suggest creating a new plug in based on the customized code of the Wordpress plug in.
You may find this link helpful. It discusses Wordpress plugins and how to create them.
https://codex.wordpress.org/Writing_a_Plugin
I am a food blogger and have recently learnt about recipe rich snippets. I found some material online, mostly being about plugins. I tried using ZipList plugin, which is actually pretty good, but
For some posts, I cannot add pictures within the recipe box and
I cannot add alt text to my pictures (which I find to be quite SEO-unfriendly or is it?).
So, I was thinking of trying to implement it by myself onto my website.
Any good links or advice on how to do it? I tried looking on google but I am only coming up with plugin tutorials.
Yes, your search results are correct.
If you don't want to use a plugin, you have to code it yourself. But this is the kind of thing that you don't want attached to your theme's functions.php ("without a plugin"). Because you have to be able to swap themes and preserve this functionality. Themes are for design and content display. Plugins for functionality. All those themes with SEO incorporated are simply dumb.
So, you end up writing your own plugin. See this article: Create a functionality plugins instead of using Functions.php.
What is a functionality plugin?
Traditionally, if you wanted to create a new function for your blog to add to its functionality, the advice has been to add the code snippet to your theme’s functions.php file. Now that’s all well and good and it will work fine, but what happens when you change your site’s theme (which you can guarantee will happen at least every few years) or the theme gets updated? Since functions.php is located in your active theme folder, if you change your theme, it inherently becomes defunct.
All that being said, what I'd suggest is that you create a Custom Post Type to handle your recipe snippets. You'll have all the default functionality of WordPress customized to your needs. The CPT could have only Title, Content and Featured Image, eventually your own taxonomy (recipe categories).
Useful links:
Documentation of CPTs
Smashing Magazine tutorial
WP Tuts tutorial
Or you can use a nice plugin to create your CPT :)
I tried looking for a quick and dirty getting started with wordpress theme development tutorial. Now I know how to go and discover things myself, I'm looking for "top ten FAQ for programmers" when starting wordpress development. (For example, Turn on debugging and where the debugging option is located), how best to setup your dev environment.
All I can find is elaborate or too low level or too high level guides to it. Coming from a background of creating custom wordpress-like applications makes me frustrated.
So perhaps someone can list of the few things I need. I don't need to know how wordpress works, what a database or widget or page is.
Question I was specifically searching for:
1. How do I make wordpress watch the theme folder for changes from my IDE ( I can't really believe anybody would develop through the wordpress admin theme editor...No Undo history!). Changing the files doesn't seem to take affect until I re-install the theme. Debug mode needs to be true?
Any links condensed version of this: http://codex.wordpress.org/Theme_Development or similar?
WordPress use a hierarchy of files to determine what ends up being shown to the user. For starters all you need to create a WordPress theme is a style.css and index.php.
This is what you will have to put in your style.css in order to make it a valid WordPress theme:
/*
Theme Name: Your theme name
Theme URI: http://www.example.com/
Description: Describe your theme.
Author: Your name or company
Author URI: http://www.example.com/
Version: 1.0
Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu (optional)
License:
License URI:
General comments (optional).
*/
All you really need to include is a unique name for your theme and WordPress will recognize it and list it among your other themes. Even though that works, I would recommend including as much info as possible.
With just two files, index.php will then run for every single page view, no matter the type of content the user asks for. You can extend this by adding files like page.php to display all your pages, single.php to display single posts differently and so on.
I highly recommend getting familiar with the WordPress Codex. This is a good place to start:
http://codex.wordpress.org/Template_Hierarchy
The image below explains the hierarchy and what file ends up being served. I use it sometimes for reference, there is no need to memorize it entirely.
you need to become familiar with basic wordpress functions like the_permalink, the_title, the_content, etc. these are easy to remember and you can always refer to wordpress.org documentation if you don't want any out of box functionality and you pay more attention to design
if you intend to submit theme to wordpress.org than turn on debugging wile developing and read this before start http://codex.wordpress.org/Theme_Review
Theme development for beginners can be made easier by basing it on an existing theme such as the twentytwelve theme. I have written a blog post on it here http://johnadavies.me/2013/09/19/wordpress-child-theme-development/
John
turning on debugging it's the root-directory config-file.php look for faction call in
// Enable WP_DEBUG mode
define('WP_DEBUG', true);
I'm developing a theme for wordpress and would like to know the best way to show highlights on the home page.
Examples:
I thought two ways:
Custom post types -a custom post "highlight" with metabox for image, text and link.
Theme Options - a page with options for each box.
What is the right way?
Neither. What you want can be achieved using either Wordpress' core functions and/or Custom Fields. Consider using Custom Meta Boxes if you have a client that requires a more intuitive setup, or installing something like the Types Plugin to do it for you.
This will allow you to attach your own variables to given Posts/Pages.
To gain access to a post's Custom Fields, click the Screen Options button at the top of the Post Editor to enable Custom Fields.
Personally, I would Enable Support for Thumbnails for your Highlights image, use The Excerpt for your Highlight copy, and use either The Title or a Custom Field for the heading.
This way, you can keep all your eggs in one basket rather than overcomplicating things with Custom Post Types or Theme Options Pages.
Look at the Plugin "Ether Content Builder"
You could use either of the methods you've suggested. In my opinion getting involved with lots of meta boxes on one specific page template for this is a total waste of time - there is only an image, a header and an excerpt linking to a post/page. Three posts (whether custom or not) will handle that with featured image, excerpt and the page/post title.
I also think doing a Custom Post type is too much just for three posts on the homepage. If you go the posts route just create a new post category called Home Highlights and put your three posts in there, pull them in via a custom loop built on WP_Query.
Yes you can go the Theme Options route too. If it's the client updating the site then it can look quite professional this way, I've started using a plugin called Options Tree after it came integrated with Super Skeleton, it makes it very easy to build your custom theme options which work just as well too.
A matter of opinion really, rather than a hard and fast 'this one is definitely better'!