PageRenderTime 45ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/Project/faci-qsoft/wp-content/themes/noo-jobmonster/framework/admin/customizer/live-ajax.php

https://gitlab.com/hop23typhu/list-theme
PHP | 198 lines | 124 code | 61 blank | 13 comment | 15 complexity | 13159a04df357ca5a758b1fe62efcdab MD5 | raw file
  1. <?php
  2. if( !function_exists( 'noo_cusomizer_upload_settings' ) ) :
  3. function noo_cusomizer_upload_settings(){
  4. $file_name = $_FILES['noo-customizer-settings-upload']['name'];
  5. $file_ext = pathinfo($file_name, PATHINFO_EXTENSION);
  6. // $file_size = $_FILES['noo-customizer-settings-upload']['size'];
  7. if ( $file_ext == 'json' ) {
  8. $encode_options = file_get_contents( $_FILES['noo-customizer-settings-upload']['tmp_name'] );
  9. if( !empty($encode_options) ) {
  10. echo ( $encode_options );
  11. exit();
  12. }
  13. }
  14. exit('-1');
  15. }
  16. endif;
  17. add_action( 'wp_ajax_noo_cusomizer_upload_settings', 'noo_cusomizer_upload_settings' );
  18. if( !function_exists( 'noo_get_customizer_css_layout' ) ) :
  19. function noo_get_customizer_css_layout(){
  20. check_ajax_referer('noo_customize_live_css', 'nonce');
  21. ob_start();
  22. require_once( dirname( __FILE__ ) . '/css-php/layout.php' );
  23. $css = ob_get_contents(); ob_end_clean();
  24. // Remove comment
  25. $css = preg_replace( '#/\*.*?\*/#s', '', $css );
  26. // Remove space
  27. $css = preg_replace( '/\s*([{}|:;,])\s+/', '$1', $css );
  28. // Remove start space
  29. $css = preg_replace( '/\s\s+(.*)/', '$1', $css );
  30. echo ($css);
  31. exit();
  32. }
  33. endif;
  34. add_action( 'wp_ajax_noo_get_customizer_css_layout', 'noo_get_customizer_css_layout' );
  35. add_action( 'wp_ajax_nopriv_noo_get_customizer_css_layout', 'noo_get_customizer_css_layout' );
  36. if( !function_exists( 'noo_get_customizer_css_design' ) ) :
  37. function noo_get_customizer_css_design(){
  38. check_ajax_referer('noo_customize_live_css', 'nonce');
  39. ob_start();
  40. require_once( dirname( __FILE__ ) . '/css-php/design.php' );
  41. $css = ob_get_contents(); ob_end_clean();
  42. // Remove comment
  43. $css = preg_replace( '#/\*.*?\*/#s', '', $css );
  44. // Remove space
  45. $css = preg_replace( '/\s*([{}|:;,])\s+/', '$1', $css );
  46. // Remove start space
  47. $css = preg_replace( '/\s\s+(.*)/', '$1', $css );
  48. echo ($css);
  49. exit();
  50. }
  51. endif;
  52. add_action( 'wp_ajax_noo_get_customizer_css_design', 'noo_get_customizer_css_design' );
  53. add_action( 'wp_ajax_nopriv_noo_get_customizer_css_design', 'noo_get_customizer_css_design' );
  54. if( !function_exists( 'noo_get_customizer_css_typography' ) ) :
  55. function noo_get_customizer_css_typography(){
  56. check_ajax_referer('noo_customize_live_css', 'nonce');
  57. ob_start();
  58. require_once( dirname( __FILE__ ) . '/css-php/typography.php' );
  59. $css = ob_get_contents(); ob_end_clean();
  60. // Remove comment
  61. $css = preg_replace( '#/\*.*?\*/#s', '', $css );
  62. // Remove space
  63. $css = preg_replace( '/\s*([{}|:;,])\s+/', '$1', $css );
  64. // Remove start space
  65. $css = preg_replace( '/\s\s+(.*)/', '$1', $css );
  66. echo ($css);
  67. exit();
  68. }
  69. endif;
  70. add_action( 'wp_ajax_noo_get_customizer_css_typography', 'noo_get_customizer_css_typography' );
  71. add_action( 'wp_ajax_nopriv_noo_get_customizer_css_typography', 'noo_get_customizer_css_typography' );
  72. if( !function_exists( 'noo_get_customizer_css_header' ) ) :
  73. function noo_get_customizer_css_header(){
  74. check_ajax_referer('noo_customize_live_css', 'nonce');
  75. ob_start();
  76. require_once( dirname( __FILE__ ) . '/css-php/header.php' );
  77. $css = ob_get_contents(); ob_end_clean();
  78. // Remove comment
  79. $css = preg_replace( '#/\*.*?\*/#s', '', $css );
  80. // Remove space
  81. $css = preg_replace( '/\s*([{}|:;,])\s+/', '$1', $css );
  82. // Remove start space
  83. $css = preg_replace( '/\s\s+(.*)/', '$1', $css );
  84. echo ($css);
  85. exit();
  86. }
  87. endif;
  88. add_action( 'wp_ajax_noo_get_customizer_css_header', 'noo_get_customizer_css_header' );
  89. add_action( 'wp_ajax_nopriv_noo_get_customizer_css_header', 'noo_get_customizer_css_header' );
  90. if( !function_exists( 'noo_ajax_get_attachment_url' ) ) :
  91. function noo_ajax_get_attachment_url(){
  92. check_ajax_referer('noo_customize_attachment', 'nonce');
  93. if ( ! isset( $_POST['attachment_id'] ) ) {
  94. exit();
  95. }
  96. $attachment_id = $_POST['attachment_id'];
  97. echo wp_get_attachment_url( $attachment_id );
  98. exit();
  99. }
  100. endif;
  101. add_action( 'wp_ajax_noo_ajax_get_attachment_url', 'noo_ajax_get_attachment_url' );
  102. add_action( 'wp_ajax_nopriv_noo_ajax_get_attachment_url', 'noo_ajax_get_attachment_url' );
  103. if( !function_exists( 'noo_ajax_get_menu' ) ) :
  104. function noo_ajax_get_menu(){
  105. check_ajax_referer('noo_customize_menu', 'nonce');
  106. if ( ! isset( $_POST['menu_location'] ) ) {
  107. exit();
  108. }
  109. $menu_location = $_POST['menu_location'];
  110. ?>
  111. <div class="topbar-content">
  112. <?php if ( has_nav_menu( $menu_location ) ) :
  113. wp_nav_menu( array(
  114. 'theme_location' => $menu_location,
  115. 'container' => false,
  116. 'depth' => 1,
  117. 'menu_class' => 'noo-menu'
  118. ) );
  119. else :
  120. echo '<ul class="noo-menu"><li><a href="' . home_url( '/' ) . 'wp-admin/nav-menus.php">' . __( 'Assign a menu', 'noo' ) . '</a></li></ul>';
  121. endif; ?>
  122. </div>
  123. <?php
  124. exit();
  125. }
  126. endif;
  127. add_action( 'wp_ajax_noo_ajax_get_menu', 'noo_ajax_get_menu' );
  128. add_action( 'wp_ajax_nopriv_noo_ajax_get_menu', 'noo_ajax_get_menu' );
  129. if( !function_exists( 'noo_ajax_get_social_icons' ) ) :
  130. function noo_ajax_get_social_icons(){
  131. check_ajax_referer('noo_customize_social_icons', 'nonce');
  132. noo_social_icons();
  133. exit();
  134. }
  135. endif;
  136. add_action( 'wp_ajax_noo_ajax_get_social_icons', 'noo_ajax_get_social_icons' );
  137. add_action( 'wp_ajax_nopriv_noo_ajax_get_social_icons', 'noo_ajax_get_social_icons' );