Skip to content

Instantly share code, notes, and snippets.

@ray1980
ray1980 / Vagrantfile
Created September 13, 2019 07:21 — forked from wolstena/Vagrantfile
Vagrant multi server
# -*- mode: ruby -*-
# vim: set ft=ruby :
# vim: set smartindent
# vim: set tabstop=2
# vim: set shiftwidth=2
provision = true
vagrant_api_version = "2"
boxes = [
<?php
/**
* Plugin Name: WP REST API Subdomain
* Plugin URI: https://wordpress.org/plugins/wp-rest-api-subdomain/
* Author: Mark McWilliams
* Author URI: https://profiles.wordpress.org/markmcwilliams/
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Description: Move your RESTful API to a subdomain in WordPress
@ray1980
ray1980 / WordPress Conditional Custom Meta Box
Created September 6, 2018 05:35 — forked from WagnerMatos/WordPress Conditional Custom Meta Box
WordPress Custom Meta Box that can used only on certain post types, pages, etc.
<?php
/*/////////////////////////////////////////////////////////////////////////////////////
//// Load scripts and styles for Meta box */
// enqueue scripts and styles, but only if is_admin
if(is_admin()) {
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_script('jquery-ui-slider');
wp_enqueue_script('custom-js', get_template_directory_uri().'/library/metaboxes/js/custom-js.js');
wp_enqueue_style('jquery-ui-custom', get_template_directory_uri().'/library/metaboxes/css/jquery-ui-custom.css');
@ray1980
ray1980 / msdn-itellyou-getter.py
Created August 28, 2018 04:34 — forked from ysc3839/msdn-itellyou-getter.py
msdn-itellyou-getter
#!/usr/bin/env python
import re
import json
import requests
HEADERS = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36'}
POST_HEADERS = {'origin': 'https://msdn.itellyou.cn', 'referer': 'https://msdn.itellyou.cn/'}
def main():
@ray1980
ray1980 / gist:f36e709d715bceb0cdfcdefd2ea51dbb
Created June 29, 2018 08:22 — forked from zvineyard/gist:2625997
WordPress: Comments Template
<?php
$default_avatar = 'http://zacvineyard.com/blog/wp-content/themes/zac/images/default-avatar.png';
?>
<a id="comments"></a>
<h2>Comments</h2>
<?php if($comments) : ?>
<ol class="comments">
<?php foreach($comments as $comment) : ?>
<li id="comment-<?php comment_ID(); ?>" class="<?php if ($comment->user_id == 1) echo "authcomment";?>">
<?php if ($comment->comment_approved == '0') : ?>
@ray1980
ray1980 / functions.php
Created June 29, 2018 05:25 — forked from i-like-robots/functions.php
Wordpress custom comment form
<?php
/**
* Comment form hidden fields
*/
function comment_form_hidden_fields()
{
comment_id_fields();
if ( current_user_can( 'unfiltered_html' ) )
{
/**
* Archive pagination
* @param string $prevText Previous page link text. Leave blank to ignore.
* @param string $nextText Next page link text. Leave blank to ignore.
* @param integer $break Number of page links to display before truncation. Set to 0 to ignore.
*/
public static function archive_pagination($prevText = 'Previous', $nextText = 'Next', $break = 10)
{
// Maximum pages
global $wp_query;
@ray1980
ray1980 / custom-menu-panel.php
Created June 2, 2018 02:43 — forked from nikolov-tmw/custom-menu-panel.php
This registers a custom meta box for nav menus and renders it. Obviously $my_items would ideally be not hard-coded and instead it would come somewhere from the DB. The custom items add to the menu and save properly, but will probably not be displayed correctly. You might need to hook to the 'wp_setup_nav_menu_item' filter in order to fix the men…
<?php
function my_register_menu_metabox() {
$custom_param = array( 0 => 'This param will be passed to my_render_menu_metabox' );
add_meta_box( 'my-menu-test-metabox', 'Test Menu Metabox', 'my_render_menu_metabox', 'nav-menus', 'side', 'default', $custom_param );
}
add_action( 'admin_head-nav-menus.php', 'my_register_menu_metabox' );
/**
@ray1980
ray1980 / bridge-walker-nav-menu.php
Created April 20, 2018 02:23 — forked from kucrut/bridge-walker-nav-menu.php
WordPress Nav Menu walker that returns menu items as multidimensional array (items will children)
<?php
/**
* Nav menu walker
*/
class Bridge_Walker_Nav_Menu extends Walker_Nav_Menu {
/**
* Prepare item
*
<?php
/**
* Menu item custom fields example
*
* Copy this file into your wp-content/mu-plugins directory.
*
* @package Menu_Item_Custom_Fields
* @version 0.1.0
* @author Dzikri Aziz <kvcrvt@gmail.com>
*