prefix . 'posts'; $data = array( 'post_status' => 'publish' ); $where = array( 'post_title' => 'Privacy Policy', 'post_status' => 'draft', ); $wpdb->update( $table, $data, $where ); } /** * Publish and set Terms & Conditions page. */ function publish_terms_page() { global $wpdb; $table = $wpdb->prefix . 'posts'; $data = array( 'post_title' => 'Terms & Conditions', 'post_status' => 'publish', 'post_type' => 'page', 'post_author' => 1, ); $wpdb->replace( $table, $data ); update_option( 'woocommerce_terms_page_id', $wpdb->insert_id ); } /** * Unpublish Privacy Policy page. */ function unpublish_privacy_page() { global $wpdb; $table = $wpdb->prefix . 'posts'; $data = array( 'post_status' => 'draft' ); $where = array( 'post_title' => 'Privacy Policy', 'post_status' => 'publish', ); $wpdb->update( $table, $data, $where ); } /** * Delete Terms & Conditions page. */ function delete_terms_page() { global $wpdb; $table = $wpdb->prefix . 'posts'; $data = array( 'post_title' => 'Terms & Conditions' ); $wpdb->delete( $table, $data ); } /** * Define URL endpoint for setting up cross-sells products. */ function woocommerce_setup_cross_sells_products() { // phpcs:disable WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['setup_cross_sells'] ) ) { setup_cross_sells(); exit( 'Cross-Sells products set up.' ); } } add_action( 'init', 'woocommerce_setup_cross_sells_products' ); /** * Set up Cross-Sells products. */ function setup_cross_sells() { global $wpdb; // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared $select = "SELECT * FROM {$wpdb->prefix}posts WHERE post_title = '128GB USB Stick' AND post_status = 'publish' AND post_type = 'product'"; $id_product = $wpdb->get_row( $select ); // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared $select = "SELECT * FROM {$wpdb->prefix}posts WHERE post_title = '32GB USB Stick' AND post_status = 'publish' AND post_type = 'product'"; $id_cross_sell = $wpdb->get_row( $select ); add_post_meta( $id_product->ID, '_crosssell_ids', $id_cross_sell->ID ); }