Add woocommerce filter after ajax function [closed]

Below is my function which runs on ajax and it upload image in media, now i want to add this in my woocomerrce cart but it does not work.

here $cart_item_meta returns path of the file in array.

function my_action_callback(  ){

            $addon_id = array();

            if( isset($_FILES) ){

$attach_info=wp_upload_bits($_FILES["file"]["name"], null, file_get_contents($_FILES["file"]["tmp_name"]));

$attach_id = wp_insert_attachment($data, $attach_info['file'], 0);

                $addon_id['media_id'] = $attach_id;
                $addon_id['media_url'] = wp_get_attachment_url( esc_attr( $attach_id ) );
                $cart_item_meta['wau_addon_ids'][] = $addon_id;

            add_filter( 'woocommerce_add_cart_item_data', $cart_item_meta, 10, 2 );


Go to Source
Author: Vishal

Inline Styles on all native blocks

Is it possible to apply inline styles to all blocks via filters? Or do only some blocks support it? basically I want to add the ability of adding a background image to a single column.
So I added an extra attribute to store the background img url (named backgroundImg) and tested that its saved.

I am trying to use blocks.getSaveContent.extraProps to apply the background image to the inline style like so..

if ("wp-block-column" === props.className) {
    return lodash.merge(props, {
        style: {
            backgroundImage: "url(" + props.backgroundImg + ")",

When I run this however the background IMG url is ‘undefined’. However I have tested and know that props.backgroundImg is being saved. I can add more of my code as needed, but any ideas on why it isn’t applying the saved url?

Go to Source
Author: user13989254

How to add ‘total’ value to custom column title on the posts list page

I have added custom column to all posts page by this code:

function len_columns_head($defaults) {
    $defaults['post_len'] = 'Symbols';
    return $defaults;
function len_columns_content($column_name, $post_ID) {
    if ($column_name == 'post_len') {
        $post    = get_post($post_ID); 
        $content = $post->post_content;
        $length  = strlen($content);
        if ($length) {
            echo $length.' symbols';

add_filter('manage_posts_columns', 'len_columns_head');
add_action('manage_posts_custom_column', 'len_columns_content', 10, 2);

but now i need to add total count of symbols to column title like this: “Symbols, 123456 total”. How can i achieve this? I have tried to add global variable to functions.php and add $length to it on every len_columns_content call, but that didn’t work

Go to Source
Author: dmitry

How would I go about replacing this function in my child theme located in inc/template-tags.php

How would I replace this function that lies inside inc/template-tags.php in my parent theme

function theme_navigation() {
        <div id="theme-nav-container">
            <nav id="site-navigation" class="main-navigation">
                <?php wp_nav_menu( array('theme_location' => 'theme-studios-primary', 'menu_class' => 'sf-menu', 'fallback_cb' => false, 'walker'  => new theme ) ); ?><div class="clearfix-pro"></div>
            <div class="clearfix-pro"></div>
        <!-- close #theme-nav-container -->

There is no add action that it is hooked on to, there is no check to see if the function already exists. How would I replace it without touching the parent theme. I have removed much of the code in the function for brevity but I think it still makes sense.

Thanks ahead of time

Go to Source
Author: Anders Kitson