• Home
  • Contact Me
  • Forum
  • Podcast
WordPress Tavern
Where Every Drink Is On The House
Browse: Home / code
WP-Snippets Launches Newly Designed Site

WP-Snippets Launches Newly Designed Site

By Jeffro on January 16, 2012

WP-Snippets has gone through a few changes as of late. Among them is a responsive design, a button to mark snippets as favorites, better ways of filtering snippets, and a few other enhancements. WP-Snippets is one of those really cool ideas that I talked about during the early days of WordPress Weekly and I’m stoked to see someone out there actually turn the idea into a reality.

Posted in News | Tagged code, resources, snippets, wordpress | 3 Responses

Avoid Hardcoding Your Copyright Information

Avoid Hardcoding Your Copyright Information

By Jeffro on December 30, 2011

How many of you still update your themes footer every year to change the copyright date? Thanks to a small snippet of code, you can add this to your footer.php file which will negate the need to manually change the copyright information every year. The code snippet is php the_time(‘Y’) An excellent primer for how to use this snippet within the footer.php file is explained via Lorelle VanFossen.

Posted in WordPress | Tagged code, copyright, date, functions | 13 Responses

Alex King Releases Post Formats Admin UI Code

By Jeffro on October 26, 2011

Alex King has made available code that creates an admin UI for using Post Formats. While working on their upcoming new theme, FavePersonal, the CrowdFavorite team created an admin interface for post formats that takes advantage of custom fields and replaces the built-in radio button post format selector with tabs across the top of the post editor. Judging by the comments and tweets, it looks like a lot of people would like to see this end up in the core of WordPress.    ∞

Posted in Plugins | Tagged code, Plugins, post formats, Themes | 2 Responses

Interview With Oliver – Creator Of WPSeek.com

Interview With Oliver – Creator Of WPSeek.com

By Jeffro on September 12, 2011

What was your inspiration for creating WPSeek?
The first idea of wpseek wasn’t actually to create a public search engine for WordPress developers. When I finished creating a little Firefox add-on called “WordPress Helper” [1] some years back, I was using wpseek as a kind of search result page for requests made with the “WordPress Helper” add-on. The idea was that users can highlight functions, template tags or whatever on any page they browse and a mouse click would bring them to a wpseek result page with all of the information that was related to the search term. Having dynamic result pages for various WordPress-related search queries was basically the birth of wpseek as it is now.

WPseek.com Frontpage

How many times have you found yourself using the site for reference?
Well, I find myself using it quite often along with the official Codex and core files while writing plugins. For easy use, I added wpseek to Firefox’ search engines on the upper right so I can look up any function without getting too distracted from writing the actual plugin. Personally I find it pretty handy, and so I hope it is for the majority of users. I think the most useful information for me is the compatibility info (when has a function been introduced and deprecated in WP core). That saved me quite some time I guess. Oh well, where’s the non-narcissistic smilie?

Behind the scenes, can you tell us a little bit about how the site works?
Basically it is a search engine like Google, Yahoo or Bing. The only difference is that you cannot search porn. And it’s a bit more specific and niche business. Apart from that the usage is like with any other search engine: enter a search term (a function, template tag or hook) and the site gives you all the information it has that is related to your search term. This includes general information about the function, code snippets, version info, external links to the Codex, user discussions on the wp.org forums and user notes posted on wpseek.com. There are 8 crawlers doing their job for the site, running periodically from hourly to monthly. Some of them are collecting WP code data from local copies and repositories, others are posting on Twitter occasionally notifying my followers of new WP releases or new functions added to the wpseek database. Recently I wrote a blog post about some of the (publicly visible) bots running on wpseek for those who are interested: http://wpseek.com/blog/2011/twitter-and-the-wpseek-bot/105/

In terms of updating the site with functions, is it automatic or do you have to add everything regarding the function to the site yourself?
Everyone knows that coders (like I am) are lazy folks so everything wpseek does is automated. Means that the foundation of wpseek is – as stated above already – several crawlers and tasks that run periodically in order to catch information related to WordPress code. wpseek currently holds a database of about WP 5,000 functions and 1,500 hooks. It would be impossible for me to keep this data up-to-date on an hourly basis. I do review all the stuff, though. Just to keep track of bugs and inaccurate data.

Search Result Page For A Function On WPSeek

I noticed that WPSeek has an API. What can interested parties do with your API?
The API allows everyone to get all the data that’s stored on the wpseek databases and that can be found on the result pages. Which means function info, code snippets, similar functions etc. The goal was to be able to make wpseek available for any platform. You could set up an iPhone/iPad code lookup app or a web app to lookup function version compatibility including auto-complete. You could actually fork wpseek.com and make your own. Luckily seekwp.com is already taken. For anyone who’s interested, you can find the API (along with a jQuery plugin) here: http://wpseek.com/api/ Feel free to play and do whatever you like with it!

Codex Links In WPSeek Search Results

Do you think WPSeek.com is a better reference to use for help rather than the Codex or do they work hand in hand with each other?
wpseek.com is definitely just one of the MANY WordPress resources out there! And I’m not just saying this because I don’t have another non-narcissistic smilie at hand. The great advantage of the official Codex is that it’s community-driven. wpseek is basically a one-man-show. I usually search the Codex for usage examples. They have a lot in there. More than that, the Codex is like a huge manual for WordPress users while wpseek is just a code search engine. So, yeah, they go hand in hand with each other, just like all WordPress resources out there. I wouldn’t mind a catchall-codex.wordpressp.org-to-wpseek.com redirect, though.

Any last thoughts you wanted to share?
Two things:
1. Good to see you back posting on WPTavern, Jeff!
2. Thanks Andreas Petermann for the regex-o-rama!

[1] https://addons.mozilla.org/en-US/firefox/addon/wordpress-helper/

Posted in WordPress | Tagged code, functions, resources, search, wpseek | 4 Responses

Code Snippet To Reduce Memory Usage

By Jeffro on August 29, 2011

Joost de Valk has published a code snippet along with an explanation regarding the reduction of memory usage when using get_permalink with post objects. This may come in handy for plugin developers who are not already using this technique.    ∞

Posted in WordPress | Tagged code, memory, permalink, snippet

Chip Bennett Explains The Right Way To Custom Gravatars

Chip Bennett Explains The Right Way To Custom Gravatars

By Jeffro on September 27, 2010

Inspired by an article that explains how to bypass WordPress core functions in order to implement custom gravatars, Chip Bennett explains how to properly work with custom gravatars without having to bypass any core functionality. Using Chips tutorial, creating custom avatars for your users is a cinch. Always better to work WITH core instead of against it, especially when it’s much easier to accomplish the task.

Posted in WordPress | Tagged chip, code, custom, gravatars | 1 Response

My Child Theme Technical Hurdle

My Child Theme Technical Hurdle

By Jeffro on May 26, 2009

As most of you are aware, I ended up choosing to edit a child theme of the Theme Hybrid framework called Hybrid News. Out of the gate, using a child theme that is built on top of a framework certainly has a learning curve. For instance, if I installed a plugin where the directions told me to place a line of code in a certain theme template file, I couldn’t do that in this child theme since it’s primary purpose is to be compiled mostly of CSS without touching the core of the framework which holds the theme together.

Instead, it’s up to me to figure out how to add that plugins code to my child themes functions.php file. Something which requires I as an end user to know about filters, hooks, or other weird developing terms. In this instance, I believe child themes have raised the technical bar. I know if I put in a support query, Justin will be right there to answer it but I feel like a loony for having to rely on support in order to accomplish something which was easy before hand. I know some would argue that functions of a plugin should be added to a custom functions.php anyway to prevent it disappearing if a theme upgrade were to occur.

Other than this hurdle, I don’t have much to complain about. The experience has gone over rather well and it was nice to just edit the CSS of a theme for once without having to edit 5 separate template pages.

So should their be an easier way to customize where and when a plugins output will show up in a theme by implementing an interface of sorts for these plugin functions or should I just buckle down and learn a thing or two regarding functions.php, hooks, filters, and those other funky terms?

Posted in Themes | Tagged child themes, code, css, editing | 6 Responses

Even A Widgetifyr Stumps Me

Even A Widgetifyr Stumps Me

By Jeffro on May 22, 2009

widgetifyrlogo

A few days ago, Glenn Bennett got in touch with me to let me know about a site called Widgetifyr.com. This site is a service which aims at making the WordPress widget creation process much easier than creating the code from scratch every time.

If you’ve ever tried to turn your code into a wordpress plugin (which is how WordPress widgets get installed) you know it can get a bit tedious. Our service lets you just paste your code into a form along with some addition information and we “magically” turn it into a WordPress Plugin that allows your widget to be used in WordPress.

Immediately I thought this was a cool idea. So I took it for a test drive to see if I could create a widget using a regular WordPress function such as get_posts. As it turns out, even a widget generator can stump me.

creatingthewidget

The way this works is that you create a plugin file which you can download at the end, upload it to your plugins folder, activate it and then use the widget. So the first part of the process deals with the basic plugin stuff such as the name, version, author, etc. At the bottom of this page is the important part. This is where you name your PHP Function Name. In the text area, you’re supposed to paste your PHP code which would reside between the brackets. Here is what mine looked like.

phpfunctionname

I used this code from the example shown on the codex related to this function. Once that was done, I clicked on the create button which takes the function, wraps it with the widget code and then gives me the chance to view the code in a txt editor to copy, paste in my favorite editor and than save that file as get_posts.php. I then uploaded this file to my plugins folder. Upon activation, I was greeted with a fatal error:

Parse error: syntax error, unexpected ‘}’ in public_html/wptavern/wp-content/plugins/get_posts.php.php on line 33

Here is line 33.

line33

I received this error anytime I tried to activate a plugin I created. I’m not sure what I did wrong but after looking through the widgetifyr help page, to get a gist as to what the widget code is supposed to look like, and it’s obvious that you need to have a little PHP experience in order to really use this tool to its fullest potential.

The more I tinkered with the site, the more I realized that Otto’s Executable PHP Widget is a much easier, speedier solution for me. With this plugin, I can create widgets without having to worry about HTML or echoing anything. Here is one example of how I use this plugin.

widgetinaction

No copying of code, no uploading, and it just works (as long as I put the function in correctly). If you’re a coder, let me know if the service makes it easier for you to create widgets. As for myself, I’ll stick with a Otto’s solution.

Posted in WordPress | Tagged code, generator, php, widgets | 5 Responses

Plugin Code Repository Bookmarklet

Plugin Code Repository Bookmarklet

By Jeffro on May 15, 2009

Ryan McCue has released a cool bookmarklet which when used on the WordPress Plugin Repository, will take you directly to the code browser for that plugin. The bookmarklet works on subpages of the plugin page as well as the installation or FAQ pages. If you’re using FireFox, drag the link for the bookmarklet to your bookmarks toolbar. Then, when on a plugin page within the repository, click the button and you’ll be taken right to the code repository for it.

Posted in Plugins | Tagged code, Plugins, resources, shortcut | 1 Response

© Copyright WPTavern 2012 All rights reserved About / Stats / Poll Archive / Site Archive // Powered by WordPress Mtn. Dew And Hybrid