PLL_Settings_Share_Slug

Settings class to advertize the Share slugs module.

Defined (1)

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

/modules/share-slug/settings-share-slug.php  
  1. class PLL_Settings_Share_Slug extends PLL_Settings_Module { 
  2.  
  3. /** 
  4. * constructor 
  5. * @since 1.9 
  6. * @param object $polylang polylang object 
  7. */ 
  8. public function __construct( &$polylang ) { 
  9. parent::__construct( $polylang, array( 
  10. 'module' => 'share-slugs',  
  11. 'title' => __( 'Share slugs', 'polylang' ),  
  12. 'description' => __( 'Allows to share the same url slug accross languages for posts and terms.', 'polylang' ),  
  13. ) ); 
  14.  
  15. if ( class_exists( 'PLL_Share_Post_Slug', true ) && get_option( 'permalink_structure' ) ) { 
  16. add_action( 'admin_print_footer_scripts', array( $this, 'print_js' ) ); 
  17.  
  18. /** 
  19. * tells if the module is active 
  20. * @since 1.9 
  21. * @return bool 
  22. */ 
  23. public function is_active() { 
  24. return class_exists( 'PLL_Share_Post_Slug', true ) && $this->options['force_lang'] && get_option( 'permalink_structure' ); 
  25.  
  26. /** 
  27. * displays upgrade message 
  28. * @since 1.9 
  29. * @return string 
  30. */ 
  31. public function get_upgrade_message() { 
  32. return class_exists( 'PLL_Share_Post_Slug', true ) ? '' : $this->default_upgrade_message(); 
  33.  
  34. /** 
  35. * displays the javascript to handle dynamically the change in url modifications 
  36. * as sharing slugs is not possible when the language is set from the content 
  37. * @since 1.9 
  38. */ 
  39. public function print_js() { 
  40. wp_enqueue_script( 'jquery' ); 
  41.  
  42. $activated = sprintf( '<span class="activated">%s</span>', $this->action_links['activated'] ); 
  43. $deactivated = sprintf( '<span class="deactivated">%s</span>', $this->action_links['deactivated'] ); 
  44.  
  45. ?> 
  46. <script type='text/javascript'> 
  47. //<![CDATA[ 
  48. ( function( $ ) { 
  49. $( "input[name='force_lang']" ).change( function() { 
  50. var value = $( this ).val(); 
  51. if ( value > 0 ) { 
  52. $( "#pll-module-share-slugs" ).removeClass( "inactive" ).addClass( "active" ).children( "td" ).children( ".row-actions" ).html( '<?php echo $activated; ?>' ); 
  53. else { 
  54. $( "#pll-module-share-slugs" ).removeClass( "active" ).addClass( "inactive" ).children( "td" ).children( ".row-actions" ).html( '<?php echo $deactivated; ?>' ); 
  55. } ); 
  56. } )( jQuery ); 
  57. // ]]> 
  58. </script><?php