Created
July 18, 2013 15:15
-
-
Save jmariano13/6030152 to your computer and use it in GitHub Desktop.
Plugin Defaults
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php add_action ( 'hook_name', 'your_function_name', [priority], [accepted_args] ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <php | |
| add_filter( 'the_content', 'ch2epl_email_page_filter' ); | |
| function ch2epl_email_page_filter ( $the_content ) { | |
| // build url to mail message icon downloaded | |
| // from iconarchive.com | |
| $mail_icon_url = plugins_url( 'mailicon.png', __FILE__ ); | |
| // Set initial value of $new_content variable to previous | |
| // content | |
| $new_content = $the_content; | |
| // Append image with mailto link after content, including | |
| // the item title and permanent URL | |
| $new_content .= "<a title='E-mail article link' | |
| href='mailto:[email protected]?subject=Check out | |
| this interesting article entitled "; | |
| $new_content .= get_the_title(); | |
| $new_content .= "&body=Hi!%0A%0AI thought you would enjoy | |
| this article entitled "; | |
| $new_content .= get_the_title(); | |
| $new_content .= ".%0A%0A"; | |
| $new_content .= get_permalink(); | |
| $new_content .= "%0A%0AEnjoy!'> | |
| <img alt='' src='" . $mail_icon_url. "' /></a>"; | |
| // Return filtered content for display on the site | |
| return $new_content; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'wp_head', 'ch2pho_page_header_output' ); | |
| function ch2pho_page_header_output() { ?> | |
| <script type="text/javascript"> | |
| var gaJsHost = ( ( "https:" == document.location.protocol ) ? | |
| "https://ssl." : "http://www." ); | |
| document.write( unescape( "%3Cscript src='" + gaJsHost + | |
| "google-analytics.com/ga.js' \n\ | |
| type='text/javascript'%3E%3C/script%3E" ) ); | |
| </script> | |
| <script type="text/javascript"> | |
| try { | |
| var pageTracker = _gat._getTracker( "UA-xxxxxx-x" ); | |
| pageTracker._trackPageview(); | |
| } catch( err ) {} | |
| </script> | |
| <?php } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Plugin Name: Chapter 2 - Plugin Header | |
| Plugin URI: | |
| Description: Declares a plugin that will be visible in the | |
| WordPress admin interface | |
| Version: 1.0 | |
| Author: Yannick Lefebvre | |
| Author URI: http://ylefebvre.ca | |
| License: GPLv2 | |
| */ | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'the_content', 'ch2lfa_link_filter_analytics' ); | |
| function ch2lfa_link_filter_analytics ( $the_content ) { | |
| $new_content = str_replace( "href", | |
| "onClick=\"recordOutboundLink(this, 'Outbound Links', '" . | |
| home_url() . "' );return false;\" href", $the_content ); | |
| return $new_content; | |
| } | |
| add_action( 'wp_footer', 'ch2lfa_footer_analytics_code' ); | |
| function ch2lfa_footer_analytics_code() { ?> | |
| <script type="text/javascript"> | |
| function recordOutboundLink( link, category, action ) { | |
| _gat._getTrackerByName()._trackEvent( category, action ); | |
| setTimeout( 'document.location = "' + link.href + '"', 100 ); | |
| } | |
| </script> | |
| <?php } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'wp_head', 'ch2fi_page_header_output' ); | |
| function ch2fi_page_header_output() { | |
| $icon_url = plugins_url( 'favicon.ico', __FILE__ ); | |
| ?> | |
| <link rel="shortcut icon" href="<?php echo $icon_url; ?>" /> | |
| <?php } | |
| //Other Functions to Find File Locations | |
| // get_theme_root(): Returns the address of the theme installation directory | |
| // get_template_directory_uri(): Retrieves the URI to the current theme's files | |
| // admin_url(): Provides the address of the WordPress administrative pages | |
| // content_url(): Indicates where the wp-content directory can be found | |
| // site_url() and home_url(): Return the site address | |
| // includes_url(): Provides the location of WordPress include files | |
| // wp_upload_dir(): Indicates the directory where user-uploaded files are stored |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'wp_title', 'ch2tf_title_filter' ); | |
| function ch2tf_title_filter ( $title ) { | |
| //Select new title based on item type | |
| if ( is_front_page() ) | |
| $new_title = 'Front Page >> '; | |
| elseif ( get_post_type() == 'page' ) | |
| $new_title = 'Page >> '; | |
| elseif ( get_post_type() == 'post' ) | |
| $new_title = 'Post >> '; | |
| // Append previous title to title prefix | |
| if ( isset( $new_title ) ) { | |
| $new_title .= $title; | |
| // Return new complete title to be displayed | |
| return $new_title; | |
| } else { | |
| return $title; | |
| } | |
| } | |
| //Output: the browser's title bar or navigation tabs display additional text before | |
| //their name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //inside wp-config | |
| define( 'WP_DEBUG', true ); | |
| //Other debugging features that can be activated from the wp-config.php file are as follows: | |
| // WP_DEBUG_LOG: Stores all debug messages in a file named debug.log in the site's | |
| //wp-content directory for later analysis | |
| // WP_DEBUG_DISPLAY: Indicates whether or not error messages should be | |
| // displayed on-screen | |
| // SAVEQUERIES: Stores database queries in a variable that can be displayed in the | |
| // page footer (see http://codex.wordpress.org/Editing_wp-config. | |
| // php#Save_queries_for_analysis for more info) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment