Skip to content

Instantly share code, notes, and snippets.

@Crocoblock
Crocoblock / get-meta.php
Last active February 19, 2024 09:11
Get current JetEngine listing object meta value ( somewhat similar to ACF get_field() )
<?php
//You may just use get_post_meta() to get post/term/user meta
//However, in Listing Grid, you may use get_meta() method for convenience
$value = jet_engine()->listings->data->get_meta( $meta_key, $object );
/**
* Get object meta value. Works for Posts, Terms, Users, Comments
* $object defaults to null, then the value will be retrieved from the current listing object
@MjHead
MjHead / get-jet-engine-meta-fields.php
Last active April 6, 2024 17:55
JetEngine. Get registered meta fields by given context - post type, taxonomy or user
<?php
/**
* Get fields for the given context and object
* Should be called on hook 'init' with priority 11 or later
*/
// Fields for Post post type
$post_fields = jet_engine()->meta_boxes->get_fields_for_context( 'post_type', 'post' );
// Fields for Product post type
@MjHead
MjHead / form-custom-hook.php
Created September 19, 2021 08:07
JetFormBuilder. Example of custom hook with API request and redirect.
<?php
/**
* 'api-request' - is a customm hook name
*/
add_action( 'jet-form-builder/custom-action/api-request', function( $request, $action_handler ) {
$post_id = ! empty( $request['inserted_post_id'] ) ? $request['inserted_post_id'] : false;
if ( ! $post_id ) {
return;
@Prakasaka
Prakasaka / bash-colors.md
Created July 25, 2020 09:14 — forked from JBlond/bash-colors.md
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
function __prefix__add_relation_meta( $post_id, $meta_key, $related_posts = array() ) {
$relation = jet_engine()->relations->get_relation_info( $meta_key );
if ( ! $relation ) {
return;
}
if ( empty( $related_posts ) ) {
jet_engine()->relations->data->delete_all_related_meta( $meta_key, $post_id );
@xpn
xpn / azuread_decrypt_msol_v2.ps1
Created April 11, 2020 01:34
Updated method of dumping the MSOL service account (which allows a DCSync) used by Azure AD Connect Sync
Write-Host "AD Connect Sync Credential Extract v2 (@_xpn_)"
Write-Host "`t[ Updated to support new cryptokey storage method ]`n"
$client = new-object System.Data.SqlClient.SqlConnection -ArgumentList "Data Source=(localdb)\.\ADSync;Initial Catalog=ADSync"
try {
$client.Open()
} catch {
Write-Host "[!] Could not connect to localdb..."
return
@MjHead
MjHead / jet-engine-metabox-from-code.php
Created February 26, 2020 08:31
Register custom meta box for JetEngine from code
<?php
add_action( 'jet-engine/meta-boxes/register-instances', 'my_register_meta_box' );
function my_register_meta_box( $meta_boxes_manager ) {
// Replace my_post_type_slug with your actual post type slug
$post_type = 'my_post_type_slug';
$object_name = $post_type . '_group';
@MjHead
MjHead / options-values-in-code.php
Last active May 5, 2024 03:33
Get option values for JetEngine options pages inside the PHP code
<?php
/**
* Method 1
* Can be used for: Any storage type
*
* page-slug - replace this with your Option Page slug
* option-name - replace this with your option Name/ID
*/
$value = jet_engine()->listings->data->get_option( 'page-slug::option-name' );
@enepomnyaschih
enepomnyaschih / base64.js
Last active March 6, 2024 23:45
https://www.npmjs.com/package/byte-base64 - Encode JS Uint8Array, simple array of bytes or native JS string to base64 and back
/*
MIT License
Copyright (c) 2020 Egor Nepomnyaschih
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@FranciscoG
FranciscoG / acf_repeater_shortcode.php
Last active April 18, 2024 00:00
An Advanced Custom Fields shortcode that allows to loop through a field with a repeater. This only handles simple cases, it can't handle nested repeater fields
<?php
/**
* ACF Pro repeater field shortcode
*
* I created this shortcode function because it didn't exist and it was being requested by others
* I originally posted it here: https://support.advancedcustomfields.com/forums/topic/repeater-field-shortcode/
*
* @attr {string} field - (Required) the name of the field that contains a repeater sub group
* @attr {string} sub_fields - (Required) a comma separated list of sub field names that are part of the field repeater group
* @attr {string} post_id - (Optional) Specific post ID where your value was entered. Defaults to current post ID (not required). This can also be options / taxonomies / users / etc