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 wpajax_load_more_posts(){ | |
$page = sanitize_key( $_POST['page'] ); // Previously saved in JS or somewhere else | |
// Arguments | |
$args = array( | |
'category_name' => 'Portfolio', | |
'posts_per_page' => 6, | |
'paged' => $page | |
); | |
// The Query |
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
class My_Custom_Theme_Options { | |
function odin_theme_settings_example() { | |
$settings = new Odin_Theme_Options ( 'odin-settings', // Slug/ID of the Settings Page (Required) | |
'Theme Settings', // Settings page name (Required) | |
'manage_options' ); // Page capability (Optional) [default is manage_options] | |
$settings->set_tabs ( array ( | |
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
jQuery( 'form.checkout, form#order_review' ).addClass("processing").block({ | |
message: null , | |
overlayCSS: { | |
background: "#fff", | |
opacity: .6 | |
} | |
}); |
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 odin_contact_author_form($author_id) { | |
$author_email = get_the_author_meta( 'user_email', $author_id ); | |
$form = new Odin_Contact_Form( | |
'form_id', // ID do formulário | |
'eu@email.com', // E-mail do destinatário. | |
array( 'vc@email.com', 'tu@email.com', $author_email ), // array com e-mails que receberão cópia. | |
array( 'alguem@email.com' ) // array com e-mails que receberão cópia oculta. | |
// array( 'class' => 'form' ) // array com atributos para o formulário. | |
// 'file' // string com método que será enviado o anexo, no caso 'file' como anexo e 'url' para enviar links. |
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 setPostViews($postID) { | |
$count_key = 'post_views_count'; | |
$count = get_post_meta($postID, $count_key, true); | |
if($count == ""){ | |
$count = 0; | |
delete_post_meta($postID, $count_key); | |
add_post_meta($postID, $count_key, '1'); | |
wp_cache_set( "view_" . $postID, TRUE, "", 0 ); | |
}else{ |
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 theme_name_scripts() { | |
if( is_user_logged_in() ){ | |
wp_enqueue_style( 'style-logged-in', get_stylesheet_uri(). '/css/logged-in.min.css', array(), '1.0.0' ); | |
}else{ | |
wp_enqueue_style( 'style-logged-out', get_stylesheet_uri(). '/css/logged-out.min.css', array(), '1.0.0' ); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' ); |
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 custom Pretty Link to Custom Post Type or Custom Taxonomy | |
* | |
* Change @@@ to your CPT or CT slug... | |
* | |
* Change ??? to custom link like example or anything else... | |
* | |
*/ | |
function wp_permastructs(){ |
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
$.imgReload = function() { | |
var retries = 0; | |
var loaded = 1; | |
$("img").each(function() { | |
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) { | |
var src = $(this).attr("src"); | |
var date = new Date(); | |
$(this).attr("src", src + "?v=" + date.getTime()); //slightly change url to prevent loading from cache | |
loaded =0; | |
} |
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 | |
/** Custom Pagination */ | |
function custom_pagination($total_pages, $current_page, $pageByGet = true){ | |
// Only paginate if we have more than one page | |
if ( $total_pages > 1 ) { | |
$big = 999999999; | |
// Structure of "format" depends on whether we’re using pretty permalinks |