Skip to content

Instantly share code, notes, and snippets.

@WPDevHQ
WPDevHQ / gutenberg-locked-warning.md
Created Aug 3, 2017
Warning on locked content in Gutenberg.
View gutenberg-locked-warning.md

#BuiltWithGutenberg!

Nore WordPress Theme!

@WPDevHQ
WPDevHQ / custom-menu-widget.css
Created Aug 1, 2017
Horizontal aligned menu via the WordPress custom menu widget
View custom-menu-widget.css
/*
* Footem Custom Menu Widget
*/
#footer-menu-widget {
padding: 1% 0;
background-color: transparent;
color: #294e6b;
}
#footer-menu-widget h2.widget-title {
View child-theme-enqueue.php
<?php
function gp_child_scripts() {
wp_enqueue_style( 'gpchild-custom-css', get_theme_file_uri( '/customCss/modalStyling.css' ) );
wp_enqueue_script( 'gpchild-custom-js', get_theme_file_uri( '/js/modalScript.js' ), array(), '4.8', true );
}
add_action( 'wp_enqueue_scripts', 'gp_child_scripts' );
View functions.php
<?php
add_action('wp_head', 'webworks_facebook_analytics');
function webworks_facebook_analytics() {
if(current_user_can('manage_options')) {
return;
}
?>
@WPDevHQ
WPDevHQ / Contract Killer 3.md
Created Mar 19, 2017 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers
View Contract Killer 3.md

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@WPDevHQ
WPDevHQ / wp_localize_script
Last active Feb 20, 2017
wp-localize-script.txt
View wp_localize_script
// In the case of a theme this goes in functions.php and for plugins I use plugin.php :)
function frontend_assets(){
// Enqueue your assets here and add your localization like so!
wp_localize_script( $this->ssp_plugin_slug, 'ss_panel', array(
'success' => __( 'Here are your search results!', 'textdomain' ),
'failure' => __( 'Sorry, no results matched your search query. Try searching again?', 'textdomain' ),
));
}
add_action( 'wp_enqueue_scripts', 'frontend_assets' );
@WPDevHQ
WPDevHQ / custom-functions.php
Last active Dec 7, 2017
Keep accordion closed on page load
View custom-functions.php
<?php // Leave this out if you already have an opening php tag in your file!
function elementor_accordion_title() { ?>
<script>
jQuery(document).ready(function() {
jQuery('.elementor-accordion-title').removeClass('active');
jQuery('.elementor-accordion-content').css('display', 'none');
});
</script>
<?php }
add_action( 'wp_footer', 'elementor_accordion_title' );
@WPDevHQ
WPDevHQ / menu-options.php
Last active Jan 16, 2017
Show standard or humburger menu on desktop depending on user selection in customizer
View menu-options.php
<?php
if ( get_theme_mod( 'menu-style' ) == A ) {
//Output standard menu
$handle = 'themeprefix-style';
$menu_style = '.main-navigation{ display: block; } .menu-toggle{ display: none; } ';
wp_add_inline_style( $handle, $menu_style );
} else {
//Output mobile menu
@WPDevHQ
WPDevHQ / replacement-url.php
Last active Dec 30, 2020
Replace WooCommerce product link in shop with a custom product page url
View replacement-url.php
<?php
add_action( 'woocommerce_product_options_advanced', 'woostore_elementor_product_link' );
function woostore_elementor_product_link() {
global $woocommerce, $post;
echo '<div class="options_group">';
woocommerce_wp_text_input(
array(
View functions.php
/**
* Redirect to a specific page when clicking on Continue Shopping in the single product page
*
* @return void
*/
function wc_custom_redirect_continue_shopping( $message ) {
if ( strpos( $message, __( 'View Cart', 'woocommerce' ) ) !== false ) {
$message = str_replace( esc_url( wc_get_page_permalink( 'cart' ) ), esc_url( wc_get_page_permalink( 'shop' ) ), $message );
$message = str_replace( __( 'View Cart', 'woocommerce' ), esc_html__( 'Continue Shopping', 'woocommerce' ), $message );