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
/** | |
* add_flagging_link_comment - Add report link to comment content | |
* | |
* Add report link to comment content | |
* | |
* @since 1.0 | |
* | |
* @param string $comment_text | |
* @param object $comment | |
* |
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 | |
echo '<pre>'; | |
for ($j = 1; $j < 10; $j++) { | |
for ($k = 0; $k < $j; $k++) { | |
echo "\n\$i % $j == $k: \n"; | |
for ($i = 0; $i < 10; $i++) { | |
echo "$i : "; | |
if ($i % $j == $k) { | |
echo "TRUE"; |
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 | |
// $posts is some content to loop over and output. Perhaps 28 items. | |
// We want raindow coloured boxes so loop over 7 possible colours. | |
$posts_count = 0; | |
foreach ( $posts as $post ) : | |
$colour = ''; | |
if ( $posts_count % 7 == 0 ) { | |
$colour = 'red'; | |
} elseif ( $posts_count % 7 == 1 ) { | |
$colour = 'orange'; |
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
<div class="row"> | |
<?php | |
// $posts is some content to loop over and output. | |
$posts_count = 0; | |
foreach ( $posts as $post ) : | |
echo $post; | |
if ( $posts_count % 3 == 2 ) : // Fires every 3rd item since we are counting from 0. ?> | |
</div><div class="row> | |
<?php endif; |
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
/** | |
* Check if a given ip is in a network https://gist.github.com/tott/7684443 | |
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1 | |
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed | |
* @return boolean true if the ip is in this range / false if not. | |
*/ | |
function ip_in_range( $ip, $range ) { | |
if ( strpos( $range, '/' ) == false ) { | |
$range .= '/32'; | |
} |
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
/** | |
* Add Garlic.js compatability to TinyMCE on front-end | |
* | |
* @param array $settings TinyMCE settings array. | |
* @return array Modified TinyMCE settings array. | |
*/ | |
function mytheme_tinymce_garlicjs_compat( $settings ) { | |
if ( ! is_admin() ) { | |
$settings['setup'] = "function(editor) { | |
editor.on('change keyup', function(e){ |
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 ?> | |
<label for="filter-country">Country</label> | |
<select id="filter-country" class="form-control" name="country"> | |
<option selected="" value="">All countries</option> | |
<?php | |
if ( false === ( $cptcountries = get_transient( 'cpt_countries' ) ) ) { | |
global $wpdb; | |
$cpt_countries = $wpdb->get_col( "select distinct term_taxonomy_id from $wpdb->term_relationships where object_id in ( select ID from $wpdb->posts where post_type='cpt' )" ); | |
$cptcountries = get_terms( array( 'taxonomy' => 'country', 'include' => $cpt_countries ) ); | |
if ( ! empty( $cptcountries ) && ! is_wp_error( $cptcountries ) ) { |
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 | |
/** | |
* Clone of wp_count_comments from WP4.2. | |
*/ | |
function myblogs_count_comments( $post_id = 0 ) { | |
global $wpdb; | |
$post_id = (int) $post_id; | |
/** | |
* Filter the comments count for a given post. |
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
#!/bin/bash | |
# | |
# Manage .htpasswd files | |
# Store script name for use in output. | |
me=$( basename $0 ) | |
# Utility function for exiting. |
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 | |
/** | |
* Update .htaccess to whitelist logo when modified in platform settings. | |
*/ | |
function cc_logo_htaccess() { | |
// Fire only on Platform Settings options page. | |
$screen = get_current_screen(); | |
if ( 'cc-configurator_page_cc-settings' === $screen->id && ( $_POST['acf']['field_576c2a5137029'] || $_POST['acf']['field_576c2a9e3702a'] ) ) { | |
// Store files in an array. |
OlderNewer