Archives: Snippets
Product Detail from External Source
function my_produkt_detail($ean, $field_path = ”, $default = ”) { static $cache = array(); try { if (empty($ean) || !is_string($ean)) { return $default; } if (!isset($cache[$ean])) { $detail_url = “https://db.ecoinform.de/ecodb.php/produktdetail?partner=2a3ea8f338618ff8&lang=DE&ean=” . urlencode($ean); $response = wp_remote_get($detail_url, array( ‘timeout’ => 30, ‘headers’ =>…Continue reading
Esraa Ahmed
<script id=”Microsoft_Omnichannel_LCWidget” src=”https://oc-cdn-public-eur.azureedge.net/livechatwidget/scripts/LiveChatBootstrapper.js”” onerror=”(function(el){el.parentNode.removeChild(el);var s=document.createElement(‘script’);s.src=’https://ocprodpubliceurgs.blob.core.windows.net/livechatwidget/scripts/LiveChatBootstrapper.js’;s.setAttribute(‘id’, ‘Microsoft_Omnichannel_LCWidget’);s.setAttribute(‘data-app-id’, ‘0ed30dad-2656-43ce-b290-e393b6a96d2f’);s.setAttribute(‘data-lcw-version’, ‘prod’);s.setAttribute(‘data-org-id’, ‘0b965a30-b361-f011-8ee5-000d3ab5d97a’);s.setAttribute(‘data-org-url’, ‘https://m-0b965a30-b361-f011-8ee5-000d3ab5d97a.eu.omnichannelengagementhub.com’);document.body.appendChild(s);})(this);” data-app-id=”0ed30dad-2656-43ce-b290-e393b6a96d2f” data-lcw-version=”prod” data-org-id=”0b965a30-b361-f011-8ee5-000d3ab5d97a” data-org-url=”https://m-0b965a30-b361-f011-8ee5-000d3ab5d97a.eu.omnichannelengagementhub.com” async></script>Continue reading
Untitled Snippet
Untitled Snippet
<script id=”Microsoft_Omnichannel_LCWidget” src=”https://oc-cdn-public-eur.azureedge.net/livechatwidget/scripts/LiveChatBootstrapper.js”” onerror=”(function(el){el.parentNode.removeChild(el);var s=document.createElement(‘script’);s.src=’https://ocprodpubliceurgs.blob.core.windows.net/livechatwidget/scripts/LiveChatBootstrapper.js’;s.setAttribute(‘id’, ‘Microsoft_Omnichannel_LCWidget’);s.setAttribute(‘data-app-id’, ‘0ed30dad-2656-43ce-b290-e393b6a96d2f’);s.setAttribute(‘data-lcw-version’, ‘prod’);s.setAttribute(‘data-org-id’, ‘0b965a30-b361-f011-8ee5-000d3ab5d97a’);s.setAttribute(‘data-org-url’, ‘https://m-0b965a30-b361-f011-8ee5-000d3ab5d97a.eu.omnichannelengagementhub.com’);document.body.appendChild(s);})(this);” data-app-id=”0ed30dad-2656-43ce-b290-e393b6a96d2f” data-lcw-version=”prod” data-org-id=”0b965a30-b361-f011-8ee5-000d3ab5d97a” data-org-url=”https://m-0b965a30-b361-f011-8ee5-000d3ab5d97a.eu.omnichannelengagementhub.com” async></script>Continue reading
Untitled Snippet
Convert headings to sentence case
function convert_to_sentence_case($text) { $exceptions = array( ‘API’, ‘URL’, ‘HTML’, ‘CSS’, ‘PHP’, ‘SQL’, ‘XML’, ‘JSON’, ‘HTTP’, ‘HTTPS’, ‘CEO’, ‘CTO’, ‘CFO’, ‘USA’, ‘UK’, ‘EU’, ‘AI’, ‘ML’, ‘IoT’, ‘GPS’, ‘FAQ’, ‘PDF’, ‘SEO’, ‘ROI’, ‘KPI’, ‘B2B’, ‘B2C’, ‘SaaS’, ‘WordPress’, ‘WooCommerce’, ‘jQuery’, ‘JavaScript’, ‘MySQL’, ‘AWS’…Continue reading
Untitled Snippet
const crypto = require(‘crypto’); const secret = ‘•••••••••’; // Your verification secret key const userId = current_user.id // A string UUID to identify your user const hash = crypto.createHmac(‘sha256’, secret).update(userId).digest(‘hex’);Continue reading
PRINT WP POST
add_filter(‘the_content’, function($content) { if (!is_single()) return $content; $button = ‘ Print Post ‘; $pos = strpos($content, ‘ ‘); if ($pos !== false) { return substr_replace($content, $button, $pos + 4, 0); } return $button . $content; });Continue reading
Admin Privileges Being Returned
add_action(‘init’, function () { if (current_user_can(‘administrator’)) { $role = get_role(‘administrator’); if ($role) { // Capabilities related to editing pages, posts, and more $capabilities = [ ‘edit_posts’, ‘edit_others_posts’, ‘edit_published_posts’, ‘edit_pages’, ‘edit_others_pages’, ‘edit_published_pages’, ‘publish_posts’, ‘publish_pages’, ‘delete_posts’, ‘delete_others_posts’, ‘delete_published_posts’, ‘delete_pages’, ‘delete_others_pages’, ‘delete_published_pages’, ‘read’,…Continue reading