Skip to content

Instantly share code, notes, and snippets.

@Maden-maxi
Maden-maxi / avada-options.php
Created December 23, 2017 16:32
Filter for avada theme options
<?php
add_filter('avada_options_sections', 'avada_child_options_sections');
function avada_child_options_sections( $sections )
{
$sections['header']['fields']['header_info_1']['fields']['header_layout']['choices']['v8'] = AVADA_CHILD_THEME_DIR_URI . '/assets/img/header-pattern/header-8.png';
$sections['header']['fields']['header_info_1']['fields']['header_number']['required'][] = array(
'setting' => 'header_layout',
'operator' => '=',
@Maden-maxi
Maden-maxi / download_external.php
Last active August 25, 2017 14:54
Download exteranls scripts
<?php
function download_file( $file_url, $save_to ) {
$content = file_get_contents( $file_url );
file_put_contents( $save_to, $content );
}
if ( ! wp_next_scheduled( 'download_external_scripts_cron_hook' ) ) {
wp_schedule_event( time(), 'daily', 'download_external_scripts_cron_hook' );
}
@Maden-maxi
Maden-maxi / sticky_footer.js
Created August 18, 2017 17:02
logic of sticky footer
@Maden-maxi
Maden-maxi / wp_hierachy_categegories.php
Created July 10, 2017 11:32
Create a rest route with response categories in hiearachical structure
<?php
/**
* Class GK_Category_Walker
*/
class GK_Category_Walker extends Walker_Category{
public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
/** This filter is documented in wp-includes/category-template.php */
$cat_name = apply_filters(
'list_cats',
<?php
function color_inverse_rgb($color){
$rgb = trim( $color );
if( strrpos($rgb, 'rgb') ){
$rgb = str_replace('rgb(', '', $rgb);
$rgb = str_replace(')','',$rgb);
$rgb_array = explode(',',$rgb);
foreach ($rgb_array as $key => $rgb_color ){
$rgb_array[$key] = 255 - (int)$rgb_color;
}
@Maden-maxi
Maden-maxi / hide_for_page_speed_insights.php
Created June 20, 2017 08:16
Not display content if site tested by Google Page Speed Insights
<?php if (!isset($_SERVER['HTTP_USER_AGENT']) || stripos($_SERVER['HTTP_USER_AGENT'], 'Speed Insights') === false): ?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-46357715-1', 'auto');
ga('send', 'pageview');
</script>
@Maden-maxi
Maden-maxi / loop-module.ejs
Last active June 7, 2017 16:26
loop module number
<%
for(var i=0; i < quantity; i++ ) {
var modIncrement = i+1;
var mod = modIncrement % 3;
if( ( mod == 1 ) ){
%>
<%- include('user/page-start', {index: i}); %>
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
add_filter( 'fw_ext_page_builder_content_wrapper_class', '_fw_page_builder_wrapper_class' );
function _fw_page_builder_wrapper_class($class)
{
return 'my-custom-wrapper-class';
}
@Maden-maxi
Maden-maxi / .htaccess
Created April 10, 2017 08:51 — forked from markredballoon/.htaccess
Wordpress .htaccess with gzip compression and client side caching
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress