Skip to content

Instantly share code, notes, and snippets.

@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-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-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-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-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-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-hide-admin-pages.php
Last active March 7, 2019 02:09
Define the following constants through your Child Theme to hide the Theme Options and/or Theme License admin pages.
// Hide the Theme Settings admin page from the WP Dashboard sidebar.
define( 'FREELANCER_SETTINGS_PAGE_HIDE', true );
// Hide the Theme License admin page from the WP Dashboard sidebar.
define( 'FREELANCER_LICENSE_PAGE_HIDE', true );
@cobaltapps
cobaltapps / freelancer-defining-custom-layouts.php
Created September 13, 2017 14:16
The following provides all of the ways to set the various layouts offered in Freelancer.
// Define a Right Sidebar layout.
add_filter( 'freelancer_layout', 'freelancer_return_right_sidebar' );
// Define a Left Sidebar layout.
add_filter( 'freelancer_layout', 'freelancer_return_left_sidebar' );
// Define a No Sidebar layout.
add_filter( 'freelancer_layout', 'freelancer_return_no_sidebar' );
// Define a No Sidebar Narrow layout.
@cobaltapps
cobaltapps / freelancer-custom-layout-function.php
Last active March 7, 2019 02:10
An example of a custom function used to assign a custom layout to Freelancer using a conditional and the freelancer_layout filter hook.
add_action( 'wp_head', 'my_custom_layout' );
/*
* This would assign a No Sidebar layout to all "Pages"
* on your site, but have no effect on any other area.
*/
function my_custom_layout() {
// If NOT a "Page" then do nothing.
if ( ! is_page() )
return;
@cobaltapps
cobaltapps / freelancer-add-custom-body-classes.php
Created September 13, 2017 13:31
Easily add custom body classes to your site using the following code inside your Child Theme's PHP files.
// Add a single body class through a string.
freelancer_add_body_classes( 'my-custom-body-class' );
// Add multiple body classes through an array.
freelancer_add_body_classes( array( 'my-custom-body-class', 'another-body-class' ) );