theme-settings.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. /*****************************
  3. * Remove Menus from Dashboard
  4. *****************************/
  5. function remove_menus()
  6. {
  7. //remove_menu_page( 'index.php' ); //Dashboard
  8. //remove_menu_page( 'jetpack' ); //Jetpack*
  9. //remove_menu_page( 'edit.php' ); //Posts
  10. //remove_menu_page( 'upload.php' ); //Media
  11. //remove_menu_page( 'edit.php?post_type=page' ); //Pages
  12. //remove_menu_page( 'edit-comments.php' ); //Comments
  13. //remove_menu_page( 'themes.php' ); //Appearance
  14. //remove_menu_page( 'plugins.php' ); //Plugins
  15. //remove_menu_page( 'users.php' ); //Users
  16. //remove_menu_page( 'tools.php' ); //Tools
  17. //remove_menu_page( 'options-general.php' ); //Settings
  18. }
  19. // add_action('admin_menu', 'remove_menus');
  20. /**
  21. * Read More button in excerpt
  22. */
  23. function new_excerpt_more($more)
  24. {
  25. return '... <a class="readmore" href="' . get_permalink() . ' ">Read more <i class="fa fa-external-link"></i></a>';
  26. }
  27. // add_filter('excerpt_more', 'new_excerpt_more');
  28. /**
  29. * Custome Lenght of excerpt
  30. */
  31. // function custom_excerpt_length( $length ) {
  32. // return 50;
  33. // }
  34. // add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
  35. /**
  36. * Numbered Pagination
  37. */
  38. function pagination($pages = '', $range = 4)
  39. {
  40. $showitems = ($range * 2) + 1;
  41. global $paged;
  42. if (empty($paged)) $paged = 1;
  43. if ($pages == '') {
  44. global $wp_query;
  45. $pages = $wp_query->max_num_pages;
  46. if (!$pages) {
  47. $pages = 1;
  48. }
  49. }
  50. if (1 != $pages) {
  51. echo "<div class=\"pagination\"><span>Page " . $paged . " of " . $pages . "</span>";
  52. if ($paged > 2 && $paged > $range + 1 && $showitems < $pages) echo "<a href='" . get_pagenum_link(1) . "'>&laquo; First</a>";
  53. if ($paged > 1 && $showitems < $pages) echo "<a href='" . get_pagenum_link($paged - 1) . "'>&lsaquo; Previous</a>";
  54. for ($i = 1; $i <= $pages; $i++) {
  55. if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems)) {
  56. echo ($paged == $i) ? "<span class=\"current\">" . $i . "</span>" : "<a href='" . get_pagenum_link($i) . "' class=\"inactive\">" . $i . "</a>";
  57. }
  58. }
  59. if ($paged < $pages && $showitems < $pages) echo "<a href=\"" . get_pagenum_link($paged + 1) . "\">Next &rsaquo;</a>";
  60. if ($paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages) echo "<a href='" . get_pagenum_link($pages) . "'>Last &raquo;</a>";
  61. echo "</div>\n";
  62. }
  63. }
  64. /**
  65. * stop wp removing div tags
  66. */
  67. function tinymce_settings($settings)
  68. {
  69. // html elements being stripped
  70. $settings['extended_valid_elements'] = 'div[*],article[*]';
  71. // only html elements to keep
  72. //$settings['valid_elements'] = 'a,strong/b,div,h1,h2,h3,section';
  73. // paste elements to keep
  74. //$opts = '*[*]';
  75. //$settings['paste_word_valid_elements'] = $opts;
  76. // don't remove line breaks
  77. //$settings['remove_linebreaks'] = false;
  78. $settings['allow_html_in_named_anchor'] = true;
  79. // convert newline characters to BR
  80. //$settings['convert_newlines_to_brs'] = true;
  81. // don't remove redundant BR
  82. //$settings['remove_redundant_brs'] = false;
  83. // only html elements to keep
  84. //$settings['wpautop'] = false;
  85. // pass back to wordpress
  86. return $settings;
  87. }
  88. // add_filter( 'tiny_mce_before_init', 'tinymce_settings' );
  89. // Removing the Editor from a WordPress Post Type
  90. // add_action('init', function () {
  91. // remove_post_type_support('faculty', 'editor');
  92. // }, 99);
  93. function prefix_disable_gutenberg($current_status, $post_type)
  94. {
  95. if ($post_type === 'news' || $post_type === 'event' || $post_type === 'success_story' || $post_type === 'alumni' || $post_type === 'notice') return false;
  96. return $current_status;
  97. }
  98. add_filter('use_block_editor_for_post_type', 'prefix_disable_gutenberg', 10, 2);
  99. function gs_custom_menu_order($menu_ord)
  100. {
  101. if (!$menu_ord) return true;
  102. return array(
  103. 'index.php',
  104. // 'separator1',
  105. 'edit.php?post_type=page',
  106. 'edit.php',
  107. 'upload.php',
  108. 'edit-comments.php',
  109. 'separator1',
  110. );
  111. /* -- DEFAULTS -- */
  112. /*
  113. return array(
  114. 'index.php',
  115. 'separator1',
  116. 'edit.php?post_type=page',
  117. 'edit.php',
  118. 'edit.php?post_type=[your_post_type_slug]',
  119. 'upload.php',
  120. 'link-manager.php',
  121. 'edit-comments.php',
  122. 'separator2',
  123. 'themes.php',
  124. 'plugins.php',
  125. 'users.php',
  126. 'tools.php',
  127. 'options-general.php'
  128. );
  129. */
  130. }
  131. add_filter('custom_menu_order', 'gs_custom_menu_order');
  132. add_filter('menu_order', 'gs_custom_menu_order');