Actions and scripts for WordPress
Joke code for your website. Will work not only on WordPress. Flipping the site with css3 styles.
1 2 3 4 5 |
body{ -moz-transform: rotate(180deg); -webkit-transform: rotate(180deg); -o-transform: rotate(180deg); } |
Replacing individual words when adding comments
Using the code, you can define a list of stop words (for example, so word swear wp-***in) or make it so that when you add a single word in the comments, it is replaced with a special link. Attention: Data changes directly in the database, not in output.
1 2 3 4 5 6 7 8 9 10 11 |
add_filter( 'pre_comment_content', 'wps_filter_comment' ); function wps_filter_comment($comment) { $replace = array( // 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS' 'foobar' => '*****', 'hate' => 'love', 'zoom' => 'zoom' ); $comment = str_replace(array_keys($replace), $replace, $comment); return $comment; } |
Adding Buttons to the WordPress Visual Editor
Add code to file functions.php your theme and you will have subscript and superscript buttons. Useful if you need to write formulas in blog posts WordPress. Parameter mce_buttons_3 can be replaced by mce_buttons_2 He shows, in which row will the new buttons be.
1 2 3 4 5 6 |
function enable_more_buttons($buttons) { $buttons[] = 'sub'; $buttons[] = 'sup'; return $buttons; } add_filter("mce_buttons_3", "enable_more_buttons"); |
Disable admin panels (There is an admin) fully
To completely disable the admin panel on the user side for everyone, including the administrator can use the code:
1 2 3 |
<? add_filter ( "show_admin_bar ' , '__return_false' ); ?> |
Page thumbnail in the list of all WordPress admin pages in a separate column seemed very convenient to me and I wrote a lesson about one of the codes that I found. Now I will offer you another option for solving this problem.. More simple, but a little worse previous.
1 2 3 4 5 6 7 8 9 10 11 |
add_filter('manage_posts_columns', 'posts_columns', 5); add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2); function posts_columns($defaults){ $defaults['riv_post_thumbs'] = __('Thumbs'); return $defaults; } function posts_custom_columns($column_name, $id){ if($column_name === 'riv_post_thumbs'){ echo the_post_thumbnail( 'featured-thumbnail' ); } } |
Displaying content in a separate column in the list of articles.
One of the visitors of my site asked for help in solving the problem. The problem was that there were a lot of jokes on the site, some of them needed to be removed, and leave others. Since there was a lot of content on the site, and the jokes are short, then it was inconvenient to go to the page to view it. Scratching his turnip and, as always, realizing, that there is not enough time to solve all the problems, I decided to postpone the problem until better and freer times. The task was solved by me when writing the next lesson and here is the code for solving this, as it turned out not a difficult task.
Adding code to your theme's functions.php file.
1 2 3 4 5 6 7 8 9 10 11 |
add_filter('manage_posts_columns', 'posts_columns', 5); add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2); function posts_columns($defaults){ $defaults['riv_post_thumbs'] = __('Контент'); return $defaults; } function posts_custom_columns($column_name, $id){ if($column_name === 'riv_post_thumbs'){ echo the_content(); } } |
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.
This is the last thing I asked, with jokes.
Everything works great, what you need. Didn't even expect. I don't know how to thank.
Glad the code was helpful. Stay tuned for more great things to come, it works with the WordPress API.
I just noticed the button “Expanded”….
Which button? Didn't understand a bit.
In the records at the top right under the search. There are two small buttons.
1 “List View” (default)
2 “Expanded” shows the full news title
Really, somehow forgot about them ). Thanks for the comment, I'll take it into account.