Plugin Directory

Changeset 2091443

Timestamp:
05/20/2019 12:43:29 PM (5 years ago)
Author:
momo360modena
Message:

manually release 1.1.7

Location:
acf-options-for-polylang
Files:
30 added
9 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • acf-options-for-polylang/trunk/CHANGELOG.md

    r2082004 r2091443  
    11# Changelog
     2
     3
     4
     5
     6
     7
     8
     9
    210
    311## 1.1.6 - 19 Mar 2019
  • acf-options-for-polylang/trunk/README.md

    r2082004 r2091443  
    1 <a href="https://beapi.fr">![Be API Github Banner](assets/images/banner-github.png)</a>
     1<a href="https://beapi.fr">![Be API Github Banner](/banner-github.png)</a>
    22
    33# BEA - ACF Options For Polylang
    44
     5
     6
    57You are using Advanced Custom Fields for creating option pages and you have Polylang installed for awsome multilingual site ?
    68
    7 Sadly, Polylang is not handling ACF's Option Pages. Which means values will be the same for all languages you have set :(
     9Sadly, Polylang is not handling ACF's Option Pages. Which means values will be the same for all languages you have set
    810
    911We are here to save your life ! Once this plugin is activated, you will be able to set a different value for each language, and if none is set, the "All languages" value will be used as default one.
     
    1113# How ?
    1214
    13 This plugin is storing a value for each language into database. <b>That means at activation, all data will not be anymore available, but still in database.</b>Then Polylang's lang is used to get the values from the DB. Simply contribute your option page by selecting the Polylang's language from admin flags ui.
     15This plugin will store a value for each language into database. Then Polylang's languages are used to get the values from the DB. <b>That means at activation, all existing data will not be anymore available, but still in database. You will retrieve it ad plugin deactivation.</b>
     16
     17Then to set and contribute your option page, simply use the Polylang's language admin flags ui.
    1418
    1519# Requirements
    1620
    17 - [WordPress](https://wordpress.org/) 4.7+
    18 - Tested up to 4.9.4
    19 - PHP 5.6
     21- Require [WordPress](https://wordpress.org/) 4.7+ / Tested up to 5.2
     22- Require PHP 5.6
    2023- [Advanced Custom Fields](https://www.advancedcustomfields.com/pro) 5.6.0+
    2124- [Polylang](https://polylang.pro/)
     
    2326# Installation
    2427
    25 Once activated Polylang's languages into admin area will affect ACF's options pages.
     28First activate and configure Polylang in you site.
     29Then activate ACF Options For Polylang to handle ACF Options in setted Polylang's languages.
    2630
    2731## WordPress
     
    4347
    4448- Almost simple fields (text, textarea, links, etc)
    45 - Repeater fields ( with simple fields )
     49- Repeater fields ()
    4650
    4751## More features to come
     
    5256
    5357## Next Roadmap
    54 - todo
     58-
    5559
    5660## Contributing
     
    6367
    6468## For developers
     69
     70
     71
     72
     73
     74
     75
     76
     77
    6578
    6679The plugin is designed to get the Polylang "All languages" value if the current lang one is empty. But if you are not interested about this behaviour, you can programmatically deactivate it using the following filter by setting to false.
     
    95108## License
    96109
    97 BEA - ACF Options for Polylang is licensed under the [GPLv3 or later](LICENSE.md).
     110BEA - ACF Options for Polylang is licensed under the [GPLv or later](LICENSE.md).
  • acf-options-for-polylang/trunk/bea-acf-options-for-polylang.php

    r2082004 r2091443  
    11<?php
     2
     3
     4
     5
     6
     7
     8
     9
     10
    211
    3 /*
    4  Plugin Name: BEA - ACF Options for Polylang
    5  Version: 1.1.6
    6  Plugin URI: https://github.com/BeAPI/acf-options-for-polylang
    7  Description: Add ACF options page support for Polylang.
    8  Author: Be API Technical team
    9  Author URI: https://beapi.fr
    10  Contributors: Maxime Culea
    11  ----
     12Copyright 2018-2019 Be API Technical team (human@beapi.fr)
    1213
    13  Copyright 2018 Be API Technical team (human@beapi.fr)
     14This program is free software; you can redistribute it and/or modify
     15it under the terms of the GNU General Public License as published by
     16the Free Software Foundation; either version 2 of the License, or
     17(at your option) any later version.
    1418
    15  This program is free software; you can redistribute it and/or modify
    16  it under the terms of the GNU General Public License as published by
    17  the Free Software Foundation; either version 2 of the License, or
    18  (at your option) any later version.
     19This program is distributed in the hope that it will be useful,
     20but WITHOUT ANY WARRANTY; without even the implied warranty of
     21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     22.
    1923
    20  This program is distributed in the hope that it will be useful,
    21  but WITHOUT ANY WARRANTY; without even the implied warranty of
    22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    23  GNU General Public License for more details.
    24 
    25  You should have received a copy of the GNU General Public License
    26  along with this program; if not, write to the Free Software
    27  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    28  */
    29 
     24You should have received a copy of the GNU General Public License
     25along with this program; if not, write to the Free Software
     26Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     27*/
    3028
    3129// don't load directly
     
    3533
    3634// Plugin constants
    37 define( 'BEA_ACF_OPTIONS_FOR_POLYLANG_VERSION', '1.1.6' );
     35define( 'BEA_ACF_OPTIONS_FOR_POLYLANG_VERSION', '1.1.' );
    3836define( 'BEA_ACF_OPTIONS_FOR_POLYLANG_MIN_PHP_VERSION', '5.6' );
    3937
     
    4644// Check PHP min version
    4745if ( version_compare( PHP_VERSION, BEA_ACF_OPTIONS_FOR_POLYLANG_MIN_PHP_VERSION, '<' ) ) {
    48     require_once( BEA_ACF_OPTIONS_FOR_POLYLANG_DIR . 'compat.php' );
     46    require_once;
    4947    // possibly display a notice, trigger error
    5048    add_action( 'admin_init', array( 'BEA\PB\Compatibility', 'admin_init' ) );
     49
    5150    // stop execution of this file
    5251    return;
     
    6463
    6564    \BEA\ACF_Options_For_Polylang\Main::get_instance();
     65
     66
     67
     68
    6669}
  • acf-options-for-polylang/trunk/classes/helpers.php

    r2082004 r2091443  
    1 <?php namespace BEA\ACF_Options_For_Polylang;
     1<?php
     2
     3namespace BEA\ACF_Options_For_Polylang;
    24
    35class Helpers {
     
    79     * @param $post_id
    810     *
     11
     12
     13
     14
    915     * @author Maxime CULEA
    10      *
    11      * @since  1.0.4
    12      *
    13      * @return string
    1416     */
    1517    public static function original_option_id( $post_id ) {
    16         // Check if is an object.
    17         // Todo user case.
     18        // $post_id may be an object
    1819        if ( is_object( $post_id ) ) {
    19             // Apply for all cases.
    20             switch ( get_class( $post_id ) ) {
    21                 case 'WP_Term':
    22                     $post_id = $post_id->taxonomy . '_' . $post_id->term_id;
    23                     break;
    24                 case 'WP_Comment':
    25                     $post_id = 'comment_' . $post_id->comment_ID;
    26                     break;
    27                 case 'WP_Post':
    28                     $post_id = $post_id->ID;
    29                     break;
     20            if ( isset( $post_id->post_type, $post_id->ID ) ) { // post
     21                $post_id = $post_id->ID;
     22            } elseif ( isset( $post_id->roles, $post_id->ID ) ) { // user
     23                $post_id = 'user_' . $post_id->ID;
     24            } elseif ( isset( $post_id->taxonomy, $post_id->term_id ) ) { // term
     25                $post_id = acf_get_term_post_id( $post_id->taxonomy, $post_id->term_id );
     26            } elseif ( isset( $post_id->comment_ID ) ) { // comment
     27                $post_id = 'comment_' . $post_id->comment_ID;
     28            } else { // default
     29                $post_id = 0;
    3030            }
     31
     32
     33
     34
     35
    3136        }
    3237
     
    4045     * @param string $post_id
    4146     *
    42      * @since  1.0.2
     47     * @
    4348     * @author Maxime CULEA
    4449     *
    45      * @return bool
     50     * @
    4651     */
    4752    public static function is_option_page( $post_id ) {
    48         $post_id = Helpers::original_option_id( $post_id );
     53        $post_id = ::original_option_id( $post_id );
    4954        if ( false !== strpos( $post_id, 'option' ) ) {
    5055            return true;
     
    5257
    5358        $options_pages = self::get_option_page_ids();
     59
     60
     61
    5462
    55         return ! empty( $options_pages ) && in_array( $post_id, $options_pages );
     63        return );
    5664    }
    5765
    5866    /**
    59      * Get all registered options pages as array [ post_id => page title ]
     67     * Get all registered options pages as array [ menu_slug => post_id ]
     68     *
     69     * @return array
     70     * @author Maxime CULEA
    6071     *
    6172     * @since  1.0.2
    62      * @author Maxime CULEA
    63      *
    64      * @return array
    6573     */
    6674    public static function get_option_page_ids() {
    6775        return wp_list_pluck( acf_options_page()->get_pages(), 'post_id' );
    6876    }
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
    6993}
  • acf-options-for-polylang/trunk/classes/main.php

    r2082004 r2091443  
    1 <?php namespace BEA\ACF_Options_For_Polylang;
     1<?php
     2
     3namespace BEA\ACF_Options_For_Polylang;
    24
    35class Main {
     
    2729     * Get the current Polylang's locale or the wp's one
    2830     *
     31
    2932     * @author Maxime CULEA
    3033     *
    31      * @return bool|string
    3234     */
    3335    public function set_current_site_lang() {
     
    4244     * @param $post_id
    4345     *
     46
     47
     48
    4449     * @author Jukra, Maxime CULEA
    4550     *
    46      * @since  1.1.2
    47      *
    48      * @return string
    4951     */
    5052    public function get_default_reference( $reference, $field_name, $post_id ) {
     
    7375     * @param $field
    7476     *
     77
    7578     * @author Maxime CULEA
    7679     *
    77      * @return mixed|string|void
    7880     */
    7981    public function get_default_value( $value, $post_id, $field ) {
     
    8789         * Activate or deactivate the default value (all languages) for the given post id
    8890         *
    89          * @param bool   $show_default    : whatever to show default for the given post id
     91         * @param bool : whatever to show default for the given post id
    9092         * @param string $original_post_id : the original post id without lang attributes
    9193         *
     
    108110                // Get from array all the not empty strings
    109111                $is_empty = array_filter( $value, function ( $value_c ) {
    110                     return "" !== $value_c;
     112                    return !== $value_c;
    111113                } );
    112114
    113                 if ( ! empty( $is_empty ) ) {
    114                     // Not an array of empty values
     115                if ( ! empty( $is_empty ) ) { // Not an array of empty values
    115116                    return $value;
    116117                }
    117             } else {
    118                 if ( "" !== $value ) {
    119                     // Not an empty string
     118            } elseif ( 'repeater' !== $field['type'] ) {
     119                if ( '' !== $value ) { // Not an empty string
    120120                    return $value;
    121121                }
     
    131131
    132132        // Get the "All language" value
    133         $value = acf_get_metadata( $original_post_id, $field['name'] );
     133        $value = acf_get_ );
    134134
    135135        /**
     
    148148     * @param string $original_post_id
    149149     *
    150      * @since  1.0.2
     150     * @
    151151     * @author Maxime CULEA
    152152     *
    153      * @return string
     153     * @
    154154     */
    155     function set_options_id_lang( $future_post_id, $original_post_id ) {
     155    function set_options_id_lang( $future_post_id, $original_post_id ) {
    156156        // Only on custom post id option page
    157157        if ( ! Helpers::is_option_page( $original_post_id ) ) {
     158
     159
     160
     161
    158162            return $future_post_id;
    159163        }
  • acf-options-for-polylang/trunk/classes/requirements.php

    r2082004 r2091443  
    1 <?php namespace BEA\ACF_Options_For_Polylang;
     1<?php
     2
     3namespace BEA\ACF_Options_For_Polylang;
    24
    35class Requirements {
  • acf-options-for-polylang/trunk/classes/singleton.php

    r2082004 r2091443  
    1 <?php namespace BEA\ACF_Options_For_Polylang;
     1<?php
     2
     3namespace BEA\ACF_Options_For_Polylang;
    24
    35trait Singleton {
     
    1315    final public static function get_instance() {
    1416        if ( is_null( self::$instance ) ) {
    15             self::$instance = new static;
     17            self::$instance = new static;
    1618        }
    1719
     
    3133     * If you want to have actions send at construct
    3234     */
    33     protected function init() {}
     35    protected function init() {
     36    }
    3437
    3538    /**
     
    3841     * @return void
    3942     */
    40     final private function __clone() {}
     43    final private function __clone() {
     44    }
    4145
    4246    /**
     
    4549     * @return void
    4650     */
    47     final private function __wakeup() {}
     51    final private function __wakeup() {
     52    }
    4853}
  • acf-options-for-polylang/trunk/readme.txt

    r2082198 r2091443  
    11=== ACF Options For Polylang ===
    22Contributors: momo360modena, BeAPI, maximeculea, NicolasKulka
    3 Author URI: http://beapi.fr
     3Author URI: http://beapi.fr
    44Plugin URL: https://github.com/BeAPI/acf-options-for-polylang
    55Requires at Least: 4.7
    6 Tested Up To: 4.9.4
     6Tested Up To:
    77Tags: acf, polylang, option, options, options page, advanced custom fields
    8 Stable tag: 1.1.6
     8Stable tag: 1.1.
    99Requires PHP: 5.6
     10
     11
    1012
    1113== Description ==
     
    1719We are here to save your life ! Once this plugin is activated, you will be able to set a different value for each language, and if none is set, the "All languages" value will be used as default one.
    1820
    19 ***Please refer to [Github](https://github.com/BeAPI/acf-options-for-polylang) for detailed usage instructions and issues.***
     21# How ?
    2022
    21 ## Features
     23This plugin will store a value for each language into database. Then Polylang's languages are used to get the values from the DB. <b>That means at activation, all existing data will not be anymore available, but still in database. You will retrieve it at plugin deactivation.</b>
     24
     25Then to set and contribute your option page, simply use the Polylang's language admin flags ui.
     26
     27# Features
    2228
    2329- Almost simple fields (text, textarea, links, etc)
    2430- Repeater fields (with simple fields)
    2531
    26 **How ?**
     32# Who ?
    2733
    28 This plugin will store a value for each language into database. Then Polylang's languages are used to get the values from the DB. <b>That means at activation, all existing data will not be anymore available, but still in database. You will retrieve it ad plugin deactivation.</b>
     34Created by [Be API](https://beapi.fr), the French WordPress leader agency since 2009. Based in Paris, we are more than 30 people and always [hiring](https://beapi.workable.com) some fun and talented guys. So we will be pleased to work with you.
    2935
    30 Then to set and contribute your option page, simply use the Polylang's language admin flags ui.
     36Th.
    3137
    32 == Frequently Asked Questions ==
     38To facilitate the process of submitting an issue and quicker answer, we only use Github, so don't use WP.Org support, it will not be considered.
    3339
    34 **Requirements**
    35 
    36 * [Advanced Custom Fields](https://www.advancedcustomfields.com/pro) 5.6.0+
    37 * [Polylang](https://polylang.pro/)
    38 
    39 **Installation**
     40== Installation ==
    4041
    4142First activate and configure ACF & Polylang on you site.
    4243Then activate ACF Options For Polylang to handle ACF Options in setted Polylang's languages.
    4344
    44 ***WordPress***
     45= Requirements =
     46
     47- WordPress 4.7+ / Tested up to 5.2
     48- Require PHP 5.6
     49- [Advanced Custom Fields Pro (5.6.0+)](https://www.advancedcustomfields.com/pro)
     50- [Polylang](https://polylang.pro)
     51
     52= WordPress =
    4553
    4654- Download and install using the built-in WordPress plugin installer.
     
    4957- Nothing more, this plugin is ready to use !
    5058
    51 ***Composer***
    52 
    53 - Add repository source : `{ "type": "vcs", "url": "https://github.com/BeAPI/acf-options-for-polylang" }`.
    54 - Include `"bea/acf-options-for-polylang": "dev-master"` in your composer file for last master's commits or a tag released.
    55 - Nothing more, this plugin is ready to use !
    56 
    5759== Changelog ==
    5860
    59 * 1.1.6 - 19 Mar 2019
    60     * FIX [#32](https://github.com/BeAPI/acf-options-for-polylang/issues/32) & [#40](https://github.com/BeAPI/acf-options-for-polylang/issues/40) : fix `get_field()` if an object is provided (WP Term, WP Post, WP Comment)
    61 * 1.1.5 - 11 Dec 2018
    62     * FIX wrong constant
    63 * 1.1.4 - 13 Nov 2018
    64     * Refactor by adding the Helpers class
    65     * FEATURE [#26](https://github.com/BeAPI/acf-options-for-polylang/issues/26) : allow to precise to show or hide default values for a specific option page
    66     * FEATURE [#21](https://github.com/BeAPI/acf-options-for-polylang/pull/21) : handle custom option id
    67 * 1.1.3 - 2 Aug 2018
    68     * FEATURE [#23](https://github.com/BeAPI/acf-options-for-polylang/pull/23) : requirement to php5.6 whereas namespace are 5.3
    69 * 1.1.2 - 31 Jul 2018
    70     * FIX [#22](https://github.com/BeAPI/acf-options-for-polylang/pull/22) : error with repeater fields default values
    71 * 1.1.1 - 9 Mai 2018
    72     * FIX [#15](https://github.com/BeAPI/acf-options-for-polylang/issues/15) : way requirements are checked to trigger on front / admin
    73 * 1.1.0 - Mar 2018
    74     * True (complet) plugin.
    75     * Add check for ACF 5.6.
    76 * 1.0.2 - 23 Dec 2017
    77     * Refactor and reformat.
    78     * Handle all options page and custom post_id.
    79     * Now load only if ACF & Polylang are activated.
    80     * Load later at plugins loaded.
    81 * 1.0.1 - 19 Sep 2016
    82     * Plugin update.
    83 * 1.0.0 - 8 Mar 2016
    84     * Init plugin.
     61= 1.1.7 - 07 May 2019 =
     62- Feature: Add a context-sensitive help to the user on ACF options page (tired of updating the generic options ...)
     63- Improve: object detection from ACF with get_field()
     64- Feature: Add translation POT and french translation
     65- FEATURE [#31](https://github.com/BeAPI/acf-options-for-polylang/issues/31): Brand for wp.org
     66- Test: Test up on WP 5.2
     67- FIX [#41](https://github.com/BeAPI/acf-options-for-polylang/issues/41): fix bug with all language failback and repeater
     68
     69= 1.1.6 - 19 Mar 2019 =
     70- FIX [#32](https://github.com/BeAPI/acf-options-for-polylang/issues/32) & [#40](https://github.com/BeAPI/acf-options-for-polylang/issues/40) : fix `get_field()` if an object is provided (WP Term, WP Post, WP Comment)
     71
     72= 1.1.5 - 11 Dec 2018 =
     73- FIX wrong constant
     74
     75= 1.1.4 - 13 Nov 2018 =
     76- Refactor by adding the Helpers class
     77- FEATURE [#26](https://github.com/BeAPI/acf-options-for-polylang/issues/26) : allow to precise to show or hide default values for a specific option page
     78- FEATURE [#21](https://github.com/BeAPI/acf-options-for-polylang/pull/21) : handle custom option id
     79
     80= 1.1.3 - 2 Aug 2018 =
     81- FEATURE [#23](https://github.com/BeAPI/acf-options-for-polylang/pull/23) : requirement to php5.6 whereas namespace are 5.3
     82
     83= 1.1.2 - 31 Jul 2018 =
     84- FIX [#22](https://github.com/BeAPI/acf-options-for-polylang/pull/22) : error with repeater fields default values
     85
     86= 1.1.1 - 9 Mai 2018 =
     87- FIX [#15](https://github.com/BeAPI/acf-options-for-polylang/issues/15) : way requirements are checked to trigger on front / admin
     88
     89= 1.1.0 - Mar 2018 =
     90- True (complet) plugin.
     91- Add check for ACF 5.6.
     92
     93= 1.0.2 - 23 Dec 2017 =
     94- Refactor and reformat.
     95- Handle all options page and custom post_id.
     96- Now load only if ACF & Polylang are activated.
     97- Load later at plugins loaded.
     98
     99= 1.0.1 - 19 Sep 2016 =
     100- Plugin update.
     101
     102= 1.0.0 - 8 Mar 2016 =
     103- Init plugin.
Note: See TracChangeset for help on using the changeset viewer.