PLL_Settings_Sync

Settings class for synchronization settings management.

Defined (1)

The class is defined in the following location(s).

/modules/sync/settings-sync.php  
  1. class PLL_Settings_Sync extends PLL_Settings_Module { 
  2.  
  3. /** 
  4. * constructor 
  5. * @since 1.8 
  6. * @param object $polylang polylang object 
  7. */ 
  8. public function __construct( &$polylang ) { 
  9. parent::__construct( $polylang, array( 
  10. 'module' => 'sync',  
  11. 'title' => __( 'Synchronization', 'polylang' ),  
  12. 'description' => __( 'The synchronization options allow to maintain exact same values (or translations in the case of taxonomies and page parent) of meta content between the translations of a post or page.', 'polylang' ),  
  13. ) ); 
  14.  
  15. /** 
  16. * deactivates the module 
  17. * @since 1.8 
  18. */ 
  19. public function deactivate() { 
  20. $this->options['sync'] = array(); 
  21. update_option( 'polylang', $this->options ); 
  22.  
  23. /** 
  24. * displays the settings form 
  25. * @since 1.8 
  26. */ 
  27. protected function form() {?> 
  28. <ul class="pll-inline-block-list"><?php 
  29. foreach ( self::list_metas_to_sync() as $key => $str ) { 
  30. printf( 
  31. '<li><label><input name="sync[%s]" type="checkbox" value="1" %s /> %s</label></li>',  
  32. esc_attr( $key ),  
  33. in_array( $key, $this->options['sync'] ) ? 'checked="checked"' : '',  
  34. esc_html( $str ) 
  35. ); 
  36. } ?> 
  37. </ul><?php 
  38.  
  39. /** 
  40. * sanitizes the settings before saving 
  41. * @since 1.8 
  42. * @param array $options 
  43. */ 
  44. protected function update( $options ) { 
  45. $newoptions['sync'] = empty( $options['sync'] ) ? array() : array_keys( $options['sync'], 1 ); 
  46. return $newoptions; // take care to return only validated options 
  47.  
  48. /** 
  49. * get the row actions 
  50. * @since 1.8 
  51. * @return array 
  52. */ 
  53. protected function get_actions() { 
  54. return empty( $this->options['sync'] ) ? array( 'configure' ) : array( 'configure', 'deactivate' ); 
  55.  
  56. /** 
  57. * list the post metas to synchronize 
  58. * @since 1.0 
  59. * @return array 
  60. */ 
  61. static public function list_metas_to_sync() { 
  62. return array( 
  63. 'taxonomies' => __( 'Taxonomies', 'polylang' ),  
  64. 'post_meta' => __( 'Custom fields', 'polylang' ),  
  65. 'comment_status' => __( 'Comment status', 'polylang' ),  
  66. 'ping_status' => __( 'Ping status', 'polylang' ),  
  67. 'sticky_posts' => __( 'Sticky posts', 'polylang' ),  
  68. 'post_date' => __( 'Published date', 'polylang' ),  
  69. 'post_format' => __( 'Post format', 'polylang' ),  
  70. 'post_parent' => __( 'Page parent', 'polylang' ),  
  71. '_wp_page_template' => __( 'Page template', 'polylang' ),  
  72. 'menu_order' => __( 'Page order', 'polylang' ),  
  73. '_thumbnail_id' => __( 'Featured image', 'polylang' ),  
  74. );