Skip to content

Instantly share code, notes, and snippets.

@txemaleon
txemaleon / check_git_branch_exists.sh
Created April 1, 2023 10:27 — forked from iridiumcao/check_git_branch_exists.sh
How to check if a git branch exists in the local/remote repository?
# Local:
# https://stackoverflow.com/questions/21151178/shell-script-to-check-if-specified-git-branch-exists
# test if the branch is in the local repository.
# return 1 if the branch exists in the local, or 0 if not.
function is_in_local() {
local branch=${1}
local existed_in_local=$(git branch --list ${branch})
if [[ -z ${existed_in_local} ]]; then
echo 0
@txemaleon
txemaleon / functions.php
Last active March 26, 2021 17:26
Allow HTML Tags in WordPress Excerpts
<?php
/**
* Allow HTML Tags in Wordpress Excerpt
*
* @link http://wordpress.stackexchange.com/questions/141125/allow-html-in-excerpt/141136
*/
if ( ! function_exists( 'wpse_custom_wp_trim_excerpt' ) ) :
function wpse_custom_wp_trim_excerpt( $wpse_excerpt ) {
@txemaleon
txemaleon / class.className.php
Created June 9, 2016 19:04
A Basic Class Template for Wordpress Plugins
<?php
class className {
function __construct() {}
}
function className() {
new className;
@txemaleon
txemaleon / pre.php
Created April 24, 2016 10:33
pre() es una pequeña función que muestra el contenido de una variable
<?php
/**
* Muestra el contenido de una variable
* @param mixed $texto Variable a Mostrar
* @return n/a
*/
function pre( $texto ) {
echo '<pre>';
print_r( $texto );
echo '</pre>';
@txemaleon
txemaleon / pre.sublime-snippet
Created April 24, 2016 09:42
pre.sublime-snippet
<snippet>
<content><![CDATA[
pre( \$${1:var} );${2}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>pr</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php</scope>
</snippet>
@txemaleon
txemaleon / woocommerce_myorders_sc.php
Created March 23, 2016 11:08
Shortcode to display "My Orders" in a custom page, instead of in the "My Account" Page in WooCommerce
function txl_my_orders_sc( $atts ) {
$atts = shortcode_atts( array(
'order_count' => -1,
), $atts ));
ob_start();
wc_get_template( 'myaccount/my-orders.php', array(
'order_count' => $atts[ 'order_count' ],