tweaks.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. function dw_remove_wp_ver_css_js( $src ) {
  14. if ( strpos( $src, 'ver=' ) )
  15. $src = remove_query_arg( 'ver', $src );
  16. return $src;
  17. }
  18. add_filter( 'style_loader_src', 'dw_remove_wp_ver_css_js', 9999 );
  19. add_filter( 'script_loader_src', 'dw_remove_wp_ver_css_js', 9999 );
  20. add_action( 'admin_head', 'dw_hide' );
  21. function dw_hide() {
  22. ?>
  23. <style type="text/css" media="screen">
  24. #footer {display:none;}
  25. #contextual-help-link-wrap {display: none;}
  26. #wpadminbar {display: none;}
  27. body.admin-bar #wpcontent, body.admin-bar #adminmenu {padding-top:0;}
  28. #wp-content-editor-tools{top:0 !important;position:relative!important;}
  29. #ed_toolbar{top:0px !important;}
  30. html.wp-toolbar{padding-top:0;}
  31. #postexcerpt p {display: none;}
  32. </style>
  33. <?php }
  34. function custom_excerpt_length( $length ) {
  35. return 20;
  36. }
  37. add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
  38. add_filter('wp_mail_from', 'dw_fromemail');
  39. function dw_fromemail($email) {
  40. $wpfrom = get_option('admin_email');
  41. return $wpfrom;
  42. }
  43. add_filter('wp_mail_from_name', 'dw_fromname');
  44. function dw_fromname($email){
  45. $wpfrom = get_option('blogname');
  46. return $wpfrom;
  47. }
  48. add_filter( 'embed_oembed_html', 'dw_oembed_filter', 10, 4 ) ;
  49. function dw_oembed_filter($html, $url, $attr, $post_ID) {
  50. $return = '<div class="video-container">'.$html.'</div>';
  51. $return = str_replace('frameborder="0" allowfullscreen', 'style="border:none"', $return);
  52. return $return;
  53. }
  54. add_filter( 'embed_oembed_html', 'dw_embed_oembed_html' );
  55. function dw_embed_oembed_html( $html ) {
  56. return preg_replace( '@src="https?:@', 'src="', $html );
  57. }
  58. add_action( 'admin_menu', 'daw_is_online_add_admin_menu' );
  59. add_action( 'admin_init', 'daw_is_online_settings_init' );
  60. function daw_is_online_add_admin_menu( ) {
  61. add_options_page( 'DW Status', 'DAW Online', 'manage_options', 'daw_is_online', 'daw_is_online_options_page' );
  62. }
  63. function daw_is_online_settings_init( ) {
  64. register_setting( 'dwstatus', 'daw_is_online_settings' );
  65. add_settings_section('daw_is_online_pluginPage_section', __( 'DAW Online', 'wordpress' ), 'daw_is_online_settings_section_callback', 'dwstatus');
  66. 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' );
  67. }
  68. function daw_is_online_select_field_0_render( ) {
  69. $options = get_option( 'daw_is_online_settings' ); ?>
  70. <select name='daw_is_online_settings[daw_is_online_select_field_0]'>
  71. <option value='1' <?php selected( $options['daw_is_online_select_field_0'], 1 ); ?>>Yes</option>
  72. <option value='2' <?php selected( $options['daw_is_online_select_field_0'], 2 ); ?>>No</option>
  73. </select>
  74. <?php }
  75. function daw_is_online_settings_section_callback( ) {
  76. echo __( 'This sets my online status', 'wordpress' );
  77. }
  78. function daw_is_online_options_page( ) { ?>
  79. <form action='options.php' method='post'>
  80. <?php settings_fields( 'dwstatus' );
  81. do_settings_sections( 'dwstatus' );
  82. submit_button(); ?>
  83. </form>
  84. <?php }
  85. function dw_online_get_status() {
  86. $dw_status = get_option('daw_is_online_settings');
  87. if( $dw_status['daw_is_online_select_field_0'] == '1' ) {
  88. wp_enqueue_style( 'message', get_template_directory_uri() . '/css/message.css');
  89. ?>
  90. <script type="text/javascript">function txt_dave(){$.ajax({url:"https://davidawindham.com/wha/phony/sms.php",dataType:"json",success:function(){}})}$(function(){var a;a=0,Messenger.options={extraClasses:"messenger-fixed messenger-on-bottom messenger-on-left",theme:"flat"};var b;b=Messenger().post({message:"I am currently online",type:"success",actions:{retry:{label:"Connect",delay:30,action:function(){txt_dave();var c;c=Messenger().run({errorMessage:"Please wait a moment while I get connected with you.",successMessage:"Connecting",action:function(c){return b.hide(),++a<2?c.error({status:500,readyState:0,responseText:0}):(window.location.href="http://davidawindham.com/contact/chat",b.update({message:"Redirect to Chat",hideAfter:20,type:"success",actions:!1}))}})}},cancel:{label:"No Thanks",action:function(){return b.update({message:"Maybe Next Time",hideAfter:1,type:"error",actions:!1})}}}})});</script>
  91. <?php }
  92. }
  93. function dw_online_get_chat() {
  94. $dw_status = get_option('daw_is_online_settings');
  95. if( $dw_status['daw_is_online_select_field_0'] == '1' ) { ?>
  96. <script type="text/javascript">
  97. Messenger.options = {extraClasses: "messenger-fixed messenger-on-bottom messenger-on-left",theme: "flat"};var i;i = 0;
  98. $(function(){var msg_return; msg_return = Messenger().run({id: 'one',errorMessage: 'Looking for David...', action: function(opts) {if (++i < 2) {get_dave();return opts.error({status: 500,readyState: 0,responseText: 0});}}});});
  99. 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);});}
  100. 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});}}});}
  101. 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 = '../';}}}});}
  102. 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 = '../';}}}});}
  103. $(function() {if (window.location.hash.indexOf("chat") !== -1) {$('.chat').modal('show');}});
  104. </script>
  105. <?php }
  106. }
  107. ?>