Skip to content

Instantly share code, notes, and snippets.

View digisavvy's full-sized avatar

Alex Vasquez digisavvy

View GitHub Profile
// You can use the array to define which environments your code will fire on.
if ( in_array( $_ENV['PANTHEON_ENVIRONMENT'], array( 'test', 'live' ) ) ) :
// Enter your code here
endif;
@digisavvy
digisavvy / Adding WordPress User via FTP
Created July 31, 2018 17:37
Add a WP Admin User when you ONLY have FTP access
<?php
// 1. GO TO THE THEME’S FOLDER, DOWNLOAD AND OPEN FUNCTIONS.PHP IN YOUR CODE EDITOR.
//path: /wp-content/themes/customtheme/functions.php
//2. ALL THE WAY TO THE BOTTOM OF FUNCTIONS.PHP ADD THIS LINE OF CODE:
wp_insert_user(array('user_pass' => 'password_here', 'user_login' => 'username_here', 'role' => 'administrator'));
function wpse_load_plugin_css() {
$plugin_url = plugin_dir_url( __FILE__ );
wp_enqueue_style( 'style1', $plugin_url . 'css/style1.css' );
wp_enqueue_style( 'style2', $plugin_url . 'css/style2.css' );
}
add_action( 'wp_enqueue_scripts', 'wpse_load_plugin_css' );
<?php
/**
* Load the appropriate post type for single post
*/
function dgs_load_chscpr_event_page_template( $template ) {
if ( get_post_type() == 'chscpr_event_reg' ) {
return plugin_dir_path( __FILE__ ) . 'views/single-chscpr-event.php';
}
return $template;
}
/**
* Change text strings
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function dgs_change_pods_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'More Fields' : // The string to look for and replace
if ( get_post_type() == 'post' ) {
$translated_text = __( 'Additional Article Meta', 'pods' );
@digisavvy
digisavvy / Beaver Builder Custom Post Property
Last active January 5, 2018 19:00
Simple Beaver Builder Custom Post Property/Custom Field example. This example simply generates the permalink for the current post.
/* Get the external link for each post, crate a new connection for custom post template
* The add_action will setup the post property so that it is selectable within Beaver Builder.
* The function will grab and assign the value to the post property.
* This example simple gets the current post permalink and returns/prints to screen.
*/
add_action( 'fl_page_data_add_properties', function() {
FLPageData::add_post_property( 'll_permalink', array(
'label' => 'Post Permalink',
'group' => 'posts',
// Restyle admin menu separators
function dgs_separators() {
echo '<style type="text/css">#adminmenu li.wp-menu-separator {margin: 0; background: #444;}</style>';
echo '<style type="text/css">.editor-styles-wrapper .icon-bullet .wp-block-group__inner-container { display: inherit !important; }</style>';
}
add_action( 'admin_head', 'dgs_separators' );
// Allow custom status to be selected in GF
add_filter( 'gform_post_status_options', 'add_custom_post_status' );
function add_custom_post_status( $post_status_options ) {
$post_status_options['custom_status'] = 'pitch';
return $post_status_options;
}
@digisavvy
digisavvy / remove-replace-go-to-top.php
Created October 23, 2017 23:16
Remove beaver builder's 'go to top' markup and modify it with my own.
<?php
/**
* Removes markup for built-in scroll to top link
*
* Renders scroll to top button for wp_footer.
*
*/
add_action( 'wp_head', 'dgs_remove_go_to_top' );
add_action( 'wp_footer', 'dgs_remove_go_to_top' );
function dgs_remove_go_to_top(){