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 | |
global $wpdb; | |
$sql = " | |
SELECT $wpdb->posts.* | |
FROM $wpdb->posts | |
WHERE $wpdb->posts.post_status = 'publish' | |
AND $wpdb->posts.post_type = 'post' | |
AND $wpdb->posts.post_date < NOW() |
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
/* Bootstrap pagination. | |
=========================================================================== */ | |
function itl_paging_nav() { | |
global $wp_query, $wp_rewrite; | |
// Setting up default values based on the current URL. | |
$pagenum_link = html_entity_decode( get_pagenum_link() ); | |
$url_parts = explode( '?', $pagenum_link ); | |
// Get max pages and current page out of the current query, if available. |
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
/* | |
* install stylebot from Chrome Webstore: https://chrome.google.com/extensions/detail/oiaejidbmkiecgbjeifoejpgmdaleoha | |
* import this style from backup (Stylebot Options) | |
*/ | |
{{"https://trello.com/b/":{"_enabled":true,"_rules":{"at1":{"at":true,"text":"@font-face {\n \n font-family: 'vazir-font';\n \n font-weight: normal;\n \n font-style: normal;\n src: url('https://cdn.rawgit.com/rastikerdar/vazir-font/v19.0.0/dist/Vazir.woff') format('woff');\n \n font-display: swap;\n}","type":"@font-face"},"#board":{"padding":"0 15px"},"body":{"background":"#216f95"},"body, button, html, input, select, textarea":{"font-family":"'vazir-font', 'Segoe UI', sans-serif","font-size":"16px"},".window-header:after, .window-module-title:after":{"display":"block","content":"''","clear":"both"},"#board, textarea, .checklist-item-row, .card-detail-fake-text-area, .checklist-item-details-text, .phenom.mod-comment-type .phenom-reactions, .phenom-desc, .action-comment p":{"direction":"rtl","text-align":"right"},"pre, code" |
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
@font-face { | |
font-family: 'vazir-font'; | |
font-weight: normal; | |
font-style: normal; | |
src: url('https://cdn.rawgit.com/rastikerdar/vazir-font/v19.0.0/dist/Vazir.woff') format('woff'); | |
font-display: swap; | |
} | |
#board { | |
padding: 0 15px; | |
} |
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
/* Convert string duration to ISO 8601 duration format. | |
=========================================================================== */ | |
function itl_iso8601_duration( $seconds ) { | |
$hours = floor( $seconds / 3600 ); | |
$seconds = $seconds % 3600; | |
$minutes = floor( $seconds / 60 ); | |
$seconds = $seconds % 60; | |
$iso8601 = sprintf( 'PT%s%s%s', |
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 async Attributes to Enqueue Scripts where Needed. | |
=========================================================================== */ | |
function itl_script_tag_defer( $tag, $handle ) { | |
if ( is_admin() ) { | |
return $tag; | |
} | |
if ( strpos($tag, '/wp-includes/js/jquery/jquery') ) { | |
return $tag; | |
} |
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 Custom Fee to Woocommerce Cart for Physical Products. | |
=========================================================================== */ | |
function itl_woocommerce_custom_fee() { | |
global $woocommerce; | |
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { | |
return; | |
} | |
$is_physical = false; |
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
// Let’s presume we have a ‘product’ post type, with a ‘names’ taxonomy. | |
/* The posts_orderby filter. | |
=========================================================================== */ | |
function itl_edit_posts_orderby( $orderby_statement, $wp_query ) { | |
if ( isset( $wp_query->query['orderby'] ) && 'include' == $wp_query->query['orderby'] ) { | |
$include = implode( ',', array_map( 'absint', $wp_query->query['include'] ) ); | |
$orderby_statement = "FIELD( term_taxonomy_id, $include )"; | |
} |
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
// in line 61 insert your piwik url | |
// source code: wordpress.org/plugins/woocommerce-piwik-integration/ | |
/* Get encoded categories by product. | |
=========================================================================== */ | |
function getEncodedCategoriesByProduct( $product ) { | |
$categories = get_the_terms( $product->get_id(), 'product_cat' ); | |
if ( ! $categories ) { | |
$categories = 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
// original source http://stackoverflow.com/a/35072168 | |
function itl_is_product_the_same_cat( $valid, $product_id, $quantity ) { | |
global $woocommerce; | |
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) { | |
$_product = $values['data']; | |
$terms = get_the_terms( $_product->id, 'product_cat' ); | |
$target_terms = get_the_terms( $product_id, 'product_cat' ); // get the current items |
NewerOlder