Skip to content

Instantly share code, notes, and snippets.

Avatar

Page Carbajal Page-Carbajal

View GitHub Profile
View update.md

Import values from a related table

UPDATE wp_posts AS posts,
	(SELECT post_id, meta_value FROM wp_postmeta 
		WHERE meta_key = 'wpcf-p-desc') AS meta
	SET posts.post_content = meta.meta_value
WHERE posts.ID = meta.post_id
AND posts.post_content = ''
;
View templates.md

Tres tipos diferentes de templates

1. Preconfigurado

<?php
get_header();

while( have_posts() ){
   the_post();
@Page-Carbajal
Page-Carbajal / jquery-injection.js
Created May 14, 2018
Injecting jQuery on Runtime
View jquery-injection.js
// Force jQuery Injection
(function($d){
if( 'undefined' === typeof jQuery ){
var head = document.getElementsByTagName("head")[0];
var customScript = document.createElement("script");
customScript.src = scriptSource;
customScript.onload = function(){
if( jQuery ){
/******** Start writing you jQuery code here ************/
@Page-Carbajal
Page-Carbajal / functions.php
Created Jun 17, 2016
WordPress - How to dynamically load scripts and styles based on post content
View functions.php
<?php
add_action('template_redirect','justIfContentHas');
function justIfContentHas()
{
global $post;
// Set the condition for loading your resources
if( has_shortcode($post->post_content, 'my_short_code') ){
View static_bindings_test.php
<?php
// Late Static Binding in PHP are great.
// However they are not supported in every version of PHP
// Use the code below in a new 3val.org window to test support
// for Late Static Bindings inside closures.
abstract class Demo
{
protected $item;
View git-archive.md

#Git Archive

##Archive HEAD

$ git archive HEAD --format=zip -o /path/to/archive.zip

@Page-Carbajal
Page-Carbajal / Override nested dependencies with Composer.json
Last active Feb 11, 2016
Override nested dependencies with Composer
View Override nested dependencies with Composer.json
{
"name": "page-carbajal/my-awesome-package",
"description": "My Awesome Package",
"type": "Plugin",
"authors": [
{
"name": "Page Carbajal",
"email": "awesom@pagecarbajal.com"
}
],
@Page-Carbajal
Page-Carbajal / ext-xdebug.ini
Created Jan 4, 2016
XDebug Sample Configuration
View ext-xdebug.ini
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.profiler_output_name = xdebug.profiler.%H.%t
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir=/set/a/path
@Page-Carbajal
Page-Carbajal / git-repo-to-wordpress-svn.md
Last active Oct 25, 2019
Publishing a Git Repository to WordPress with SVN
View git-repo-to-wordpress-svn.md

From a Git Repository to WordPress SVN

Well this is kind of fun right. Specially since must of us have not used SVN for over 10 years.

Lets do this. Our objective here is to create a common codebase for both SVN and Git.

Process for empty SVN Project

Doing this is not that complicated