tweaks.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. remove_action('wp_head', 'index_rel_link' );
  3. remove_action('wp_head', 'rel_canonical');
  4. remove_action('wp_head', 'start_post_rel_link', 10, 0 );
  5. remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
  6. remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0 );
  7. remove_action('wp_head', 'parent_post_rel_link', 10, 0 );
  8. remove_action('wp_head', 'rsd_link');
  9. remove_action('wp_head', 'wlwmanifest_link');
  10. remove_action('wp_head', 'wp_generator');
  11. remove_action('wp_head', 'feed_links_extra', 3 );
  12. remove_action('wp_head', 'feed_links', 2 );
  13. remove_action('wp_head', 'wp_oembed_add_discovery_links', 10, 0 );
  14. remove_action( 'wp_head', 'wp_oembed_add_host_js', 10, 0 );
  15. function dw_remove_wp_ver_css_js( $src ) {
  16. if ( strpos( $src, 'ver=' ) )
  17. $src = remove_query_arg( 'ver', $src );
  18. return $src;
  19. }
  20. add_filter( 'style_loader_src', 'dw_remove_wp_ver_css_js', 9999 );
  21. add_filter( 'script_loader_src', 'dw_remove_wp_ver_css_js', 9999 );
  22. add_action( 'admin_head', 'dw_hide' );
  23. function dw_hide() {
  24. ?>
  25. <style type="text/css" media="screen">
  26. #footer {display:none;}
  27. #contextual-help-link-wrap {display: none;}
  28. #wpadminbar {display: none;}
  29. body.admin-bar #wpcontent, body.admin-bar #adminmenu {padding-top:0;}
  30. #wp-content-editor-tools{top:0 !important;position:relative!important;}
  31. #ed_toolbar{top:0px !important;}
  32. html.wp-toolbar{padding-top:0;}
  33. #postexcerpt p {display: none;}
  34. </style>
  35. <?php }
  36. function disable_emojis_tinymce( $plugins ) {
  37. if ( is_array( $plugins ) ) {
  38. return array_diff( $plugins, array( 'wpemoji' ) );
  39. } else {
  40. return array();
  41. }
  42. }
  43. function disable_emojis() {
  44. remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
  45. remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
  46. remove_action( 'wp_print_styles', 'print_emoji_styles' );
  47. remove_action( 'admin_print_styles', 'print_emoji_styles' );
  48. remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
  49. remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
  50. remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
  51. add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
  52. }
  53. add_action( 'init', 'disable_emojis' );
  54. function custom_excerpt_length( $length ) {
  55. return 20;
  56. }
  57. add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
  58. add_filter('wp_mail_from', 'dw_fromemail');
  59. function dw_fromemail($email) {
  60. $wpfrom = get_option('admin_email');
  61. return $wpfrom;
  62. }
  63. add_filter('wp_mail_from_name', 'dw_fromname');
  64. function dw_fromname($email){
  65. $wpfrom = get_option('blogname');
  66. return $wpfrom;
  67. }
  68. add_filter( 'embed_oembed_html', 'dw_oembed_filter', 10, 4 ) ;
  69. function dw_oembed_filter($html, $url, $attr, $post_ID) {
  70. $return = '<div class="video-container">'.$html.'</div>';
  71. $return = str_replace('frameborder="0" allowfullscreen', 'style="border:none"', $return);
  72. return $return;
  73. }
  74. add_filter( 'embed_oembed_html', 'dw_embed_oembed_html' );
  75. function dw_embed_oembed_html( $html ) {
  76. return preg_replace( '@src="https?:@', 'src="', $html );
  77. }
  78. add_action( 'admin_menu', 'daw_is_online_add_admin_menu' );
  79. add_action( 'admin_init', 'daw_is_online_settings_init' );
  80. function daw_is_online_add_admin_menu( ) {
  81. add_options_page( 'DW Status', 'DAW Online', 'manage_options', 'daw_is_online', 'daw_is_online_options_page' );
  82. }
  83. function daw_is_online_settings_init( ) {
  84. register_setting( 'dwstatus', 'daw_is_online_settings' );
  85. add_settings_section('daw_is_online_pluginPage_section', __( 'DAW Online', 'wordpress' ), 'daw_is_online_settings_section_callback', 'dwstatus');
  86. add_settings_field( 'daw_is_online_select_field_0', __( 'Am I Online ?', 'wordpress' ), 'daw_is_online_select_field_0_render', 'dwstatus', 'daw_is_online_pluginPage_section' );
  87. }
  88. function daw_is_online_select_field_0_render( ) {
  89. $options = get_option( 'daw_is_online_settings' ); ?>
  90. <select name='daw_is_online_settings[daw_is_online_select_field_0]'>
  91. <option value='1' <?php selected( $options['daw_is_online_select_field_0'], 1 ); ?>>Yes</option>
  92. <option value='2' <?php selected( $options['daw_is_online_select_field_0'], 2 ); ?>>No</option>
  93. </select>
  94. <?php }
  95. function daw_is_online_settings_section_callback( ) {
  96. echo __( 'This sets my online status', 'wordpress' );
  97. }
  98. function daw_is_online_options_page( ) { ?>
  99. <form action='options.php' method='post'>
  100. <?php settings_fields( 'dwstatus' );
  101. do_settings_sections( 'dwstatus' );
  102. submit_button(); ?>
  103. </form>
  104. <?php }
  105. function dw_online_get_status() {
  106. $dw_status = get_option('daw_is_online_settings');
  107. if( $dw_status['daw_is_online_select_field_0'] == '1' ) {
  108. wp_enqueue_style( 'message', get_template_directory_uri() . '/css/messenger.css');
  109. ?>
  110. <script type="text/javascript">
  111. function txt_dave(){
  112. $.ajax({
  113. url:"https://davidawindham.com/wha/phony/sms.php",
  114. dataType:"json",
  115. success:function(){}})
  116. }
  117. $(function(){
  118. var a;a=0,Messenger.options={extraClasses:"messenger-fixed messenger-on-bottom messenger-on-left",theme:"flat"};
  119. var b;b=Messenger().post({
  120. message:"I'm Currently Online",
  121. type:'success',
  122. actions:{
  123. cancel:{
  124. label:"Connect",
  125. delay:60,
  126. action:function(){
  127. txt_dave();
  128. var c;c=Messenger().run({
  129. errorMessage:"Please wait a moment while I get connected with you.",
  130. successMessage:"Connecting",
  131. action:function(c){
  132. return b.hide(),
  133. ++a<2?c.error({
  134. status:500,
  135. readyState:0,
  136. responseText:0
  137. }):
  138. (window.location.href="http://chat.davidawindham.com",
  139. b.update({
  140. message:"Redirect to Chat",
  141. hideAfter:20,
  142. type:"success",
  143. actions:!1}))}})}
  144. }
  145. },
  146. retry:{
  147. label:"No Thanks",
  148. action:function(){
  149. return b.update({
  150. message:"Maybe Next Time",
  151. hideAfter:1,
  152. type:"error",
  153. actions:!1
  154. })
  155. }
  156. }
  157. })
  158. });
  159. </script>
  160. <?php }
  161. }
  162. function dw_online_get_chat() {
  163. $dw_status = get_option('daw_is_online_settings');
  164. if( $dw_status['daw_is_online_select_field_0'] == '1' ) { ?>
  165. <script type="text/javascript">
  166. Messenger.options = {extraClasses: "messenger-fixed messenger-on-bottom messenger-on-left",theme: "flat"};var i;i = 0;
  167. $(function(){
  168. var msg_return;
  169. msg_return = Messenger().run({
  170. id: 'one',
  171. errorMessage: 'Looking for David...',
  172. action: function(opts) {if (++i < 2) {get_dave();return opts.error({status: 500,readyState: 0,responseText: 0});}}});});
  173. function get_dave() {$(function poll() {var x = 0; var countTimer = setInterval(function () {if(x > 5){clearInterval(countTimer)}else if(x == 5){dave_not_available()}else{var URLchatAPI = "http://code.davidawindham.com:8080/status";var request = $.ajax({url: URLchatAPI,dataType: 'json',cache: false, success: function (data) {online = data.online;if(online=='yes') {$('.chat').modal('show');x = x+5;};if (online=='no') {dave_connecting();};},error: function ( xhr, tStatus, err ) {dave_error();x = x+5;}});x++;}}, 5000);});}
  174. function dave_connecting(){var y;y = 0;var msg_waiting; msg_waiting = Messenger().run({id: 'one',hideAfter: 4,errorMessage: 'Waiting on David...',action: function(opts) {if (++y < 2) {get_dave();return opts.error({status: 500,readyState: 0,responseText: 0});}}});}
  175. function dave_not_available(){var msg_error; msg_error = Messenger().post({message: 'Sorry, but I am busy.',type: 'error',id: 'one',showCloseButton: true,actions:{cancel: {label: 'Leave me a message',action: function(){window.location.href = '../';}}}});}
  176. function dave_error(){var msg_error; msg_error = Messenger().post({message: 'Oops. Something has gone wrong.',type: 'error',id: 'one',showCloseButton: true,actions:{cancel: {label: 'Leave me a message',action: function(){window.location.href = '../';}}}});}
  177. $(function() {if (window.location.hash.indexOf("chat") !== -1) {$('.chat').modal('show');}});
  178. </script>
  179. <?php }
  180. }
  181. function dw_deliver_form_mail() {
  182. if ( isset( $_POST['dw-contact'] ) ) {
  183. $fname = sanitize_text_field( $_POST["dw-fname"] );
  184. $lname = sanitize_text_field( $_POST["dw-lname"] );
  185. $email = sanitize_email( $_POST["dw-email"] );
  186. $subject = sanitize_text_field( $_POST["dw-org"] );
  187. $message = esc_textarea( $_POST["dw-message"] );
  188. $to = get_option( 'admin_email' );
  189. $headers = "From: $fname $lname <$email>" . "\r\n";
  190. if ( wp_mail( $to, $subject, $message, $headers ) ) {
  191. echo '<div class="alert alert-success" role="alert">';
  192. echo '<p>Thank you. I will be in touch.</p>';
  193. echo '</div>';
  194. }
  195. else {
  196. echo '<div class="alert alert-danger" role="alert">';
  197. echo '<p>Error, please try again</p>';
  198. echo '</div>';
  199. }
  200. }
  201. }
  202. ?>