Tag: wordpress customisation

Steps To Change Admin URL In WordPress Development Service

Change Admin URL
Let’s have a quick walk through regarding changing Admin URL with WordPress. As we all know that WordPress provides us less security compare to other CMS and Frameworks. So, in this case, to protect our website from hackers we need to perform several processes like protecting admin area, give fewer primitives to database etc.

If you have a WordPress site, then it is very easy to access admin URL of the login page. A Person who has basic knowledge of WordPress is known that by /wp-admin you can access admin page, or by /wp-login.php you can access the login page.
For the security purpose, we need to change Admin URL as well as Login page URL so that it is not easily accessible to others.

There are several plugins available in the market by which we can protect our admin area. Which are as follows:

  1. Protect wp-Admin
  2. Better WP Security
  3. Lockdown WP Admin

But, Here I am going to explain to you how we can achieve this using custom code:

You need to follow below three steps to change admin URL:

1) Add constants to wp-config.php file

define('WP_ADMIN_DIR', 'secret-folder'); 
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR);

2) Add below snippet in function.php file of your active theme

add_filter('site_url', 'wpadmin_filter', 10, 3); 
function wpadmin_filter( $url, $path, $orig_scheme ) { 
$old = array( "/(wp-admin)/"); 
$admin_dir = WP_ADMIN_DIR; 
$new = array($admin_dir); 
return preg_replace( $old, $new, $url, 1); 
}

3) Add below line to .htaccess file

RewriteRule ^secret-folder/(.*) wp-admin/$1?%{QUERY_STRING} [L]

By following above steps, you can access admin area using this URL.

Hope this helps you to make things work, feel free to leave your feedback..!!! Need more assistance Hire WordPress Developer…!

How Filter Works In WordPress

Filter Hooks are very powerful features of WordPress that provide huge amount of flexibility for modifying WordPress, including custom themes and plugins. In this tutorial, I’m just showing a simple example that demonstrates what a filter hook does.
There are four core functions that use when working with filters:
  • add_filter(): Used for adding new custom filter.
  • remove_filter(): used for removing an already registered filter.
  • apply_filters(): runs the provided data through the specified filter.
  • has_filter(): checks whether a specific filter has been registered or not.
You can think of a filter as a method for modifying data. Here an example for following colors:
function demo_show_colors() {    
    $colors = array('Red', 'Green', 'Blue');
    $list = '<ul>';
    foreach($colors as $color) {
     $list .= '<li>' . $color . '</li>';
    }
    $list .= '</ul>';
    return $list;    
}
echo demo_show_colors();
Output:
* Red
* Green
* Blue
Now if we want to modify list of colors via plugin, we need to include a filter.
function demo_show_colors() {
    $colors = array('Red', 'Green', 'Blue');
    $list = '<ul>';
    if(has_filter('modify_colors')){
     $colors = apply_filters('modify_colors', $colors);
    }
    foreach($colors as $color) {
     $list .= '<li>' . $color . '</li>';
    }
    $list .= '</ul>';
    return $list;    
}
In if condition we check if there “modify_colors” filter exists then apply that filter to $color array.
After applying filter we can add colors, remove selective colors, change color name etc.
Here’s Example For Add Color:
function add_extra_color($colors) 
{
    $extra_color = array('Navy', 'Skyblue', 'Brown');
    $colors = array_merge($extra_color, $colors);
    return $colors;
}
add_filter('modify_colors', 'add_extra_color');
Output:
* Red
* Green
* Blue
* Navy
* Skyblue
* Brown
remove_filter is used for just remove addition done by the add_filter() if any.
Here is example of remove filter:
function add_extra_color($colors) 
{
 $extra_color = array('Navy','Skyblue','Brown');
 $colors = array_merge($extra_color, $colors);
 return $colors;
}
add_filter('modify_colors', 'add_extra_color')

function demo_show_colors() 
{
 $colors = array('Red','Green','Blue');
 $list = '<ul>';
 if(has_filter('modify_colors')){
     $colors = apply_filters('modify_colors', $colors);
 }
 foreach($colors as $color) {
     $list .= '<li>' . $color . '</li>';
 }
 $list .= '</ul>';
 return $list;    
}

remove_filter('modify_colors','add_extra_color');
Output:
* Red
* Green
* Blue
Hope you all understood the concept of Filters in WordPress. Feel free to contact us for any suggestions/queries and hire WordPress developer.
Read More…. https://goo.gl/wt9svz
How To Modify WordPress Dashboard Without Plugin

How To Modify WordPress Dashboard Without Plugin

Today, I am going to provide you easy and quick steps to modify wordpress dashboard without plugin. Please follow below steps:
1. Hiding unwanted widget from wordpress dashboard
You can easily hide widgets from wordpress dashboard that you have no longer needed.
You have to add following code into your active theme’s function.php file:
add_action('wp_dashboard_setup', 'custom_hide_widgets');
function custom_hide_widgets() {
     global $wp_meta_boxes;
    
//for Activity
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']);
    
//for At Glance    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);    
}
This will hide Activity & At Glance from your wordpress dashboard.
2. Replace “Howdy” with your text in wordpress admin bar
By default in wordpress admin bar “Howdy” text is shown you can easily change it with your text. You have to add following code into your active theme’s function.php file:
function replace_howdy_with_your_text( $wp_admin_bar ) {
 $account_info=$wp_admin_bar->get_node('my-account');
 $your_title = str_replace( 'Howdy,', 'Your Text', $account_info->title );
 $wp_admin_bar->add_node( array(
     'id' => 'my-account',
     'title' => $your_title,
 ) );
}
add_filter( 'admin_bar_menu', 'replace_howdy_with_your_text', 25 );
Here we use admin_bar_menu filter to replace text.
3. Change wordpress dashboard footer text.
You can change wordpress dashboard footer text by your own text or link or other. You have to add following code into your active theme’s function.php file:
 function custom_footer_admin_text () {
       echo "Your own text or link";
  }
  add_filter('admin_footer_text', 'custom_footer_admin_text');
Here we use admin_footer_text for change admin footer text. For link you need to use anchor tag (<a>).
4. Create your own Admin Color Scheme  
You can create you own admin color scheme for that you need to create css for your color scheme. Create a directory called admin-css into your active theme and add your css file in it.