Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
Kyra Bond
- bondkyra@gmail.com
- (770) 820-5192
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
function acf_image_shortcode($atts) {
$atts = shortcode_atts(
array(
'field' => '', // ACF field name
'size' => 'medium', // Image size (thumbnail, medium, large, full)
'class' => '', // Custom class for styling
),
$atts, 'acf_image'
);
// Get the image field value
$image = get_field($atts['field']);
if ($image) {
// Ensure the field returns an array (not just a URL)
if (is_array($image)) {
$image_url = isset($image['sizes'][$atts['size']]) ? $image['sizes'][$atts['size']] : $image['url'];
$alt_text = !empty($image['alt']) ? esc_attr($image['alt']) : '';
} else {
$image_url = $image; // If it's set to return only the URL
$alt_text = '';
}
return '<img src="' . esc_url($image_url) . '" alt="' . $alt_text . '" class="' . esc_attr($atts['class']) . '">';
}
return ''; // Return nothing if no image is found
}
add_shortcode('acf_image', 'acf_image_shortcode');
// 1. Admin page to manage manual shortcodes
function bam_register_shortcode_settings_page() {
add_options_page(
'Shortcode Manager',
'Shortcodes',
'manage_options',
'bam-shortcodes',
'bam_render_shortcode_settings_page'
);
}
add_action('admin_menu', 'bam_register_shortcode_settings_page');
function bam_render_shortcode_settings_page() {
$shortcode_list = get_option('bam_shortcode_list', []);
usort($shortcode_list, function($a, $b) {
return [$a['category'], $a['label']] <=> [$b['category'], $b['label']];
});
?>
<div class="wrap">
<h1>Shortcode Manager</h1>
<form method="post">
<?php wp_nonce_field('bam_save_shortcode_list'); ?>
<p><input type="text" id="bam-shortcode-search" placeholder="Search shortcodes..." style="width: 300px;" /></p>
<table class="form-table" id="shortcode-table">
<thead><tr><th>Category</th><th>Label</th><th>Shortcode</th><th></th></tr></thead>
<tbody>
<?php foreach ($shortcode_list as $index => $row): ?>
<tr>
<td><input type="text" name="bam_shortcode_list[<?= $index ?>][category]" value="<?= esc_attr($row['category']) ?>" style="font-weight: bold;" /></td>
<td><input type="text" name="bam_shortcode_list[<?= $index ?>][label]" value="<?= esc_attr($row['label']) ?>" /></td>
<td><input type="text" name="bam_shortcode_list[<?= $index ?>][shortcode]" value="<?= esc_attr($row['shortcode']) ?>" /></td>
<td><button type="button" class="button bam-remove-row">Remove</button></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<p><button type="button" class="button" id="bam-add-row">Add Row</button></p>
<p><input type="submit" class="button-primary" value="Save Changes" /></p>
</form>
</div>
<script>
document.getElementById('bam-add-row').addEventListener('click', function() {
const table = document.querySelector('#shortcode-table tbody');
const rowCount = table.rows.length;
const row = table.insertRow();
row.innerHTML =
'<td><input type="text" name="bam_shortcode_list[' + rowCount + '][category]" style="font-weight: bold;" /></td>' +
'<td><input type="text" name="bam_shortcode_list[' + rowCount + '][label]" /></td>' +
'<td><input type="text" name="bam_shortcode_list[' + rowCount + '][shortcode]" /></td>' +
'<td><button type="button" class="button bam-remove-row">Remove</button></td>';
});
document.addEventListener('click', function(e) {
if (e.target && e.target.classList.contains('bam-remove-row')) {
e.target.closest('tr').remove();
}
});
document.getElementById('bam-shortcode-search').addEventListener('input', function() {
const query = this.value.toLowerCase();
const rows = document.querySelectorAll('#shortcode-table tbody tr');
rows.forEach(row => {
row.style.display = row.innerText.toLowerCase().includes(query) ? '' : 'none';
});
});
</script>
<?php
}
// 2. Save and clean manually entered shortcodes
function bam_save_shortcode_settings() {
if (!current_user_can('manage_options') || !isset($_POST['bam_shortcode_list'])) return;
if (!wp_verify_nonce($_POST['_wpnonce'], 'bam_save_shortcode_list')) return;
$raw_list = $_POST['bam_shortcode_list'];
$cleaned = [];
foreach ($raw_list as $row) {
$category = isset($row['category']) ? wp_unslash(trim($row['category'])) : '';
$label = isset($row['label']) ? wp_unslash(trim($row['label'])) : '';
$shortcode = isset($row['shortcode']) ? wp_unslash(trim($row['shortcode'])) : '';
if ($category && $label && $shortcode) {
$cleaned[] = [
'category' => $category,
'label' => $label,
'shortcode' => $shortcode
];
}
}
update_option('bam_shortcode_list', $cleaned);
}
add_action('admin_init', 'bam_save_shortcode_settings');
// 3. Register TinyMCE button and pass shortcode data to JS
function bam_load_editor_button($hook) {
if ($hook !== 'post.php' && $hook !== 'post-new.php') return;
add_filter("mce_buttons", function($buttons) {
$buttons[] = "my_shortcode_button";
return $buttons;
});
add_filter("mce_external_plugins", function($plugins) {
$plugins["my_shortcode_button"] = get_stylesheet_directory_uri() . "/js/custom-mce-button.js";
return $plugins;
});
// Build shortcode data
$shortcode_data = [];
// Manual entries
$rows = get_option('bam_shortcode_list', []);
foreach ($rows as $row) {
if ($row['category'] && $row['label'] && $row['shortcode']) {
$shortcode_data[$row['category']][] = [
'name' => $row['label'],
'shortcode' => $row['shortcode']
];
}
}
// Elementor templates
$templates = get_posts([
'post_type' => 'elementor_library',
'posts_per_page' => -1,
'post_status' => 'publish',
'orderby' => 'title',
'order' => 'ASC'
]);
foreach ($templates as $template) {
$types = wp_get_post_terms($template->ID, 'elementor_library_type', ['fields' => 'slugs']);
$type = isset($types[0]) ? $types[0] : 'other';
if ($type === 'page') {
$group = 'Elementor Page Templates';
} elseif ($type === 'section') {
$group = 'Elementor Section Templates';
} else {
$group = 'Other Elementor Templates';
}
$shortcode_data[$group][] = [
'name' => $template->post_title,
'shortcode' => '[awam-template id="' . $template->ID . '"]'
];
}
// ACF fields organized by group
if (function_exists('acf_get_field_groups')) {
$field_groups = acf_get_field_groups();
foreach ($field_groups as $group) {
$group_label = $group['title'];
$fields = acf_get_fields($group['key']);
if (!$fields) continue;
$submenu = [];
foreach ($fields as $field) {
$is_image = ($field['type'] === 'image');
$submenu[] = [
'name' => $field['label'] . ' (' . $field['name'] . ')',
'shortcode' => $is_image
? '[acf_image field="' . $field['name'] . '"]'
: ' . '"]'
];
}
if (!empty($submenu)) {
$shortcode_data['ACF Fields'][] = [
'name' => 'Group: ' . $group_label,
'submenu' => $submenu
];
}
}
}
// Pass to JS
wp_enqueue_script("custom_mce_button", get_stylesheet_directory_uri() . "/js/custom-mce-button.js", array("jquery"), null, true);
wp_localize_script("custom_mce_button", "MyShortcodesData", $shortcode_data);
}
add_action("admin_enqueue_scripts", "bam_load_editor_button");
(function waitForTinyMCE() {
if (typeof tinymce === "undefined" || !tinymce.PluginManager) {
setTimeout(waitForTinyMCE, 100);
return;
}
tinymce.PluginManager.add("my_shortcode_button", function(editor) {
const menuItems = [];
if (typeof MyShortcodesData === 'object') {
for (var category in MyShortcodesData) {
const items = MyShortcodesData[category].map(function(item) {
if (item.submenu) {
// This item has a submenu (like ACF Field Groups)
return {
text: item.name,
menu: item.submenu.map(function(sub) {
return {
text: sub.name,
onclick: function() {
editor.insertContent(sub.shortcode);
}
};
})
};
} else {
// Regular item
return {
text: item.name,
onclick: function() {
editor.insertContent(item.shortcode);
}
};
}
});
menuItems.push({
text: category,
menu: items
});
}
}
editor.addButton("my_shortcode_button", {
title: "Insert Shortcode",
text: "Shortcodes",
type: "menubutton",
icon: false,
menu: menuItems
});
});
})();
function solotemplate_domain_checker_shortcode() {
ob_start();
?>
<style>
.st-domain-wrapper {
display: flex;
width: 100%;
border: 1px solid #666;
border-radius: 6px;
overflow: hidden;
margin-bottom: 1rem;
}
.st-domain-wrapper input {
flex: 1;
padding: 12px;
font-size: 16px;
border: none;
outline: none;
}
.st-domain-wrapper button {
background-color: #111111;
color: #fff;
border: none;
padding: 0 20px;
cursor: pointer;
display: flex;
align-items: center;
font-size: 16px;
}
.st-domain-wrapper button:hover {
background-color: #333333;
}
.st-domain-wrapper button svg {
margin-right: 8px;
width: 18px;
height: 18px;
stroke: white;
fill: none;
stroke-width: 2;
}
#st-result {
font-weight: bold;
}
</style>
<div class="st-domain-wrapper">
<input type="text" id="st-domainInput" placeholder="Enter a domain name to search" />
<button onclick="checkSoloTemplateDomain()">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<circle cx="11" cy="11" r="8"></circle>
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
</svg>
Check
</button>
</div>
<div id="st-result"></div>
<script>
// Run on ENTER key
document.getElementById('st-domainInput').addEventListener('keydown', function(event) {
if (event.key === 'Enter') {
event.preventDefault();
checkSoloTemplateDomain();
}
});
async function checkSoloTemplateDomain() {
const rawInput = document.getElementById('st-domainInput').value.trim();
const resultDiv = document.getElementById('st-result');
resultDiv.textContent = 'Checking...';
const defaultTLDs = ['.com', '.co', '.art'];
const baseName = rawInput.toLowerCase().replace(/\..*$/, ''); // remove any TLD if present
const domainsToCheck = defaultTLDs.map(tld => `${baseName}${tld}`);
let output = '';
for (const domain of domainsToCheck) {
try {
const res = await fetch(`/domain-check.php?domain=${encodeURIComponent(domain)}`);
const data = await res.json();
const status = data.status?.[0]?.status || '';
const label = domain;
if (status.includes('available') || status.includes('inactive') || status.includes('undelegated')) {
output += `<div style="color:green;">${label} is available</div>`;
} else if (status) {
output += `<div style="color:red;">${label} is taken</div>`;
} else {
output += `<div>${label} — unable to check</div>`;
}
} catch (error) {
output += `<div>${domain} — error checking</div>`;
}
}
resultDiv.innerHTML = output;
}
</script>
<?php
return ob_get_clean();
}
add_shortcode('solotemplate_domain_checker', 'solotemplate_domain_checker_shortcode');
<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
// Replace this with your actual RapidAPI key
$rapidApiKey = 'YOUR_API_KEY_HERE';
$domain = $_GET['domain'] ?? null;
if (!$domain) {
echo json_encode(['error' => 'No domain provided']);
exit;
}
$url = "https://domainr.p.rapidapi.com/v2/status?domain=" . urlencode($domain);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-RapidAPI-Key: $rapidApiKey",
"X-RapidAPI-Host: domainr.p.rapidapi.com"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Hi, this is a comment.
To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
Commenter avatars come from Gravatar.