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 | |
/* | |
* Completely untested, but may work. :-) | |
*/ | |
function tgm_quick_write_file() { | |
$url = wp_nonce_url( 'YOUR NONCIFIED URL HERE (if you are using a post mechanism to write the file' ); | |
$method = ''; // WP_Filesystem will populate this automatically | |
if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) |
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 | |
/** | |
* Factory method for creating a new image filter object instance. The image param must | |
* be a valid directory path to the image. | |
* | |
* @since 1.0.0 | |
* | |
* @param int $id The image attachment ID | |
* @param string $image The real path to the image being filtered | |
* @param string $filter The type of filter to be applied to the image |
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 | |
add_action( 'wp_login', array( $this, 'update_creds' ), 10, 2 ); | |
public function update_creds( $login, $user ) { | |
// Do your stuff here | |
} |
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 | |
add_action( 'wp_login', 'update_some_random_option' ); | |
function update_some_random_option() { | |
update_option( 'my_test_option', 'I have been saved!' ); | |
} | |
add_action( 'admin_notices', 'check_some_random_option' ); | |
function check_some_random_option() { |
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 | |
/** Add nonce to wp_localize_script */ | |
wp_localize_script( 'qvote-ajax', 'QVoteAJAX', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'vote_nonce' ) ) ); | |
/** Pass nonce in Ajax request */ | |
var data = { | |
action: 'qvote_count', | |
postid: postid, | |
vtype: vtype, | |
count: count, |
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 | |
add_action( 'tgmsp_before_slider_output', 'tgm_unregister_soliloquy_style' ); | |
function tgm_unregister_soliloquy_style( $id ) { | |
// If you only want to do it for a particular slider, use the $id param to test against a slider in particular | |
wp_dequeue_script( 'soliloquy-style' ); | |
} |
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
/** | |
* Prevents unnatural scaling when shifting viewport modes on iPhone/iPod/iPad. | |
* | |
* When shifting from portrait to landscape mode on an iPad, some responsive | |
* CSS will cause the landscape view to be scaled upon switch. This bit of JS | |
* prevents that by first ensuring that we have the responsive meta tag enabled, | |
* setting the initials scales back to the original load state, and then re-enabling | |
* resizing once the user makes their first gesture on the screen. | |
*/ | |
if ( navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i) ) { |
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
<!--[if IE]> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
$(".flex-container").each(function(i, el){ | |
$(el).hover(function(){ | |
$(this).addClass("flex-hover"); | |
}, function(){ | |
$(this).removeClass("flex-hover"); | |
}); | |
}); |
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 | |
add_action( 'wp_enqueue_scripts', 'my_custom_callback_function' ); | |
function my_custom_callback_function() { | |
wp_register_script('scrollbar', get_template_directory_uri() .'/jquery.mCustomScrollbar.js', '3.1.4', '1.0.0', true); | |
wp_enqueue_script('scrollbar'); | |
} |
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 | |
$xml = simplexml_load_file( 'path/to/my/file.xml' ); | |
/** To list out all of the attributes and their values, loop through each child node and output it */ | |
foreach ( $xml->children() as $node ) | |
echo $node->getName() . ': ' . $node; |