Skip to content

Instantly share code, notes, and snippets.

View Asikur22's full-sized avatar
💜
Web Developer | In Love with WordPress

Asiqur Rahman Asikur22

💜
Web Developer | In Love with WordPress
View GitHub Profile
@Asikur22
Asikur22 / server.md
Last active July 22, 2019 11:40
[Browser Sync] #Server #Port

Install Browser Sync

npm install -g browser-sync

Run Browse Sync for Static Site

browser-sync start --server --directory --files "**/*"
@Asikur22
Asikur22 / functions.php
Last active April 10, 2019 17:17
[Add Login/Logout Link to Menu] #MenuPanel
function gl_loginout_menu_link( $items, $args ) {
if ($args->theme_location == 'primary') {
if (is_user_logged_in()) {
$items .= '<li class="right"><a href="'. wp_logout_url() .'">'. __("Log Out") .'</a></li>';
} else {
$items .= '<li class="right"><a href="'. wp_login_url(get_permalink()) .'">'. __("Log In") .'</a></li>';
}
}
return $items;
@Asikur22
Asikur22 / .htaccess
Last active April 10, 2019 17:21
[Redirect urls exactly, just change domain name with Apache] #htaccess #URL
RewriteEngine On
RewriteCond %{HTTP_HOST} ^asique.me$ [OR]
RewriteCond %{HTTP_HOST} ^www.asique.me$
RewriteRule ^(.*)$ https://asique.net/$1 [R=301,L]
##Redirect Type
##301 Permanent Redirect
##307 Temporary Redirect
@Asikur22
Asikur22 / functions.php
Last active September 1, 2019 04:44
[Add CSS Class to Last Menu Item] #WordPress #AnchorTag
/*
* Add CSS Class to Last Menu Item Anchor Tag
*/
function add_specific_menu_atts( $atts, $item, $args ) {
if ( $args->menu->count == $item->menu_order && $args->theme_location == 'primary' ) {
$atts[ 'class' ] = 'btn-def';
}
return $atts;
}
@Asikur22
Asikur22 / functions.php
Created April 10, 2019 17:26
[Disable Redux Framework Developer Mode “dev_mode”] #ThemeOptions #WordPress
<?php
/*
* Disable Redux Developer Mode dev_mode
*/
function redux_disable_dev_mode_plugin( $redux ) {
if ( ! function_exists( 'redux_disable_dev_mode_plugin' ) ) {
if ( $redux->args['opt_name'] != 'redux_demo' ) {
$redux->args['dev_mode'] = false;
$redux->args['forced_dev_mode_off'] = false;
@Asikur22
Asikur22 / .htaccess
Created April 10, 2019 17:28
[Password Protect Folder with Apache .htaccess file]
##Create new file named “.htaccess” in the folder with this Content
AuthName "Password Protected!"
AuthType Basic
AuthUserFile /home/cpanel_user_name/public_html/folder_name/.htpasswd
require valid-user
##Create new file named “.htpasswd” in the same folder with this Content (Username:Password)
asiq:12345
@Asikur22
Asikur22 / finctions.php
Created April 10, 2019 17:31
[Add “odd” “even” Class Name to “post_class”] #WordPress
/*
* Add "odd" "even" Class Name to "post_class"
*/
function odd_even_post_class( $classes ) {
global $oddeven_class;
$oddeven_class = ( $oddeven_class == 'odd' ) ? 'even' : 'odd';
$classes[] = $oddeven_class;
@Asikur22
Asikur22 / functions.php
Created April 10, 2019 17:32
[Change WordPress Upload Directory for Specific Files Types] #Media
/*
* Change Upload Directory for Specific Files Type
* Only works in WordPress 3.3+
*/
function wpse47415_pre_upload( $file ) {
add_filter( 'upload_dir', 'wpse47415_custom_upload_dir' );
return $file;
}
@Asikur22
Asikur22 / functions.php
Created April 10, 2019 17:38
[Limit Category to 1 Category in WordPress Edit Screen] #Taxonomy
/*
* Limit Category to 1 Category in Edit Screen.
*/
function limit_cat_to_one() {
if ( is_admin() ) {
?>
<script>
jQuery( document ).ready( function ( $ ) {
$( "#category-all input:checkbox" ).change( function () {
@Asikur22
Asikur22 / functions.php
Created April 10, 2019 17:40
[Remove WordPress Dashboard Widget] #AdminView
/*
* Remove WordPress Dashboard Widget
*/
function remove_dashboard_widgets() {
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' ); //Quick Press widget
remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' ); //Recent Drafts
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' ); //WordPress.com Blog
remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' ); //Other WordPress News
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' ); //Incoming Links
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' ); //Plugins