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
$category_ids = array(); //Inicializa a array onde guardaremos os IDS | |
$fromDB = term_exists($string['category'][$i], 'category' ); // Busca a categoria no banco. Se existir, teremos o ID dela, se não, NULL | |
if($fromDB === NULL) // Se for NULL quer dizer que é uma categoria nova que precisa ser adicionada | |
{ | |
$term = wp_insert_term($string['category'][$i], 'category'); // Adiciona a categoria nova no banco e guarda o ID gerado; | |
$category_ids[] = $term['term_id']; | |
} else { | |
$category_ids[] = $fromDB['term_id']; // Guarda no array o ID da categoria que já existe no banco | |
} |
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 | |
/** | |
* Insert thumbnail by URL | |
* Is very good to execute wp_insert_post | |
* | |
* @author Lenivene Bezerra | |
* @param string $url Image url external or no | |
* @param int $post_ID Post id to insert thumbnail | |
* @return ID Thumbnail | WP_Error | |
*/ |
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 | |
/** | |
* ---------------------------------------------------------------------------------------- | |
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/engine/plug/converter.php` | |
* ---------------------------------------------------------------------------------------- | |
*/ | |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Auto Detect</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" /> | |
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" /> |
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 | |
// Load WordPress | |
require_once 'path/to/www/wp-load.php'; | |
require_once ABSPATH . '/wp-admin/includes/taxonomy.php'; | |
// Set the timezone so times are calculated correctly | |
date_default_timezone_set('Europe/London'); | |
// Create post |
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 | |
header('Content-Type: text/html; charset=utf-8'); | |
set_time_limit(0); | |
require "classes/SimpleImage.php"; | |
require "funcoes/functions.php"; | |
//FAZ A CONEXÃO COM O BANCO | |
$conn = conn(); |
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
const request = require('request'); | |
const cheerio = require('cheerio'); | |
var searchTerm = 'tech'; | |
var searchUrl = 'https://www.google.com/search?q=' + searchTerm + '&tbm=nws'; | |
var savedData = []; | |
request(searchUrl, function(err, response, html) { | |
// First we'll check to make sure no errors occurred when making the request | |
if (err) { |
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
public function user_exists($user_id) | |
{ | |
$this->db->where('user_id', $user_id); | |
$query = $this->db->get('sometablenamehere'); | |
if($query->num_rows >= 1) | |
{ | |
//if query finds one row relating to this user then execute code accordingly here | |
} | |
} |
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 | |
if (isset($_SERVER['REMOTE_ADDR'])) { | |
die(':)'); | |
} | |
echo "Cron is running"; | |
$hostname = 'localhost'; | |
$username = 'cl50-whiskey_p'; | |
$password = 'rmBRsm!kK'; |
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
$app_directory = dirname(BASEPATH); | |
$export_location = $app_directory . '/assets/exports/'; | |
$filename = "export-" . date('Y-m-d H-i-s') . ".csv"; | |
$export_location = $export_location . $filename; | |
$query = $this->db->query(" | |
SELECT users.id, users.firstname, users.lastname, users.email, users.dob, messages.line1, messages.line2, messages.line3, messages.barcode_selected, address.my_address, address.firstname, address.lastname, address.address1, address.address2, address.town, address.postcode, address.datecreated | |
FROM users | |
JOIN messages |
OlderNewer