Translate third party plugin and save translation files in custom theme

First of all, I’d strongly recommend against storing translations for a plug-in in your theme. It has no reason to be there, and you’ll loose the translations when you change/update the theme. The correct place to store translations is wp-content/languages/plugins/. This code does that, and targets the domain ‘other_plugin’: function wpse159536_override_mofile_path( $mofile, $domain ){ if( … Read more

Restrict backend but allow to use post.php?action=delete&post=POSTID from front-end

This will allow you to access post.php and still restrict the back-end. You need have action, action name as delete, post key and value, and wpnonce kay and value. Otherwise, it will redirect you to homepage. function disable_wp_admin() { if ( ! is_admin() ) return; if ( current_user_can( ‘manage_options’ ) ) return; if (( current_user_can( … Read more

Remove Adminstrator Hyperlink from a user having role to add and see users

I think something like this should work just fine: function my_views_users($args) { $hidden_role=”administrator”; // it will hide filter with role ‘administrator’ – you can change it to some other role $users_counts = count_users(); $total_users = $users_counts[‘total_users’] – $users_counts[‘avail_roles’][$hidden_role]; $args[‘all’] = “<a href=”https://wordpress.stackexchange.com/questions/97309/$url”$class>” . sprintf( _nx( ‘All <span class=”count”>(%s)</span>’, ‘All <span class=”count”>(%s)</span>’, $total_users, ‘users’ ), number_format_i18n( … Read more

Retrieve categories of a WooCommerce product in hierachical order

The get_category_parents is a function that retrieve the parent categories passing as argument a category id. So, if you have a product and you want to retrieve a list of attached categories to it, the right function is get_the_terms.That function return all the categories objects, without order, and so you can take the first of … Read more

I’m trying to create security question field for my login page

There is no login_post action that I know of – use the authenticate filter instead, inside wp_authenticate(), called by wp_signon(): function wpse_185339_check_user_answer( $user ) { if ( $_SERVER[‘REQUEST_METHOD’] === ‘POST’ ) { if ( empty( $_POST[ ‘user_proof’ ] ) ) { $user = new WP_Error( ‘proofempty’, ‘<strong>ERROR</strong>: You did not answer the proof-of-humanship question.’ ); … Read more

remove custom taxonomy metabox form custom post type

Change your taxonomy registration parameter show_ui to false… register_taxonomy(‘package_hotel’,’package’,array( ‘hierarchical’ => false, ‘labels’ => $Package_labels, ‘show_ui’ => false, ‘update_count_callback’ => ‘_update_post_term_count’, ‘query_var’ => true, ‘show_in_nav_menus’ => false, ‘rewrite’ => array( ‘slug’ => ‘hotels’ ), ));