1 2 3 4 5 6 7 8 9 |
find . -name '*.DS_Store' -type f -delete or, sudo find / -name .DS_Store -delete; |
WordPress Developers (Must Have) Plugins
The following plugins are very useful to WordPress developers. These may help you to make a standard and error-free theme and plugin.
- Developer.
- Debug Bar
- Query Monitor.
- Theme Check.
- User Switching.
- Regenerate Thumbnails.
- Log Deprecated Notice.
- RTL Tester, RTL Tester Mirror.
- Monster Widget.
- PHP Compatibility.
- SG Optimizer.
Thank you!
Conditional Script Loading for Shotcode
In the functions.php file or in your plugin file write the code below –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
/** * Check if it should load frontend scripts * * @return mixed|void */ private function should_load_scripts() { global $post; $load_scripts = is_active_widget( false, false, 'wpl_logo_carousel_pro_widget_content', true ) || ( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'logo-carousel-pro' ) ); return apply_filters( 'logo_carousel_pro_load_scripts', $load_scripts ); } /** * Plugin Scripts and Styles * */ function public_scripts() { if ( $this->should_load_scripts() ) { wp_enqueue_script( 'jquery-isotope-min-js', MY_URL . 'assets/js/jquery.isotope.min.js', array( 'jquery' ), $this->version, false ); } } |
Select Text on Click of a Div with CSS
1 2 3 4 5 6 7 8 9 10 11 12 13 |
.selectable{ -webkit-touch-callout: all; /* iOS Safari */ -webkit-user-select: all; /* Safari */ -khtml-user-select: all; /* Konqueror HTML */ -moz-user-select: all; /* Firefox */ -ms-user-select: all; /* Internet Explorer/Edge */ user-select: all; /* Chrome and Opera */ } |
How to Set a default Title for the custom post?
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function wpl_lc_add_custom_title( $data, $postarr ) { if($data['post_type'] == 'wpl_lcp_shortcodes') { if(empty($data['post_title'])) { $data['post_title'] = 'Untitled Carousel'; } } return $data; } add_filter('wp_insert_post_data', 'wpl_lc_add_custom_title', 10, 2 ); |
Now use the function
1 2 3 4 5 |
the_title(); |
Gray Scale with CSS with Cross Bowser Support
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
img { filter: gray; /* IE6-9 */ -webkit-filter: grayscale(1); /* Google Chrome, Safari 6+ & Opera 15+ */ filter: grayscale(1); /* Microsoft Edge and Firefox 35+ */ } /* Disable grayscale on hover */ img:hover { -webkit-filter: grayscale(0); filter: none; } |
JavaScript Debugger in Google Chrome
Windows and Linux:
Ctrl + Shift + I keys to open Developer Tools
Ctrl + Shift + J to open Developer Tools and bring focus to the Console.
Ctrl + Shift + C to toggle Inspect Element mode.
Mac:
⌥ + ⌘ + I keys to open Developer Tools
⌥ + ⌘ + J to open Developer Tools and bring focus to the Console.
⌥ + ⌘ + C to toggle Inspect Element mode
To pause an event, hover over the event and press fn+f8.
How to a Add Custom Meta Box for Multiple Post Type
1 2 3 4 5 6 7 8 9 10 11 12 13 |
add_action( 'add_meta_boxes', 'myplugin_add_custom_box' ); function myplugin_add_custom_box() { add_meta_box( 'myplugin_sectionid', __( 'My Post Section Title', 'myplugin_textdomain' ), 'myplugin_inner_custom_box', 'post' ); add_meta_box( 'myplugin_sectionid', __( 'My Post Section Title', 'myplugin_textdomain' ), 'myplugin_inner_custom_box', 'page' ); } |
See: Stackexchange , Codex
How to get Category Slug by Category ID in WordPress?
I have got the category id list with the variable $my_cats_id.
So now I have used my own trick to get the slug –
1 2 3 4 5 |
echo str_replace( ' ', '-', strtolower( get_cat_name( $my_cats_id ) ) ); |
How to Create a .pot file for theme or plugin with POEdit
Here is how you can create a .pot file for your theme with POEdit (free edition, version 1.7.7) on OS X.
Best practice is to save language files in a folder named “languages” in your theme directory. If you haven’t already, create it before you start.
In POEdit: Continue reading How to Create a .pot file for theme or plugin with POEdit
How to Add Custom Setting Page to WordPress Theme or Plugin?
We are going to create a setting page for WordPress themes and plugins. The output should look like –
Continue reading How to Add Custom Setting Page to WordPress Theme or Plugin?