views: unknown Ajax call in custom views_exposed_filters by changing dropdown list

I have two filters exposed as selected fields (County and District) using Hook_form_ID_alter.

I would like to alter the #base options for the District in the County I selected to show related options.

But somehow the Ajax I wrote has no effect and instead it has other errors of exceeding the load limit as shown in the image.

enter the image description here

The code is written in the theme.module file, any suggestion is appreciated, thanks!

function ajaxReplaceDistrictOptions(&$form, FormStateInterface $form_state) {

    $district = (
       'City1' => (
         'district1' => 'district1',
         'district2' => 'district2',
         'district3' => 'district3',
       ),
       'City2' => (
         'district4' => 'district4',
         'district5' => 'district5',
         'district6' => 'district6',
       )
    );
    if ($selected_value = $form_state->getValue('field_store_address_county')){
        $selected_county = $form('field_store_address_county')('#options')($selected_value);
        $form('field_store_address_district')('#options') = $district($selected_county);
    }

    return $form('field_store_address_district');
}

function theme_form_views_exposed_form_alter (&$form, FormStateInterface $form_state, $form_id) {

    if($form('#id') == "views-exposed-form-s3-shop-map-shops-list" ){

        $county = (
          'County1' => 'County1',
          'County2' => 'County2',
          'County3' => 'County3',
        );

        $form("actions")("submit")("#value") = t('Confirm');

        $county_field = 'field_store_address_county';
        $form($county_field) = (
            '#type' => 'select',
            '#multiple' => FALSE,
            '#empty_option' => t('County'),
            '#options' => $county,
            '#ajax' => (
                'callback' => 'ajaxReplaceDistrictOptions',
                'wrapper' => 'district-list',
                'method' => 'replace',
                'effect' => 'fade',
            )
        );
        unset($form($county_field)('#size'));

        $district_field = 'field_store_address_district';
        $form($district_field) = (
            '#type' => 'select',
            '#multiple' => FALSE,
            '#empty_option' => t('District'),
            '#prefix' => '
', '#suffix' => '
', ); } }

Can you call a function that returns a procedure empty?

I read about function vs procedure
function and procedure both are subroutines but the function returns a value and the procedure does not.

Can a function that returns empty be called a procedure?

Give reasons with definitions …

post meta: how to call function "set_post_meta ()" from javascript?

I want to add the Publish Likes functionality in my custom post type (game). I've put clickable icons and I don't like them game-footer-like-btn in the footer of my post in single.php and in the post file. Now what I want is that when a user presses the like (clickable) icon I want to check if he / she has already voted for it and otherwise create or update the post as a meta count key within the target post and the same goes for the target user. The problem is that when a user presses the Like button, I have to manage it inside the JS but I'm not sure what to call set_post_meta($post->ID) or update_post_meta($post->ID) from JS. Or if there is some other way to avoid it? The following is my code for the custom post loop.

have_posts() ) : $r->the_post();?>

        

       `

WeChat: "The voice call may be compromised and incur charges on the current network"

In a WeChat video call, I periodically see the following message: "The voice call may be compromised and incur charges on the current network," even after pressing OK. What does this mean? How can I prevent this message from appearing again?

Call a plugin function from WordPress theme header file

wp-content / plugins / ultimate-member / includes / core / class-permalinks.php

namespace umcore;
class Permalinks { 
        function __construct() {
            add_action( 'init',  array( &$this, 'activate_account_via_email_link' ), 1 );
        }
}

I want to call this function & # 39; active_account_via_email_link & # 39; from wordpress / theme / header.php

My code so far:

$action = new umcorePermalinks;
$action->activate_account_via_email_link();

The error :
Fatal error: Error not detected: class & # 39; um core Permalinks & # 39; was not found. at /home/xyzz/public_html/xyz/wp-content/themes/university/header-frontpage.php:5 ​​Stack Trace: # 0

views – How to call rest api in Drupal8 after submitting form

I created an internal API call like '/api/v1/user/promotional-emails' this API calls some external APIs and we are updating data there. In postman api works well.

Now i created a user form like '/user/promotional-emails' this form is finely displayed but i have to call a previously created API call '/api/v1/user/promotional-emails'. but it is always giving NULL in response.

I tried to follow the method but it doesn't work. I don't know what to do.

/**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    global $base_url;

    $result1 = $form_state->getValue('option1');
    $result2 = $form_state->getValue('option2');
    $result3 = $form_state->getValue('option3');
    $result4 = $form_state->getValue('option4');

    $json = (
        'headers' => (
          'Content-Type' => 'application/json',
        ),
          'form_params' => (
                  'EmailAddress' => 'test@gmail.com',
                  'EmailOptin' => true,
                  'option1' => $result1,
                  'option2' => $result2,
                  'option3' => $result3,
                  'option4' => $result4
              )
            );
    $options = ('option1' => $result1,'option2' => $result2,'option3' => $result3,'option4' => $result4, 'EmailAddress' => 'test@gmail.com');

Option 1 I tried:

 $url = $base_url . '/api/v1/user/promotional-emails';

     $client = new Client(('verify' => false));

     $rest_response = $client->request('POST', $url, $json);

This is also giving NULL

Option 2 I tried

$client = Drupal::service('http_client_factory')->fromOptions(array('verify' => FALSE));
    $request = $client->post($base_url.'/api/v1/user/promotional-emails', $options);
    $response = json_decode($request->getBody());

Here too I am becoming null. Can any body help me in this?

My API call function is like this.

public function unsubscribeEmail(Request $request) {
    // Get post body data in json.
    $requestContent = json_decode($request->getContent(), TRUE);
    // Get token.
    print_r($request); exit;
}

swift: if the screen doesn't change, ReplayKit doesn't call processSampleBuffer () with video

I am trying to publish the iOS screen using ReplayKit2 through the RTMP protocol.

The main problem is that if the screen doesn't change, ReplayKit doesn't call processSampleBuffer () with video in landscape mode.

If ReplayKit does not call processSampleBuffer, the application does not send any packets to the RTMP server, so the RTMP live stream stops.

I want ReplayKit to keep the processSampleBuffer call even when there are no changes on the screen.

Online sharepoint – Role Assignment – Get MemberId and RoleDefinitionBindings in a REST API call

I want to get all the role assignments for a site with MemberId and RoleDefinitionBindings. I list the role assignments for some site with call _api/web/roleassignmentsThen for each role assignment I make 2 additional calls: to get MemberId and RoleDefinitionBindings.

Unfortunately, that is too slow. Is there a way to do this in fewer calls to the REST API?

a 6 confident comments for the movie The Call of the Wild

Watch The Call of the Wild online

javascript – Magento 2: Call a JS function from another JS file?

You are Accessing a JS function from another JS file solution not assigned to my problem, please give me instructions on how I can call getPureValue: function () from tax.js somewhere in minicart.js

tax.js

 /**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * @api
 */

define((
    'ko',
    'Magento_Checkout/js/view/summary/abstract-total',
    'Magento_Checkout/js/model/quote',
    'Magento_Checkout/js/model/totals',
    'mage/translate',
    'underscore'
), function (ko, Component, quote, totals, $t, _) {
    'use strict';

    var isTaxDisplayedInGrandTotal = window.checkoutConfig.includeTaxInGrandTotal,
        isFullTaxSummaryDisplayed = window.checkoutConfig.isFullTaxSummaryDisplayed,
        isZeroTaxDisplayed = window.checkoutConfig.isZeroTaxDisplayed,
        taxAmount = 0,
        rates = 0;

    return Component.extend({
        defaults: {
            isTaxDisplayedInGrandTotal: isTaxDisplayedInGrandTotal,
            notCalculatedMessage: $t('Not yet calculated'),
            template: 'Magento_Tax/checkout/summary/tax'
        },
        totals: quote.getTotals(),
        isFullTaxSummaryDisplayed: isFullTaxSummaryDisplayed,

        /**
         * @return {Boolean}
         */
        ifShowValue: function () {
            if (this.isFullMode() && this.getPureValue() == 0) { //eslint-disable-line eqeqeq
                return isZeroTaxDisplayed;
            }

            return true;
        },

        /**
         * @return {Boolean}
         */
        ifShowDetails: function () {
            if (!this.isFullMode()) {
                return false;
            }

            return this.getPureValue() > 0 && isFullTaxSummaryDisplayed;
        },

        /**
         * @return {Number}
         */
        getPureValue: function () {
            var amount = 0,
                taxTotal;

            if (this.totals()) {
                taxTotal = totals.getSegment('tax');

                if (taxTotal) {
                    amount = taxTotal.value;
                }
            }
            console.log(amount);
                console.log('getPureValue');
            return amount;
        },

        /**
         * @return {*|Boolean}
         */
        isCalculated: function () {
             console.log('isCalculated');
            return this.totals() && this.isFullMode() && totals.getSegment('tax') != null;
        },

        /**
         * @return {*}
         */
        getValue: function () {
            var amount;
             console.log('getValue');
             console.log(amount);
            if (!this.isCalculated()) {
                return this.notCalculatedMessage;
            }
            amount = totals.getSegment('tax').value;

            return this.getFormattedPrice(amount);
        },

        /**
         * @param {*} amount
         * @return {*|String}
         */
        formatPrice: function (amount) {
            return this.getFormattedPrice(amount);
        },

        /**
         * @param {*} parent
         * @param {*} percentage
         * @return {*|String}
         */
        getTaxAmount: function (parent, percentage) {
            var totalPercentage = 0;
 console.log('getTaxAmount');
            taxAmount = parent.amount;
            rates = parent.rates;
            _.each(rates, function (rate) {
                totalPercentage += parseFloat(rate.percent);
            });

            return this.getFormattedPrice(this.getPercentAmount(taxAmount, totalPercentage, percentage));
        },

        /**
         * @param {*} amount
         * @param {*} totalPercentage
         * @param {*} percentage
         * @return {*|String}
         */
        getPercentAmount: function (amount, totalPercentage, percentage) {
             console.log('getPercentAmount');
            return parseFloat(amount * percentage / totalPercentage);
        },

        /**
         * @return {Array}
         */
        getDetails: function () {
            var taxSegment = totals.getSegment('tax');
 console.log('getDetails');
            if (taxSegment && taxSegment('extension_attributes')) {
                return taxSegment('extension_attributes')('tax_grandtotal_details');
            }

            return ();
        }
    });
});

minicart.js

 /**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

define((
    'uiComponent',
    'Magento_Customer/js/customer-data',
    'jquery',
    'ko',
    'underscore',
    'sidebar',
    'mage/translate',
    'mage/dropdown'
), function (Component, customerData,$, ko, _) {
    'use strict';

    var sidebarInitialized = false,
        addToCartCalls = 0,
        miniCart;

    miniCart = $('(data-block='minicart')');

    /**
     * @return {Boolean}
     */
    function initSidebar() {
        if (miniCart.data('mageSidebar')) {
            miniCart.sidebar('update');
        }

        if (!$('(data-role=product-item)').length) {
            return false;
        }
        miniCart.trigger('contentUpdated');

        if (sidebarInitialized) {
            return false;
        }
        sidebarInitialized = true;
        miniCart.sidebar({
            'targetElement': 'div.block.block-minicart',
            'url': {
                'checkout': window.checkout.checkoutUrl,
                'update': window.checkout.updateItemQtyUrl,
                'remove': window.checkout.removeItemUrl,
                'loginUrl': window.checkout.customerLoginUrl,
                'isRedirectRequired': window.checkout.isRedirectRequired
            },
            'button': {
                'checkout': '#top-cart-btn-checkout',
                'remove': '#mini-cart a.action.delete',
                'close': '#btn-minicart-close'
            },
            'showcart': {
                'parent': 'span.counter',
                'qty': 'span.counter-number',
                'label': 'span.counter-label'
            },
            'minicart': {
                'list': '#mini-cart',
                'content': '#minicart-content-wrapper',
                'qty': 'div.items-total',
                'subtotal': 'div.subtotal span.price',
                'maxItemsVisible': window.checkout.minicartMaxItemsVisible
            },
            'item': {
                'qty': ':input.cart-item-qty',
                'button': ':button.update-cart-item'
            },
            'confirmMessage': $.mage.__('Are you sure you would like to remove this item from the shopping cart?')
        });
    }

    miniCart.on('dropdowndialogopen', function () {
        initSidebar();
    });

    return Component.extend({
        shoppingCartUrl: window.checkout.shoppingCartUrl,
        maxItemsToDisplay: window.checkout.maxItemsToDisplay,
        cart: {},

        // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
        /**
         * @override
         */
        initialize: function () {
            var self = this,
                cartData = customerData.get('cart');

            this.update(cartData());
            cartData.subscribe(function (updatedCart) {
                addToCartCalls--;
                this.isLoading(addToCartCalls > 0);
                sidebarInitialized = false;
                this.update(updatedCart);
                initSidebar();
            }, this);
            $('(data-block="minicart")').on('contentLoading', function () {
                addToCartCalls++;
                self.isLoading(true);
            });

            if (
                cartData().website_id !== window.checkout.websiteId && cartData().website_id !== undefined ||
                cartData().storeId !== window.checkout.storeId && cartData().storeId !== undefined
            ) {
                customerData.reload(('cart'), false);
            }

            return this._super();
        },


        //jscs:enable requireCamelCaseOrUpperCaseIdentifiers

        isLoading: ko.observable(false),
        initSidebar: initSidebar,

        /**
         * Close mini shopping cart.
         */
        closeMinicart: function () {
            $('(data-block="minicart")').find('(data-role="dropdownDialog")').dropdownDialog('close');
        },


        /**
         * @return {Boolean}
         */
        closeSidebar: function () {
            var minicart = $('(data-block="minicart")');

            minicart.on('click', '(data-action="close")', function (event) {
                event.stopPropagation();
                minicart.find('(data-role="dropdownDialog")').dropdownDialog('close');
            });

            return true;
        },


        /**
         * @param {String} productType
         * @return {*|String}
         */
        getItemRenderer: function (productType) {
            return this.itemRenderer(productType) || 'defaultRenderer';
        },

        /**
         * Update mini shopping cart content.
         *
         * @param {Object} updatedCart
         * @returns void
         */
        update: function (updatedCart) {
            console.log('helloworld');
            _.each(updatedCart, function (value, key) {
                if (!this.cart.hasOwnProperty(key)) {
                    this.cart(key) = ko.observable();
                }
                this.cart(key)(value);
            }, this);
        },

        /**
         * Get cart param by name.
         * @param {String} name
         * @returns {*}
         */
        getCartParam: function (name) {
            if (!_.isUndefined(name)) {
                if (!this.cart.hasOwnProperty(name)) {
                    this.cart(name) = ko.observable();
                }
            }
console.log('helloworld');
            return this.cart(name)();

        },

        /**
         * Returns array of cart items, limited by 'maxItemsToDisplay' setting
         * @returns ()
         */
        getCartItems: function () {
            var items = this.getCartParam('items') || ();

            items = items.slice(parseInt(-this.maxItemsToDisplay, 10));
console.log('helloworld');
            return items;
        },

        /**
         * Returns count of cart line items
         * @returns {Number}
         */
        getCartLineItemsCount: function () {
            var items = this.getCartParam('items') || ();

            return parseInt(items.length, 10);
        }
    });
});