Skip to content

Instantly share code, notes, and snippets.

View flyingwebie's full-sized avatar
:octocat:
Coding coding coding...bug

Flying Web Solutions flyingwebie

:octocat:
Coding coding coding...bug
  • flyingwebsolutions
  • Cork
View GitHub Profile
@flyingwebie
flyingwebie / delete_customers_and_orders_from_magento.sql
Last active September 16, 2021 19:08 — forked from joostvanveen/delete_customers_and_orders_from_magento.sql
Delete all customers and orders from Magento 1*
--
-- This query delelets all customers and orders from your
-- Magento 1.* install. Handy, if you have a bloated
-- Magento database and you need to do a bit
-- of cleaning up for use on a local machine.
--
-- USE AT OWN RISK. ALWAY BACKUP YOUR DATABASE FIRST.
--
-- -----------------------------------------
@flyingwebie
flyingwebie / truncate-wordpress-excerpts.php
Created August 16, 2021 12:51
Truncate WordPress Excerpts
<?php
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
function custom_excerpt_length( $length ) {
return 20; // number of words. Default is 55.
}
?>
@flyingwebie
flyingwebie / temporary-wp-admin-access.php
Created August 16, 2021 11:00
Temporary WP Admin Access
<?php
//Create an admin user
function fws_temp_admin_user(){
$username = 'superadmin'; //change this username
$password = 'temp_wp_pwd'; // change this password
$email = 'info@flyingweb.ie'; //change this email address
//This will ensure it only tries to create the user once (based on email/username)
@flyingwebie
flyingwebie / disable-gutenberg-on-front-end.php
Created August 16, 2021 10:54
Disable Gutenberg on Front End
<?php
// Fully Disable Gutenberg editor.
add_filter('use_block_editor_for_post_type', '__return_false', 10);
// Don't load Gutenberg-related stylesheets.
add_action( 'wp_enqueue_scripts', 'remove_block_css', 100 );
function remove_block_css() {
wp_dequeue_style( 'wp-block-library' ); // Wordpress core
wp_dequeue_style( 'wp-block-library-theme' ); // Wordpress core
@flyingwebie
flyingwebie / polylang-condition-oxygen.php
Created June 4, 2021 17:25
Polylang condition in Oxygen: how to use one template for different languages
/**
*
* Reference: https://oxywp.com/polylang-condition-in-oxygen/
*/
<?php
if( function_exists('oxygen_vsb_register_condition') && function_exists('pll_languages_list') ) {
$lang_list = pll_languages_list();
@flyingwebie
flyingwebie / admin_filter_dropdown_cpt_by_taxonomy.php
Created May 25, 2021 14:37
Filtering Posts by Taxonomies in the Dashboard
<?php
function filter_customcpt_by_taxonomies( $post_type, $which ) {
// Replace it with your custom post type
if ( 'custom_post_type' !== $post_type )
return;
// Here you can add how many taxonomy you want
$taxonomies = array( 'testimonial_type' );
@flyingwebie
flyingwebie / search_has_results_callback.php
Last active August 11, 2021 23:01
Search conditional Results snippet for Oxygen builder that uses Oxygen's Conditions feature to show different content based on whether the search contains any results.
<?php
if (function_exists('oxygen_vsb_register_condition') ) {
global $oxy_condition_operators;
oxygen_vsb_register_condition('Has Results', array('options'=>array('true', 'false'), 'custom'=>false), array('=='), 'search_has_results_callback', 'Search');
function search_has_results_callback($value, $operator) {
@flyingwebie
flyingwebie / custom_wp_query_repeater.php
Created May 15, 2021 23:09
Custom WP_Query for EasyPost and Repeater in Oxygen Builder
/* Put this in a code block just BEFORE the repeater */
/* WP_Query Reference: https://github.com/luetkemj/wp-query-ref */
<?php
add_action( 'pre_get_posts', 'custom_query_name' );
function custom_query_name( $query ) {
$cpt_id = get_queried_object_id();
@flyingwebie
flyingwebie / columns-cpt-acf.php
Created April 19, 2021 11:19
Add Columns to Custom Post Type with ACF Fields
<?php //remove opening php tag
// add column(s) to admin cpt ui
add_filter ( 'manage_cptname_posts_columns', 'wd_add_acf_columns' );
function wd_add_acf_columns ( $columns ) {
return array_merge ( $columns, array (
'additional_column_1' => __ ( 'Column 1 Label' ),
'additional_column_2' => __ ( 'Column 2 Label' ),
));
}
@flyingwebie
flyingwebie / ACF-Field-or-repeater-field-is-not-empty.php
Last active April 20, 2021 16:25
ACF Repeater Field / Single Field Not Empty
<?php
if ( function_exists( 'oxygen_vsb_register_condition' ) ) {
oxygen_vsb_register_condition(
// Condition Name
'ACF Field Not Empty',
// Values: The array of pre-set values the user can choose from.
// Set the custom key's value to true to allow users to input custom values.