This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function apiCall(body, method, url) { | |
let headers = new Headers(); | |
headers.append("Content-Type", "application/json"); | |
const requestOptions = { | |
method: method, | |
headers: headers, | |
body: JSON.stringify(body), | |
redirect: "follow", | |
}; | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Protect all files within the uploads folder | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
#RewriteCond %{HTTP_COOKIE} !.*wordpress_logged_in.*$ [NC] | |
#RewriteCond %{REQUEST_URI} ^(.*?/?)wp-content/uploads/sites/[0-9]+/user_uploads|answers/.* [NC] | |
#RewriteRule . http://%{HTTP_HOST}%1/wp-login.php?redirect_to=%{REQUEST_URI} [L,QSA] | |
RewriteCond %{REQUEST_FILENAME} -f | |
# RewriteRule needs the path of folder that we have our files. As an example the folder is on uploads folder on wp and named cv_uploads | |
RewriteRule "^wp-content/uploads/cv_uploads/(.*)$" singledl-file.php?file=$1 [QSA,L] | |
</IfModule> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_users_email_by_role($role) | |
{ | |
$args = array( | |
'role' => $role, | |
); | |
$users = get_users($args); | |
$emails = array(); | |
foreach ($users as $user) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function uploadToAttachmentsFromURL($url) | |
{ | |
$upload_dir = wp_upload_dir(); | |
$image_data = file_get_contents($url); | |
$filename = basename($url); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getPostTypeCommentsCount($cpt){ | |
$args = array( | |
'post_type' => $cpt, | |
'posts_per_page' => -1 | |
); | |
$commentCount = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkAFM(afm) { | |
afm = afm.split("").reverse().join(""); | |
let Num1 = 0; | |
for (var iDigit = 1; iDigit <= 8; iDigit++) { | |
Num1 += afm.charAt(iDigit) << iDigit; | |
} | |
return (Num1 % 11) % 10 == afm.charAt(0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function selectRandom(array) { | |
return array[Math.floor(Math.random() * array.length)]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function send_email_attachment($to, $subject, $template,$render_object,$attachments) | |
{ | |
$headers = array('Content-Type: text/html; charset=UTF-8', 'From: SiteName <noreply@siteDomain>'); | |
$GLOBALS["use_html_content_type"] = TRUE; | |
ob_start(); | |
require(locate_template($template)); | |
$body = ob_get_contents(); | |
ob_end_clean(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getPostOfSpecificDate($date){ | |
$args = array( | |
'post_type' => 'post', | |
'posts_per_page' => -1, | |
'post_status' => 'any', | |
'date_query' => array( | |
array( | |
'year' => $date['year'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If our server has a timezone out of Greece as an example , we can use this function to get the time of that timezone | |
// Supported timezones https://www.php.net/manual/en/timezones.php | |
// Supported time & date formats https://www.php.net/manual/en/datetime.format.php | |
function GetCityTimeDate($format,$timezone) | |
{ | |
$tz = $timezone; | |
$timestamp = time(); | |
$dt = new DateTime("now", new DateTimeZone($tz)); //first argument "must" be a string | |
$dt->setTimestamp($timestamp); //adjust the object to correct timestamp |
OlderNewer