• Resolved Patryk

    (@triloworld)


    Hello, this plugin need update. Now it won’t show language correct.

    Solution in my own instance that need to be added to plugin:

    File: apaczka-pl-mapa-punktow/apaczka-points-map.php

    Code modified (check include_translations hook and new method for loading translations):

    
    <?php
    /**
     * Plugin Name: Apaczka.pl Mapa Punktów
     * Description: Wtyczka pozwoli Ci w prosty sposób skonfigurować i wyświetlić mapę punktów dla twoich metod dostawy tak aby twój Klient mógł wybrać punkt, z którego chce odebrać przesyłkę.
     * Version:     1.0.2
     * Text Domain: apaczka-pl-mapa-punktow
     * Author:      Inspire Labs
     * Author URI:  https://inspirelabs.pl/
    
     * Domain Path: /languages
     *
     * WC tested up to: 4.8
     *
     * Copyright 2020 Inspire Labs sp. z o.o.
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 2 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program; if not, write to the Free Software
     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     *
     * @package Mapa Punktów WooCommerce
     */
    
    namespace Apaczka_Points_Map;
    
    // If this file is called directly, abort.
    if ( ! defined( 'ABSPATH' ) ) {
    	exit;
    }
    
    define( 'APACZKA_POINTS_MAP_DIR_URL', plugin_dir_url( __FILE__ ) );
    define( 'APACZKA_POINTS_MAP_DIR', plugin_dir_path( __FILE__ ) );
    	
    /**
     * Main plugin helper.
     */
    class Points_Map_Plugin {
    	/**
    	 * Maps_Plugin constructor.
    	 */
    	public function __construct() {
    		$this->init_hooks();
    	}
    
    	/**
    	 * Init Hooks.
    	 */
    	public function init_hooks() {
    		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_front_scripts' ) );
    		add_action( 'woocommerce_integrations_init', array( $this, 'include_wc_integration_class' ) );
    		add_filter( 'woocommerce_integrations', array( $this, 'add_integration_filter' ) );
    		add_action( 'init', array( $this, 'include_class' ) );
    		add_action( 'init', array( $this, 'include_translations' ) );
    		add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
    	}
    
    	/**
    	 * Includes front scripts.
    	 */
    	public function enqueue_front_scripts() {
    		if ( ! function_exists( 'get_plugin_data' ) ) {
    			require_once ABSPATH . 'wp-admin/includes/plugin.php';
    		}
    
    		$plugin_data = get_plugin_data( __FILE__ );
    
    		wp_enqueue_style( 'apaczka-points-map-style', APACZKA_POINTS_MAP_DIR_URL . 'public/css/apaczka-points-map.css', '', $plugin_data['Version'] );
    		wp_enqueue_script( 'apaczka-client-map-js', 'https://mapa.apaczka.pl/client/apaczka.map.js', '', $plugin_data['Version'], false );
    	}
    
    	/**
    	 * Include class integration with WooCommerce.
    	 */
    	public function include_wc_integration_class() {
    		if ( ! class_exists( 'Maps_Integration' ) ) {
    			require_once APACZKA_POINTS_MAP_DIR . 'includes/class-wc-settings-integration.php';
    		}
    	}
    
    	/**
    	 * WooCommerce integration init.
    	 *
    	 * @param array $integrations .
    	 * @return mixed
    	 */
    	public function add_integration_filter( $integrations ) {
    		$integrations[] = 'Apaczka_Points_Map\WC_Settings_Integration';
    		return $integrations;
    	}
    
    	/**
    	 * Include translations.
    	 */
    	public function include_translations() {
    		load_plugin_textdomain( 'apaczka-pl-mapa-punktow', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 
    	}
    	
    	/**
    	 * Include required class.
    	 */
    	public function include_class() {
    		require_once APACZKA_POINTS_MAP_DIR . 'includes/sdk/api.class.php';
    	}
    
    	/**
    	 * Display plugin action links.
    	 *
    	 * @param array $links .
    	 * @return array
    	 */
    	public function plugin_action_links( $links ) {
    		$plugin_links = array(
    			'<a href="' . admin_url( 'admin.php?page=wc-settings&tab=integration&section=woocommerce-maps-apaczka' ) . '">' . __( 'Settings', 'apaczka-pl-mapa-punktow' ) . '</a>',
    		);
    
    		return array_merge( $plugin_links, $links );
    	}
    }
    
    if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
    	new Points_Map_Plugin();
    	require_once APACZKA_POINTS_MAP_DIR . 'includes/class-shipping-integration-helper.php';
    	require_once APACZKA_POINTS_MAP_DIR . 'includes/class-wc-shipping-integration.php';
    	require_once APACZKA_POINTS_MAP_DIR . 'includes/class-delivery-points-map.php';
    
    	if ( in_array( 'flexible-shipping/flexible-shipping.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
    		require_once APACZKA_POINTS_MAP_DIR . 'includes/class-flexible-shipping-integration.php';
    	}
    }
    
    • This topic was modified 3 years, 3 months ago by Yui. Reason: please use CODE button for code formatting
Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author ilabs

    (@inspirelabs)

    Hello,

    I tested the plugin again in WP 5.6. The translation works correctly in the Polish and English language versions.

    Can you explain exactly what the problem is?

    As for your fix
    “Since WordPress 4.6 translations now take translate.wordpress.org as priority and so plugins that are translated via translate.wordpress.org do not necessary require load_plugin_textdomain () anymore. If you don’t want to add a load_plugin_textdomain () call to your plugin you have to set the Requires at least: field in your readme.txt to 4.6.”
    https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#loading-text-domain

    I also have a translation problem. Despite the selected Polish language, I have the English words “Select a Delivery Point” on the order finalization page.

    WP: 5.6
    Plugin: 1.0.2
    PHP: 8.0

    • This reply was modified 3 years, 3 months ago by bfaliszek.
    Plugin Author ilabs

    (@inspirelabs)

    Finally, I found the cause of this issue. We have a problem with the Polish translation at https://translate.wordpress.org/. In this case, I used load_plugin_textdomain as suggested by Patryk (@triloworld). Please update the plugin to the new version v1.1.0.

    • This reply was modified 3 years, 3 months ago by ilabs.

    v1.1.0 fixed the translation problem in my case, but now the map with delivery points does not open. With the previous version, the plugin opened correctly and worked.

    Plugin Author ilabs

    (@inspirelabs)

    bfaliszek (@bfaliszek) can you send more details? Does the browser console show any java script error? Can you send the address of your online store?

    @inspirelabs
    JS error:

    Uncaught ReferenceError: ApaczkaMap is not defined
        at (index):161

    link to store: https://myopenair.com/sklep/

    Plugin Author ilabs

    (@inspirelabs)

    bfaliszek thanks for submitting the error details. We have fixed this bug. Please update the plugin to v1.1.1.

    @inspirelabs

    after updating to v1.1.1 I have exactly the same error as before. Map still not working

    Plugin Author ilabs

    (@inspirelabs)

    bfaliszek we need to check your WordPress theme to solve this problem. Please contact directly to pawel.tarasiuk@inspirelabs.pl.

    Plugin Author ilabs

    (@inspirelabs)

    We checked the Hestia theme (v3.0.8). Everything is ok, the map opens correctly. Below is a link to the test page (WP 5.6, WooCommerce 4.9.1, Apaczka.pl Points Map v1.1.1)
    https://hestia.sc.testbox.pro/

    Has your Hestia theme been modified? It seems there is no call to the action “wp_body_open” which is responsible for the init of the map.
    Perhaps the error is caused by a conflict with another plugin you are using. Try to disable all plugins except Apaczka.pl Map Points and WooCommerce.
    If this does not help, please contact us directly, we will need access to your website to perform the analysis.

    Plugin Author ilabs

    (@inspirelabs)

    We have released a new version of the plugin (v1.1.2) in which the map call has been moved to a separate js file. This is the solution to the problem of opening the map in custom themes.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Translation – WP 5.6’ is closed to new replies.