<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CloudFW. stránka &#8211; WebStudio Nové Trendy</title>
	<atom:link href="https://www.webstudio-novetrendy.dev/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.webstudio-novetrendy.dev</link>
	<description>Webové stránky, správa webu, SEO</description>
	<lastBuildDate>Mon, 10 Jul 2017 15:57:40 +0000</lastBuildDate>
	<language>cs</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.17</generator>
	<item>
		<title>Create a Custom Database Error Page in WordPress</title>
		<link>https://www.webstudio-novetrendy.dev/create-a-custom-database-error-page-in-wordpress/</link>
		
		<dc:creator><![CDATA[novetrendy]]></dc:creator>
		<pubDate>Mon, 10 Jul 2017 11:44:04 +0000</pubDate>
				<category><![CDATA[Snippets]]></category>
		<guid isPermaLink="false">https://www.webstudio-novetrendy.dev/?p=526</guid>

					<description><![CDATA[If WordPress is unable to connect to the database, it will check for the presence of your custom error page (wp-content/db-error.php)and then serve it up to your visitors. Otherwise, if a custom error page is not present, the default error page is displayed (ugly). To create your own database error page, simply create your custom [&#8230;]]]></description>
										<content:encoded><![CDATA[If WordPress is unable to connect to the database, it will check for the presence of your custom error page <code>(wp-content/db-error.php)</code>and then serve it up to your visitors.
Otherwise, if a custom error page is not present, the default error page is displayed (ugly).
To create your own database error page, simply create your custom page, name it <code>db-error.php</code>, and upload it to the <code>wp-content</code>.
Next code display custom DB error page and send email to admin every 15 minuts (if the error persists).
<blockquote class="ui--blockquote"><p>That&#8217;s all &#8211; it&#8217;s easy, right?</p>
</blockquote>
[php]
&lt;?php
header( &#039;HTTP/1.1 503 Service Temporarily Unavailable&#039; );
header( &#039;Status: 503 Service Temporarily Unavailable&#039; );
header( &#039;Retry-After: 3600&#039; ); // 60 minut

if ( !empty( $_SERVER[&#039;HTTP_CLIENT_IP&#039;] ) ) { $ip=$_SERVER[&#039;HTTP_CLIENT_IP&#039;]; }
elseif ( !empty( $_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;] ) ) { $ip=$_SERVER[&#039;HTTP_X_FORWARDED_FOR&#039;]; }
else { $ip=$_SERVER[&#039;REMOTE_ADDR&#039;]; }


/*********** Because now we don´t have access to DB, we use json file to store timestamp variable **********/
$file = &#039;timestamp.json&#039;; // Name of the json file
$timestamp = time(); // Timestamp in UNIX format
$have_to_send = NULL; // Initialization variable

if ( file_exists( $file) ) { // We check if file exists
    $time_out = json_decode( file_get_contents( $file ), true ); // If case YES, we have set variable $time_out
    $have_to_send = $time_out - $timestamp; // We set variable $have_to_send - send email ?
    }

else { // If case NO, we create the json file and save in to file timestamp + 15 minuts (send email only one per 15 minuts)
$set_time_out = $timestamp + ( 900 );// +15 minutes - you can change to everything
$fp = fopen( $file, &#039;w&#039; ); // We open the json file for writing
fwrite($fp, json_encode($set_time_out)); // We writing variable $set_time_out to the json file
fclose($fp); // We close the json file
$time_out = $set_time_out; // We set variable $time_out
}


if ( $have_to_send &lt;= 1 ){ // We send email after first DB error, or after 15 minuts from last send email

    $mailto   = &quot;Name ";
    $mailfrom   = "dberror@".$_SERVER['SERVER_NAME'];

if ( $_SERVER['REQUEST_URI'] != "/wp-content/db-error.php" ) {
    $headers  = "Content-Type: text/html; charset=utf-8n" . "From: ". $mailfrom;
    $message  = 'Database error while accessing URL: <a href="http://' .$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] .'">'. 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] .'</a>The URL was accessed from the IP address: <a href="http://whatismyipaddress.com/ip/'.$ip.'">' .$ip.'</a>'; // message + URL where the error occured + IP from where it was accessed
    $subject  = "DB error on server ".$_SERVER['SERVER_NAME'];
    mail($mailto,$subject,$message,$headers); // We will send an email
}

if ( ( $time_out - $timestamp ) 


    
        The bucket has a hole in the bottom, sweet Lisa, nice Lisa
        

       
        body {
            background: #fff;
            font: 16px Georgia,serif;
            line-height: 1.3;
            margin: 0;
            padding: 0;
            }
        #content {
            background: #fff url(/wp-content/hole.jpg) no-repeat left top;
            height: 225px;
            margin: 80px auto 0;
            padding: 75px 50px 0 400px;
            width: 375px;
            }
        h1 {
            font-size: 34px;
            font-weight: normal;
            margin-top: 0;
            }
        p {
            margin: 0 0 10px 5px;
            }
        

        
        
            
                Oops!
                <p>Something went wrong, trying to figure out what. Check us again soon, if we came to that!</p>
                
                
                
[/php]Frontend result

    
        The bucket has a hole in the bottom, sweet Lisa, nice Lisa
        

       
        body {
            background: #fff;
            font: 16px Georgia,serif;
            line-height: 1.3;
            margin: 0;
            padding: 0;
            }
        #content {
            background: #fff url(/obsah/hole.jpg) no-repeat left top;
            height: 225px;
            margin: auto 0;
            padding: 75px 50px 0 400px;
            width: 100%;
            }
        h1 {
            font-size: 34px;
            font-weight: normal;
            margin-top: 0;
            }
        p {
            margin: 0 0 10px 5px;
            }
        

        
        
            
                Oops!
                <p>Something went wrong, trying to figure out what. Check us again soon, if we came to that!</p>
                
                
                ]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Snippets</title>
		<link>https://www.webstudio-novetrendy.dev/snippets/</link>
		
		<dc:creator><![CDATA[novetrendy]]></dc:creator>
		<pubDate>Wed, 13 May 2015 08:13:22 +0000</pubDate>
				<category><![CDATA[Snippets]]></category>
		<guid isPermaLink="false">https://www.webstudio-novetrendy.dev/?p=301</guid>

					<description><![CDATA[Custom tracking code for the thanks page You can add your custom tracking code to the theme functions.php file, based on this: add_action( 'woocommerce_thankyou', 'my_custom_tracking' ); function my_custom_tracking( $order_id ) { // Lets grab the order $order = new WC_Order( $order_id ); /** * Put your tracking code here * You can get the order [&#8230;]]]></description>
										<content:encoded><![CDATA[Custom tracking code for the thanks page

<p>You can add your custom tracking code to the theme functions.php file, based on this:</p>
add_action( 'woocommerce_thankyou', 'my_custom_tracking' );
function my_custom_tracking( $order_id ) {
// Lets grab the order
 $order = new WC_Order( $order_id );
/**
 * Put your tracking code here
 * You can get the order total etc e.g. $order-&gt;get_order_total();
 **/
}
<strong>Please note:</strong> This snippet is for adding tracking for a separate piece of analytic software you may have installed.


Allow HTML in term (category, tag) descriptions

<p>By default WordPress strips HTML from category descriptions. You can get around this by adding a small snippet to your theme functions.php file:</p>
foreach ( array( 'pre_term_description' ) as $filter ) {
    remove_filter( $filter, 'wp_filter_kses' );
}
 
foreach ( array( 'term_description' ) as $filter ) {
    remove_filter( $filter, 'wp_kses_data' );
}
<p>The first part prevents html from being stripped from term descriptions.</p>
<p>The second part prevents html being stripped out when using the term description function (http://codex.wordpress.org/Function_Reference/term_description).</p>


Editing product data tabs
Removing Tabs
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );

function woo_remove_product_tabs( $tabs ) {

unset( $tabs['description'] );          // Remove the description tab
unset( $tabs['reviews'] );             // Remove the reviews tab
unset( $tabs['additional_information'] );      // Remove the additional information tab

return $tabs;

}


Renaming Tabs
<p>Use the following snippet to rename tabs.</p>
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {

$tabs['description']['title'] = __( 'More Information' );        // Rename the description tab
$tabs['reviews']['title'] = __( 'Ratings' );                // Rename the reviews tab
$tabs['additional_information']['title'] = __( 'Product Data' );    // Rename the additional information tab

return $tabs;

}


Re-ordering Tabs
<p>Use the following snippet to change the tab order</p>
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {

	$tabs['reviews']['priority'] = 5;			// Reviews first
	$tabs['description']['priority'] = 10;			// Description second
	$tabs['additional_information']['priority'] = 15;	// Additional information third

	return $tabs;
}
<p>&nbsp;</p>
Customise a tab
<p>The following snippet will replace the description tab with a custom function</p>
add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
function woo_custom_description_tab( $tabs ) {

$tabs['description']['callback'] = 'woo_custom_description_tab_content';    // Custom description callback

return $tabs;
}

function woo_custom_description_tab_content() {
echo '&lt;h2&gt;Custom Description&lt;/h2&gt;';
echo '&lt;p&gt;Here\'s a custom description&lt;/p&gt;';
}


Add a custom tab
<p>Use the following snippet to add a custom global product tab</p>
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {

// Adds the new tab

$tabs['test_tab'] = array(
'title'     =&gt; __( 'New Product Tab', 'woocommerce' ),
'priority'     =&gt; 50,
'callback'     =&gt; 'woo_new_product_tab_content'
);

return $tabs;

}
function woo_new_product_tab_content() {

// The new tab content

echo '&lt;h2&gt;New Product Tab&lt;/h2&gt;';
echo '&lt;p&gt;Here\'s your new product tab.&lt;/p&gt;';

}


The Additional Information tab
<p>Please note that the “<strong>Additional Information</strong>” tab will only show if the product has weight, dimensions or attributes (not used for variation for variable products). If you try to apply a change to that tab and if the product does not have weight, dimensions or attribute, you will get an error message similar to :</p>
<p>Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in /mysite/obsah/moduly/woocommerce/templates/single-product/tabs/tabs.php on line 35</p>
<p>In that case you have to use WooCommerce conditional tags:</p>

has_attributes()
has_dimensions()
has_weight()

add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );

function woo_rename_tabs( $tabs ) {

global $product;

if( $product-&gt;has_attributes() || $product-&gt;has_dimensions() || $product-&gt;has_weight() ) { // Check if product has attributes, dimensions or weight
$tabs['additional_information']['title'] = __( 'Product Data' );    // Rename the additional information tab
}

return $tabs;

}

]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
