tweaks.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. html.wp-toolbar{padding-top:0;}
  29. #postexcerpt p {display: none;}
  30. </style>
  31. <?php }
  32. add_filter('wp_mail_from', 'dw_fromemail');
  33. function dw_fromemail($email) {
  34. $wpfrom = get_option('admin_email');
  35. return $wpfrom;
  36. }
  37. add_filter('wp_mail_from_name', 'dw_fromname');
  38. function dw_fromname($email){
  39. $wpfrom = get_option('blogname');
  40. return $wpfrom;
  41. }
  42. add_filter( 'embed_oembed_html', 'dw_oembed_filter', 10, 4 ) ;
  43. function dw_oembed_filter($html, $url, $attr, $post_ID) {
  44. $return = '<div class="video-container">'.$html.'</div>';
  45. $return = str_replace('frameborder="0" allowfullscreen', 'style="border:none"', $return);
  46. return $return;
  47. }
  48. add_filter( 'embed_oembed_html', 'dw_embed_oembed_html' );
  49. function dw_embed_oembed_html( $html ) {
  50. return preg_replace( '@src="https?:@', 'src="', $html );
  51. }
  52. add_action( 'admin_menu', 'daw_is_online_add_admin_menu' );
  53. add_action( 'admin_init', 'daw_is_online_settings_init' );
  54. function daw_is_online_add_admin_menu( ) {
  55. add_options_page( 'DW Status', 'DAW Online', 'manage_options', 'daw_is_online', 'daw_is_online_options_page' );
  56. }
  57. function daw_is_online_settings_init( ) {
  58. register_setting( 'dwstatus', 'daw_is_online_settings' );
  59. add_settings_section('daw_is_online_pluginPage_section', __( 'DAW Online', 'wordpress' ), 'daw_is_online_settings_section_callback', 'dwstatus');
  60. 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' );
  61. }
  62. function daw_is_online_select_field_0_render( ) {
  63. $options = get_option( 'daw_is_online_settings' ); ?>
  64. <select name='daw_is_online_settings[daw_is_online_select_field_0]'>
  65. <option value='1' <?php selected( $options['daw_is_online_select_field_0'], 1 ); ?>>Yes</option>
  66. <option value='2' <?php selected( $options['daw_is_online_select_field_0'], 2 ); ?>>No</option>
  67. </select>
  68. <?php }
  69. function daw_is_online_settings_section_callback( ) {
  70. echo __( 'This sets my online status', 'wordpress' );
  71. }
  72. function daw_is_online_options_page( ) { ?>
  73. <form action='options.php' method='post'>
  74. <?php settings_fields( 'dwstatus' );
  75. do_settings_sections( 'dwstatus' );
  76. submit_button(); ?>
  77. </form>
  78. <?php }
  79. function dw_online_get_status() {
  80. $dw_status = get_option('daw_is_online_settings');
  81. if( $dw_status['daw_is_online_select_field_0'] == '1' ) { ?>
  82. <script type="text/javascript">
  83. var i;i = 0;
  84. $(function(){
  85. Messenger.options = {extraClasses: "messenger-fixed messenger-on-bottom messenger-on-left",theme: "flat"};
  86. var msg; msg = Messenger().post({
  87. message: 'I am currently online', type: 'success',
  88. actions: {retry: {label: 'Connect', delay: 30,
  89. action: function(){
  90. txt_dave();
  91. var msg_return; msg_return = Messenger().run({
  92. errorMessage: 'Please wait a moment while I am texted a message to get connected with you.',
  93. successMessage: 'Connecting Now!',
  94. action: function(opts) {
  95. msg.hide();
  96. if (++i < 2) {
  97. return opts.error({status: 500,readyState: 0,responseText: 0});
  98. }
  99. else {
  100. window.location.href = 'contact/chat';
  101. return msg.update({message: 'Redirect to Chat', hideAfter: 20, type: 'success', actions: false});
  102. }
  103. }
  104. });
  105. }
  106. },
  107. cancel: {
  108. label: 'No Thanks',
  109. action: function() {
  110. return msg.update({message: 'Maybe Next Time', hideAfter: 1, type: 'error', actions: false});
  111. }
  112. }
  113. }
  114. });
  115. });
  116. function txt_dave() {
  117. $.ajax({
  118. url: 'https://davidawindham.com/wha/phony/sms',
  119. dataType: 'json',
  120. success: function(data){},
  121. });
  122. }
  123. </script>
  124. <?php }
  125. }
  126. function dw_online_get_chat() {
  127. $dw_status = get_option('daw_is_online_settings');
  128. if( $dw_status['daw_is_online_select_field_0'] == '1' ) { ?>
  129. <script type="text/javascript">
  130. var i;i = 0;
  131. $(function(){
  132. Messenger.options = {extraClasses: "messenger-fixed messenger-on-bottom messenger-on-left",theme: "flat"};
  133. var msg_return; msg_return = Messenger().run({
  134. id: 'one',
  135. errorMessage: 'Looking for David...',
  136. action: function(opts) {
  137. if (++i < 2) {
  138. get_dave();
  139. return opts.error({status: 500,readyState: 0,responseText: 0});
  140. }
  141. }
  142. });
  143. });
  144. function get_dave() {
  145. $(function poll() {
  146. var x = 0;
  147. var countTimer = setInterval(function () {
  148. if(x > 5){clearInterval(countTimer)}
  149. else if(x == 5){dave_not_available()}
  150. else{
  151. var URLchatAPI = "http://macs.local:8080/status";
  152. var request = $.ajax({
  153. url: URLchatAPI,
  154. dataType: 'json',
  155. cache: false,
  156. success: function (data) {
  157. online = data.online;
  158. if(online=='yes'){
  159. $('.chat').modal('show');
  160. x = x+5;
  161. };
  162. if(online=='no'){
  163. dave_connecting();
  164. };
  165. },
  166. error: function ( xhr, tStatus, err ) {
  167. dave_error();
  168. x = x+5;
  169. }
  170. });
  171. x++;
  172. }
  173. }, 5000);
  174. });
  175. }
  176. function dave_connecting(){
  177. Messenger.options = {extraClasses: "messenger-fixed messenger-on-bottom messenger-on-left",theme: "flat"};
  178. var y;y = 0;
  179. var msg_waiting; msg_waiting = Messenger().run({
  180. id: 'one',
  181. hideAfter: 4,
  182. errorMessage: 'Waiting on David...',
  183. action: function(opts) {
  184. if (++y < 2) {
  185. get_dave();
  186. return opts.error({status: 500,readyState: 0,responseText: 0});
  187. }
  188. }
  189. });
  190. }
  191. function dave_not_available(){
  192. Messenger.options = {extraClasses: "messenger-fixed messenger-on-bottom messenger-on-left",theme: "flat"};
  193. var msg_error; msg_error = Messenger().post({
  194. message: 'Sorry, but I am busy.',
  195. type: 'error',
  196. id: 'one',
  197. showCloseButton: true,
  198. actions:{
  199. cancel: {
  200. label: '<a href="../">Leave me a message</a>',
  201. action: function(){
  202. window.location.href = '../';
  203. }
  204. }
  205. }
  206. });
  207. }
  208. function dave_error(){
  209. Messenger.options = {extraClasses: "messenger-fixed messenger-on-bottom messenger-on-left",theme: "flat"};
  210. var msg_error; msg_error = Messenger().post({
  211. message: 'Oops. Something has gone wrong.',
  212. type: 'error',
  213. id: 'one',
  214. showCloseButton: true,
  215. actions:{
  216. cancel: {
  217. label: '<a href="../">Leave me a message</a>',
  218. action: function(){
  219. window.location.href = '../';
  220. }
  221. }
  222. }
  223. });
  224. }
  225. $(function() {
  226. if (window.location.hash.indexOf("chat") !== -1) {
  227. $('.chat').modal('show');
  228. }
  229. });
  230. </script>
  231. <?php }
  232. }
  233. ?>