Support » Plugin: Apaczka.pl Mapa Punktów » Translation – WP 5.6

  • 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 1 year, 4 months ago by Yui. Reason: please use CODE button for code formatting
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Translation – WP 5.6’ is closed to new replies.