This file contains 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 | |
if ( | |
strpos($_SERVER["HTTP_USER_AGENT"], "facebookexternalhit/") !== false || | |
strpos($_SERVER["HTTP_USER_AGENT"], "Facebot") !== false | |
) { | |
echo "Facebook is coming!"; | |
} else { | |
echo "Sad, You are not Facebook."; | |
} |
This file contains 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 | |
@ini_set('error_log', NULL); | |
@ini_set('log_errors', 0); | |
@ini_set('max_execution_time', 0); | |
@error_reporting(0); | |
@set_time_limit(0); | |
if(!defined("PHP_EOL")) | |
{ |
This file contains 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_action( 'media_send_to_editor', 'mxp_before_insert_media'); | |
function mxp_before_insert_media($html, $id, $attachment) { | |
//此方法針對全媒體,不只有圖片 | |
$html = preg_replace('/width="(\d+)"/i', 'width="auto"', $html); | |
$html = preg_replace('/height="(\d+)"/i', 'height="auto"', $html); | |
return $html; | |
} |
This file contains 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 | |
/** | |
* Extend WordPress search to include custom fields | |
* | |
* Author: http://adambalee.com | |
* Post: https://adambalee.com/search-wordpress-by-custom-fields-without-a-plugin/ | |
*/ | |
/** | |
* Join posts and postmeta tables |
This file contains 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 | |
//functions.php | |
add_action( 'woocommerce_after_cart', 'mxp_auto_cart_update_qty_script' ); | |
function mxp_auto_cart_update_qty_script() { | |
?> | |
<script> | |
jQuery('div.woocommerce').on('change', '.qty', function(){ | |
jQuery("[name='update_cart']").removeAttr('disabled'); | |
jQuery("[name='update_cart']").trigger("click"); | |
}); |
This file contains 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
<!doctype html> | |
<head> | |
<meta charset="utf-8"> | |
<title>網站建構中! - 敲敲設計</title> | |
<style> | |
body { text-align: center; padding: 150px; } | |
h1 { font-size: 50px; } | |
body { font: 20px Helvetica, sans-serif; color: #333; } | |
article { display: block; text-align: left; width: 650px; margin: 0 auto; } | |
a { color: #dc8100; text-decoration: none; } |
This file contains 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
DELETE wp_posts,wp_postmeta | |
FROM wp_posts | |
INNER JOIN wp_postmeta ON wp_posts.ID=wp_postmeta.post_id | |
WHERE wp_posts.post_type LIKE 'product'; |
This file contains 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 | |
//functions.php | |
function mxp_set_remote_image_to_post_thumbnail($post_id) { | |
$link = get_post_meta($post_id, 'mxp-remote-image', true); | |
if (filter_var($link, FILTER_VALIDATE_URL) === FALSE) { | |
return false; | |
} | |
if (!has_post_thumbnail($post_id)) { | |
require_once ABSPATH . 'wp-admin/includes/media.php'; | |
require_once ABSPATH . 'wp-admin/includes/file.php'; |
This file contains 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 | |
//functions.php | |
function woocommerce_version_check($version = '3.3') { | |
if (function_exists('is_woocommerce_active') && is_woocommerce_active()) { | |
global $woocommerce; | |
if (version_compare($woocommerce->version, $version, ">=")) { | |
return true; | |
} | |
} | |
return false; |
This file contains 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
#!/usr/bin/env bash | |
clear | |
# Take User Inputs | |
read -p "Site URL: " url | |
read -p "Site title: " title | |
read -p "Site Slug: " sslug | |
read -p "DB Name: " db | |
read -p "DB Pass: " dbpass | |
read -p "WP Prefix: " pf | |
pass=$(date +%s | sha256sum | base64 | head -c 32 ; echo) |