Skip to content

Instantly share code, notes, and snippets.

View elvismdev's full-sized avatar
🇨🇺

Elvis Morales elvismdev

🇨🇺
View GitHub Profile
@claudiosanches
claudiosanches / functions.php
Created September 12, 2014 13:49
WooCommerce 2.2 - Register new order statuses.
<?php
// My new order statuses.
function register_my_new_order_statuses() {
register_post_status( 'wc-status-name', array(
'label' => _x( 'Status Name', 'Order status', 'textdomain' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
@GaryJones
GaryJones / phpmd.xml
Created September 12, 2014 15:04
PHPMD Ruleset for a WordPress Theme
<?xml version="1.0"?>
<ruleset name="phpmd.xml"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>PHPMD Ruleset for a WordPress Theme</description>
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag" />
<rule ref="rulesets/cleancode.xml/ElseExpression" />
<rule ref="rulesets/cleancode.xml/StaticAccess" />
<?php
/**
* Get the file size of any remote resource (using get_headers()),
* either in bytes or - default - as human-readable formatted string.
*
* @author Stephan Schmitz <eyecatchup@gmail.com>
* @license MIT <http://eyecatchup.mit-license.org/>
* @url <https://gist.github.com/eyecatchup/f26300ffd7e50a92bc4d>
*
* @param string $url Takes the remote object's URL.
@henocdz
henocdz / tooltipster-dynamic-color.js
Last active August 11, 2017 07:09
Tooltipster dynamic color on hover
$('.tooltip').tooltipster({
functionBefore: function(origin, continueTooltip){
continueTooltip();
var color = origin.data('color');
if(!color){ return false; }
$('.tooltipster-default').css({
'background-color': color
});
@ThomasLeCoz
ThomasLeCoz / ld_woosubs_course_access.php
Created February 15, 2015 13:22
Functions to give or remove access to LearnDash courses
// Remove Access to the course linked to the subscription key
function remove_course_access( $user_id, $subscription_key ) {
// Get the course ID related to the subscription
$subscription = WC_Subscriptions_Manager::get_subscription( $subscription_key );
$courses_id = get_post_meta($subscription['product_id'], '_related_course', true);
// Update access to the courses
if ($courses_id && is_array($courses_id)) {
foreach ($courses_id as $course_id) {
@mgussekloo
mgussekloo / gist:8ec5fa53c1505d032991
Last active January 26, 2018 00:09
Timberdate-filter for Twig, to use in combination with Wordpress & Timber
Add to something like functions.php
// https://www.skyverge.com/blog/down-the-rabbit-hole-wordpress-and-timezones/
function wp_get_timezone_string() {
// if site timezone string exists, return it
if ( $timezone = get_option( 'timezone_string' ) )
return $timezone;
// get UTC offset, if it isn't set then return UTC
@wpmark
wpmark / using-media-handle-sideload.php
Created July 10, 2015 10:32
Using Media Handle Sideload
<?php
/* set the url of the file to sideload - probably be from $_POST or something */
$url = 'http://domain.com/image.jpg';
/**
* donwload the url into wordpress
* saved temporarly for now
*/
$tmp = download_url( $url );
{
"name": "shelob9/router-experiment",
"require": {
"silex/silex": "~1.3",
"twig/twig": "^2.0@dev"
},
"minimum-stability": "dev",
"autoload": {
"psr-4": {
"shelob9\\router\\": "src"
@anestan
anestan / functions.php
Last active March 10, 2018 00:02
icelock - Use Polylang Plugins for customizer homepage
// check Polylang exist
if ( function_exists('pll_register_string') ) {
$icelock_title_portfolio_section = get_theme_mod('icelock_title_portfolio_section', '');
pll_register_string('Portfolio Section Title', $icelock_title_portfolio_section);
$icelock_title_team_section = get_theme_mod('icelock_title_team_section', '');
pll_register_string('Team Section Title', $icelock_title_team_section);
$icelock_title_recent_post_section = get_theme_mod('icelock_title_recent_post_section', '');
pll_register_string('Recent Post Section Title', $icelock_title_recent_post_section);
$icelock_title_testimonials_section = get_theme_mod('icelock_title_testimonials_section', '');
pll_register_string('Testimonial Section Title', $icelock_title_testimonials_section);
development:
adapter: mysql2
encoding: utf8
database: my_database
username: root
roles:
- admin
- developer
- guest
password: