class-custom-sidebars-integration-polylang.php
8 years ago
class-custom-sidebars-integration-wml.php
7 years ago
class-custom-sidebars-integration-wpml.php
8 years ago
class-custom-sidebars-integration.php
8 years ago
class-custom-sidebars-integration.php
47 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Integrate sidebar locations |
| 4 | * |
| 5 | * @since 3.1.2 |
| 6 | */ |
| 7 | abstract class CustomSidebarsIntegration { |
| 8 | |
| 9 | protected $languages = array(); |
| 10 | protected $key_name = ''; |
| 11 | |
| 12 | abstract public function prepare( $tabs ); |
| 13 | abstract public function replace( $replacements, $options ); |
| 14 | abstract public function get_location( $req, $defaults ); |
| 15 | |
| 16 | /** |
| 17 | * It should be abstract static function, but ... |
| 18 | * https://bugs.php.net/bug.php?id=53081 |
| 19 | */ |
| 20 | public static function instance() {} |
| 21 | |
| 22 | /** |
| 23 | * Set languages |
| 24 | * |
| 25 | * @since 3.1.2 |
| 26 | * |
| 27 | * @param array $options Current save option. |
| 28 | * @param string $id Sidebar |
| 29 | */ |
| 30 | public function set_location( $options, $id, $sidebars, $data ) { |
| 31 | $options[ $this->key_name ] = array(); |
| 32 | foreach ( $sidebars as $sb_id ) { |
| 33 | if ( isset( $data[ $this->key_name ] ) ) { |
| 34 | foreach ( $data[ $this->key_name ] as $sb_id => $value ) { |
| 35 | if ( ! isset( $options[ $this->key_name ] ) ) { |
| 36 | $options[ $this->key_name ] = array(); |
| 37 | } |
| 38 | foreach ( $value as $lang ) { |
| 39 | $options[ $this->key_name ][ $lang ][ $sb_id ] = $id; |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | return $options; |
| 45 | } |
| 46 | }; |
| 47 |