Posts

Showing posts from April, 2014

add a stylesheet to functions.php

you have to create a new folder on your theme folder, name it functions then create a new css file with a name of functions.css. After flling your css file add this code to functions.php after mytheme_add_admin function 

WordPress Post Image to Headline Hover Effect with jQuery and CSS

<!--HTML--> <div class="viewport"> <a href="http://orkbet.com"> <span class="dark-background">Northern Saw-whet Owl <em>Photo by Matt Bango</em></span> <img src=" http://orkbet.com/image .jpg" alt="Northern Saw-Whet Owl" /> </a> </div>

Loading Conditional Function Stylesheets/JavaScript in WordPress

Add style.css or javascript in wordpress function.php? Just wp_enqueue_style. Flow this cod. function theme_name_scripts() { wp_enqueue_style( 'style-name', get_stylesheet_uri() ); wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );

Wordpress Styleset CSS call function.php

function ork_soft_scripts_styles() { wp_enqueue_style( 'orksoft-style', get_stylesheet_uri(), array(), '' ); wp_enqueue_style( 'logintab', get_template_directory_uri() . '/logintab/logintab.css', array(), '' );

Add an Admin link to the WordPress “All-Settings” page

//Add an Admin link to the WordPress All-Settings page function all_settings_link() { add_options_page(__('All Settings'), __('All Settings'), 'administrator', 'options.php'); } add_action('admin_menu', 'all_settings_link');

Automatically close missing tags from the WYSIWYG editor for wordpress

// AUTOMATICALLY CLEAN UP HTML WYSIWYG EDITOR BY CLOSING MISSING TAGS    function clean_bad_content($bPrint = false) {  global $post;  $szPostContent  = $post->post_content;  $szRemoveFilter = array("~<p[^>]*>\s?</p>~", "~<a[^>]*>\s?</a>~", "~<font[^>]*>~", "~<\/font>~", "~style\=\"[^\"]*\"~", "~<span[^>]*>\s?</span>~");  $szPostContent  = preg_replace($szRemoveFilter, '', $szPostContent);  $szPostContent  = apply_filters('the_content', $szPostContent);  if ($bPrint == false) return $szPostContent;   else echo $szPostContent;    }

Disable Upgrade Message for Non-Admin for Wordpress

if ( !current_user_can( 'manage_options' ) ) {   add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );   add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) ); }

Custom Logos for Login page and Admin in wordpress

function custom_admin_logo() {     echo '         <style type="text/css">             #header-logo { background-image: url('.get_bloginfo('template_directory').'/path/to/images/admin-logo.png) !important; }         </style>     '; }

Changing Wordpress "Posts" menu name in admin to ("Articles") or..

// hook the translation filters add_filter('gettext','change_post_to_article'); add_filter('ngettext','change_post_to_article'); function change_post_to_article( $translated ) { $translated = str_ireplace('Post','Article',$translated );// ireplace is PHP5 only return $translated; }

Remove "Comments" link from admin bar if comment status is closed for Wordpress

/**  * Disable 'Comments' link if default status is _closed_  */ function remove_comments()  {     $default_comment_status = get_option( 'default_comment_status' );

Disable browser upgrade warning in wordpress 3.2

//Disable browser upgrade warning in wordpress 3.2 function disable_browser_upgrade_warning() {     remove_meta_box( 'dashboard_browser_nag', 'dashboard', 'normal' ); } add_action( 'wp_dashboard_setup', 'disable_browser_upgrade_warning' );

Get the Users Real IP Address whenever possible a theme for wordpress

// Gets the user's real IP address $_SERVER['REMOTE_ADDR'] = getRealIpAddress(); function getRealIpAddress( $validate = true ) {     if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) {         $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);         $ip = trim($ips[count($ips) - 1]);

Easy WordPress Security Fixes

Remove the version string from the code. No point in telling folks what version we're running. Removes any error messages (Wrong Password, No Such User, etc.) from admin login screens When the admin posts a comment, a CSS class is added. This removes the admin name in comments.

Remove Wordpress Admin/Backend Menus for all users, only except User #1 (first Admin)

//Remove Admin Backend Menus for all users, except User #1 (usually the first Admin)     function remove_menus () { global $menu; $user = wp_get_current_user();     if ($user->ID!=1) { // Is not administrator,

Remove Wordpress Admin (User #1) from User list

//Remove Admin (User #1) from User list    function your_pre_user_query($user_search) {   $user = wp_get_current_user();   if ($user->ID!=1) {     global $wpdb;     $user_search->query_where = str_replace('WHERE 1=1',       "WHERE 1=1 AND {$wpdb->users}.ID<>1",$user_search->query_where);   } } add_action('pre_user_query','your_pre_user_query');       

Add "Next-page"-button in (post/page) WYSIYG-editor in your WordPress

//Add "Next-page"-button in WYSIYG-editor    add_filter('mce_buttons','wysiwyg_editor'); function wysiwyg_editor($mce_buttons) {     $pos = array_search('wp_more',$mce_buttons,true);     if ($pos !== false) {         $tmp_buttons = array_slice($mce_buttons, 0, $pos+1);         $tmp_buttons[] = 'wp_page';         $mce_buttons = array_merge($tmp_buttons, array_slice($mce_buttons, $pos+1));     }     return $mce_buttons; }     

Make WordPress Editor Allow iFrames

// make TinyMCE allow iframes add_filter('tiny_mce_before_init', create_function( '$a', '$a["extended_valid_elements"] = "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]"; return $a;') );

Sharpen Resized Images (only jpg) your WordPress

function ajx_sharpen_resized_files( $resized_file ) {     $image = wp_load_image( $resized_file );     if ( !is_resource( $image ) )         return new WP_Error( 'error_loading_image', $image, $file );

Login username or email address in WordPres without a Plugin

Image

Add Custom User Profile Fields in WordPress

// CUSTOM USER PROFILE FIELDS    function my_custom_userfields( $contactmethods ) {     // ADD CONTACT CUSTOM FIELDS     $contactmethods['contact_phone_office']     = 'Office Phone';     $contactmethods['contact_phone_mobile']     = 'Mobile Phone';     $contactmethods['contact_office_fax']       = 'Office Fax';     // ADD ADDRESS CUSTOM FIELDS     $contactmethods['address_line_1']       = 'Address Line 1';     $contactmethods['address_line_2']       = 'Address Line 2 (optional)';     $contactmethods['address_city']         = 'City';     $contactmethods['address_state']        = 'State';     $contactmethods['address_zipcode']      = 'Zipcode';     return $contactmethods;    }    add_filter('user_contactmethods','my_...

Add Spam & Delete Links to Comments on Front End use WordPress

// spam & delete links for all versions of wordpress function delete_comment_link($id) {     if (current_user_can('edit_post')) {         echo '| <a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php?action=cdc&c='.$id.'">del</a> ';         echo '| <a href="'.get_bloginfo('wpurl').'/wp-admin/comment.php?action=cdc&dt=spam&c='.$id.'">spam</a>';     } }

Remove the WordPress Version Info for Security ad on function

// remove version info from head and feeds function complete_version_removal() {     return ''; } add_filter('the_generator', 'complete_version_removal');

Loading jQuery from the Google CDN ad WordPress function.php

// even more smart jquery inclusion :) add_action( 'init', 'jquery_register' ); // register from google and for footer function jquery_register() { if ( !is_admin() ) {

WordPress related articles/post using category without plugin

More visitor will visit your site. For showing the related articles you need copy following code into your functions.php file.

How to Display WordPress Post Thumbnails with Captions

Image

Most Commented Posts in WordPress

Image

Display Related Posts in WordPress by tags

Image

Show Most Popular Posts In the Last 30 Days your Wordpress

<ul> <?php function filter_where($where = '')  { $where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'"; return $where; 

WordPress post title Limit to 50 characters

Image

WordPress Contact Form usein jQuery without a Plugin

Creating the WordPress Page Template Copy & Pest: <?php  /*  Template Name: Contact-Form  */  ?>

create a contact form for your WordPress theme

Many WordPress plugins can add a contact form to your blog, but a plugin is not necessary. In this tutorial, I’m going to show you how you can create a built-in contact form for your WordPress theme. You can copy and pest. Create you php file  contact.php and copy this codex pest.

WordPress Contact Form Without Plugin

There are a lot of different plugins available to put a contact form on your WordPress site, but I like to use as few plugins as i can get away with. So if you feel the same way, here’s a simple way to add a contact form, with some simple cut & paste of your site’s existing  page.php  file.

How to change default email sender of your WordPress site

Changes the default From:wordpress@yoursite.com header of WP emails to Site Name<no-reply@yoursite.com> In order to work, this piece of code has to be placed in the functions.php file of your WP theme

Automatically New Post Notify your WordPressme register mbers

Do you ever wished to be able to automatically send an email to your registered users and notify them of a new post on your WordPress blog? See you 2 codex. You can  following any one codex. Only copy and pest your functions.php file just any 1 codex.