This file contains 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 | |
// contact form 7 dynamic value populations | |
// usage [select field-name values:post-list] (checkbox, radio works as well) | |
// for adding custom Form-Tag Check https://contactform7.com/2015/01/10/adding-a-custom-form-tag/ | |
function cf7DynamicListExample($tag) | |
{ | |
$options = $tag['options']; |
This file contains 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 | |
function editMediaTemplate($html) | |
{ | |
$class = 'attachment-link'; | |
return str_ireplace('<a href', sprintf('<a class="%s" href', $class), $html); | |
} | |
add_filter('media_send_to_editor', 'editMediaTemplate', 20, 3); |
This file contains 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 | |
// usage: echo timeAgo(get_the_time('U')); | |
function timeAgo($time) | |
{ | |
$out = ''; | |
$now = time(); | |
$diff = $now - $time; |
This file contains 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 | |
function getPosts() | |
{ | |
$args = [ | |
'post_type' => 'post', | |
'posts_per_page' => 5, | |
'paged' => $_GET['page'], | |
]; |
This file contains 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 | |
function queryPareRequest($query) | |
{ | |
if ( | |
!$query->is_main_query() | |
|| 2 != count($query->query) | |
|| !isset($query->query['page']) | |
) { | |
return; |
This file contains 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 | |
function registerThemeWidgets() | |
{ | |
register_widget('Example_widget'); | |
} | |
add_action('widgets_init', 'registerThemeWidgets'); | |
class Example_widget extends WP_Widget |
This file contains 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 | |
function truncate($full, $length) | |
{ | |
$length = abs((int)$length); | |
if (strlen($full) > $length) { | |
$first = preg_replace("/^(.{1,$length})(\s.*|$)/s", '\\1', $full); | |
$second = substr($full, strlen($first)); | |
} |
This file contains 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
var sticky = (function($) { | |
var content = '.page-content'; | |
var element = '.sticky-block'; | |
if (!$(element).length || !(content).length) | |
return; | |
var barHeight = $(element).height(); | |
var barOffset = $(element).offset().top; |
This file contains 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
var firstWord = (function($) { | |
var selector = '.first-word'; | |
$(selector).each(addWrap); | |
function addWrap() { | |
var word = $(this).html(); | |
var index = word.indexOf(' '); |
This file contains 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
var fileInput = (function($) { | |
var selector = 'input[type="file"]'; | |
$(selector).on('change', modifyLabel); | |
function modifyLabel(event) { | |
var fileName = ''; | |
var id = $(this).attr('id'); | |
var label = $('label[for="'+ id +'"]'); |
OlderNewer