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 | |
$tasks = array( | |
array( | |
'id' => 1, | |
'name' => 'Write down some tasks', | |
'priority' => 1, | |
'completed' => true, | |
), | |
array( | |
'id' => 2, |
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 | |
/** | |
* Show posts which are only under uncategorized term | |
* 1 is the id of Uncategorized term | |
*/ | |
function op_show_only_uncategorized( $query ) { | |
if ( is_admin() || ! $query->is_main_query() || ! $query->is_category( 1 ) ) { | |
return; | |
} | |
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 | |
/** | |
* Enqueue assets (js/css) | |
*/ | |
function prefix_enqueue_assets() { | |
wp_enqueue_script( | |
'prefix-script', | |
get_template_directory_uri() . '/assets/js/scripts.js', | |
array('jquery'), | |
null, |
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 | |
$paged = get_query_var('paged') ? get_query_var('paged') : 1; | |
$args = array( | |
'post_type' => 'post', | |
'paged' => $paged, | |
'post__not_in' => get_option( 'sticky_posts' ), | |
'ignore_sticky_posts' => true, | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'post_format', |
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 | |
function op_add_category_rule( $rules ) { | |
$rule = array( | |
'category/(.+?)-([0-9]+)/?$' => 'index.php?category_name=$matches[1]&category_id=$matches[2]' | |
); | |
return $rule + $rules; | |
} | |
add_filter( 'category_rewrite_rules', 'op_add_category_rule' ); |
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 | |
/** | |
* Add awesome tab to tab list | |
* | |
* @param array $tabs Tabs list | |
* @return array | |
*/ | |
function op_add_awesome_tab( $tabs ) { | |
$tabs['awesome-tab'] = array( | |
'label' => esc_html__( 'Awesome Tab', 'text-domain' ), |
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 | |
/** | |
* Disable theme update notification | |
* | |
* Disabled this notification because there is a theme | |
* in WP theme directory with same name. | |
* We'll do this based on author name as author won't be same | |
* | |
* @param array $theme Installed themes information | |
* @return array Modified information |
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
// WordPress Time Constants | |
MINUTE_IN_SECONDS = 60 (seconds) | |
HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS | |
DAY_IN_SECONDS = 24 * HOUR_IN_SECONDS | |
WEEK_IN_SECONDS = 7 * DAY_IN_SECONDS | |
MONTH_IN_SECONDS = 30 * DAY_IN_SECONDS | |
YEAR_IN_SECONDS = 365 * DAY_IN_SECONDS |
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 | |
/** | |
* Simple & concise Solution | |
*/ | |
function op_block_add_to_cart() { | |
wc_add_notice( sprintf( | |
/** translators: %1$s is cart url, %2$s is checkout url */ | |
esc_html__( 'You cannot purchase more than 1 item at a time. %1$s or %2$s', 'op' ), | |
'<a href="' . esc_url( wc_get_cart_url() ) . '">' . esc_html__( 'View cart', 'op' ) . '</a>', | |
'<a href="' . esc_url( wc_get_checkout_url() ) . '">' . esc_html__( 'checkout', 'op' ) . '</a>' |
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 | |
/** | |
* Show last 5 attachments in media popup | |
*/ | |
/** | |
* Attachment query arguments | |
* @param array $args Query arguments | |
* @return array Update query argumnets | |
*/ |