{"id":57,"date":"2009-11-01T20:04:29","date_gmt":"2009-11-01T18:04:29","guid":{"rendered":"http:\/\/www.bretterhofer.at\/blog\/?page_id=57"},"modified":"2010-04-07T22:20:27","modified_gmt":"2010-04-07T20:20:27","slug":"auto_wp_options","status":"publish","type":"page","link":"https:\/\/bretterhofer.at\/blog\/projects\/wordpress-plugins\/auto_wp_options\/","title":{"rendered":"auto_wp_options"},"content":{"rendered":"<p>auto_wp_options<\/p>\n<p>This is a plugin for my needs to simplify my wordpress installation.<\/p>\n<p>I use a local installation at http:\/\/www.bretterhofer.local and then moved it to http:\/\/www.bretterhofer.at.<\/p>\n<p>But there are some wp_options that need to be changed if you move to a different server.<\/p>\n<pre>function auto_wp_options()\r\n{\r\n $siteurl=getHostUrl();\r\n $filesystemroot_of_wordpress=str_replace ( \"\\\\\", \"\/\", realpath(dirname(__FILE__).\"\/..\/..\/..\/\").\"\/\");\r\n\r\n die(\"auto_wp_options: \".$filesystemroot_of_wordpress);\r\n $sql\u00a0 = \"UPDATE wp_options SET\u00a0 option_value='\".$global_aplicationRoot.\"wordpress\/' WHERE option_name='siteurl';\";\r\n $resultset = $wpdb-&gt;query($sql);\r\n\r\n $sql\u00a0 = \"UPDATE wp_options SET\u00a0 option_value='\".$global_aplicationRoot.\"wordpress\/' WHERE option_name='home';\";\r\n $resultset = $wpdb-&gt;query($sql);\r\n\r\n $sql\u00a0 = \"UPDATE wp_options SET\u00a0 option_value='\".$filesystemroot_of_wordpress.\"wordpress\/wp-content\/uploads' WHERE option_name='upload_path';\";\r\n $resultset = $wpdb-&gt;query($sql);\r\n}\r\n\/**************************************************\r\nSome wp_options need to be adjusted\r\n\r\nBest would be just on session start. Currently it happens at plugins_loaded\r\n\r\n*\/\r\nadd_action ( 'plugins_loaded ', 'auto_wp_options' );\r\n\/\/\u00a0\u00a0\u00a0 applied to the comment author's IP address prior to saving the comment in the database.\r\nadd_filter ( 'pre_comment_user_ip','auto_reverse_proxy_pre_comment_user_ip');\r\n\r\nadd_action('admin_menu', 'my_plugin_menu');<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>auto_wp_options This is a plugin for my needs to simplify my wordpress installation. I use a local installation at http:\/\/www.bretterhofer.local and then moved it to<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":101,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/bretterhofer.at\/blog\/wp-json\/wp\/v2\/pages\/57"}],"collection":[{"href":"https:\/\/bretterhofer.at\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/bretterhofer.at\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/bretterhofer.at\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bretterhofer.at\/blog\/wp-json\/wp\/v2\/comments?post=57"}],"version-history":[{"count":6,"href":"https:\/\/bretterhofer.at\/blog\/wp-json\/wp\/v2\/pages\/57\/revisions"}],"predecessor-version":[{"id":60,"href":"https:\/\/bretterhofer.at\/blog\/wp-json\/wp\/v2\/pages\/57\/revisions\/60"}],"up":[{"embeddable":true,"href":"https:\/\/bretterhofer.at\/blog\/wp-json\/wp\/v2\/pages\/101"}],"wp:attachment":[{"href":"https:\/\/bretterhofer.at\/blog\/wp-json\/wp\/v2\/media?parent=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}