Skip to content

Instantly share code, notes, and snippets.

<?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 / 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',
@Maden-maxi
Maden-maxi / sticky_footer.js
Created August 18, 2017 17:02
logic of sticky footer
@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 / 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' => '=',