Skip to content

Instantly share code, notes, and snippets.

View sky4git's full-sized avatar

Sky4git sky4git

  • Melbourne, Australia
View GitHub Profile
@sky4git
sky4git / add_buttons_to_tinymce.js
Created December 22, 2014 06:19
Add button(s) to TinyMCE 4.x in Wordpress 4.x
( function() {
tinymce.PluginManager.add( 'dqshortcodes', function( editor, url ) {
console.log(url);
// Add a button that opens a window
editor.addButton( 'showrecent', {
text: 'Recent posts',
icon: false,
onclick: function() {
// Open window
@sky4git
sky4git / theme-meta.php
Created May 18, 2015 12:27
Option tee add meta boxes to page template
// ref: http://themeforest.net/forums/thread/option-tree-metabox-and-page-templates/75063
$post_id = (isset($_GET['post'])) ? $_GET['post'] : ((isset($_POST['post_ID'])) ? $_POST['post_ID'] : false);
if ($post_id) :
$post_template = get_post_meta($post_id, '_wp_page_template', true);
if ($post_template == 'template-home.php') ot_register_meta_box($my_meta_box);
endif;
@sky4git
sky4git / async-wordpress-js.php
Last active August 29, 2015 14:21
Async Wordpress Scripts
// Note: This filter can go into functions.php
function add_defer_to_wp( $url )
{
if ( FALSE === strpos( $url, '.js' ) )
{ // not our file
return $url;
}
// Must be a ', not "!
return "$url' async";
}
@sky4git
sky4git / woocommerce.php
Created June 6, 2015 02:30
Hide Shop page title woocommerce
add_filter( 'woocommerce_show_page_title' , 'woo_hide_page_title' );
/**
* woo_hide_page_title
*
* Removes the "shop" title on the main shop page
*
* @access public
* @since 1.0
* @return void
// Remove WooCommerce Theme Support admin message
add_theme_support( 'woocommerce' );
@sky4git
sky4git / README.md
Last active August 29, 2015 14:25 — forked from limzykenneth/README.md

Deploy your site with git securely

This gist assumes:

  • you have a local git repo
  • you have an online remote repository (github)
  • you have a server running Apache with git already installed

you should be able to do the same with Java, Perl, RoR, JSP etc. however you'll need to recreate the (rather simple) PHP script

@sky4git
sky4git / .gitignore
Last active August 29, 2015 14:25 — forked from redoPop/.gitignore
Template .gitignore file for WordPress projects
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
// Shop page id by woocommerce function
$shop_page_id = wc_get_page_id( 'shop' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
@sky4git
sky4git / .htaccess
Created August 11, 2015 12:11
Spam referrers list & block in htaccess
# Start HackRepair.com Blacklist
RewriteEngine on
# Start Abuse Agent Blocking
RewriteCond %{HTTP_USER_AGENT} "^Mozilla.*Indy" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Mozilla.*NEWT" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^$" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Maxthon$" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^SeaMonkey$" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Acunetix" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^binlar" [NC,OR]
@sky4git
sky4git / git-svn commands
Last active September 28, 2016 10:59
Git SVN Wordpress steps
Follow first steps from
http://teleogistic.net/2010/09/10/using-github-with-wordpress-org-plugin-svn/
https://teleogistic.net/2011/05/23/revisiting-git-github-and-the-wordpress-org-plugin-repository/
# Run commands by steps
1: git rebase trunk
2: git svn dcommit
3: git svn tag 1.1
4: git tag -a 1.1 -m "Tagging 1.1" [optional]
5: git push --tags