Skip to content

Instantly share code, notes, and snippets.

View cipriantepes's full-sized avatar
🏠
Working from home

Ciprian Tepes cipriantepes

🏠
Working from home
View GitHub Profile
@cipriantepes
cipriantepes / genesis-functions.php
Created November 26, 2019 09:12
Change widget title tag in genesis
// original source - https://wpsites.net/web-design/change-genesis-widget-title-html-tag-from-h4/
add_filter( 'genesis_register_widget_area_defaults', __NAMESPACE__ . '\change_all_widget_titles_to_p' );
function change_all_widget_titles_to_p( $defaults ) {
$defaults['before_title'] = '<p class="widget-title widgettitle">';
$defaults['after_title'] = "</p>\n";
return $defaults;
@cipriantepes
cipriantepes / gf-enter-prevent-submission.php
Created May 22, 2019 08:14 — forked from uamv/gf-enter-prevent-submission.php
Disables form submission when pressing Enter, unless user has tabbed to submit button or page advance button.
<?php
function twxyz_prevent_gform_submission( $form ) { ?>
<script type="text/javascript">
jQuery(document).bind('gform_post_render', function(){
jQuery(document).on( 'keypress', '.gform_wrapper', function (e) {
var code = e.keyCode || e.which;
if ( code == 13 && ! jQuery( e.target ).is( 'textarea,input[type="submit"],input[type="button"]' ) ) {
e.preventDefault();
return false;
# Thanks to: https://gist.github.com/jdbartlett/444295
# Ignore everything in the root except the "wp-content" directory.
/*
!.gitignore
!wp-content/
# Ignore everything in the "wp-content" directory, except the "plugins" and "themes" directories.
wp-content/*
!wp-content/plugins/
@cipriantepes
cipriantepes / robots.txt
Created February 22, 2018 13:00
WordPress SEO robots.txt
User-agent: *
Disallow: /wp-admin/
Disallow: /wp-login.php
Disallow: /?s=
Disallow: /search/
Allow: /wp-admin/admin-ajax.php
Sitemap: https://
@cipriantepes
cipriantepes / .htaccess
Created August 21, 2017 19:17
GravityForms fix 403 admin-ajax.php
### DISABLE mod_security firewall
### Some rules are currently too strict and are blocking legitimate users
### We only disable it for URLs that contain the regex below
### The regex below should be placed between "m#" and "#"
### (this syntax is required when the string contains forward slashes)
### @src https://stackoverflow.com/questions/12928360/how-can-i-disable-mod-security-in-htaccess-file
<IfModule mod_security.c>
<If "%{REQUEST_URI} =~ "m#/wp-admin/admin.php?page=gf_edit_forms/#">
SecFilterEngine Off
</If>
@cipriantepes
cipriantepes / .htaccess
Created June 15, 2017 21:06
WordPress redirect to secure non-www
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
@cipriantepes
cipriantepes / gist:e35e4378449a6c59d7a8500c5b1da858
Created March 22, 2017 18:42 — forked from mohammadmursaleen/gist:9622098e43afdab6025e
Adding custom fields above WOOCOMMERCE add to cart button
<?php
// To add custom data above add to cart button in woocommerce
// step 1
add_action('wp_ajax_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
add_action('wp_ajax_nopriv_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback');
function wdm_add_user_custom_data_options_callback()
@cipriantepes
cipriantepes / .htaccess
Created January 18, 2017 17:31
Host-relative redirect to www (non-domain specific)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
@cipriantepes
cipriantepes / custom-logo.php
Last active September 5, 2016 20:04 — forked from neilgee/custom-logo.php
Using Custom Logo with Genesis via Customizer
<?php
add_theme_support( 'custom-logo', array(
'height' => 240, // set to your dimensions
'width' => 240,
'flex-height' => true,
'flex-width' => true,
) );
@cipriantepes
cipriantepes / Submenu.php
Last active January 9, 2016 01:18
WordPress loop through posts with hierarchy
<?php
private function get_all_posts( $post_id, $type = 'page' ) {
//* $posts is an array
$posts = get_posts( array(
'post_type' => $type,
'post_parent' => $post_id,
'nopaging' => true,
'orderby' => 'menu_order',
'hierarchical' => true,