Skip to content

Instantly share code, notes, and snippets.

View trey8611's full-sized avatar
💭
listening to n*sync

Trey trey8611

💭
listening to n*sync
View GitHub Profile
@trey8611
trey8611 / export-jetengine-relations.md
Created March 20, 2024 20:14 — forked from juanlistab/export-jetengine-relations.md
Export JetEngine Relations with WP All Import

How to Export JetEngine Relations

This function will use the default "jet_rel_default" table in JetEngine to look for the post_id of the parent and return its relations from the "child_object_id" column. If you're using a separate table for your relations, you can change the $table_name value.

Instructions:

  • Add a New Field in WP All Export (see https://d.pr/i/OW9dze).
  • Set a name for the column and use "ID" for the field to export (see https://d.pr/i/v5Mq98).
  • Modify the function as needed, paste it in the Function Editor and paste the name of the function in the "Export the value returned by a PHP function" field (see https://d.pr/i/2c6c07).
  • The function will return a list of IDs separated with pipes by default, but if you want to export the titles instead, you need to change the $mode in "function my_export_je_relation ($post_id, $mode = 'id')" to "title".
@trey8611
trey8611 / import-jetengine-relations.md
Created March 20, 2024 20:13 — forked from juanlistab/import-jetengine-relations.md
Import Data to JetEngine Relations

How to Import JetEngine Relations

This snippet will work for One to One, One to Many and Many to Many relationships:

Instructions:

  • Create a "_temp_child" temporary field to store the values of the relations you want to import (see https://d.pr/i/cIooGf). It will accept multiple values separated with commas, and you can use either the ID or the Title.
  • Edit the snippet using the instructions below and paste it in the Function Editor inside WP All Import.
  • The "jet_rel_default" table is the default table used for relations in JetEngine. If you're using a separate table, you'll need to set that table's name instead.
  • You'll need to specify the relationship ID in 'rel_id’; you can find it here (see https://d.pr/i/eSVZ32).
@trey8611
trey8611 / migrating-bbpress-content.md
Last active October 29, 2024 16:58 — forked from mbissett/migrating-bbpress-content.md
Migrating bbPress content with WP All Export and WP All Import

Introduction

Exporting/importing bbPress data presently requires some custom code that utilizes our API: http://www.wpallimport.com/documentation/developers/action-reference/.

Below, we have a general guide on how to do a basic forum/topics/replies migration. Keep in mind that this is only an example and you may need to modify the approach/code to make it work exactly as desired.

Code

Save the following code in the Function Editor (All Import -> Settings):

add_action( 'pmxi_saved_post', 'soflyy_forum_data', 10, 3 );
@trey8611
trey8611 / import-if-syntax.md
Created November 7, 2020 13:51 — forked from Programmer095/import-if-syntax.md
XPath IF statements

WP All Import - IF/ELSE statement examples

Here are some example WP All Import [IF] statements. The criteria for an IF statment is written in XPath 1.0 syntax and can use XPath functions. Although powerful, XPath syntax can be quite complex. In many cases it might be easier to use a PHP function as shown here.

The [ELSE]<something> part is optional

Number is equal to:

[IF({price[.=0]})]Zero[ELSE]Not Zero[ENDIF]

@trey8611
trey8611 / emails.php
Created August 12, 2020 17:48 — forked from tameemsafi/emails.php
Send an email programmatically in wordpress with wp_mail using the woocommerce transaction emails template.
<?php
// Define a constant to use with html emails
define("HTML_EMAIL_HEADERS", array('Content-Type: text/html; charset=UTF-8'));
// @email - Email address of the reciever
// @subject - Subject of the email
// @heading - Heading to place inside of the woocommerce template
// @message - Body content (can be HTML)
function send_email_woocommerce_style($email, $subject, $heading, $message) {
@trey8611
trey8611 / Import Types.md
Last active July 26, 2021 12:56 — forked from KittenCodes/Import Types.md
WP All Import - A description of different import types "New Items" and "Existing Items"

A description of import types

  • New Items Import -

This is primarily used to create and manage products. It keeps internal track of the products that it imports, which means that it can later update/create/delete products as they're changed/added/removed in your import file (see: http://www.wpallimport.com/documentation/recurring/update-import). It's also the only import type that can add/remove variations for variable products.

One limitation of new items imports is that cannot detect/update products that it didn't previously create. If you need to use a "New Items" import with a file that contains existing products, you can use WP All Import's API to prevent duplicates from being imported: https://www.wpallimport.com/documentation/developers/code-snippets/#do-not-create-products-with-duplicate-sku.

  • Existing Items Import -
@trey8611
trey8611 / import-ftp-proxy.php
Last active February 18, 2022 16:56 — forked from m-thomson/import-ftp-proxy.php
This proxy script reads the specified file over FTP and outputs it over HTTP. Thus, you can point WP ALL Import at the URL for this script on your server to provide a "bridge" between FTP and HTTP. This is provided with the hope it will be useful but custom PHP and importing over FTP is not officially supported.
<?php
// Note: Anyone could access your data if they guess this URL. You should remove this file from the server
// after importing or name it to something "unguessable". For even better security use an .htaccess rule.
//
// If you're experiencing problems you can uncomment the following line so errors will be sent to the file.
// ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
//
// Enter the FTP (or HTTP) URL of your data file below.
$url = "ftp://username:[email protected]/full/path/to/file.csv";