Skip to content

Instantly share code, notes, and snippets.

@edwinvelez
edwinvelez / wp_install.sh
Created Apr 4, 2017
Bash Script to Install WordPress from a Local Machine to Remote Server
View wp_install.sh
#!/bin/bash
# Update variables as needed.
SSH_REMOTE_INFO="username@remotehost"
WP_HOME_DIR="path/to/remote/wp/homedir"
DB_NAME="db_name"
DB_USER_NAME="db_user_name"
DB_USER_PASS="db_user_pass"
DB_HOST="localhost"
SITE_URL="http://example.com"
@edwinvelez
edwinvelez / unattended_mysql_install.sh
Created Apr 28, 2017
Completes an unattend installation of MySQL with phpMyAdmin.
View unattended_mysql_install.sh
#!/bin/bash
#
# Author: Edwin Velez
# Author URI: edwinvelez.net
# Description: Completes an unattend installation of MySQL with phpMyAdmin.
MYSQL_HOST=“localhost”
MYSQL_PASSWORD="Password"
PHPMYADMIN_APP_PASSWORD="Password"
PHPMYADMIN_MYSQL_PASSWORD="Password"
@edwinvelez
edwinvelez / functions.php
Created Mar 13, 2019
Set Reading Settings Programmatically
View functions.php
<?php
/**
* Set Reading Settings Programmatically
*
* @author Edwin Velez (https://edwinvelez.net)
* @link https://edwinvelez.net/set-reading-settings-programmatically/
*/
// Set static front page.
@edwinvelez
edwinvelez / functions.php
Last active May 20, 2019
Compare Two Domain Name Values
View functions.php
<?php
/**
* Compare Two Domain Name Values
*
* @author Edwin Velez (https://edwinvelez.net)
* @link https://edwinvelez.net/compare-two-domain-name-values/
*/
// The domain name or host you want to compare. Can also be a host i.e. http://localhost
@edwinvelez
edwinvelez / functions.php
Created Mar 13, 2019
Set Reading Settings on Theme Activation
View functions.php
<?php
/**
* Set Reading Settings on Theme Activation
*
* @author Edwin Velez (https://edwinvelez.net)
* @link https://edwinvelez.net/set-reading-settings-on-theme-activation/
*/
function ev_set_reading_settings() {
@edwinvelez
edwinvelez / external_links.js
Last active Apr 25, 2019
Open External Links in New Tab
View external_links.js
@edwinvelez
edwinvelez / genesis-build-sidebar-toc.js
Created Jun 14, 2019
Build Table of Contents in Sidebar of a Genesis Theme
View genesis-build-sidebar-toc.js
/**
* Scans for <h1> to <h6> HTML tags contained within 'genesis-content' and builds a Table of Contents in the primary
* sidebar.
*
* @summary Dynamically builds a Table of Contents for in page navigation.
* @author Edwin Velez (edwinvelez.net)
*
* @version 1.0.1
*/
View functions.php
<?php
/**
* Edwin Velez
*
* Starting point for all WordPress themes.
*
* @package EdwinVelez
* @author Edwin Velez (https://edwinvelez.net)
* @license GPL-2.0-or-later
View functions.php
<?php
$current_user = wp_get_current_user()->roles;
if ( in_array('administrator', $current_user) ) {
echo 'Current user is an administrator.';
}
View my-plugin-file.php
<?php
/**
* Create an array of strings based on this file's absolute file system path as found in this plugin's root
* directory (not web root). Each index of the array is delimited by a forward slash "/".
*/
$this_file_tokenized_path = explode( '/', plugin_basename( __DIR__ ) );
$this_plugin_root_dir_name = $this_file_tokenized_path[ 0 ];
$substr_start_pos = strpos( plugin_dir_path( __DIR__ ), $this_plugin_root_dir_name );
You can’t perform that action at this time.