:

: ()

: >
()
()
:
:
:
:

: > (.)

1:

2: ,

3: :

: >
: >
'-', '%20' => '-', '_' => '-', ); $sanitized_filename = str_replace( array_keys( $invalid ), array_values( $invalid ), $sanitized_filename ); $sanitized_filename = preg_replace('/[^A-Za-z0-9-\. ]/', '', $sanitized_filename); // Remove all non-alphanumeric except . $sanitized_filename = preg_replace('/\.(?=.*\.)/', '', $sanitized_filename); // Remove all but last . $sanitized_filename = preg_replace('/-+/', '-', $sanitized_filename); // Replace any more than one - in a row $sanitized_filename = str_replace('-.', '.', $sanitized_filename); // Remove last - if at the end $sanitized_filename = strtolower( $sanitized_filename ); // Lowercase return $sanitized_filename; } if(get_option('aiomh_ascii_file_name')==1) add_filter( 'sanitize_file_name', 'aiomh_sanitize_file_name', 10, 1 ); // Nén ảnh if(get_option('aiomh_jpeg_quality')==1) add_filter('jpeg_quality', function($arg){ $aiomh_jpeg_quality_value = get_option('aiomh_jpeg_quality_value')==''?75:get_option('aiomh_jpeg_quality_value'); return $aiomh_jpeg_quality_value; }); // Tự thêm thumbnail if(get_option('aiomh_auto_upload_and_set_thumb')==1) { function aiomh_sb_get_first_image_url_from_text($content) { $doc = new DOMDocument(); @$doc->loadHTML($content); $xpath = new DOMXPath($doc); $src = $xpath->evaluate('string(//img/@src)'); return $src; } function aiomh_sb_get_image_attachments($post_id) { return get_children(array('post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image')); } function aiomh_sb_get_first_image_attachment($post_id) { $attach_images = aiomh_sb_get_image_attachments($post_id); $result = null; if(count($attach_images) > 0) { $result = array_shift($attach_images); } return $result; } function aiomh_sb_create_folder($file_path) { if(!file_exists($file_path)) { mkdir($file_path); } } function aiomh_sb_copy($source, $destination) { if(@fclose(@fopen($source, 'r'))) { copy($source, $destination); return true; } return false; } function aiomh_sb_set_post_thumbnail($post_id) { if(current_theme_supports('post-thumbnails') && !has_post_thumbnail($post_id)) { $first_image = aiomh_sb_get_first_image_attachment($post_id); if($first_image) { set_post_thumbnail($post_id, $first_image->ID); return true; } else { $post = get_post($post_id); if($post) { $first_image = aiomh_sb_get_first_image_url_from_text($post->post_content); $attach_id = aiomh_sb_fetch_media($first_image); if($attach_id > 0) { set_post_thumbnail($post_id, $attach_id); return true; } } } } return false; } function aiomh_sb_auto_set_thumbnail($post_id) { if (wp_is_post_revision($post_id)) { return; } aiomh_sb_set_post_thumbnail($post_id); } add_action('save_post', 'aiomh_sb_auto_set_thumbnail'); function aiomh_sb_fetch_media($image_url) { $attach_id = 0; $wp_upload_dir = wp_upload_dir(); $base_dir = trailingslashit($wp_upload_dir['basedir']) . 'sb-media'; $base_url = trailingslashit($wp_upload_dir['url']) . 'sb-media'; aiomh_sb_create_folder($base_dir); $parts = pathinfo($image_url); $random = rand(); $random = md5($random); $file_name = 'sb-media-' . $parts['filename'] . '-' . $random . '.' . $parts['extension']; $file_path = trailingslashit($base_dir) . $file_name; $file_url = trailingslashit($base_url) . $file_name; if(aiomh_sb_copy($image_url, $file_path)) { $attachment = array( 'guid' => $file_url ); $attach_id = aiomh_sb_insert_attachment($attachment, $file_path); } return $attach_id; } function aiomh_sb_insert_attachment($attachment, $file_path) { if(!file_exists($file_path)) { return 0; } $file_type = wp_check_filetype(basename($file_path), null); $attachment['post_mime_type'] = $file_type['type']; if(!isset($attachment['guid'])) { return 0; } $attachment['post_status'] = isset($attachment['post_status']) ? $attachment['post_status'] : 'inherit'; if(!isset($attachment['post_title'])) { $attachment['post_title'] = preg_replace('/\.[^.]+$/', '', basename($file_path)); } $attach_id = wp_insert_attachment($attachment, $file_path); if($attach_id > 0) { aiomh_sb_update_attachment_meta($attach_id, $file_path); } return $attach_id; } function aiomh_sb_update_attachment_meta($attach_id, $file_path) { if(!function_exists('wp_generate_attachment_metadata')) { require_once(ABSPATH . 'wp-admin/includes/image.php'); } $attach_data = wp_generate_attachment_metadata($attach_id, $file_path); wp_update_attachment_metadata($attach_id, $attach_data); } } // Đếm lượt xem if(get_option('aiomh_post_views')==1) { add_action('wp_loaded', 'aiomh_auto_set_post_view2'); function aiomh_auto_set_post_view2() { if (!function_exists('getPostViews')) { function getPostViews($postID){ // hàm này dùng để lấy số người đã xem qua bài viết $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ // Nếu như lượt xem không có delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0"; // giá trị trả về bằng 0 } return $count; // Trả về giá trị lượt xem } } if(!function_exists('setPostViews')) { function setPostViews($postID) {// hàm này dùng để set và update số lượt người xem bài viết. $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; // cộng đồn view update_post_meta($postID, $count_key, $count); // update count } } } add_action('wp_enqueue_scripts', 'aiomh_auto_set_post_view'); function aiomh_auto_set_post_view() { if(is_single()) { global $post; setPostViews($post->ID); } } } } // Kiểm tra tiêu đề trùng if(get_option('aiomh_check_duplicate_title')==1) { function aiomh_add_my_admin_script(){ wp_enqueue_script('admin_script', plugins_url( 'all-in-one-must-have/js/check_duplicate_title.js' ), array('jquery'),AIOMH_VERSION); wp_localize_script( 'admin_script', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'we_value' => 1234 ) ); } add_action('admin_enqueue_scripts', 'aiomh_add_my_admin_script'); add_action( 'wp_ajax_my_action', 'aiomh_my_action_callback' ); function aiomh_my_action_callback() { global $wpdb; $title_exists = $wpdb->get_results( " SELECT ID FROM $wpdb->posts WHERE post_title LIKE '" . $_POST['this_convidado_title'] . "' AND post_type = '" . $_POST['post_type'] . "' " ); if($_POST['post_ID'] != ""){ foreach ($title_exists as $key => $this_id) { if($_POST['post_ID'] == $this_id->ID){ $this_is_the_post = $this_id->ID; } } } if($this_is_the_post){ echo (count($title_exists)-1); } else { echo count($title_exists); } die(); } } // REMOVE WP EMOJI if(get_option('aiomh_remove_emoji')==1) { remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('wp_print_styles', 'print_emoji_styles'); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); } // Remove nav id + class menu if(get_option('aiomh_remove_menu_class')==1) { add_filter('nav_menu_css_class', 'aiomh_css_attributes_filter', 100, 1); add_filter('nav_menu_item_id', 'aiomh_css_attributes_filter', 100, 1); add_filter('page_css_class', 'aiomh_css_attributes_filter', 100, 1); function aiomh_css_attributes_filter($var) { $keep_menu_class = explode(',', get_option('aiomh_remove_menu_class_value').','); return is_array($var) ? array_intersect($var, $keep_menu_class) : ''; } } // Disable comments if(get_option('aiomh_disable_comments')==1) { // Disable support for comments and trackbacks in post types function aiomh_disable_comments_post_types_support() { $post_types = get_post_types(); foreach ($post_types as $post_type) { if(post_type_supports($post_type, 'comments')) { remove_post_type_support($post_type, 'comments'); remove_post_type_support($post_type, 'trackbacks'); } } } add_action('admin_init', 'aiomh_disable_comments_post_types_support'); // Close comments on the front-end function aiomh_disable_comments_status() { return false; } add_filter('comments_open', 'aiomh_disable_comments_status', 20, 2); add_filter('pings_open', 'aiomh_disable_comments_status', 20, 2); // Hide existing comments function aiomh_disable_comments_hide_existing_comments($comments) { $comments = array(); return $comments; } add_filter('comments_array', 'aiomh_disable_comments_hide_existing_comments', 10, 2); // Remove comments page in menu function aiomh_disable_comments_admin_menu() { remove_menu_page('edit-comments.php'); } add_action('admin_menu', 'aiomh_disable_comments_admin_menu'); // Redirect any user trying to access comments page function aiomh_disable_comments_admin_menu_redirect() { global $pagenow; if ($pagenow === 'edit-comments.php') { wp_redirect(admin_url()); exit; } } add_action('admin_init', 'aiomh_disable_comments_admin_menu_redirect'); // Remove comments metabox from dashboard function aiomh_disable_comments_dashboard() { remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal'); } add_action('admin_init', 'aiomh_disable_comments_dashboard'); // Remove comments links from admin bar function aiomh_disable_comments_admin_bar() { if (is_admin_bar_showing()) { remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60); } } add_action('init', 'aiomh_disable_comments_admin_bar'); } //register_setting( 'aiomh-setting', 'aiomh_change_dir_admin' ); if(get_option('aiomh_change_dir_admin')==1) { function add_my_rule() { $dir_admin = get_option('aiomh_change_dir_admin_value'); add_rewrite_rule($dir_admin.'?', 'wp-login.php?ok='.$dir_admin, 'top'); global $wp_rewrite; $wp_rewrite->flush_rules(); } add_action('init', 'add_my_rule'); $admins = array( home_url( 'wp-admin', 'relative' ), home_url( 'dashboard', 'relative' ), home_url( 'admin', 'relative' ), site_url( 'dashboard', 'relative' ), site_url( 'admin', 'relative' ), home_url( 'wp-login.php', 'relative' ), home_url( 'login', 'relative' ), site_url( 'login', 'relative' ), ); if ( $GLOBALS['pagenow'] === 'wp-login.php' || in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins ) ) { $dir_admin = get_option('aiomh_change_dir_admin_value'); session_start(); $pass_level1 = $dir_admin; if(isset($_GET["ok"])){$ok = $_GET["ok"];$_SESSION["ok"] = $ok;} $ok = isset($_SESSION["ok"])?$_SESSION["ok"]:0; if($ok!=$pass_level1){exit();} } } if(get_option('aiomh_lock_wpadmin')==1) { $admins = array( home_url( 'wp-admin', 'relative' ), home_url( 'dashboard', 'relative' ), home_url( 'admin', 'relative' ), site_url( 'dashboard', 'relative' ), site_url( 'admin', 'relative' ), home_url( 'wp-login.php', 'relative' ), home_url( 'login', 'relative' ), site_url( 'login', 'relative' ), ); if ( $GLOBALS['pagenow'] === 'wp-login.php' || in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins ) ) { $config['user_aiomh'] = get_option('aiomh_lock_wpadmin_user'); $config['pass_aiomh'] = get_option('aiomh_lock_wpadmin_pass'); if ($_SERVER['PHP_AUTH_USER'] !== $config['user_aiomh'] || $_SERVER['PHP_AUTH_PW'] !== $config['pass_aiomh']){ header('WWW-Authenticate: Basic realm="Login?"'); header('HTTP/1.0 401 Unauthorized'); echo '
Wrong !
'; exit(); } } } // Disable xmlrpc if(get_option('aiomh_disable_xmlrpc')==1) { add_filter('xmlrpc_enabled', '__return_false'); } // Hidden verwp if(get_option('aiomh_hidden_verwp')==1) { remove_action('wp_head', 'wp_generator'); //Remove file readme.html $pos_wpcontent = strpos(__FILE__,'wp-content'); $file_readme = substr( __FILE__, 0, $pos_wpcontent ).'readme.html'; if(file_exists($file_readme)) unlink($file_readme); } // Remove jquery if(get_option('aiomh_remove_jquery')==1) { add_filter( 'wp_default_scripts', 'aiomh_remove_jquery_migrate' ); function aiomh_remove_jquery_migrate( &$scripts){ if(!is_admin()){ $scripts->remove( 'jquery'); } } } // Remove js,css plugins if(get_option('aiomh_remove_plugin_jscss')==1) { function aiomh_dequeue_my_css_fun($id) { if($id!='') { $remove_js_css = explode(',', $id.','); $count_remove_js_css = count($remove_js_css); for($i=0;$i<$count_remove_js_css-1;$i++) { wp_dequeue_style($remove_js_css[$i]); wp_deregister_style($remove_js_css[$i]); } } } function aiomh_dequeue_my_css() { aiomh_dequeue_my_css_fun(get_option('aiomh_remove_plugin_jscss_all')); if(is_home() || is_front_page()) aiomh_dequeue_my_css_fun(get_option('aiomh_remove_plugin_jscss_home')); if(is_category() || is_archive()) aiomh_dequeue_my_css_fun(get_option('aiomh_remove_plugin_jscss_category')); if(is_single()) aiomh_dequeue_my_css_fun(get_option('aiomh_remove_plugin_jscss_single')); } add_action( 'wp_enqueue_scripts', 'aiomh_dequeue_my_css', 9999 ); } ?>