wp 정리

16420 단어 WordPress
get('Version'));

//define('UNIFY_URL', get_template_directory_uri());//    
//define('UNIFY_URL', get_template_directory_uri());//     
define('UNIFY_URL', get_template_directory_uri());//    

/**
 *     
 *
*/
/* ------------------------------------------------------ */
// Remove help and screen context & Options        【  】 【    】
// http://wordpress.stackexchange.com/questions/73561/how-to-remove-all-widgets-from-dashboard
add_filter( 'contextual_help', 'wpse_25034_remove_dashboard_help_tab', 999, 3 );
add_filter( 'screen_options_show_screen', 'wpse_25034_remove_help_tab' );
 
function wpse_25034_remove_dashboard_help_tab( $old_help, $screen_id, $screen )
{
    if( 'dashboard' != $screen->base )
    return $old_help;
    $screen->remove_help_tabs();
    return $old_help;
}
 
function wpse_25034_remove_help_tab( $visible )
{
    global $current_screen;
    if( 'dashboard' == $current_screen->base )
    return false;
    return $visible;
}
/* ------------------------------------------------------ */
/* ------------------------------------------------------ */
// Disable the Admin Bar.   WordPress         
// From: http://yoast.com/disable-wp-admin-bar/
add_filter( 'show_admin_bar', '__return_false' );
 
function sp_hide_admin_bar_settings()
{
    ?>display_name;
    $logout = wp_logout_url("/");
 
    if(is_user_logged_in())
    {
        echo '';
        echo "jQuery(document).ready(function ($) { $('#admin-menu-show').click(function() { $('.adminEdit').toggle('fast');});});";
    }
 
    if ( current_user_can('edit_post'))
    {
        edit_post_link(" Edit Page","

$displayName logged in | Log Out | Dashboard | ","

"); ?>

$displayName logged in | Log Out"; ?>

.toplevel_page_better-wp-security .side, #w3tc-dashboard-widgets, #wpseo_content_top + .postbox-container {display:none;} '; } /* ------------------------------------------------------ */ /* ------------------------------------------------------ */ /* Convert absolute URLs in content to site relative ones WordPress , , Thisismyurl.com: Inspired by http://thisismyurl.com/6166/replace-wordpress-static-urls-dynamic-urls/ */ function sp_clean_static_url($content) { $thisURL = get_bloginfo('url'); $stuff = str_replace(' src=\"'.$thisURL, ' src=\"', $content ); $stuff = str_replace(' href=\"'.$thisURL, ' href=\"', $stuff ); return $stuff; } add_filter('content_save_pre','sp_clean_static_url','99'); /* ------------------------------------------------------ */ /* ------------------------------------------------------ */ // Add confirmation dialogue box when publishing posts/pages , // https://gist.github.com/plasticmind/4337952 /* = Add a "molly guard" to the publish button */ add_action( 'admin_print_footer_scripts', 'sr_publish_molly_guard' ); function sr_publish_molly_guard() { echo " jQuery(document).ready(function($){ $('#publishing-action input[name=\"publish\"]').click(function() { if(confirm('Are you sure you want to publish this?')) { return true; } else { $('#publishing-action .spinner').hide(); $('#publishing-action img').hide(); $(this).removeClass('button-primary-disabled'); return false; } }); }); "; } /* ------------------------------------------------------ */ // ------------------------------------------------------------------------------ // Include Featured Image & Add Link Back To Original Post , RSS feed // http://www.paulund.co.uk/7-tips-to-improve-your-wordpress-rss-feed // ------------------------------------------------------------------------------ function feed_copyright_disclaimer($content) { global $post; if(has_post_thumbnail($post->ID)) { $featuredImage = '

' . get_the_post_thumbnail($post->ID,"medium-large").'

'; } $content = $featuredImage."

".get_the_excerpt()."

".'

Read all of this article on the website.

'; return $content; } add_filter('the_excerpt_rss','feed_copyright_disclaimer'); add_filter('the_content_feed','feed_copyright_disclaimer'); // ------------------------------------------------------------------------------ /* ------------------------------------------------------ */ // Filter to replace the shortcode text with HTML5 compliant code WordPress HTML5 // http://codex.wordpress.org/Function_Reference/add_filter function my_img_caption_shortcode_filter($val, $attr, $content = null) { extract(shortcode_atts(array( 'id' => '', 'align' => '', 'width' => '', 'caption' => '' ), $attr)); if ( 1 > (int) $width || empty($caption) ) return $val; $capid = ''; if ( $id ) { $id = esc_attr($id); $capid = 'id="figcaption_'. $id . '" '; $id = 'id="' . $id . '" aria-labelledby="figcaption_' . $id . '" '; } return '
' . do_shortcode( $content ) . '
' . $caption . '
'; } add_filter('img_caption_shortcode', 'my_img_caption_shortcode_filter',10,3); /* ------------------------------------------------------ */ add_filter('content_save_pre', 'auto_save_image'); function auto_save_image($content) { $upload_path = ''; $upload_url_path = get_bloginfo('url'); // if (($var = get_option('upload_path')) !=''){ $upload_path = $var; } else { $upload_path = 'wp-content/uploads'; } if(get_option('uploads_use_yearmonth_folders')) { $upload_path .= '/'.date("Y",time()).'/'.date("m",time()); } // if(($var = get_option('upload_url_path')) != '') { $upload_url_path = $var; } else { $upload_url_path = bloginfo('url'); } if(get_option('uploads_use_yearmonth_folders')) { $upload_url_path .= '/'.date("Y",time()).'/'.date("m",time()); } require_once ("../wp-includes/class-snoopy.php"); $snoopy_Auto_Save_Image = new Snoopy; $img = array(); // if ( !empty( $_REQUEST['post_title'] ) ) $post_title = wp_specialchars( stripslashes( $_REQUEST['post_title'] )); $text = stripslashes($content); if (get_magic_quotes_gpc()) $text = stripslashes($text); preg_match_all("/ src=(\"|\'){0,}(http:\/\/(.+?))(\"|\'|\s)/is",$text,$img); $img = array_unique(dhtmlspecialchars($img[2])); foreach ($img as $key => $value){ set_time_limit(180); // , if(str_replace(get_bloginfo('url'),"",$value)==$value&&str_replace(get_bloginfo('home'),"",$value)==$value){ // , , $fileext = substr(strrchr($value,'.'),1); $fileext = strtolower($fileext); if($fileext==""||strlen($fileext)>4) $fileext = "jpg"; $savefiletype = array('jpg','gif','png','bmp'); if (in_array($fileext, $savefiletype)){ if($snoopy_Auto_Save_Image->fetch($value)){ $get_file = $snoopy_Auto_Save_Image->results; }else{ echo "error fetching file: ".$snoopy_Auto_Save_Image->error."
"; echo "error url: ".$value; die(); } $filetime = time(); $filepath = "/".$upload_path;// !is_dir("..".$filepath) ? mkdirs("..".$filepath) : null; //$filename = date("His",$filetime).random(3); $filename = substr($value,strrpos($value,'/'),strrpos($value,'.')-strrpos($value,'/')); //$e = '../'.$filepath.$filename.'.'.$fileext; //if(!is_file($e)) { // copy(htmlspecialchars_decode($value),$e); //} $fp = @fopen("..".$filepath.$filename.".".$fileext,"w"); @fwrite($fp,$get_file); fclose($fp); $wp_filetype = wp_check_filetype( $filename.".".$fileext, false ); $type = $wp_filetype['type']; $post_id = (int)$_POST['temp_ID2']; $title = $post_title; $url = $upload_url_path.$filename.".".$fileext; $file = $_SERVER['DOCUMENT_ROOT'].$filepath.$filename.".".$fileext; // $attachment = array( 'post_type' => 'attachment', 'post_mime_type' => $type, 'guid' => $url, 'post_parent' => $post_id, 'post_title' => $title, 'post_content' => '', ); $id = wp_insert_attachment($attachment, $file, $post_parent); $text = str_replace($value,$url,$text); // } } }0 $content = AddSlashes($text); remove_filter('content_save_pre', 'auto_save_image'); return $content; } function mkdirs($dir){ if(!is_dir($dir)){ mkdirs(dirname($dir)); mkdir($dir); } return ; } function dhtmlspecialchars($string) { if(is_array($string)) { foreach($string as $key => $val) { $string[$key] = dhtmlspecialchars($val); } }else{ $string = str_replace('&', '&', $string); $string = str_replace('"', '"', $string); $string = str_replace('', '>', $string); $string = preg_replace('/&(#\d;)/', '&\1', $string); } return $string; }

좋은 웹페이지 즐겨찾기