Skip to content

Instantly share code, notes, and snippets.

@cobaltapps
cobaltapps / freelancer-disable-icons.php
Created September 13, 2017 14:27
Define the following constant through your Child Theme to disable the enqueueing of the Freelancer Icon styles.
// Disable the Freelancer custom icon set styles.
define( 'FREELANCER_ICONS_DISABLE', true );
@cobaltapps
cobaltapps / freelancer-set-custom-icons-url
Created September 13, 2017 14:31
Use the following filter hook to set your own custom icons URL to override the default Freelancer Icons and add your own.
/*
* Edit the add_filter code below to add
* your own custom icon set in place of Freelancer's.
*
* NOTE: Do not define the FREELANCER_ICONS_DISABLE
* constant if you want to use the filter code below.
*/
add_filter( 'freelancer_icons_url', function() { return get_stylesheet_directory_uri() . '/icons/css/custom-icons.min.css'; } );
@cobaltapps
cobaltapps / freelancer-add-custom-scripts.php
Created September 13, 2017 14:38
Use the following code inside the function hooked into wp_enqueue_scripts inside your Child Theme's functions.php file.
/* # Custom Scripts
* To add custom scripts just create a scripts.js file in your root
* child theme folder and use the code below to enqueue it.
*/
wp_enqueue_script( 'freelancer-child-scripts', get_stylesheet_directory_uri() . '/scripts.js', array( 'jquery' ), FREELANCER_CHILD_THEME_VERSION, true );
@cobaltapps
cobaltapps / freelancer-enqueue-custom-scripts.php
Last active March 7, 2019 02:07
See the full code snippet that enqueues custom scripts through your Child Theme's functions.php file.
add_action( 'wp_enqueue_scripts', 'freelancer_child_enqueue_scripts' );
/*
* Enqueue custom Child Theme scripts.
*/
function freelancer_child_enqueue_scripts() {
/* # Custom Scripts
* To add custom scripts just create a scripts.js file in your root
* child theme folder and use the code below to enqueue it.
*/
@cobaltapps
cobaltapps / freelancer-action-hooks-structure-example.php
Last active March 7, 2019 02:07
An example of some basic HTML structure with some do_action code to help illustrate how WordPress action hooks work.
<!-- Example of a basic HTML structure and some action hook calls
to help show how action hooks are setup in specific locations,
ready to be hooked into with the add_action call. -->
<body>
<!-- Generally hooks that are created by the theme
start with their theme name at the beginning of
the hook name, in this generic case "theme_". -->
<?php do_action( 'theme_hook_before_container' ); ?>
@cobaltapps
cobaltapps / freelancer-basic-add-action-example.php
Created September 13, 2017 17:54
A basic example of how to add_action a custom function into a specific hook location.
add_action( 'theme_hook_before_content', 'my_custom_text' );
/*
* Echo some text inside a function and then hook
* that function into a specified hook location
* using the add_action WordPress function.
*/
function my_custom_text() {
echo 'Hello World!';
@cobaltapps
cobaltapps / freelancer-action-filter-example.php
Last active March 7, 2019 02:06
An example of what an applied filter might look like inside a theme when compared to a non filtered value.
// "Read More" text value without a filter.
$read_more_text = 'Continue reading...';
// "Read More" text value a filter applied.
$read_more_text = apply_filters( 'theme_read_more_text', 'Continue reading...' );
@cobaltapps
cobaltapps / freelancer-add-filter-example.php
Created September 13, 2017 18:16
A simple example of how to filter a custom value into an applied filter.
/*
* This is the cleanest way to do this, using an anonymous function,
* but such a function requires PHP 5.3 or higher.
*/
add_filter( 'theme_read_more_text', function() { return 'Read more ->'; } );
/*
* This is the same anonymous function example,
* but formatted differently for those who might
* the first example a bit confusing.
@cobaltapps
cobaltapps / freelancer-wordpress-conditionals-example.php
Created September 13, 2017 18:42
An example of how to use WordPress Conditional Tags inside of custom functions.
add_action( 'theme_before_content', 'my_banner_ad' );
/*
* This conditional example ensures that the banner ad only
* displays on the front page by returning nothing if it
* is NOT the front page.
*/
function my_banner_ad() {
if ( ! is_front_page() )
return;
@cobaltapps
cobaltapps / themer-pro-admin-bar-add-node-example.php
Created October 20, 2017 14:10
Themer Pro code that allows for quick-edit-access to Page Template files from the front-end of your website.
if ( function_exists( 'themer_pro_admin_bar_add_node') )
themer_pro_admin_bar_add_node( $file = 'page-builder.php', $subdir = '', $fullscreen = false );