scrape!
Category Archives: PHP
register_activation_hook(__FILE__, ‘wojciech_borowicz_mec_cron_job_schedule’); function wojciech_borowicz_mec_cron_job_schedule() { if (! wp_next_scheduled ( ‘wojciech_borowicz_remove_expired_events_cron_job’ )) { wp_schedule_event(time(), ‘daily’, ‘wojciech_borowicz_remove_expired_events_cron_job’); } } add_action(‘wojciech_borowicz_remove_expired_events_cron_job’, ‘wojciech_borowicz_remove_expired_events’); function wojciech_borowicz_remove_expired_events() { $args = array( ‘post_type’ => ‘mec-events’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘posts_per_page’=> ‘-1’, ); $loop = new WP_Query( $args ); if( $loop->have_posts() ): $today = date(‘Y-m-d’); while( $loop->have_posts() ): $loop->the_post(); global $post; […]
add_filter(‘style_loader_tag’, ‘flatsomeIconsPreloader’, 10, 2); function flatsomeIconsPreloader($html, $handle) { if( 0 != strpos( $html, ‘flatsome-icons’ ) ) { $html = str_replace( “rel=’stylesheet'”, “rel=’preload’ as=’style’ “, $html ); $html .= “”; } return $html; }
function my_shortcode() { $message = ‘Hello world!’; // Output needs to be return return $message; } // register shortcode add_shortcode(‘shortcodeNameToCall’, ‘my_shortcode’);
$query = mysqli_query($mySQLiConnection, “SELECT * FROM table WHERE 1=1”); $array = array(); // look through query while($row = mysqli_fetch_assoc($query)){ // add each row returned into an array $array[] = $row; // OR just echo the data: echo $row[‘username’]; // etc } print_r($array);
$link = mysqli_connect($db_host, $username, $password, $database); if (!$link) { echo “Error: Unable to connect to MySQL.” . PHP_EOL; echo “Debugging errno: ” . mysqli_connect_errno() . PHP_EOL; echo “Debugging error: ” . mysqli_connect_error() . PHP_EOL; exit; } echo “Success: A proper connection to MySQL was made! The my_db database is great.” . PHP_EOL; echo “Host information: […]