4 new WordPress code snippets
Hiding extra items in the user profile
In this case, it can be noted that the code hides the color scheme, which often prevents users from working..
1 2 3 4 |
function hide_personal_options(){ echo "\n" . '<script type="text/javascript">jQuery(document).ready(function($) { $(\'form#your-profile > h3:first\').hide(); $(\'form#your-profile > table:first\').hide(); $(\'form#your-profile\').show(); });</script>' . "\n"; } add_action('admin_head','hide_personal_options'); |
Removing the generator tag in WordPress rss.
This is useful for protecting your website from being hacked., without knowing the version of the site and on which engine it was created, it will be harder for a hacker to hack your site.
1 2 3 4 |
function remove_feed_generator() { return ''; } add_filter('the_generator', 'remove_feed_generator'); |
Embed iframe in wordpress
Add the suggested code snippet to your theme's functios.php file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
add_shortcode('iframe', array('iframe_shortcode', 'shortcode')); class iframe_shortcode { function shortcode($atts, $content=null) { extract(shortcode_atts(array( 'url' => '', 'scrolling' => 'no', 'width' => '100%', 'height' => '500', 'frameborder' => '0', 'marginheight' => '0', ), $atts)); if (empty($url)) return '<!-- Iframe: You did not enter a valid URL -->'; return '<iframe src="'.$url.'" title="" width="'.$width.'" height="'.$height.'" scrolling="'.$scrolling.'" frameborder="'.$frameborder.'" marginheight="'.$marginheight.'"><a href="'.$url.'" target="_blank">'.$url.'</a></iframe>'; } } |
After creating a shortcode, you can paste it in the place you need:
1 |
[iframe url="https://wpsnipp.com" width="100" height="100" scrolling="yes" frameborder="1" marginheight="2"] |
We change the standard inscription “Forgot password?” to “Recover password?”
1 2 3 4 5 6 |
add_filter( 'gettext', 'register_text' ); add_filter( 'ngettext', 'register_text' ); function register_text( $translated ) { $translated = str_ireplace( 'Забыли пароль?', 'Востановить пароль?', $translated ); return $translated; } |
This change will look like this:
This method is also perfect for replacing other inscriptions or for translating individual parts of the admin panel into Russian.
Code checked, it works great.
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.