Skip to content

Instantly share code, notes, and snippets.

@eto4detak
eto4detak / footer-script.php
Last active August 21, 2019 18:07
wp php js footer script
@eto4detak
eto4detak / email.php
Created November 30, 2018 21:49
wp php email
<?php
function sendEmail($fromEmail,$fromEmailName,$toEmail,$toEmailName,$subject,$message,$extra='') {
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'To: '.$toEmailName.' <'.$toEmail.'>' . "\r\n";
$headers .= 'From: '.$fromEmailName.' <'.$fromEmail.'>' . "\r\n";
if(wp_mail($toEmail,$subject,$message,$headers)) {
}else {
@eto4detak
eto4detak / xml.php
Last active December 3, 2018 15:11
php xml
<?php
$movies = new SimpleXMLElement(file_get_contents('http://www.cbr.ru/scripts/XML_daily.asp?date_req=03/12/2018'));
function get_xml_from_url($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
@eto4detak
eto4detak / geo.php
Last active December 16, 2018 16:08
wp php geo
<?php
if(!is_admin()){
add_action('print_footer_scripts', 'print_script_addsdgsdgsd', 99);
}
function print_script_addsdgsdgsd()
{
if( !empty($_COOKIE['geo'])){
@eto4detak
eto4detak / number.php
Last active August 4, 2019 20:18
php number
<?php
$int_value = ctype_digit($value) ? intval($value) : null;
if ($int_value === null)
{
echo 'null';
}else{
echo 'NUMBER';
}
@eto4detak
eto4detak / JSON.php
Created December 8, 2018 08:38
wp php JSON
<?php
public function __construct()
{
add_action('print_footer_scripts', array($this,'print_script_addsdgsdgsd'), 99);
}
public function print_script_addsdgsdgsd()
{
if( !empty($this->elements)){
@eto4detak
eto4detak / parse-xml.php
Created December 8, 2018 08:53
php parse xml
<?php
public function RecurseXML2($xml = '')
{
function RecurseXML($xml, &$vals, $parent = "")
{
$childs = 0;
$child_count = -1; # Not realy needed.
$arr = array();
@eto4detak
eto4detak / sql-create-column.php
Last active June 25, 2019 18:40
wp php sql create column
<?php
// $code = 11;
// $department = 2;
// $subdivision = 3;
// $address =4;
// $title =5 ;
// $full_title = 6;
// $short_title =7 ;
@eto4detak
eto4detak / timer.js
Created December 14, 2018 23:06
js timer
<h1>Countdown Clock</h1>
<div id="clockdiv">
<div>
<span class="days"></span>
<div class="smalltext">Days</div>
</div>
<div>
<span class="hours"></span>
<div class="smalltext">Hours</div>
</div>
@eto4detak
eto4detak / esc.php
Last active December 23, 2018 22:01
wp php esc
<input type="hidden" name="redirect_to" value="<?php echo esc_url($redirect_to); ?>">
<?php
update_user_meta($current_user->ID, '_psyho_date', sanitize_text_field($form->date));