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
add_filter( 'wp_nav_menu_items', 'add_login_logout_register_menu', 199, 2 ); | |
function add_login_logout_register_menu( $items, $args ) { | |
//print_r($args); | |
if ( $args->menu != 'footer-1' ) { // Add links on specific menu | |
return $items; | |
} | |
if ( is_user_logged_in() ) { | |
$items .= '<li><a href="' . wp_logout_url('home') . '">' . __( 'Logout' ) . '</a></li>'; | |
} else { |
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 | |
// ref - http://codular.com/curl-with-php | |
// Get cURL resource | |
$curl = curl_init(); | |
// Set some options - we are passing in a useragent too here | |
curl_setopt_array($curl, array( | |
CURLOPT_RETURNTRANSFER => 1, | |
CURLOPT_URL => 'http://localhost/wp/r&d/wp-json/wp/v2/posts/375', | |
CURLOPT_USERAGENT => 'Codular Sample cURL Request' | |
)); |
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
/// Add title attribue in site logo | |
add_filter( 'get_custom_logo', 'as_add_title_attr_in_logo' ); | |
function as_add_title_attr_in_logo() { | |
$siteName = get_bloginfo('name'); | |
$custom_logo_id = get_theme_mod( 'custom_logo' ); | |
$html = sprintf( '<a href="%1$s" class="site-logo" rel="home" title="'.$siteName.'" itemprop="url">%2$s</a>', | |
home_url( '/' ), | |
wp_get_attachment_image( $custom_logo_id, 'full', false, array( | |
'class' => 'custom-logo', | |
) ) |
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
// Find and Replace whole word with new one | |
// Would replace the word egg, as a word boundary. So should replace egg but not eggplant. | |
jQuery("span").text(function () { | |
return jQuery(this).text().replace(/\bContactta drd\b/, "Home"); | |
}); |
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
// Remove Height and Width parameters from the_post_thumbnail function | |
add_filter('post_thumbnail_html', 'remove_thumbnail_dimensions', 10); | |
add_filter('image_send_to_editor', 'remove_thumbnail_dimensions', 10); | |
function remove_thumbnail_dimensions($html) | |
{ | |
$html = preg_replace('/(width|height)=\"\d*\"\s/', "", $html); | |
return $html; | |
} | |
/** |
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
// Move comment box in bottom of the form | |
function wpb_move_comment_field_to_bottom( $fields ) { | |
$comment_field = $fields['comment']; | |
unset( $fields['comment'] ); | |
$fields['comment'] = $comment_field; | |
return $fields; | |
} | |
add_filter( 'comment_form_fields', 'wpb_move_comment_field_to_bottom' ); |
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
// Change login link for Woocommerce product review's "Login" link | |
add_filter( 'login_url', 'my_login_page', 10, 2 ); | |
function my_login_page( $login_url, $redirect ) { | |
return home_url( '/my-account/?redirect_to=' . $redirect ); | |
} | |
add_filter('woocommerce_login_redirect', 'rohil_login_redirect'); | |
function rohil_login_redirect( $redirected_to ) { |
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
// Disable support for comments and trackbacks in post types | |
function df_disable_comments_post_types_support() { | |
$post_types = get_post_types(); | |
foreach ($post_types as $post_type) { | |
if(post_type_supports($post_type, 'comments')) { | |
remove_post_type_support($post_type, 'comments'); | |
remove_post_type_support($post_type, 'trackbacks'); | |
} | |
} |
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
// Move comment box in bottom of the form | |
function wpb_move_comment_field_to_bottom( $fields ) { | |
$comment_field = $fields['comment']; | |
unset( $fields['comment'] ); | |
$fields['comment'] = $comment_field; | |
return $fields; | |
} | |
add_filter( 'comment_form_fields', 'wpb_move_comment_field_to_bottom' ); |
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
// ref - https://stackoverflow.com/questions/26522789/how-to-run-sh-on-windows-command-prompt | |
- open "Git Bash | |
- navigate to desitination drive, ie - cd f: | |
- navigate to desitination directory, ie - cd foldername/sub-folder/.. | |
- download github repository to destination folder | |
- run "shell script" file, ie - bash build-plugin.sh | |
- thats it |