Skip to content

Instantly share code, notes, and snippets.

View cabrerahector's full-sized avatar

Héctor Cabrera cabrerahector

View GitHub Profile
@cabrerahector
cabrerahector / bitbucket-pipelines.yml
Last active January 24, 2024 14:17
Bitbucket Pipelines - Deploying to staging / production server with atlassian/ftp-deploy
image: atlassian/default-image:2
pipelines:
branches:
master:
- step:
name: Deploy to Production
deployment: production
script:
@cabrerahector
cabrerahector / bitbucket-pipelines.yml
Last active January 24, 2024 14:17
Bitbucket Pipelines - Deploying to Server with atlassian/ftp-deploy with Manual Triggers
image: atlassian/default-image:2
pipelines:
custom:
deploy-to-production:
- step:
name: Deploy to Production
deployment: production
script:
@cabrerahector
cabrerahector / bitbucket-pipelines.yml
Last active April 26, 2024 17:58
Bitbucket Pipelines - Deploying to Server with atlassian/ftp-deploy
image: atlassian/default-image:2
pipelines:
branches:
master:
- step:
name: Deploy to Production
deployment: production
script:
@cabrerahector
cabrerahector / wordpress-sort-posts-by-views.md
Last active April 15, 2023 17:57
[WordPress Popular Posts] Adding Views column to the Posts Manage page

Adding Views column to the Posts Manage page

This Gist shows how to add a sortable Views column to the post/page/custom-post-type edit screen.

Out of the box, the script will display the Views column on both the Posts and Pages screens. You can change that by editing the $post_types_with_views_column array at the beginning of the script.

How do I add this to my site?

  1. Using the text editor of your preference, create a file called wpp-sortable-columns.php and add the contents of this script to it.
  2. Place the wpp-sortable-columns.php file in wp-content\plugins.
@cabrerahector
cabrerahector / functions.php
Created January 4, 2019 22:09
Most viewed posts from [YEAR] using the WordPress Popular Posts plugin
<?php
/**
* Registers shortcode [wpp_top_viewed_posts_from].
*
* This function registers a new custom shortcode that
* outputs the top viewed posts of a given year.
*
* Requires PHP 5.3+ to work.
*
* @author Hector Cabrera (cabrerahector.com)
@cabrerahector
cabrerahector / functions.php
Last active December 10, 2018 14:46
Get Random Posts with Recently
<?php
// https://github.com/cabrerahector/recently/
/**
* Have Recently return random posts
* for widget instance ID 'recently-2'
*
* @param array $args The args passed to WP_Query.
* @param string $widget_id The ID of the current widget instance.
* @return array
@cabrerahector
cabrerahector / wpp.css
Created May 18, 2018 19:06
One-column Popular Posts
/*
* The container of our grid.
*/
.wpp-grid {
overflow: hidden;
margin: 2.5em auto;
padding: 0;
}
/*
@cabrerahector
cabrerahector / AdminController.php
Last active December 4, 2022 23:34
Laravel 5.4 Multi Auth - Custom Logout Method for Admin (see https://youtu.be/P8T3MjZPDdI)
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Auth;
class AdminLoginController extends Controller
{