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 | |
/** | |
* Imports an image from URL into media libarary. | |
* | |
* @param string $url The image URL | |
* @param string|null $title The title to use for image in the media library (also will be added as ALT text) | |
* @param int $post_parent_id Post parent ID if applicable | |
* | |
* @return int|\WP_Error ID of the newly created attachment or Wp_Error object on failure |
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 | |
/* Analytics Code */ | |
function gadwp_addcode( $gadwp ) { | |
$commands = $gadwp->get(); // Get commands array | |
array_pop( $commands ); // Pop the last element | |
$fields = array(); | |
$fields['hitType'] = 'pageview'; | |
$commands[] = $gadwp->prepare( 'send', $fields ); // Add a new line to the commands array |
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 | |
if( ! function_exists('wp_parse_args_recursive') ) { | |
/** | |
* Parses arguments considering multi-dimensional arrays and objects. | |
* | |
* @param mixed $args | |
* @param mixed $default | |
* @param bool $preserve_integer_keys | |
* | |
* @return mixed |
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 | |
/** | |
* Automatically login a single WordPress user upon arrival to a specific page. | |
* | |
* Redirect to home page once logged in and prevent viewing of the login page. | |
* Compatible with WordPress 3.9.1+ | |
* Updated 2014-07-18 to resolve WP_DEBUG notice: "get_userdatabylogin is deprecated since version 3.3! Use get_user_by('login') instead." | |
* Updated 2019-07-09 to reformat code, pass 2nd parameter to `do_action()`, and hook into priority 1. | |
* |