<?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>Tutorials - ThemesPress</title>
	<atom:link href="https://themespress.ca/en/categorie/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>https://themespress.ca/en/</link>
	<description>Experts en développement d’API, plugins et intégrations WordPress.</description>
	<lastBuildDate>Fri, 02 Oct 2026 19:06:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>

<image>
	<url>https://themespress.ca/wp-content/uploads/2020/10/cropped-Favicon-Themepress.ca_-32x32.png</url>
	<title>Tutorials - ThemesPress</title>
	<link>https://themespress.ca/en/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Download a WordPress Photo Gallery as a ZIP File</title>
		<link>https://themespress.ca/en/download-a-wordpress-photo-gallery-zip-file/</link>
					<comments>https://themespress.ca/en/download-a-wordpress-photo-gallery-zip-file/#respond</comments>
		
		<dc:creator><![CDATA[Themespress]]></dc:creator>
		<pubDate>Fri, 02 Oct 2026 18:47:35 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=9541</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p><strong>Download a WordPress photo gallery as a ZIP file:</strong></p>
<p>Do you use <a href="https://wordpress.org/" target="_blank" rel="noopener">WordPress</a> to showcase your photos and want to let visitors download an entire gallery at once? Whether you are a professional photographer, artist, or portfolio website manager, offering gallery downloads as ZIP files can make sharing your images much easier.</p>
<p>Instead of asking visitors to save each photo individually, you can provide a ZIP file containing all the images from a gallery.</p>
<p>In this tutorial, we’ll show you how to offer WordPress photo gallery downloads as ZIP files and how to automate the process with a suitable plugin.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Why Offer a Photo Gallery Download as a ZIP File?</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Imagine you are a professional photographer who has just finished a photo session for a client.</p>
<p>You have selected 80 photographs that you want to deliver. You create a private gallery on your WordPress site so the client can review the images.</p>
<p>The problem? If your gallery does not include a bulk download option, your client will have to save all 80 photos one by one.</p>
<p>This quickly becomes tedious, especially when galleries contain dozens or even hundreds of images.</p>
<p>Downloading the gallery as a ZIP file solves this problem.</p>
<p>A ZIP file is an archive that combines multiple files into a single downloadable file. Your client can download all the photographs from the gallery at once, then extract the archive on their computer.</p>
<p>This feature is especially useful for wedding photographers, event photographers, marketing agencies, and portfolio creators.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >How to Download All Photos from a WordPress Gallery at Once?</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>To offer bulk downloads of your photographs, you need to generate a ZIP archive containing the images from your gallery, then make that archive available to your visitors.</p>
<p><strong>There are several ways to do this.</strong></p>
<p>You can manually create a ZIP file on your computer, upload it to your WordPress server, and add a download link to your page.</p>
<p>This method works, but you have to repeat the process every time you add, remove, or update photos in the gallery.</p>
<p>Another option is to use a WordPress plugin that can automatically generate ZIP files for your galleries.</p>
<p>That is one of the features offered by Obiweb Gallery.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Download a WordPress Photo Gallery as a ZIP File with Obiweb Gallery</h2><div class="vc_row wpb_row vc_inner vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-6"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div  class="wpb_single_image wpb_content_element vc_align_left wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img fetchpriority="high" decoding="async" width="1536" height="1024" src="https://themespress.ca/wp-content/uploads/2017/02/Obiweb-Gallery-–-La-solution-complete-pour-vos-galeries-et-portfolios-WordPress.png" class="vc_single_image-img attachment-full" alt="Obiweb Gallery – La solution complète pour vos galeries et portfolios WordPress" title="Obiweb Gallery – La solution complète pour vos galeries et portfolios WordPress" srcset="https://themespress.ca/wp-content/uploads/2017/02/Obiweb-Gallery-–-La-solution-complete-pour-vos-galeries-et-portfolios-WordPress.png 1536w, https://themespress.ca/wp-content/uploads/2017/02/Obiweb-Gallery-–-La-solution-complete-pour-vos-galeries-et-portfolios-WordPress-300x200.png 300w, https://themespress.ca/wp-content/uploads/2017/02/Obiweb-Gallery-–-La-solution-complete-pour-vos-galeries-et-portfolios-WordPress-1024x683.png 1024w, https://themespress.ca/wp-content/uploads/2017/02/Obiweb-Gallery-–-La-solution-complete-pour-vos-galeries-et-portfolios-WordPress-768x512.png 768w, https://themespress.ca/wp-content/uploads/2017/02/Obiweb-Gallery-–-La-solution-complete-pour-vos-galeries-et-portfolios-WordPress-600x400.png 600w" sizes="(max-width: 1536px) 100vw, 1536px" /></div>
		</figure>
	</div>
</div></div></div><div class="wpb_column vc_column_container vc_col-sm-6"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p><strong>Obiweb Gallery</strong> is a WordPress plugin for creating and managing image galleries and portfolios. It also includes several features designed to simplify photo management, optimization, and downloads.</p>
<p>Among its features, the plugin can automatically generate a ZIP file for each gallery and provide a link that lets visitors download the images. <a href="https://themespress.ca/en/products/plugins-wordpress/crasy-photos-portfolio-plugin-for-wordpress/">Obiweb Gallery</a></p>
<p>Visitors can browse the photos directly on your site, then download the entire gallery in a single step.</p>

		</div>
	</div>
</div></div></div></div></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >How to Set Up ZIP Downloads?</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Here are the main steps for offering this feature on your WordPress site.</p>
<p>1. <strong>Create your photo gallery.</strong> After installing and activating Obiweb Gallery, create a gallery and add the images you want to share with your visitors or clients.</p>
<p>2. <strong>Prepare the download.</strong> Check your gallery’s download options and make sure its ZIP archive is available. Obiweb Gallery includes an automatic ZIP file generation system.</p>
<p>3. <strong>Publish your gallery.</strong> Add your gallery to the WordPress page of your choice. Obiweb Gallery supports shortcodes as well as integrations with Elementor and WPBakery.</p>
<p>4. <strong>Test the download.</strong> Open the gallery as a visitor would, use the download link, and make sure the ZIP file contains the expected photographs.</p>
<p>The goal is to provide a simple experience: visitors browse the images in the gallery, then download the full set of photos whenever they want.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >What Happens When You Update a Gallery?</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>A photographer may need to add new images after publishing a gallery or replace certain photographs.</p>
<p><a href="https://themespress.ca/en/obiweb-gallery-wordpress-galleries-portfolios/" target="_blank" rel="noopener"><strong>Obiweb Gallery</strong></a> includes a manual ZIP archive regeneration system in the WordPress admin area, along with a scheduled task to keep the archives updated.</p>
<p>This feature eliminates the need to manually recreate each archive on your computer after making changes.</p>
<p>However, it is still important to make sure that the ZIP file available to visitors matches the latest version of your gallery.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Optimize Your Gallery Images with WebP</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Bulk downloads are especially useful for your clients, but image file size can also affect your website’s performance.</p>
<p>High-resolution photographs can be large. When a gallery contains many images, displaying them can lead to longer loading times.</p>
<p>Obiweb Gallery includes an image conversion feature for WebP, along with optional integration with the Tinify API for compression.</p>
<p>The WebP format generally helps reduce the file size of images used on the web while maintaining good visual quality.</p>
<p>This lets you address two complementary needs: provide lighter, faster-loading galleries and allow your clients to download their photographs in a ZIP archive.</p>
<p>However, it is important to distinguish between the images displayed on your website and the files delivered to your clients. If you provide photographs intended for printing, make sure the archive contains the files in the expected dimensions and formats.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >A Few Precautions Before Sharing Your Galleries</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Before making a ZIP file available, make sure the photographs can actually be shared with the people who will access the gallery.</p>
<p>For a private photo session, it is best to protect access to the page and also verify the access conditions for the ZIP file itself. A protected page does not necessarily guarantee that the archive cannot be accessed directly through its URL.</p>
<p>Also remember to test the download from a mobile device and check the archive size, especially when your gallery contains high-resolution photographs.</p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/download-a-wordpress-photo-gallery-zip-file/">Download a WordPress Photo Gallery as a ZIP File</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/download-a-wordpress-photo-gallery-zip-file/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Updating your Formidable Forms Pro License</title>
		<link>https://themespress.ca/en/updating-formidable-forms-pro-license/</link>
					<comments>https://themespress.ca/en/updating-formidable-forms-pro-license/#respond</comments>
		
		<dc:creator><![CDATA[Themespress]]></dc:creator>
		<pubDate>Wed, 14 Jan 2026 18:06:57 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Formidable Form]]></category>
		<category><![CDATA[License key]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=8395</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>It is possible that Formidable Forms Pro cannot recognize the newest license key. In certain cases, the Formidable → Settings page displays blank. In this case, you won&#8217;t be able to update your license key within the WordPress admin.</p>
<p>When this happens, you can update the license key directly in the database via phpMyAdmin seeing as WordPress stores it in the wp_options table. So when the admin page is blank, you can update it manually.</p>
<p>However, you should use this method as a last resort. It allows you to fix a blocked or corrupted license without having to uninstall the plugin or lose data. Before anything, make sure to backup your database.</p>
<p>Once the license updated, the <a href="https://formidableforms.com/" target="_blank" rel="noopener">Formidable</a> → Settings page will become accessible once again. You can then return to the Formidable admin page and update or replace the key from the WordPress interface.</p>

		</div>
	</div>

	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<ul>
<li data-start="122" data-end="357">
<p data-start="125" data-end="357"><strong data-start="125" data-end="177">Updating the license in the database</strong><br data-start="177" data-end="180" />When the <strong data-start="199" data-end="224">Formidable → Settings</strong> page becomes inaccessible (blank page), the license key can be edited directly in the modifiée <code data-start="325" data-end="337">wp_options</code> table via <strong data-start="342" data-end="356">phpMyAdmin</strong>.</p>
</li>
<li data-start="359" data-end="583">
<p data-start="362" data-end="583"><strong data-start="362" data-end="412">Re-establishing access to the Formidable Settings page</strong><br data-start="412" data-end="415" />This update allows you to <strong>fix the issue</strong> in order to be able to accesss the <strong data-start="525" data-end="550">Formidable → Settings</strong> page within the WordPress admin.</p>
</li>
<li data-start="585" data-end="859">
<p data-start="588" data-end="859"><strong data-start="588" data-end="641">Updating the license from the WordPress interface</strong><br data-start="641" data-end="644" />Once the page is accessible, it is highly recommended to return to the <strong data-start="695" data-end="735"><a href="https://formidableforms.com/" target="_blank" rel="noopener">Formidable</a></strong> <strong>settings</strong> and <strong>update or confirm the license key from te interface</strong> in order to restore normal functionality to the plugin.</p>
</li>
</ul>

		</div>
	</div>
<div id="ts-enlighterjs-container-2303145" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-2303145" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">UPDATE wp_options
SET option_value = &#039;a:1:{s:7:&quot;license&quot;;s:32:&quot;YOUR API KEY HERE&quot;;}&#039;
WHERE option_name = &#039;frmpro-credentials&#039;;</pre></div></div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/updating-formidable-forms-pro-license/">Updating your Formidable Forms Pro License</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/updating-formidable-forms-pro-license/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Calculating Average Shipping Cost per Order &#8211; WooCommerce</title>
		<link>https://themespress.ca/en/average-shipping-cost/</link>
					<comments>https://themespress.ca/en/average-shipping-cost/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Sat, 28 Oct 2023 20:24:44 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=7502</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>With this tutorial, we will calculate the average shipping cost per order across all orders; including those with no shipping fees. You can tweak the function like this:</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Calculating the average order shipping cost for all orders</h2><div id="ts-enlighterjs-container-5101442" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-5101442" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="standard" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">function woocl_calculate_average_shipping_cost_per_order_all_orders() {
    $args = array(
        &#039;status&#039; =&gt; array(&#039;wc-completed&#039;, &#039;wc-shipped&#039;),
        &#039;limit&#039; =&gt; -1,
        &#039;return&#039; =&gt; &#039;ids&#039;,
    );
    $shipped_orders = wc_get_orders($args);

    $total_shipping_cost = 0;
    $total_orders = count($shipped_orders);

    foreach ($shipped_orders as $order_id) {
        $order = wc_get_order($order_id);
        $shipping_total = (float) $order-&gt;get_shipping_total();
        $total_shipping_cost += $shipping_total;
    }

    if ($total_orders &gt; 0) {
        $average_shipping_cost_per_order = $total_shipping_cost / $total_orders;
    } else {
        $average_shipping_cost_per_order = 0;
    }

    return $average_shipping_cost_per_order;
}
</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Let&#8217;s now display it in our template.</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-6864501" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-6864501" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="standard" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">$average_shipping_cost_per_order = woocl_calculate_average_shipping_cost_per_order_all_orders();
echo &#039;Co&ucirc;t moyen d\&#039;exp&eacute;dition par commande (toutes les commandes): &#039; . wc_price($average_shipping_cost_per_order);
</pre></div><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Calculating the average order shipping cost: Order with shipping fees</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>If you want to calculate average order shipping costs for orders with a <strong>shipping value</strong>, you can use the following function:</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-2034403" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-2034403" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="standard" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">function woocl_calculate_average_shipping_cost_for_orders_with_shipping() {
    $args = array(
        &#039;status&#039; =&gt; array(&#039;wc-completed&#039;, &#039;wc-shipped&#039;),
        &#039;limit&#039; =&gt; -1,
        &#039;return&#039; =&gt; &#039;ids&#039;,
    );
    $shipped_orders = wc_get_orders($args);

    $total_shipping_cost = 0;
    $orders_with_shipping = 0;

    foreach ($shipped_orders as $order_id) {
        $order = wc_get_order($order_id);
        $shipping_total = (float) $order-&gt;get_shipping_total();

        if ($shipping_total &gt; 0) {
            $total_shipping_cost += $shipping_total;
            $orders_with_shipping++;
        }
    }

    if ($orders_with_shipping &gt; 0) {
        $average_shipping_cost = $total_shipping_cost / $orders_with_shipping;
    } else {
        $average_shipping_cost = 0;
    }

    return $average_shipping_cost;
}
</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Displaying average order shipping cost (only for orders with a shipping value)</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-6160746" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-6160746" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="standard" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">$average_shipping_cost = woocl_calculate_average_shipping_cost_for_orders_with_shipping();
echo &#039;Co&ucirc;t moyen d\&#039;exp&eacute;dition (uniquement les commandes avec frais d\&#039;exp&eacute;dition): &#039; . wc_price($average_shipping_cost);
</pre></div></div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/average-shipping-cost/">Calculating Average Shipping Cost per Order – WooCommerce</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/average-shipping-cost/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>MemberPress Subscriptions &#8211; WooCommerce customer account</title>
		<link>https://themespress.ca/en/memberpress-subscriptions-woocommerce-customer-account/</link>
					<comments>https://themespress.ca/en/memberpress-subscriptions-woocommerce-customer-account/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Sat, 14 Oct 2023 22:46:38 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=7464</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>With this tutorial, we will add a new tab that will allow you to access MemberPress subs for each customer in their respective WooCommerce profiles.</p>
<p>We&#8217;re looking to add a new tab in the customer&#8217;s WooCommerce account.</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-3202916" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-3202916" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="standard" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">//New Tab Woocommerce
add_filter ( &#039;woocommerce_account_menu_items&#039;, &#039;subscriptions_woocommerce_link&#039;, 40 );
function subscriptions_woocommerce_link( $menu_links ){
	$menu_links = array_slice( $menu_links, 0, 5, true )
	+ array( &#039;subscriptions&#039; =&gt; &#039;Adh&eacute;sions Memberpress&#039; )
	+ array_slice( $menu_links, 5, NULL, true );
	return $menu_links;
}

//Register permalink endpoint
add_action( &#039;init&#039;, &#039;subscriptions_woocommerce_link_add_endpoint&#039; );
function subscriptions_woocommerce_link_add_endpoint() {
    add_rewrite_endpoint( &#039;subscriptions&#039;, EP_PAGES );
}

//Content for the new page in My Account, woocommerce_account_{ENDPOINT NAME}_endpoint
add_action( &#039;woocommerce_account_subscriptions_endpoint&#039;, &#039;subscriptions_endpoint_content&#039; );
function subscriptions_endpoint_content() {
	echo &#039;&lt;h2&gt;Adh&eacute;sions&lt;/h2&gt;&#039;;
	echo do_shortcode(&#039;[mepr-account-form]&#039;);
}</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Once you&#8217;ve added the code in your functions.php file, you will need to go in your WordPress configurations and re-save your permalinks without changing the configurations.<strong>Simply click on Update.</strong></p>

		</div>
	</div>

	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Now, we will rewrite the display layout of the MemberPress template.</p>
<p>In order to proceed, you&#8217;ll need a WordPress theme or child theme. In the enabled theme, you&#8217;ll need to add a new <strong>MemberPress</strong> folder in the root folder of your theme and then add the <strong>mpca-manage-account-template.php</strong> file in the newly created folder.</p>
<p>You will also need the <strong>memberpress-corporate/app/views/mpca-manage-account-template.php</strong> file in the same MemberPress folder.</p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/memberpress-subscriptions-woocommerce-customer-account/">MemberPress Subscriptions – WooCommerce customer account</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/memberpress-subscriptions-woocommerce-customer-account/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Number of WordPress Media Query</title>
		<link>https://themespress.ca/en/number-of-wordpress-media-query/</link>
					<comments>https://themespress.ca/en/number-of-wordpress-media-query/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Sat, 19 Aug 2023 18:36:49 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=7347</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Number of WordPress Media Query</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>With this tutorial, we will create a query that will return the number of media (i.e. images) that have been uploaded in WordPress.</p>
<p>Let&#8217;s start with image type. In our query below, we will create an SQL query that will fetch the number of images uploaded today. <strong>Le post mime type</strong></p>
<p>.<strong>Here&#8217;s the SQL query inside a shortcode:</strong></p>

		</div>
	</div>
<div id="ts-enlighterjs-container-8571116" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-8571116" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">/**************************** Count des images telechargees aujourd&#039;hui ********************************/

function count_attachments_today() {
    global $wpdb;

    $today = getdate();
    $year = $today[&#039;year&#039;];
    $month = $today[&#039;mon&#039;];
    $day = $today[&#039;mday&#039;];

    $count = $wpdb-&gt;get_var(
        $wpdb-&gt;prepare(
            &quot;SELECT COUNT(ID) FROM $wpdb-&gt;posts
            WHERE post_type = &#039;attachment&#039;
            AND post_mime_type LIKE &#039;image%%&#039;
            AND YEAR(post_date) = %d
            AND MONTH(post_date) = %d
            AND DAY(post_date) = %d&quot;,
            $year, $month, $day
        )
    );

    return &#039;&lt;div class=&quot;addo40px addocenter&quot;&gt;&#039; . $count . &#039;&lt;/div&gt;&#039;;
}
add_shortcode( &#039;attachmentcounttoday&#039;, &#039;count_attachments_today&#039; );</pre></div><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Number of WordPress Media Query</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>We will now do the same query, but this type for the video format. <strong>Once again, here&#8217;s the SQL query inside a shortcode:</strong></p>

		</div>
	</div>
<div id="ts-enlighterjs-container-3169989" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-3169989" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">/**************************** Count des videos telechargees aujourd&#039;hui ********************************/

function count_videos_attachments_today() {
    global $wpdb;

    $today = getdate();
    $year = $today[&#039;year&#039;];
    $month = $today[&#039;mon&#039;];
    $day = $today[&#039;mday&#039;];

    $count = $wpdb-&gt;get_var(
        $wpdb-&gt;prepare(
            &quot;SELECT COUNT(ID) FROM $wpdb-&gt;posts
            WHERE post_type = &#039;attachment&#039;
            AND post_mime_type LIKE &#039;video%%&#039;
            AND YEAR(post_date) = %d
            AND MONTH(post_date) = %d
            AND DAY(post_date) = %d&quot;,
            $year, $month, $day
        )
    );

    return &#039;&lt;div class=&quot;addo40px addocenter&quot;&gt;&#039; . $count . &#039;&lt;/div&gt;&#039;;
}
add_shortcode( &#039;videoattachmentcounttoday&#039;, &#039;count_videos_attachments_today&#039; );
</pre></div></div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/number-of-wordpress-media-query/">Number of WordPress Media Query</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/number-of-wordpress-media-query/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Class PHP &#8211; API You Tube &#8211; Version 3</title>
		<link>https://themespress.ca/en/class-php-api-you-tube-version-3/</link>
					<comments>https://themespress.ca/en/class-php-api-you-tube-version-3/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Sat, 22 Jul 2023 13:21:14 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=7176</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>We have created a basic PHP class that will let you connect to YouTube&#8217;s API and display a video or a channel based on its ID and matching data.</p>
<h3>Here are the video&#8217;s data available:</h3>
<ul>
<li>Title</li>
<li>Description</li>
<li>Thumbnail</li>
<li>Views</li>
<li>Likes</li>
<li>Dislikes</li>
<li>Comments</li>
<li>Date Published</li>
<li>Channel Title</li>
<li>Tags</li>
<li>Default Language</li>
</ul>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Class PHP - API You Tube</h2><div id="ts-enlighterjs-container-4553530" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-4553530" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="standard" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">/////////////////////////// Requires and includes admin theme  /////////////////////////

class WPVYouTubeAPI {
    private $apiKey;

    public function __construct($apiKey)
    {
       $this-&gt;apiKey = $apiKey;
    }

    /**
     * Retrieves videos by channel ID.
     * @param string $channelId The ID of the channel.
     * @param int $maxResults The maximum number of videos to retrieve.
     * @return array An array containing the channel name and videos.
     */
    public function wpvgetVideosByChannel($channelId, $maxResults = 10) {
        $url = &quot;https://www.googleapis.com/youtube/v3/search?part=snippet&amp;channelId={$channelId}&amp;maxResults={$maxResults}&amp;key={$this-&gt;apiKey}&quot;;
        $response = $this-&gt;wpvsendRequest($url);
        $videos = array();
        foreach ($response[&#039;items&#039;] as $item) {
            $videoId = $item[&#039;id&#039;][&#039;videoId&#039;];
            $video = $this-&gt;getVideoDetails($videoId);
            $videos[] = $video;
        }
        // Retrieve the channel name from the first item in the response
        $channelName = $response[&#039;items&#039;][0][&#039;snippet&#039;][&#039;channelTitle&#039;];
        return array(
            &#039;channelName&#039; =&gt; $channelName,
            &#039;videos&#039; =&gt; $videos
        );
    }
    
    /**
     * Retrieves video details by video ID.
     * @param string $videoId The ID of the video.
     * @return array An array containing the video details.
     */
    public function wpvgetVideoDetails($videoId)
    {
        $url = &quot;https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics&amp;id={$videoId}&amp;key={$this-&gt;apiKey}&quot;;

        $response = $this-&gt;wpvsendRequest($url);

        $video = array(
            &#039;title&#039; =&gt; $response[&#039;items&#039;][0][&#039;snippet&#039;][&#039;title&#039;],
            &#039;description&#039; =&gt; $response[&#039;items&#039;][0][&#039;snippet&#039;][&#039;description&#039;],
            &#039;thumbnail&#039; =&gt; $response[&#039;items&#039;][0][&#039;snippet&#039;][&#039;thumbnails&#039;][&#039;default&#039;][&#039;url&#039;],
            &#039;views&#039; =&gt; $response[&#039;items&#039;][0][&#039;statistics&#039;][&#039;viewCount&#039;],
            &#039;likes&#039; =&gt; $response[&#039;items&#039;][0][&#039;statistics&#039;][&#039;likeCount&#039;],
            &#039;dislikes&#039; =&gt; $response[&#039;items&#039;][0][&#039;statistics&#039;][&#039;dislikeCount&#039;],
            &#039;comments&#039; =&gt; $response[&#039;items&#039;][0][&#039;statistics&#039;][&#039;commentCount&#039;],
            &#039;publishedAt&#039; =&gt; $response[&#039;items&#039;][0][&#039;snippet&#039;][&#039;publishedAt&#039;],
            &#039;duration&#039; =&gt; $response[&#039;items&#039;][0][&#039;contentDetails&#039;][&#039;duration&#039;],
            &#039;channelTitle&#039; =&gt; $response[&#039;items&#039;][0][&#039;snippet&#039;][&#039;channelTitle&#039;],
            &#039;tags&#039; =&gt; $response[&#039;items&#039;][0][&#039;snippet&#039;][&#039;tags&#039;],
            &#039;categoryId&#039; =&gt; $response[&#039;items&#039;][0][&#039;snippet&#039;][&#039;categoryId&#039;],
            &#039;defaultLanguage&#039; =&gt; $response[&#039;items&#039;][0][&#039;snippet&#039;][&#039;defaultLanguage&#039;],
            &#039;liveBroadcastContent&#039; =&gt; $response[&#039;items&#039;][0][&#039;snippet&#039;][&#039;liveBroadcastContent&#039;],
            &#039;license&#039; =&gt; $response[&#039;items&#039;][0][&#039;status&#039;][&#039;license&#039;],
            &#039;embedHtml&#039; =&gt; $response[&#039;items&#039;][0][&#039;player&#039;][&#039;embedHtml&#039;],
            &#039;allowedRegions&#039; =&gt; $response[&#039;items&#039;][0][&#039;contentDetails&#039;][&#039;regionRestriction&#039;][&#039;allowed&#039;],
            &#039;blockedRegions&#039; =&gt; $response[&#039;items&#039;][0][&#039;contentDetails&#039;][&#039;regionRestriction&#039;][&#039;blocked&#039;],
            // Add any other data you want to retrieve
        );

        return $video;
    }

    /**
     * Sends a request to the specified URL using cURL.
     * @param string $url The URL to send the request to.
     * @return array The JSON response as an associative array.
     * @throws Exception If cURL encounters an error.
     */
    private function wpvsendRequest($url)
    {
        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL =&gt; $url,
            CURLOPT_RETURNTRANSFER =&gt; true,
            CURLOPT_FOLLOWLOCATION =&gt; true,
            CURLOPT_ENCODING =&gt; &quot;&quot;,
            CURLOPT_TIMEOUT =&gt; 30,
            CURLOPT_HTTP_VERSION =&gt; CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST =&gt; &quot;GET&quot;,
        ));

        $response = curl_exec($curl);
        $err = curl_error($curl);

        curl_close($curl);

        if ($err) {
            throw new Exception(&quot;cURL Error #:&quot; . $err);
        }
        return json_decode($response, true);
    }
    
    /**
     * Retrieves the comments of a video by its video ID.
     * @param string $videoId The ID of the video.
     * @return array An array containing the video comments.
     */
    public function wpvgetVideoComments($videoId) {
        $url = &#039;https://www.googleapis.com/youtube/v3/commentThreads?videoId=&#039; . $videoId . &#039;&amp;part=snippet&amp;maxResults=10&amp;key=&#039; . $this-&gt;apiKey;
        $response = $this-&gt;wpvsendRequest($url);
        
        $comments = array();
        
        if (isset($response[&#039;items&#039;])) {
            foreach ($response[&#039;items&#039;] as $item) {
                $comment = $item[&#039;snippet&#039;][&#039;topLevelComment&#039;][&#039;snippet&#039;][&#039;textDisplay&#039;];
                $comments[] = $comment;
            }
        }
        
        return $comments;
    }
    
    /**
     * Retrieves the channel ID from a video by its video ID.
     * @param string $videoId The ID of the video.
     * @return string|null The channel ID, or null if not found.
     */
    public function wpvgetChannelIdFromVideo($videoId){
        $url = &quot;https://www.googleapis.com/youtube/v3/videos?part=snippet&amp;id={$videoId}&amp;key={$this-&gt;apiKey}&quot;;
        $response = $this-&gt;wpvsendRequest($url);
        if (!empty($response[&#039;items&#039;])) {
            $channelId = $response[&#039;items&#039;][0][&#039;snippet&#039;][&#039;channelId&#039;];
            return $channelId;
        }
        return null;
    }
    
    /**
     * Formats the number of views to a human-readable format.
     * @param int $views The number of views.
     * @return string The formatted views.
     */
    public function wpvformatViews($views) {
        if ($views &gt;= 1000000000) {
            return round($views / 1000000000, 1) . &#039; billion&#039;;
        } elseif ($views &gt;= 1000000) {
            return round($views / 1000000, 1) . &#039; million&#039;;
        } elseif ($views &gt;= 1000) {
            return round($views / 1000, 1) . &#039; thousand&#039;;
        } else {
            return $views;
        }
    }
   
}</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>We will now call the PHP class and display the data. You need to update your <strong>API key in the $apiKey variable</strong> and then make call dynamically <strong>your video&#8217;s ID in the $videoId variable.</strong></p>

		</div>
	</div>
<div id="ts-enlighterjs-container-4280947" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-4280947" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="standard" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">// API Call Class PHP
$apiKey = &#039;YOUR API KEY HERE&#039;;
$youtube = new WPVYouTubeAPI($apiKey);
$videoId = &#039;YOUR VIDEO ID HERE&#039;;

// Get video details
$videoDetails = $youtube-&gt;wpvgetVideoDetails($videoId);
$channelId = $youtube-&gt;wpvgetChannelIdFromVideo($videoId);
$publishedDate = date(&#039;Y-m-d&#039;, strtotime($videoDetails[&#039;publishedAt&#039;]));

// Echo the title of the video
echo &#039;Titre : &#039; . $videoDetails[&#039;title&#039;] . &#039;&lt;br&gt;&#039;;

//echo &#039;Description : &#039; . $videoDetails[&#039;description&#039;] . &#039;&lt;br&gt;&#039;;
echo &#039;&lt;img src=&quot;&#039; . $videoDetails[&#039;thumbnail&#039;] . &#039;&quot; alt=&quot;Thumbnail de la vid&eacute;o&quot;&gt;&lt;br&gt;&#039;;

// Display the formatted duration
//echo &#039;Dur&eacute;e : &#039; . $formattedDuration . &#039;&lt;br&gt;&#039;;

// Echo the channel title
echo &#039;Channel : &#039; . $videoDetails[&#039;channelTitle&#039;] . &#039;&lt;br&gt;&#039;;

// Echo the published date of the video
echo &#039;Publi&eacute; le : &#039; . $publishedDate . &#039;&lt;br&gt;&#039;;

// Check if default language is available
if (!empty($videoDetails[&#039;defaultLanguage&#039;])) {
    echo &#039;Language : &#039; . $videoDetails[&#039;defaultLanguage&#039;] . &#039;&lt;br&gt;&#039;;
} else {
    echo &#039;Language : Undefined&lt;br&gt;&#039;;
}

// Display license
if (!empty($videoDetails[&#039;license&#039;])) {
    echo &#039;License : &#039; . $videoDetails[&#039;license&#039;] . &#039;&lt;br&gt;&#039;;
} else {
    echo &#039;License : Not specified&lt;br&gt;&#039;;
}

// Display the Channel Name of the video 
if (!empty($videoDetails[&#039;channelId&#039;])) {
    $maxResults = 10; // Maximum number of videos to retrieve
    $videosData = $youtube-&gt;wpvgetVideosByChannel($channelId, $maxResults);
    $channelName = $videosData[&#039;channelName&#039;];
    $videos = $videosData[&#039;videos&#039;];
    echo &quot;Channel Name: $channelName&lt;br&gt;&quot;;
} else {
    echo &quot;No channel found for the video.&lt;br&gt;&quot;;
}

// Display the tags
if (isset($videoDetails[&#039;tags&#039;])) {
    if (is_array($videoDetails[&#039;tags&#039;])) {
        $formattedTags = array_map(&#039;ucfirst&#039;, $videoDetails[&#039;tags&#039;]); // Apply ucfirst to each tag
        $tags = implode(&#039;, &#039;, $formattedTags);
        echo &#039;Tags: &#039; . $tags . &#039;&lt;br&gt;&#039;;
    } else {
        $tags = ucfirst($videoDetails[&#039;tags&#039;]); // Capitalize the first letter
        echo &#039;Mots-cl&eacute;s : &#039; . $tags . &#039;&lt;br&gt;&#039;;
    }
} else {
    echo &#039;Mots-cl&eacute;s : None&lt;br&gt;&#039;;
}

// Display the Views of the video 
echo &#039;Vues : &#039; . $youtube-&gt;wpvformatViews($videoDetails[&#039;views&#039;]) . &#039;&lt;br&gt;&#039;;

// Display the Likes of the video 
echo &#039;Passion&eacute;(e)s : &#039; . $videoDetails[&#039;likes&#039;] . &#039;&lt;br&gt;&#039;;

// Display the Dislikes of the video 
$dislikes = $videoDetails[&#039;dislikes&#039;];
if ($dislikes &gt; 0) {
    echo &#039;Dislikes : &#039; . $dislikes . &#039;&lt;br&gt;&#039;;
} else {
    echo &#039;Dislikes : 0&lt;br&gt;&#039;;
}

// Display the Favorites of the video 
$favorites = $videoDetails[&#039;favorites&#039;];
if ($favorites &gt; 0) {
    echo &#039;Favorites : &#039; . $favorites . &#039;&lt;br&gt;&#039;;
} else {
    echo &#039;Favorites : 0&lt;br&gt;&#039;;
}

// Display the Comments of the video 
echo &#039;Comments : &#039; . $videoDetails[&#039;comments&#039;] . &#039;&lt;br&gt;&#039;;</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>You can also include <strong><a href="https://fontawesome.com/v5/search" target="_blank" rel="noopener">Font Awesome Version 5</a></strong> icons by creating an <a href="https://gist.github.com/danielmcclure/d1b8e492bedcced7c8016ed37f197623" target="_blank" rel="noopener"><strong>enqueue script</strong></a> or <strong>add it in the Class PHP WPVYouTubeAPI class</strong>.</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-6515569" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-6515569" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="standard" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">// Enqueue Font Awesome 5 in WordPress 
function themespress_load_font_awesome() {
    // You can find the current URL for the latest version here: https://fontawesome.com/start
    wp_enqueue_style( &#039;font-awesome-free&#039;, &#039;//use.fontawesome.com/releases/v5.6.3/css/all.css&#039; );
}
add_action( &#039;wp_enqueue_scripts&#039;, &#039;themespress_load_font_awesome&#039; );</pre></div></div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/class-php-api-you-tube-version-3/">Class PHP – API You Tube – Version 3</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/class-php-api-you-tube-version-3/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Create a Shortcode for Modified Posts</title>
		<link>https://themespress.ca/en/create-a-shortcode-for-modified-posts/</link>
					<comments>https://themespress.ca/en/create-a-shortcode-for-modified-posts/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Sat, 04 Mar 2023 20:38:37 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=7025</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>With this tutorial, we will create a shortcode that will fetch the most recent posts or post types.</p>
<p>In our example, we will fetch the posts edited in the last 15 days.</p>
<p>However, we will <strong>display all published posts in the last 15 days</strong>. Afterward, we will tweak <strong>our query to adapt it to edited/modified posts</strong>.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Displaying posts published in the last 15 days</h2><div id="ts-enlighterjs-container-7704106" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-7704106" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">/**************************** Last Posts 15 days ********************************/
add_shortcode( &#039;lastaddoposts&#039;, &#039;addo_list_posts_publied&#039; );
function addo_list_posts_publied(){ 
	$date_range = strtotime ( &#039;-15 day&#039; );
	// Custom WP query query
	$args = array(
		&#039;post_type&#039;         =&gt; array(&#039;post&#039;),
		&#039;post_status&#039;       =&gt; &#039;publish&#039;,
		&#039;order&#039;             =&gt; &#039;DESC&#039;, 
		&#039;date_query&#039;        =&gt; array(
			array(
				&#039;after&#039; =&gt; array(
					&#039;year&#039;  =&gt; date(&#039;Y&#039;, $date_range ),
					&#039;month&#039; =&gt; date(&#039;m&#039;, $date_range ),
					&#039;day&#039;   =&gt; date(&#039;d&#039;, $date_range ),
				),
			)
		)
	);
	$query = new WP_Query( $args );

    echo &#039;&lt;ul style=&quot;padding:0&quot;&gt;&#039;;
		if ( $query-&gt;have_posts() ) {
			while ( $query-&gt;have_posts() ) { 
			$query-&gt;the_post();
			echo &#039;&lt;div class=&quot;col-md-3&quot; style=&quot;display:inline-block;&quot;&gt;&#039;;
				echo &#039;&lt;li style=&quot;position:relative&quot;&gt;&#039;;	
					echo &#039;&lt;a style=&quot;display:block;background-color: #490b3d;padding: 10px 25px;color: white;&quot; href=&quot;&#039; . get_the_permalink() . &#039;&quot;&gt;&#039;;
					echo the_title();
					echo&#039;&lt;/a&gt;&#039;;
					echo &#039;&lt;span style=&quot;padding:0px 5px;background:#f1b814;color:white;position:absolute;top:-10px;right:0;font-size:11px&quot;&gt;&#039; . get_the_time(&#039;d-m-Y&#039;) . &#039;&lt;/span&gt;&#039;;
				echo &#039;&lt;/li&gt;&#039;;
			echo &#039;&lt;/div&gt;&#039;;
			}
		}
	else {
		echo &#039;Il n&amp;#39;y a eu aucune publication ces derni&egrave;res semaines&#039;;
	}
	wp_reset_postdata();
    echo &#039;&lt;/ul&gt;&#039;;		
}</pre></div><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Shortcode within pages</h2><div id="ts-enlighterjs-container-1913106" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-1913106" class="ts-enlighterjs-pre-nohighlight" style="" data-enlighter-language="no-highlight" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">[lastaddoposts]</pre></div><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Shortcode within templates</h2><div id="ts-enlighterjs-container-1883053" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-1883053" class="ts-enlighterjs-pre-nohighlight" style="" data-enlighter-language="no-highlight" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">&lt;?php echo do_shortcode( &#039;[lastaddoposts]&#039; ); ?&gt;</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>We will now adapt our query and display <strong>the last modified posts</strong> within the last <strong>15 days</strong>.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Displaying posts modified in the last 15 days</h2><div id="ts-enlighterjs-container-7251687" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-7251687" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">/**************************** Last Posts modified 15 days ********************************/
add_shortcode( &#039;postsaddomodified&#039;, &#039;addo_list_posts_modified&#039; );
function addo_list_posts_modified() {
	// query args
    $args = array(
		&#039;posts_per_page&#039;        =&gt; &#039;10&#039;,
		&#039;post_type&#039;             =&gt; &#039;post&#039;,
		&#039;post_status&#039;           =&gt; &#039;publish&#039;,
		&#039;orderby&#039;               =&gt; &#039;modified&#039;,
		&#039;order&#039;                 =&gt; &#039;DESC&#039;,
		&#039;ignore_sticky_posts&#039;   =&gt; &#039;1&#039;,
		&#039;caller_get_posts&#039;      =&gt; 1,
		&#039;date_query&#039; =&gt; array(
        &#039;relation&#039;   =&gt; &#039;OR&#039;,
        array(
            &#039;column&#039;  =&gt; &#039;post_date&#039;,
            &#039;after&#039;   =&gt; &#039;-1 days&#039;
        ),
        array(
            &#039;column&#039;  =&gt; &#039;post_modified&#039;,
            &#039;after&#039;   =&gt; &#039;-15 days&#039;
        )
    )
    );

    // query
    $updated = new WP_Query($args);

?&gt;
&lt;ul style=&quot;padding:0&quot;&gt;
	&lt;?php if ( $updated-&gt;have_posts() ) : ?&gt;
	&lt;?php while ( $updated-&gt;have_posts() ) : $updated-&gt;the_post(); ?&gt;
	&lt;div class=&quot;col-md-3&quot; style=&quot;display:inline-block;padding:0px&quot;&gt;
		&lt;li style=&quot;position:relative&quot;&gt;	
			&lt;a style=&quot;display:block;background-color: #490b3d;padding: 10px 25px;color: white;margin:0 0 10px 0&quot; href=&quot;https://famillebreboin.ca/photos/&quot;&gt;
			   &lt;?php the_title(); ?&gt;
			&lt;/a&gt;
			&lt;span style=&quot;padding:0px 5px;background:#f1b814;color:white;position:absolute;top:-10px;right:0;font-size:11px&quot;&gt;
			&lt;?php get_the_time(&#039;d-m-Y&#039;); ?&gt;
			&lt;/span&gt;
		&lt;/li&gt;
	&lt;/div&gt;
	&lt;?php endwhile; ?&gt;
	&lt;?php wp_reset_postdata(); ?&gt;
	&lt;?php else : ?&gt;
		&lt;?php echo &#039;Il n&amp;#39;y a eu aucun album mis &agrave; jour&#039;;  ?&gt;
	&lt;?php endif; ?&gt;
&lt;/ul&gt;
&lt;?php }</pre></div><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Shortcode within pages</h2><div id="ts-enlighterjs-container-3636283" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-3636283" class="ts-enlighterjs-pre-nohighlight" style="" data-enlighter-language="no-highlight" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">[postsaddomodified]</pre></div><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Shortcode within templates</h2><div id="ts-enlighterjs-container-3212035" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-3212035" class="ts-enlighterjs-pre-nohighlight" style="" data-enlighter-language="no-highlight" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">&lt;?php echo do_shortcode( &#039;[postsaddomodified]&#039; ); ?&gt;</pre></div></div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/create-a-shortcode-for-modified-posts/">Create a Shortcode for Modified Posts</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/create-a-shortcode-for-modified-posts/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Redirecting 404 Pages</title>
		<link>https://themespress.ca/en/redirecting-404-pages/</link>
					<comments>https://themespress.ca/en/redirecting-404-pages/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Thu, 22 Dec 2022 15:21:17 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=6916</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element vc_custom_1671721681346" >
		<div class="wpb_wrapper">
			<p><strong>Redirecting 404 pages:</strong> There are many ways and reasons to redirect your 404 pages. With this tutorial, we will redirect 404 pages to the homepage with the <a href="https://developer.wordpress.org/reference/hooks/template_redirect/" target="_blank" rel="noopener">template_redirect</strong></a> hook.</p>

		</div>
	</div>
</div></div></div></div>
<div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading vc_custom_1671721735184" >Redirecting your 404 pages</h2></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><div id="ts-enlighterjs-container-3317327" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-3317327" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">add_action(&#039;template_redirect&#039;, &#039;themespress_redirect_404_to_homepage&#039;, 999);
function themespress_redirect_404_to_homepage(){
    if(!is_404())
    return;
    wp_redirect(home_url());
    exit;
}</pre></div>
	<div class="wpb_text_column wpb_content_element vc_custom_1671722090656" >
		<div class="wpb_wrapper">
			<p>This function will ensure that all 404 oages will be redirected and in this case a 404.php template is not necessary in your theme.</p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/redirecting-404-pages/">Redirecting 404 Pages</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/redirecting-404-pages/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WordPress Table: Formidable Form Data</title>
		<link>https://themespress.ca/en/wordpress-table-formidable-form-data/</link>
					<comments>https://themespress.ca/en/wordpress-table-formidable-form-data/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Fri, 21 Oct 2022 13:32:30 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=6864</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>You want to create a new data entry in a custom WordPress table from a Formidable form? Let&#8217;s say you want to create a table in order to get data from a form or generate stats. </p>
<p>Once your table has been created with the required columns, <strong>you need to make sure that the columns matches your form&#8217;s fields.</strong></p>
<p>If you want to create a table with a function, here&#8217;s an interesting article that explains a function that will <a href="https://deliciousbrains.com/creating-custom-table-php-wordpress/" target="_blank" rel="noopener"><strong>create a WordPress table</strong></a></p>

		</div>
	</div>

	<div  class="wpb_single_image wpb_content_element vc_align_left wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img decoding="async" width="1903" height="955" src="https://themespress.ca/wp-content/uploads/2022/10/Creer-une-entree-table-venant-dun-formulaire-Formidable.png" class="vc_single_image-img attachment-full" alt="Create a table from data obtained via a Formidable form" title="Create a table from data obtained via a Formidable form" srcset="https://themespress.ca/wp-content/uploads/2022/10/Creer-une-entree-table-venant-dun-formulaire-Formidable.png 1903w, https://themespress.ca/wp-content/uploads/2022/10/Creer-une-entree-table-venant-dun-formulaire-Formidable-600x301.png 600w, https://themespress.ca/wp-content/uploads/2022/10/Creer-une-entree-table-venant-dun-formulaire-Formidable-300x151.png 300w, https://themespress.ca/wp-content/uploads/2022/10/Creer-une-entree-table-venant-dun-formulaire-Formidable-1024x514.png 1024w, https://themespress.ca/wp-content/uploads/2022/10/Creer-une-entree-table-venant-dun-formulaire-Formidable-768x385.png 768w, https://themespress.ca/wp-content/uploads/2022/10/Creer-une-entree-table-venant-dun-formulaire-Formidable-1536x771.png 1536w, https://themespress.ca/wp-content/uploads/2022/10/Creer-une-entree-table-venant-dun-formulaire-Formidable-1320x662.png 1320w" sizes="(max-width: 1903px) 100vw, 1903px" /></div>
		</figure>
	</div>
<div id="ts-enlighterjs-container-4177106" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-4177106" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="standard" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">//////////////////////////////////////////////////////////////////////
// Create database table
//////////////////////////////////////////////////////////////////////

function database_wooclassementstats() {
	global $wpdb;
	$charset_collate = $wpdb-&gt;get_charset_collate();
	$table_name = $wpdb-&gt;prefix . &#039;wooclassementstats&#039;;
		$sql = &quot;CREATE TABLE $table_name (
		id mediumint(9) NOT NULL AUTO_INCREMENT,
		viewdate date DEFAULT &#039;0000-00-00&#039; NOT NULL,
		viewtime time DEFAULT &#039;00:00:00&#039; NOT NULL,
		productid int(11) NOT NULL,
		productname varchar(60) NOT NULL,
		producturl text NOT NULL,
		userip varchar(60) NOT NULL,
		username varchar(60) NOT NULL,
		userid bigint(20) NOT NULL,
		usercountry text NOT NULL,
		usercity varchar(255) NOT NULL,
		userbrowser varchar(255) NOT NULL,
		userbrowserversion varchar(255) NOT NULL,
		userbrowserplateform varchar(255) NOT NULL,	
		userviews smallint(5) NOT NULL,
		userclicks smallint(5) NOT NULL,
		urlfrom text NOT NULL,
		type varchar(60) DEFAULT &#039;vue&#039; NOT NULL,
		language varchar(60) NOT NULL,
		UNIQUE KEY id (id)
		) $charset_collate;&quot;;
	require_once( ABSPATH . &#039;wp-admin/includes/upgrade.php&#039; );
	dbDelta( $sql );
}	
add_action( &#039;init&#039;, &#039;database_wooclassementstats&#039;);</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Here&#8217;s our table within <strong>phpMyAdmin.</strong></p>

		</div>
	</div>

	<div  class="wpb_single_image wpb_content_element vc_align_left wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img decoding="async" width="1917" height="448" src="https://themespress.ca/wp-content/uploads/2022/10/Creation-de-table-dans-phpMyAdmin.png" class="vc_single_image-img attachment-full" alt="Possible web outage due to WPML" title="Creating tables in phpMyAdmin" srcset="https://themespress.ca/wp-content/uploads/2022/10/Creation-de-table-dans-phpMyAdmin.png 1917w, https://themespress.ca/wp-content/uploads/2022/10/Creation-de-table-dans-phpMyAdmin-600x140.png 600w, https://themespress.ca/wp-content/uploads/2022/10/Creation-de-table-dans-phpMyAdmin-300x70.png 300w, https://themespress.ca/wp-content/uploads/2022/10/Creation-de-table-dans-phpMyAdmin-1024x239.png 1024w, https://themespress.ca/wp-content/uploads/2022/10/Creation-de-table-dans-phpMyAdmin-768x179.png 768w, https://themespress.ca/wp-content/uploads/2022/10/Creation-de-table-dans-phpMyAdmin-1536x359.png 1536w, https://themespress.ca/wp-content/uploads/2022/10/Creation-de-table-dans-phpMyAdmin-1320x308.png 1320w" sizes="(max-width: 1917px) 100vw, 1917px" /></div>
		</figure>
	</div>

	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>As you can see there are multiple columns in our WordPress table.</p>
<p>First, change the name of the table, <strong>wooclassementstats</strong> to the naming convention of <strong>your table</strong>.</p>
<p>You&#8217;ll also need to replace the columns&#8217; names and adapting them to the data you&#8217;re looking for.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading vc_custom_1666357967792" >Adding Formidable fields data</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>For that we&#8217;re gonna need the <a href="https://formidableforms.com/knowledgebase/formidable-hooks/" target="_blank" rel="noopener"><strong>hook Formidable Form</strong></a> called <a href="https://formidableforms.com/knowledgebase/frm_after_create_entry/" target="_blank" rel="noopener">frm_after_create_entry</a></p>
<p>Within our hook, we will add a condition where it&#8217;ll need to fetch data from the form according to the specific form ID.</p>
<p>The <strong>$values</strong> variable includes all the data fetched from the form. Change the <strong>columns&#8217; names</strong> and <strong>IDs of the matching fields</strong> for each field.</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-4799772" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-4799772" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">add_action(&#039;frm_after_create_entry&#039;, &#039;copy_into_my_table&#039;, 20, 2);
function copy_into_my_table($entry_id, $form_id){ 
  if($form_id == 2){ //change 4 to the form id of the form to copy
    global $wpdb;
    $values = array(
    &#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][24], 
    &#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][25], 
    &#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][22],
    &#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][21],
    &#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][26],
    &#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][23],
    &#039;col_name&#039;         =&gt; &#039;&#039;,
    &#039;col_name&#039;         =&gt; &#039;&#039;, 
    &#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][27],
    );
    //replace 25 and 26 with the field ids of the Formidable form. Change col_name to the column names in your table
    $wpdb-&gt;insert(&#039;wpeo_LDAAnalytics&#039;, $values); 
  }
}</pre></div><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading vc_custom_1666357768117" >For Multi-sites websites</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>If you have a multisite, first thing you&#8217;ll need to do is make sure all forms have their own unique IDs. You will need the <a href="https://developer.wordpress.org/reference/functions/switch_to_blog/" target="_blank" rel="noopener"><strong>switch_to_blog</strong></a> function.</p>
<p>Our form&#8217;s condition will need to be set between <strong>switch_to_blog</strong> and <strong>restore_current_blog();</strong> which will respect the blog&#8217;s query.</p>

		</div>
	</div>
</div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><div id="ts-enlighterjs-container-4839317" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-4839317" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">//////////////////////// Insert datas after create entry from Form  /////////////////////

add_action(&#039;frm_after_create_entry&#039;, &#039;copy_into_my_table&#039;, 20, 2);
function copy_into_my_table($entry_id, $form_id){ 
	switch_to_blog(2);
	if($form_id == 2){ //change 4 to the form id of the form to copy
		global $wpdb;
		$values = array(
		&#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][24], 
		&#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][25], 
		&#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][22],
		&#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][21],
		&#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][26],
		&#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][23],
		&#039;col_name&#039;         =&gt; &#039;&#039;,
		&#039;col_name&#039;         =&gt; &#039;&#039;, 
		&#039;col_name&#039;         =&gt; $_POST[&#039;item_meta&#039;][27],
		);
		//replace 25 and 26 with the field ids of the Formidable form. Change col_name to the column names in your table
		$wpdb-&gt;insert(&#039;wpeo_LDAAnalytics&#039;, $values); 
	}
	restore_current_blog();
}</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>In conclusion, injecting data in a WordPress table will allow you to have duplicates of the data or offering stats to your clients.</p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/wordpress-table-formidable-form-data/">WordPress Table: Formidable Form Data</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/wordpress-table-formidable-form-data/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Completing a Selection Field &#8211; Formidable Form</title>
		<link>https://themespress.ca/en/selection-field-formidable-form/</link>
					<comments>https://themespress.ca/en/selection-field-formidable-form/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Tue, 04 Oct 2022 21:16:54 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=6750</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>With this tutorial we will show you how to complete a selection field in Formidable Form. <a href="https://shareasale.com/r.cfm?b=841990&amp;u=1476870&amp;m=64739&amp;urllink=&amp;afftrack=" target="_blank" rel="noopener"><strong>Formidable form</strong></a> is one of the best form creation plugin available.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Create a form and add a selection field</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>You can create a form, configure it and add it where you want it on your WordPress website.</p>
<p>Once the form is configured, you can add the necessary fields. <strong>(Note that some fields are only available in the PRO version)</strong></p>

		</div>
	</div>

	<div  class="wpb_single_image wpb_content_element vc_align_left wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="1884" height="706" src="https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-16-05-08-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress.png" class="vc_single_image-img attachment-full" alt="" title="Screenshot 2022-10-04 at 16-05-08 Formidable Formulaires ‹ Viamultimedia Hébergement Web — WordPress" srcset="https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-16-05-08-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress.png 1884w, https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-16-05-08-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress-600x225.png 600w, https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-16-05-08-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress-300x112.png 300w, https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-16-05-08-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress-1024x384.png 1024w, https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-16-05-08-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress-768x288.png 768w, https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-16-05-08-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress-1536x576.png 1536w, https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-16-05-08-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress-1320x495.png 1320w" sizes="auto, (max-width: 1884px) 100vw, 1884px" /></div>
		</figure>
	</div>

	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>For this example, we will add a custom selection field.</p>
<p>By clicking on our field, <strong>we can see its ID on the right-hand side</strong>. This ID is important as we&#8217;ll use it for certain queries.</p>
<div id="malwarebytes-root"></div>

		</div>
	</div>

	<div  class="wpb_single_image wpb_content_element vc_align_left wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="1333" height="95" src="https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-17-20-16-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress.png" class="vc_single_image-img attachment-full" alt="" title="Screenshot 2022-10-04 at 17-20-16 Formidable Formulaires ‹ Viamultimedia Hébergement Web — WordPress" srcset="https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-17-20-16-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress.png 1333w, https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-17-20-16-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress-600x43.png 600w, https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-17-20-16-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress-300x21.png 300w, https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-17-20-16-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress-1024x73.png 1024w, https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-17-20-16-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress-768x55.png 768w, https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-17-20-16-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress-1320x94.png 1320w" sizes="auto, (max-width: 1333px) 100vw, 1333px" /></div>
		</figure>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Dynamically completing the selection field - our posts</h2></div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-8"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>For this query, we will create a <a href="https://formidableforms.com/knowledgebase/frm_setup_new_fields_vars/" target="_blank" rel="noopener"><strong>frm_setup_new_fields_vars</strong></a> function from Formidable Form.</p>
<p>To edit resulting values, we will add the <a href="https://formidableforms.com/knowledgebase/frm_setup_new_fields_vars/" target="_blank" rel="noopener"><strong>frm_setup_new_fields_vars</strong></a> filter.</p>
<p>In our function, we will fetch our ID (<span class="nu0">72</span>) of the field where the results will be displayed; i.e. our posts.</p>
<p>In our function, we created a default label for our selection. (For our example, we&#8217;re using <strong>Select a question</strong>)</p>
<p><strong>label => &#8220;Select a question&#8221;</strong></p>

		</div>
	</div>
</div></div></div><div class="wpb_column vc_column_container vc_col-sm-4"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div  class="wpb_single_image wpb_content_element vc_align_left wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img loading="lazy" decoding="async" width="432" height="658" src="https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-16-57-23-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress.png" class="vc_single_image-img attachment-full" alt="Articles WordPress dans un champ sélection Formidable Form" title="Screenshot 2022-10-04 at 16-57-23 Formidable Formulaires ‹ Viamultimedia Hébergement Web — WordPress" srcset="https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-16-57-23-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress.png 432w, https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-16-57-23-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress-416x634.png 416w, https://themespress.ca/wp-content/uploads/2022/10/Screenshot-2022-10-04-at-16-57-23-Formidable-Formulaires-‹-Viamultimedia-Hebergement-Web-—-WordPress-197x300.png 197w" sizes="auto, (max-width: 432px) 100vw, 432px" /></div>
		</figure>
	</div>
</div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><div id="ts-enlighterjs-container-9035988" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-9035988" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">add_filter(&#039;frm_setup_new_fields_vars&#039;, &#039;themespress_select_field_function&#039;, 20, 2);
add_filter(&#039;frm_setup_edit_fields_vars&#039;, &#039;themespress_select_field_function&#039;, 20, 2);

function themespress_select_field_function($values, $field){

	if($field-&gt;id == 72){
		$arrayPositions = array();
		$pushobj = array(
			value =&gt; &quot;&quot;,
			label =&gt; &quot;S&eacute;lectionnez une question&quot;
		);
		array_push($arrayPositions, $pushobj);
		$positionQuery = new WP_Query( array( &#039;post_type&#039; =&gt; &#039;questions&#039;, &#039;posts_per_page&#039; =&gt; -1, &#039;orderby&#039; =&gt; &quot;menu_order&quot;, &#039;order&#039; =&gt; &quot;ASC&quot;) );
		if ( $positionQuery-&gt;have_posts() ) {
			while ( $positionQuery-&gt;have_posts() ) {
				$positionQuery-&gt;the_post();
				$pushobj = array(
					value =&gt; get_the_title(),
					label =&gt; get_the_title()
				);
				array_push($arrayPositions, $pushobj);
			}
			wp_reset_postdata();
		}

	   	$values[&#039;options&#039;] = $arrayPositions;
	}
	return $values;
}</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>And finally, in your query, you can adapt whether you want to display posts or pages.</p>
<div id="malwarebytes-root"></div>

		</div>
	</div>
<div id="ts-enlighterjs-container-1559416" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-1559416" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">$positionQuery = new WP_Query( array( &#039;post_type&#039; =&gt; &#039;questions&#039;, &#039;posts_per_page&#039; =&gt; -1, &#039;orderby&#039; =&gt; &quot;menu_order&quot;, &#039;order&#039; =&gt; &quot;ASC&quot;) );</pre></div>
	<div class="wpb_text_column wpb_content_element read-more" >
		<div class="wpb_wrapper">
			<p><a href="https://themespress.ca/?s=Formidable+form" target="_blank" rel="noopener">Formidable form posts</a></p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/selection-field-formidable-form/">Completing a Selection Field – Formidable Form</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/selection-field-formidable-form/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
