Skip to content

Instantly share code, notes, and snippets.

View Page-Carbajal's full-sized avatar

Page Carbajal Page-Carbajal

View GitHub Profile
@Page-Carbajal
Page-Carbajal / git-repo-to-wordpress-svn.md
Last active October 25, 2019 16:56
Publishing a Git Repository to WordPress with SVN

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

@Page-Carbajal
Page-Carbajal / update.md
Last active January 3, 2019 13:44
UPDATE SELECT

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 = ''
;
@Page-Carbajal
Page-Carbajal / templates.md
Last active November 26, 2018 16:28
Page Templates

Tres tipos diferentes de templates

1. Preconfigurado

<?php
get_header();

while( have_posts() ){
   the_post();
@Page-Carbajal
Page-Carbajal / get-post-thumbnail.gist.class.php
Last active May 19, 2018 03:20
WordPress - Get Post Thumbnail URL
<?php
/**
* Return the Post Thumbnail URL if $post has thumbnail
* $post is a WordPress Post Object
* @param $post
* @return string
*/
private function getPostThumbnailURL( $post ){
if ( has_post_thumbnail( $post->ID ) ){
@Page-Carbajal
Page-Carbajal / jquery-injection.js
Created May 14, 2018 15:00
Injecting jQuery on Runtime
// 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 June 17, 2016 22:20
WordPress - How to dynamically load scripts and styles based on post content
<?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') ){
<?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;
@Page-Carbajal
Page-Carbajal / Override nested dependencies with Composer.json
Last active February 11, 2016 23:04
Override nested dependencies with Composer
{
"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 January 4, 2016 03:37
XDebug Sample Configuration
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 / getByMeta.php
Last active September 30, 2015 22:15
Get WordPress Posts By Meta
<?php
function getPostByMeta( $metaKey, $metaValue, $operatos = '=' ){
$args = array(
'showposts' => -1,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => $metaKey,
'value' => $metaValue,