This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function logged_in( $expirein ) { | |
| return 604800; // 1 week in seconds | |
| } | |
| add_filter( 'auth_cookie_expiration', 'logged_in' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter('widget_tag_cloud_args','style_tags'); | |
| function style_tags($args) { | |
| $args = array( | |
| 'largest' => '10', | |
| 'smallest' => '10', | |
| 'format' => 'list', | |
| ); | |
| return $args; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function my_paginate_links() { | |
| global $wp_rewrite, $wp_query; | |
| $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1; | |
| $pagination = array( | |
| 'base' => @add_query_arg('paged','%#%'), | |
| 'format' => '', | |
| 'total' => $wp_query->max_num_pages, | |
| 'current' => $current, | |
| 'prev_text' => __('« Previous'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function maintenace_mode() { | |
| if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {wp_die('Maintenance.');} | |
| } | |
| add_action('get_header', 'maintenace_mode'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getPostViews($postID){ | |
| $count_key = 'post_views_count'; | |
| $count = get_post_meta($postID, $count_key, true); | |
| if($count==''){ | |
| delete_post_meta($postID, $count_key); | |
| add_post_meta($postID, $count_key, '0'); | |
| return "0 View"; | |
| } | |
| return $count.' Views'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'sidebars_widgets', 'disable_sidebar_widgets' ); | |
| function disable_sidebar_widgets( $sidebars_widgets ) { | |
| if ( is_page('about-me') ) | |
| $sidebars_widgets = array( false ); | |
| return $sidebars_widgets; | |
| } | |
| ?> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function content_twitter_mention($content) { | |
| return preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/', "$1<a href=\"http://twitter.com/$2\" target=\"_blank\" rel=\"nofollow\">@$2</a>", $content); | |
| } | |
| add_filter('the_content', 'content_twitter_mention'); | |
| add_filter('comment_text', 'content_twitter_mention'); | |
| Uses: | |
| Really just add function and use @twitter_username that’s enough test now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( 'preprocess_comment', 'minimal_comment_length' ); | |
| function minimal_comment_length( $commentdata ) { | |
| $minimalCommentLength = 20; | |
| if ( strlen( trim( $commentdata['comment_content'] ) ) < $minimalCommentLength ) | |
| { | |
| wp_die( 'All comments must be at least ' . $minimalCommentLength . ' characters long.' ); | |
| } | |
| return $commentdata; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function restrict_admin() | |
| { | |
| if ( ! current_user_can( 'manage_options' ) ) { | |
| wp_redirect( site_url() ); | |
| exit; | |
| } | |
| } | |
| add_action( 'admin_init', 'restrict_admin', 1 ); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Disable changing the theme for anyone a part from the admin user | |
| * Only can be changes | |
| */ | |
| add_action('admin_init', 'disable_changing_theme_for_non_admin'); | |
| function disable_changing_theme_for_non_admin() { | |
| global $submenu, $userdata; | |
| get_currentuserinfo(); | |
| if ($userdata->ID != 1) { |