Skip to content

Instantly share code, notes, and snippets.

View amostajo's full-sized avatar
💣
I may be slow to respond.

Ale Mostajo amostajo

💣
I may be slow to respond.
View GitHub Profile
@amostajo
amostajo / callables.php
Created March 23, 2017 00:56
Callable test as proposed by @carlalexander
<?php
/**
* Callables executable test.
*
* @link https://github.com/semperfiwebdesign/all-in-one-seo-pack/issues/403
* @author Alejandro Mostajo <@amostajo>
*/
/**
@amostajo
amostajo / settings.php
Created March 20, 2017 18:17
Post Gallery - Default settings by code.
<?php
// The class settings is located at PostGallery\Models\PostGallery
// There are 2 ways of calling and using this class.
// - 1 - Using use statement
use PostGallery\Models\PostGallery;
$settings = PostGallery::find();
// - 2 - Without use statement
$settings = PostGallery\Models\PostGallery::find();
@amostajo
amostajo / RebaseRepo.bash
Last active July 23, 2016 19:32
Pull from forked repo. Updates a repository that was forked and had an approved pull request.
# source:http://stackoverflow.com/questions/7244321/how-do-i-update-a-github-forked-repository
# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
git fetch upstream
@amostajo
amostajo / doc.action.legacy.php
Last active April 22, 2016 06:19
Wordpress MVC - Add action legacy
<?php
class Main extends Plugin
{
public function init()
{
// This will call 'save_post' function located in Main class.
add_action( 'save_post', [ &$this, 'save_post' ] );
}
// Callback handler for action 'save_post'.
@amostajo
amostajo / doc.action.addview2.php
Created April 22, 2016 06:13
Wordpress MVC - Add action with view and parameters.
<?php
public function on_admin()
{
$this->add_action( 'ajax_logo', 'view@images.logo', [ 'class' => 'logo-ajax' ] );
}
@amostajo
amostajo / doc.action.addview.php
Created April 22, 2016 06:12
Wordpress MVC - Add action with view
<?php
public function init()
{
$this->add_action( 'ajax_logo', 'view@images.logo' );
}
@amostajo
amostajo / doc.action.addcontroller3.php
Created April 22, 2016 06:11
Wordpress MVC - Add action with controller, priority and accepted tags
<?php
public function on_admin()
{
$this->add_action( 'save_post', 'PostController@save', 5, 2 );
$this->add_action( 'admin_menu', 'AdminController@menu', [ 5, $this->config ], 10, 2 );
}
@amostajo
amostajo / doc.action.addcontroller2.php
Created April 22, 2016 06:10
Wordpress MVC - Add action hook with controller and override params.
<?php
public function on_admin()
{
$this->add_action( 'admin_menu', 'AdminController@menu', [ 5, $this->config ] );
}
@amostajo
amostajo / doc.action.addcontroller.php
Created April 22, 2016 06:08
Wordpress MVC - Add action hook with controller
<?php
public function init()
{
$this->add_action( 'save_post', 'PostController@save' );
}
@amostajo
amostajo / doc.template.plugin.index.php
Last active April 22, 2016 06:07
Wordpress MVC - Main class external access plugin
<!-- Example in a wordpress template -->
<div class="theme-access">
<?php echo $myspecialplugin->my_method() ?>
</div>
<?php
// Example within wordpress php code
function test()
{
global $myspecialplugin;