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 | |
$gallery = get_field('images'); | |
$rand = array_rand($gallery, 1); | |
if( $gallery ): ?> | |
<img src="<?php echo $gallery[$rand]['sizes']['large']; ?>" alt="<?php echo $gallery[$rand]['alt']; ?>" /> | |
<?php endif; ?> |
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 | |
$args = array( | |
'post_type' => 'posts', | |
'posts_per_page' => -1, | |
); | |
$total = 0; | |
query_posts($args); | |
while ( have_posts() ) : the_post(); |
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
<!--[if lt IE 9]> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.2/html5shiv.js"></script> | |
<script src="//s3.amazonaws.com/nwapi/nwmatcher/nwmatcher-1.2.5-min.js"></script> | |
<script src="//html5base.googlecode.com/svn-history/r38/trunk/js/selectivizr-1.0.3b.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.1.0/respond.min.js"></script> | |
<![endif]--> |
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 | |
$attachment_id = get_field('field_name'); | |
$image_thumbnail = wp_get_attachment_image_src( $attachment_id, "thumbnail" ); | |
$image_medium = wp_get_attachment_image_src( $attachment_id, "medium" ); | |
$image_large = wp_get_attachment_image_src( $attachment_id, "large" ); | |
// url = $image[0]; | |
// width = $image[1]; | |
// height = $image[2]; | |
?> | |
<img data-interchange="[<?php echo $image_thumbnail[0]; ?>, (default)], [<?php echo $image_medium[0]; ?>, (large)]"/> |
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
add_filter('gettext', 'rename_admin_menu_items'); | |
add_filter('ngettext', 'rename_admin_menu_items'); | |
/** | |
* Replaces wp-admin menu item names | |
* | |
* @author Daan Kortenbach | |
* | |
* @param array $menu The menu array. | |
* | |
* @return $menu Menu array with replaced items. |
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 | |
// Geo Redirect using Cloudflare | |
$activepage = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; | |
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"]; | |
$page_from = "www.domain.tld/"; | |
$page_to = "www.newdomain.tld/"; | |
?> | |
<!-- Country Code : <?php echo $country_code; ?> --> | |
<!-- Active URL : <?php echo $activepage; ?> --> |
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
function toID($string) { | |
//Lower case everything | |
$string = strtolower($string); | |
//Make alphanumeric (removes all other characters) | |
$string = preg_replace("/[^a-z0-9_\s-]/", "", $string); | |
//Clean up multiple dashes or whitespaces | |
$string = preg_replace("/[\s-]+/", " ", $string); | |
//Convert whitespaces and underscore to dash | |
$string = preg_replace("/[\s_]/", "-", $string); | |
return $string; |
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
function safeID( $string, $separator = '_' ) | |
{ | |
$accents_regex = '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i'; | |
$special_cases = array( '&' => 'and'); | |
$string = mb_strtolower( trim( $string ), 'UTF-8' ); | |
$string = str_replace( array_keys($special_cases), array_values( $special_cases), $string ); | |
$string = preg_replace( $accents_regex, '$1', htmlentities( $string, ENT_QUOTES, 'UTF-8' ) ); | |
$string = preg_replace("/[^a-z0-9]/u", "$separator", $string); | |
$string = preg_replace("/[$separator]+/u", "$separator", $string); |