PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/sitepress-multilingual-cms/menu/_custom_types_translation.php

https://bitbucket.org/kenaku/karate
PHP | 182 lines | 167 code | 15 blank | 0 comment | 27 complexity | 8f69629caffd2b22762d00ca5efd0d45 MD5 | raw file
  1. <?php
  2. $cposts = array();
  3. $icl_post_types = $sitepress->get_translatable_documents(true);
  4. foreach($icl_post_types as $k=>$v){
  5. if(!in_array($k, array('post','page'))){
  6. $cposts[$k] = $v;
  7. }
  8. }
  9. foreach($cposts as $k=>$cpost){
  10. if(!isset($sitepress_settings['custom_posts_sync_option'][$k])){
  11. $cposts_sync_not_set[] = $cpost->labels->name;
  12. }
  13. }
  14. $notice = '';
  15. if(!empty($cposts_sync_not_set)){
  16. $notice .= '<div class="updated below-h2"><p>';
  17. $notice .= sprintf(__("You haven't set your synchronization preferences for these custom posts: %s. Default value was selected.", 'sitepress'),
  18. '<i>'.join('</i>, <i>', $cposts_sync_not_set) . '</i>');
  19. $notice .= '</p></div>';
  20. }
  21. global $wp_taxonomies;
  22. $ctaxonomies = array_diff(array_keys((array)$wp_taxonomies), array('post_tag','category', 'nav_menu', 'link_category', 'post_format'));
  23. foreach($ctaxonomies as $ctax){
  24. if(!isset($sitepress_settings['taxonomies_sync_option'][$ctax])){
  25. $tax_sync_not_set[] = $wp_taxonomies[$ctax]->label;
  26. }
  27. }
  28. if(!empty($tax_sync_not_set)){
  29. $notice .= '<div class="updated below-h2"><p>';
  30. $notice .= sprintf(__("You haven't set your synchronization preferences for these taxonomies: %s. Default value was selected.", 'sitepress'),
  31. '<i>'.join('</i>, <i>', $tax_sync_not_set) . '</i>');
  32. $notice .= '</p></div>';
  33. }
  34. ?>
  35. <?php if(isset($notice)) echo $notice ?>
  36. <?php if(!empty($cposts)): ?>
  37. <form id="icl_custom_posts_sync_options" name="icl_custom_posts_sync_options" action="">
  38. <?php wp_nonce_field('icl_custom_posts_sync_options_nonce', '_icl_nonce') ?>
  39. <table class="widefat">
  40. <thead>
  41. <tr>
  42. <th width="60%"><?php _e('Custom posts', 'sitepress');?></th>
  43. <th>&nbsp;</th>
  44. </tr>
  45. </thead>
  46. <tbody>
  47. <?php foreach($cposts as $k=>$cpost): ?>
  48. <?php
  49. $rdisabled = isset($iclTranslationManagement->settings['custom_types_readonly_config'][$k]) ? 'disabled="disabled"':'';
  50. ?>
  51. <tr>
  52. <td><?php echo $cpost->labels->name; ?></td>
  53. <td>
  54. <label><input class="icl_sync_custom_posts" type="radio" name="icl_sync_custom_posts[<?php echo $k ?>]" value="1" <?php echo $rdisabled;
  55. if(@intval($sitepress_settings['custom_posts_sync_option'][$k])==1) echo ' checked="checked"'
  56. ?> />&nbsp;<?php _e('Translate', 'sitepress') ?></label>&nbsp;
  57. <label><input class="icl_sync_custom_posts" type="radio" name="icl_sync_custom_posts[<?php echo $k ?>]" value="0" <?php echo $rdisabled;
  58. if(@intval($sitepress_settings['custom_posts_sync_option'][$k])==0) echo ' checked="checked"'
  59. ?> />&nbsp;<?php _e('Do nothing', 'sitepress') ?></label>
  60. <?php if($rdisabled): ?>
  61. <input type="hidden" name="icl_sync_custom_posts[<?php echo $k ?>]" value="<?php echo @intval($sitepress_settings['custom_posts_sync_option'][$k]) ?>" />
  62. <?php endif; ?>
  63. </td>
  64. </tr>
  65. <?php if(defined('WPML_ST_VERSION')): ?>
  66. <?php
  67. $_has_slug = isset($cpost->rewrite['slug']) && $cpost->rewrite['slug'];
  68. $_on = $sitepress_settings['posts_slug_translation']['on'] &&
  69. $_has_slug &&
  70. isset($sitepress_settings['custom_posts_sync_option'][$k]) &&
  71. $sitepress_settings['custom_posts_sync_option'][$k] == 1;
  72. $_display = $_on ? '' : 'display:none;';
  73. $_translate = !empty($sitepress_settings['posts_slug_translation']['types'][$k]);
  74. if($_has_slug){
  75. if($sitepress->get_default_language() != $sitepress_settings['st']['strings_language']){
  76. $string_id = $wpdb->get_var($wpdb->prepare("
  77. SELECT s.id FROM {$wpdb->prefix}icl_strings s
  78. JOIN {$wpdb->prefix}icl_string_translations st
  79. ON st.string_id = s.id
  80. WHERE st.language=%s AND st.value=%s AND s.name LIKE %s
  81. ", $sitepress->get_default_language(), $cpost->rewrite['slug'], 'URL slug: %'));
  82. }else{
  83. $string_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}icl_strings WHERE name = %s AND value = %s ", 'Url slug: ' . $cpost->rewrite['slug'], $cpost->rewrite['slug']));
  84. }
  85. $_slug_translations = icl_get_string_translations_by_id($string_id);
  86. }else{
  87. $_slug_translations = false;
  88. }
  89. ?>
  90. <?php if($_has_slug): ?>
  91. <tr class="icl_slug_translation_choice" style="background-color: #efefef;<?php echo $_display; ?>">
  92. <td colspan="2">
  93. <label><input name="translate_slugs[<?php echo $k ?>][on]" type="checkbox" value="1" <?php checked(1, $_translate, true) ?> />&nbsp;<?php
  94. printf(__('Use different slugs in different languages for %s.', 'sitepress'), $cpost->labels->name); ?></label>
  95. <table <?php if(empty($_translate)):?>style="display:none"<?php endif; ?>>
  96. <?php foreach($sitepress->get_active_languages() as $lang): if($lang['code'] == $sitepress_settings['st']['strings_language']) continue; ?>
  97. <tr>
  98. <td style="border: none;"><?php echo $lang['display_name']?></td>
  99. <td style="border: none;"><input name="translate_slugs[<?php echo $k ?>][langs][<?php echo $lang['code'] ?>]" type="text" value="<?php
  100. echo !empty($_slug_translations[$lang['code']]['value']) ? $_slug_translations[$lang['code']]['value'] : '';
  101. ?>" />
  102. <?php if(isset($_slug_translations[$lang['code']]) && $_slug_translations[$lang['code']]['status'] != ICL_STRING_TRANSLATION_COMPLETE): ?>
  103. <i class="icl_st_slug_tr_warn"><?php _e("Not marked as 'complete'. Press 'Save' to enable.", 'sitepress') ?></i>
  104. <?php endif; ?>
  105. </td>
  106. </tr>
  107. <?php endforeach; ?>
  108. </table>
  109. </td>
  110. </tr>
  111. <?php endif; ?>
  112. <?php endif; ?>
  113. <?php endforeach; ?>
  114. <tr>
  115. <td colspan="2">
  116. <p>
  117. <input type="submit" class="button" value="<?php _e('Save', 'sitepress') ?>" />
  118. <span class="icl_ajx_response" id="icl_ajx_response_cp"></span>
  119. </p>
  120. </td>
  121. </tr>
  122. </tbody>
  123. </table>
  124. </form>
  125. <?php endif; ?>
  126. <?php if(!empty($ctaxonomies)): ?>
  127. <form id="icl_custom_tax_sync_options" name="icl_custom_tax_sync_options" action="">
  128. <?php wp_nonce_field('icl_custom_tax_sync_options_nonce', '_icl_nonce') ?>
  129. <table class="widefat">
  130. <thead>
  131. <tr>
  132. <th width="60%"><?php _e('Custom taxonomies', 'sitepress');?></th>
  133. <th>&nbsp;</th>
  134. </tr>
  135. </thead>
  136. <tbody>
  137. <?php foreach($ctaxonomies as $ctax): ?>
  138. <?php
  139. $rdisabled = isset($iclTranslationManagement->settings['taxonomies_readonly_config'][$ctax]) ? 'disabled="disabled"':'';
  140. ?>
  141. <tr>
  142. <td><?php echo $wp_taxonomies[$ctax]->label; ?></td>
  143. <td>
  144. <label><input type="radio" name="icl_sync_tax[<?php echo $ctax ?>]" value="1" <?php echo $rdisabled;
  145. if(@$sitepress_settings['taxonomies_sync_option'][$ctax]==1) echo ' checked="checked"'
  146. ?> />&nbsp;<?php _e('Translate', 'sitepress') ?></label>&nbsp;
  147. <label><input type="radio" name="icl_sync_tax[<?php echo $ctax ?>]" value="0" <?php echo $rdisabled;
  148. if(@$sitepress_settings['taxonomies_sync_option'][$ctax]==0) echo ' checked="checked"'
  149. ?> />&nbsp;<?php _e('Do nothing', 'sitepress') ?></label>
  150. </td>
  151. </tr>
  152. <?php endforeach; ?>
  153. <tr>
  154. <td colspan="2">
  155. <p>
  156. <input type="submit" class="button" value="<?php _e('Save', 'sitepress') ?>" />
  157. <span class="icl_ajx_response" id="icl_ajx_response_ct"></span>
  158. </p>
  159. </td>
  160. </tr>
  161. </tbody>
  162. </table>
  163. </form>
  164. <?php endif; ?>
  165. <br clear="all" />