Skip to content

Instantly share code, notes, and snippets.

@guoxiangke
guoxiangke / drupal_form_ajax_check.js
Created May 4, 2014 09:22
ajax node form submit ,check before submit
(function ($) {
Drupal.behaviors.confirm = {
attach: function(context, settings) {
var events = $('.node-weibo-form input[name=op]').data('events'); // Get the jQuery events.
$('.node-weibo-form input[name=op]').unbind('mousedown'); // Remove the click events.
var name = $('.node-weibo-form input[name=title]').val();
$('.node-weibo-form input[name=op]').mousedown(function () {
// var events = $('.node-weibo-form input[name=op]').clone(true).data('events');// Get the jQuery events.
@guoxiangke
guoxiangke / overlay,js
Created May 22, 2014 02:59
js弹出层
<div class="contact_card" id="contact_card_guo" style="display:none; position:relative; z-index:99999;">
<div class="box" id="guo-hide">
<div id="guo-show">
<p><b class="f20"><?php print t("You need to be logged in order to submit your enquiry.");?></b></p>
<div class="btn_login"><a href="<?php print url('user/register');?>" class="btn_orange"><?php print t('Sign up, it\'s free');?></a></div>
<div class="btn_login"><a href="#TB_inline?height=360&width=420&inlineId=loginbox" class="btn_orange thickbox"><?php print t('Login');?></a></div>
<div id="contact_card_guo_close"><a href="#" id="TB_closeWindowButton">close</a></div>
</div>
</div>
@guoxiangke
guoxiangke / 20150526.js
Created May 26, 2014 03:45
chrome firefox input radios click auto submit
<script type="text/javascript">
$(document).ready(function(){
$("#webform-client-form-1363 .form-actions .form-radios label").live('click',function(e){//.click(function(){
e.preventDefault();
$(this).children('input').attr('checked','checked');
// console.log('click');
$("#webform-client-form-1363 .form-actions input[type=submit]").trigger("click");
});
})
</script>
@guoxiangke
guoxiangke / weixin node create book!
Created May 30, 2014 22:58
weixin node create book!
$books = array(
'0'=>'http://mp.weixin.qq.com/mp/appmsg/show?__biz=MjM5NjQwMDE2Mw==&appmsgid=10000251&itemidx=1&sign=52b2980fca36785ca3671575fa1cb098#wechat_redirect',
'1'=>'http://mp.weixin.qq.com/mp/appmsg/show?__biz=MjM5NjQwMDE2Mw==&appmsgid=10000251&itemidx=2&sign=b7e8cc04c531fc07a953d39c62411c08#wechat_redirect',
'2'=>'http://mp.weixin.qq.com/mp/appmsg/show?__biz=MjM5NjQwMDE2Mw==&appmsgid=10000251&itemidx=3&sign=df465908982990d92306ac649b9a663e#wechat_redirect',
'3'=>'http://mp.weixin.qq.com/mp/appmsg/show?__biz=MjM5NjQwMDE2Mw==&appmsgid=10000251&itemidx=4&sign=7d98347febbe2707d887f49bf8cddfff#wechat_redirect',
'4'=>'http://mp.weixin.qq.com/mp/appmsg/show?__biz=MjM5NjQwMDE2Mw==&appmsgid=10000251&itemidx=5&sign=547baf5c8b15297f80b4737a04f9ccf7#wechat_redirect',
'5'=>'http://mp.weixin.qq.com/mp/appmsg/show?__biz=MjM5NjQwMDE2Mw==&appmsgid=10000251&itemidx=6&sign=e7e45471b60e5ab7a0624f8b99b2e3a6#wechat_redirect',
'6'=>'http://mp.weixin.qq.com/mp/appmsg/show?__biz=MjM5NjQwMDE2Mw==&appmsgid=10000251&itemidx=7&
@guoxiangke
guoxiangke / jcrop_form_element_plus.module
Created July 9, 2014 04:57
默认对用户头像 剪切
//https://www.drupal.org/project/jcrop_form_element
/**
* Implements hook_form_alter().
*/
function jcrop_fapi_form_alter(&$form, &$form_state, $form_id) {
$form['picture']['picture_upload']['#type'] = 'jcrop_image';
$libraries = libraries_load('jcrop', $variant = NULL);
libraries_load_files($libraries);
array_unshift($form['#submit'], 'jcrop_form_submit');
}
@guoxiangke
guoxiangke / wp-members-core.php
Last active August 29, 2015 14:05
wordpress 邮箱验证前禁止注册用户登陆
<?php
/**
* 需求:User can register using email and user name, then log in later after receiving the validation email. All the users share the same avatar.
* 即 邮箱验证前禁止注册用户登陆
* 本需求可以使用Pie Register的验证link 并参照 http://wordpress.org/plugins/wp-members/ 的 wp-members-core.php 代码 进行实现
* Step 1: Enable plugin Pie Register http://wordpress.org/plugins/pie-register/
* Step 2: Go Pie Register -> General Settings (wp-admin/admin.php?page=pie-general-settings) set User Verification => Email Verification.
* Step 3: Add flow code in your theme functions.php
*/
/** initialize **/
@guoxiangke
guoxiangke / wordpress ajax comment
Created September 15, 2014 04:05
wordpress ajax comment! getCommentHTML???
<?php
// Method to handle comment submission
function ajaxComment($comment_ID, $comment_status) {
// If it's an AJAX-submitted comment
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
// Get the comment data
$comment = get_comment($comment_ID);
// Allow the email to the author to be sent
wp_notify_postauthor($comment_ID, $comment->comment_type);
// Get the comment HTML from my custom comment HTML function
@guoxiangke
guoxiangke / Multiple cURL Requests with PHP
Created March 17, 2015 08:03
Multiple cURL Requests with PHP
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Multiple cURL Requests with PHP</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.2/css/bootstrap.min.css">
@guoxiangke
guoxiangke / preg get URL parameter
Created June 30, 2015 03:54
//正则表达式获取URL参数 preg get URL parameter
//正则表达式获取URL参数 preg get URL parameter
//http://stackoverflow.com/questions/11706986/php-getting-url-variable-with-preg-match
$subject = "http://www.mysite.com?id=05&name=johnny";
$pattern = '/id=[0-9A-Za-z]*/'; //$pattern = '/id=[0-9]*/'; if it is only numeric.
preg_match($pattern, $subject, $matches);
print_r($matches);
@guoxiangke
guoxiangke / Geolocation maxmind
Created September 7, 2015 07:46
Geolocation maxmind
/**
* Geolocation
*/
$ip = $_SERVER['REMOTE_ADDR'];
$result = db_select('ip_geolocation', 'g')
->fields('g')
->condition('ip', $ip, '=')
->execute()
->fetchAssoc();