WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Apr 15 2011

How to Add Read More Link to Excerpts in your Genesis Child Theme

Here's how to add the Read More... link to the Excerpts for your Genesis Child Themes.

[php]// Add Read More Link to Excerpts
add_filter('excerpt_more', 'get_read_more_link');
add_filter( 'the_content_more_link', 'get_read_more_link' );
function get_read_more_link() {
return '...&nbsp;<a href="' . get_permalink() . '">Read More...</a>';
}[/php]

Written by Travis Smith · Categorized: WordPress

Apr 01 2011

How to Determine What Site Layout Is Being Used in a Genesis Child Theme

To determine what site layout is being used dynamically use this simple statement.

[php]$site_layout = genesis_site_layout();[/php]

Written by Travis Smith · Categorized: WordPress

Mar 24 2011

WordPress Contact Form Plugin Gravity Forms Updates Site, Plugin, Addons, & Documentation in v1.5

Gravity Forms WebsiteToday, we were notified that Gravity Forms has an upgrade available and when I checked they upgraded everything it seems. They've upgraded/redesigned their website, their support site and most notably, their documentation.

Gravity Forms "is a full featured contact form plugin that features a drag and drop interface, advanced notification routing, lead capture, conditional logic fields and the ability to create posts from external forms." Simply it makes form creation easy, straight forward, and saves a ton of time. Furthermore, with their new hooks/filters documentation, Gravity Forms Developers Documentationone can easily extend the use of Gravity Forms to create other forms besides basic contact and support forms! If you don't have Gravity Forms, you must get it now!

Gravity Forms Releases PayPal & User Registration Add-Ons

Gravity Forms has a small body of Add-Ons and in their newest release they have added a user-friendly way to install and activate these add-ons. Two new add-ons were released today too: PayPal and User Registration Add-Ons. The PayPal Add-On allows you to accept PayPal payments through a Gravity Form, including donations and recurring payments. The User Registration Add-On allows you to create user registration forms which include BuddyPress and Multisite integration (including integration with the PayPal Add-On).

Gravity Forms Addon Easy InstallGravity Forms PayPal AddonGravity Forms New User Registration Addon

What Can Gravity Forms Do?

Gravity Forms can create Contact Forms, Support Forms, Surveys, Polls, Guest Post Submissions, and User Generated Content. And now with their newly updated hooks/filters documentation, other form types will be limitless!

When I purchased it, I only purchased it to get rid of the craziness of using other form plugins that were clunky and difficult to style to create a Contact Form, the most popular use of Gravity Forms. You can gather basic information like: name, date, time, Phone, Address, Website, Email, and even upload files, and all of this information is validated to ensure that the user has entered the correct information (validates emails, phone numbers, etc!). It also comes with reCAPTCHA compatability for spam protection. However, I have gone beyond that to create other types of forms including surveys, polls, guest post submissions, and user-generated content. I am now experimenting with other types of form creation (and will report back later) with the hooks that I found in the code. Now with the documentation, it will be much easier.

Gravity FormsGravity Forms - Advanced FieldsGravity Forms - Post FieldsGravity Forms - Standard Fields

A few of the hidden great things about Gravity Forms is that it maintains a record of all submitted forms, ability to make notes on the submissions, email notes, conversion rate (# submitted/# viewed), and much more to come.

What's New in Gravity Forms v1.5

Multi-Page Forms

One of the most widely requested features is finally here, multi-page form capabilities. Using the new Page Break field you now have the ability split longer forms into multiple pages or steps. We have also integrated a visual paging status bar that can be used to show a progress bar or the steps involved in completing the form.

Pricing Fields

Pricing Fields allow you to create quotes and order forms. It features integrated pricing calculations and is compatible with the Gravity Forms PayPal Add-On. Pricing Fields consist of a Product Field, Option Field, Quantity Field, Shipping Field, Donation Field and Total Field. They allow you to easily turn your form into an order form and collect payments when combined with the PayPal Add-On.

Textarea Character Counter

Easily limit the number of characters entered into a textarea and include a visual character counter that lets them know how many characters are allowed and how many characters have been entered.

CSS Ready Classes

Easily create multi-column layouts using built in CSS classes. These keywords are custom CSS classes you add to the CSS Class Name option under the Advanced tab for each field. Using our pre-defined CSS class names you can easily create 2 or 3 column forms, display radio button and checkbox options in 2, 3 or 4 columns as well as turn a Section Break into a scrolling text field.

Default Notification

Gravity Forms will now automatically setup an Admin Notification that uses the WordPress Admin email as the Send To and includes all submitted form fields when a new form is created.

Post Field Enhancements

We have enhanced the content template capabilities of the Post Fields and extended them to the Post Custom Field. Now you can use the content template capabilities on the Post Title, Post Body and Post Custom Fields in the form builder. The Post Category field has been enhanced to allow for an initial placeholder value (ex. "Please Select a Category") and now supports Admin Only visibility to allow you to set a default category using the Post Category field.

Checkbox and Multiple Choice (Radio Button) HTML Support

The Checkbox and Multiple Choice (Radio Button) fields now support HTML in the option labels. This allows you to include links or use images as your options.

Shortcode Support

Love using Shortcodes? Need to insert custom code into the Email Notification, Confirmation Text or HTML Field content? Gravity Forms now supports utilizing Shortcodes in the Email Notification Message Body, Confirmation Text and within the content of an HTML Field.

Enhanced Bulk Edit Functionality

You can now reset views, or delete entries from the Edit Forms screen using enhanced options added to the Bulk Edit functionality.

New Hooks and Filters

We have added a variety of new hooks and filters, all of which are documented (with examples) in the brand new Documentation area of the support site.

Upgrade and Renewals

Now you can Upgrade or Renew your Gravity Forms License Key right from your WordPress Dashboard! Visit either the Settings page or the Update page. If an Upgrade is available, or you are within the Renewal period, you will be presented with options to purchase the Upgrade or Renewal.

Support For New Add-Ons

Gravity Forms v1.5 supports the introduction of the PayPal Add-On and User Registration Add-On which are now available for Developer License customers.

Written by Travis Smith · Categorized: WordPress

Mar 20 2011

PHP Tertiary Operator and Complex Conditional Assignment: Variable = Condition ? True Statement : False Statement

If you've been dealing with WordPress or PHP, more than likely you have seen the Ternary Operator in a statement. If you were like me, when you saw it for the first time, you had no idea what sort of assignment statement it was except possibly a conditional assignment. So what is it? The Ternary Operator is an operator that takes three (3) arguments: Condition, True Statement, and False Statement. So a complex conditional assignment is the same as a ternary operator but with more than three (3) arguments.

From Wikipedia: Ternary Operation:
[php]if ($a > $b) {
$result = $x;
} else {
$result = $y;
}
[/php]

Rewritten using the ternary operator:
[php]$result = ($a > $b) ? $x : $y;[/php]

So,
[php]$my_var = ($var1 > $var2) ? /*simple true statement */ : /*simple false statement */; [/php]

From the PHP manual:
[php]<?php
// Example usage for: Ternary Operator
$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];

// The above is identical to this if/else statement
if (empty($_POST['action'])) {
$action = 'default';
} else {
$action = $_POST['action'];
}

?>
[/php]

To create a switch-like conditional assignment as demonstrated in Wikipedia: Conditional Assignment ?:
[php]<?php
$arg = "T";
$vehicle = ($arg == 'B') ? 'bus' :
(($arg == 'A') ? 'airplane' :
(($arg == 'T') ? 'train' :
(($arg == 'C') ? 'car' :
(($arg == 'H') ? 'horse' :
'feet'))));
echo $vehicle;
?>
[/php]

Written by Travis Smith · Categorized: WordPress

Mar 01 2011

How to Find Out What Functions Do In WordPress (& Elsewhere) Using Text Editor like Notepad++

So it became apparent to me as I kept asking people and searching the WordPress Codex where such and such function was defined or used. Now, I have a process that I have refined over time that I want to share. It may not be the best process but it works and works well.

First, as with any web design or development, you need a good text editor. I use Notepad++ since I haven't forked over for a Mac (anyone who wishes to buy me one, please feel free!). Plus Notepad++ is free!

So for example, say I am looking over nav-menus.php from the WordPress core. On line 67, I come across a function called wp_get_object_terms(); So if I want to know what this is, I do one of two things or sometimes both.

  1. First, search the WordPress Codex.
  2. Second, search the WordPress Core Code (online or off).

In this example, the Codex has good information. However, sometimes (though rare) you will see that the Codex is not completely filled out or brought up-to-date or easy to understand without seeing the function.

With the second option, I typically used Yoast's PHPXref (ensuring that I am searching the correct WordPress version) until I was on a plane recently and refused to pay the $10 bucks for wifi since I had everything on my laptop. So then I turned to my text editor. (In the past, I used Windows XP with indexing to find such files; however, I'm now running Windows 7 and the search functions are horrible [and I haven't taken the time to try to figure out what's wrong with Windows 7 search ability or how to improve it]).

So if you open Notepad++, the third menu item is Search. If you click Find in Files a search menu will appear.

Finding WordPress Functions with NotePad++
Click Image for Larger Image

If you hit Ctrl+F as I often do, then select the tab that says Find in Files. Fill in function wp_get_object_terms in the Find what: input box, since I want to find where it's defined to see its accepted variables so I can use it. Then I select the file structure that I want it to search, so you could select the entire WordPress install so it searches wp-admin, wp-includes, and wp-content or just pick one of those folders.

Finding WordPress Functions with NotePad++
Click Image for Larger Image

A quick search reveals that this function is defined in taxonomy.php in the wp-includes folder. The great thing about the search is that it typically returns the entire line that its found, so NotePad++ told me what I was looking for:

function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {

.

Finding WordPress Functions with NotePad++
Click Image for Larger Image

So if I want to see the entire function to try to determine what the function does or returns if anything, I need to open the file. While Notepad++ finds the function, it's not a simple click and open that file. So I have to navigate to the file, open it and go to line 1778 to see the full function. One of the great things about WordPress is that there are a lot of comments informing the user what the function does. For this one particular function, there are 30 lines about this function including the following vital information:

 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 * @uses $wpdb
 *
 * @param int|array $object_ids The ID(s) of the object(s) to retrieve.
 * @param string|array $taxonomies The taxonomies to retrieve terms from.
 * @param array|string $args Change what is returned
 * @return array|WP_Error The requested term data or empty array if no terms found. WP_Error if $taxonomy does not exist.

This tells me that $object_ids is either an integer or an array of integers; $taxonomies is a string or an array of strings, and $args is an array of strings that can affect what is returned. It also tells me that this function returns an array or a WP_Error message.

Finding WordPress Functions with NotePad++
Click Image for Larger Image

 

So now, there's an offline version or way to search your WordPress files for function calls, function definitions, etc.

Written by Travis Smith · Categorized: WordPress

  • « Previous Page
  • 1
  • …
  • 21
  • 22
  • 23
  • 24
  • 25
  • Next Page »
  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in