Skip to content

Instantly share code, notes, and snippets.

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

Nitin Yawalkar yawalkar

🏠
Working from home
View GitHub Profile
@yawalkar
yawalkar / function.php
Created September 12, 2022 13:14
Get user details on logout with custom action
add_action( 'wp_logout', 'flowmattic_custom_logout' );
function flowmattic_custom_logout( $user_id ) {
$user_details = array();
$current_user = get_user_by( 'ID', $user_id );
$user_details['username'] = $current_user->user_login;
$user_details['user_email'] = $current_user->user_email;
$user_details['user_first_name'] = $current_user->user_firstname;
$user_details['user_last_name'] = $current_user->user_lastname;
$user_details['user_display_name'] = $current_user->display_name;
@yawalkar
yawalkar / functions.php
Last active September 26, 2022 14:39
Upload base64 encoded image to WordPress using FlowMattic
<?php
/**
* Save the base64 encoded image in WP.
*
* @param string $title Image title without extension.
* @param string $base64_img Base64 encoded image string.
*/
function flowmattic_save_base64_image( $title, $base64_img ) {
// Upload dir.
@yawalkar
yawalkar / webhook-response.php
Created July 29, 2022 20:31
Customize the webhook response being sent to the source in FlowMattic
<?php
/**
* Alter the response sent from webhook to the source.
*
* @param array $response Original response being sent to the source.
* @param string $workflow_id The workflow ID.
* @param array $capture_data Data captured in the webhook.
*
* @return array
*/
@yawalkar
yawalkar / user-element-message-filter.php
Last active June 22, 2018 07:22
User Element Registration Messages Filter
// Update strings with custom branding strings.
add_filter( 'fusion_user_login_notices_array', 'update_registration_messages_text', 10, 3 );
/**
* Update strings with the new ones.
*
* @access public
* @since 1.0
* @param array $notice_array Array with default messages.
* @param string $action The current action performed by user.
@yawalkar
yawalkar / logo-position.js
Created May 28, 2018 14:22
Move logo position in Avada header v7
Add the code in "Space befor </head>" option -
<script type="text/javascript">
jQuery( 'document' ).ready( function() {
jQuery( '.fusion-middle-logo-menu-logo.fusion-logo' ).insertAfter( jQuery('.fusion-middle-logo-menu-logo.fusion-logo').siblings(':eq(1)') );
});
</script>
@yawalkar
yawalkar / portfolio-archive.php
Created February 22, 2018 10:55
Change portfolio archive template using filter in Avada child theme
function avada_child_fusion_portfolio_archive_template( $archive_post_template ) {
$archive_portfolio_template = get_stylesheet_directory() . '/templates/archive-avada_portfolio.php';
// Checks if the archive is portfolio.
if ( is_post_type_archive( 'avada_portfolio' )
|| is_tax( 'portfolio_category' )
|| is_tax( 'portfolio_skills' )
|| is_tax( 'portfolio_tags' ) ) {
if ( file_exists( $archive_portfolio_template ) ) {
fusion_portfolio_scripts();
@yawalkar
yawalkar / portfolio-filters.php
Created January 24, 2018 15:37
Avada Portfolio Filters. Change portfolio labels on single portfolio with these filters.
// Project Description.
add_filter( 'fusion_portfolio_post_project_description_label', 'fusion_portfolio_post_project_description_label_change', 99, 4 );
function fusion_portfolio_post_project_description_label_change( $project_desc_html, $project_desc_title, $project_desc_title_style, $project_desc_tag ) {
return '<' . $project_desc_tag . ' style="' . esc_attr__( $project_desc_title_style ) . '">' . esc_html__( 'Project Description New Text', 'fusion-core' ) . '</' . $project_desc_tag . '>';
}
// Project Details.
add_filter( 'fusion_portfolio_post_project_details_label', 'fusion_portfolio_post_project_details_label_change', 99, 3 );
function fusion_portfolio_post_project_details_label_change( $project_details_html, $project_details_title, $project_details_tag ) {
@yawalkar
yawalkar / gettext-filter-multiple.php
Created November 21, 2017 14:31
Use the gettext WordPress filter to change any translatable string. Raw
<?php
/**
* Change text strings
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Border Style' :
$translated_text = __( 'Border Type', 'fusion-builder' );
@yawalkar
yawalkar / gist:d63020d428c1eec3bdae5d7fb9a2e1f1
Created January 25, 2017 13:12 — forked from pdewouters/gist:4526457
Remove the 'View' link from the admin bar for a custom post type
/**
* removes the 'view' link for CPT in the admin bar
*/
function pdw_admin_bar_render() {
global $wp_admin_bar;
if('client' == get_post_type()){
$wp_admin_bar->remove_menu('view');
}
@yawalkar
yawalkar / woo-price-filter-widget-fix.php
Created October 25, 2016 08:07
Fixes WooCommerce price filter widget max price issue
// Override the woocommerce default filter for getting max price for filter widget.
add_filter( 'woocommerce_price_filter_widget_max_amount', 'theme_woocommerce_price_filter_widget_max_amount', 10, 2 );
/**
* Fix max_price issue in price filter widget.
*
* @param int $max_price The price filter form max_price.
* @return int Max price for the filter.
*/
function theme_woocommerce_price_filter_widget_max_amount( $max_price ) {