ShahiLandin provides extensive hooks and filters for developers to customize and extend functionality. This reference covers all available actions, filters, and their usage.
Actions (do_action)
Actions allow you to hook into specific points in the plugin’s execution flow.
Plugin Lifecycle
shahilandin_loaded
Fires after the plugin is fully initialized.
Usage:
`php
addaction(‘shahilandinloaded’, function() {
// Plugin is fully loaded
// Initialize your custom functionality here
});
`
shahilandin_activated
Fires when the plugin is activated.
Parameters:
$network_wide(bool) – Whether activation is network-wide$post_id(int) – The ID of the created landing page$data(array) – The data used to create the landing page$post_id(int) – The ID of the updated landing page$data(array) – The update data$post_id(int) – The ID of the deleted landing page$post_id(int) – The ID of the published landing page$post_id(int) – The landing page ID$data(array) – View tracking data (IP, user agent, referrer, etc.)$post_id(int) – The landing page ID$goal(string) – The conversion goal name$data(array) – Conversion data$post_id(int) – The original landing page ID$variant_id(int) – The created variant ID$post_id(int) – The original landing page ID$winner_id(int|null) – The winning variant ID (null if no winner declared)$post_id(int) – The landing page ID$post_id(int) – The landing page ID$post_id(int) – The created landing page ID$import_data(array) – Import metadata$post_id(int) – The landing page ID$manifest(array) – Asset manifest with URLs$post_id(int) – The landing page ID$html(string) – The HTML content$post_id(int) – The landing page ID$css(string) – The CSS content$post_id(int) – The landing page ID$assets(array) – Array of head assets (links, meta, scripts)$post_id(int) – The landing page ID$allowed_tags(array) – Array of allowed HTML tags and attributes$sanitized_html(string) – The sanitized HTML$original_html(string) – The original HTML before sanitization$collect(bool) – Whether to collect IPs$anonymize(bool) – Whether to anonymize IPs$duration(int) – Cache duration in seconds$is_bot(bool) – Whether request is from a bot$user_agent(string) – The user agent string$split(int) – Traffic split percentage (0-100)$post_id(int) – Original landing page ID$duration(int) – Duration in days$post_id(int) – Original landing page ID$days(int) – Minimum days$size(int) – Maximum size in bytes$status(string) – Default status$enabled(bool) – Whether mirroring is enabled$minify(bool) – Whether to minify$post_id(int) – Landing page ID$enabled(bool) – Whether lazy loading is enabled$urls(array) – Array of URLs$mode(string) – Rendering mode (canvas, themescoped, themeshadow)$post_id(int) – Landing page ID$template(string) – Template file path$post_id(int) – Landing page ID$can(bool) – Whether user can create$user_id(int) – User ID$can(bool) – Whether user can edit$post_id(int) – Landing page ID$user_id(int) – User ID$email(string) – Email address$webhook(string) – Webhook URL$retain(bool) – Whether to retain data$days(int) – Retention period in days
Usage:
`php
addaction(‘shahilandinactivated’, function($network_wide) {
if ($network_wide) {
// Network-wide activation
} else {
// Single-site activation
}
}, 10, 1);
`
shahilandin_deactivated
Fires when the plugin is deactivated.
Usage:
`php
addaction(‘shahilandindeactivated’, function() {
// Cleanup tasks on deactivation
wpclearscheduledhook(‘shahilandindaily_cleanup’);
});
`
Landing Page Events
shahilandinlandingcreated
Fires after a landing page is successfully created.
Parameters:
Usage:
`php
addaction(‘shahilandinlandingcreated’, function($postid, $data) {
// Send notification
wp_mail(
getoption(‘adminemail’),
‘New Landing Page Created’,
“Landing page ‘{$data[‘posttitle’]}’ was created (ID: {$postid})”
);
}, 10, 2);
`
shahilandinlandingupdated
Fires after a landing page is updated.
Parameters:
Usage:
`php
addaction(‘shahilandinlandingupdated’, function($postid, $data) {
// Clear custom caches
deletetransient(“landingcache{$postid}”);
}, 10, 2);
`
shahilandinlandingdeleted
Fires when a landing page is deleted.
Parameters:
Usage:
`php
addaction(‘shahilandinlandingdeleted’, function($postid) {
// Cleanup related data
global $wpdb;
$wpdb->delete($wpdb->prefix . ‘customtracking’, [‘landingid’ => $post_id]);
}, 10, 1);
`
shahilandinlandingpublished
Fires when a landing page is published (status changes to ‘publish’).
Parameters:
Usage:
`php
addaction(‘shahilandinlandingpublished’, function($postid) {
// Trigger marketing automation
doaction(‘marketingautomationtrigger’, ‘landingpublished’, $post_id);
}, 10, 1);
`
Analytics Events
shahilandinviewtracked
Fires when a page view is recorded.
Parameters:
Usage:
`php
addaction(‘shahilandinviewtracked’, function($postid, $data) {
// Send to external analytics
sendtogoogle_analytics([
‘event’ => ‘page_view’,
‘pageid’ => $postid,
‘referrer’ => $data[‘referrer’] ?? ”
]);
}, 10, 2);
`
shahilandinconversiontracked
Fires when a conversion is recorded.
Parameters:
Usage:
`php
addaction(‘shahilandinconversiontracked’, function($postid, $goal, $data) {
// Log to CRM
if ($goal === ‘newsletter_signup’) {
addsubscribertocrm($data[’email’], $postid);
}
}, 10, 3);
`
Experiment Events
shahilandinexperimentcreated
Fires when a new experiment is created.
Parameters:
Usage:
`php
addaction(‘shahilandinexperimentcreated’, function($postid, $variant_id) {
// Notify team
$message = sprintf(
‘New A/B test created for landing page %d. Variant ID: %d’,
$post_id,
$variant_id
);
sendslacknotification($message);
}, 10, 2);
`
shahilandinexperimentstopped
Fires when an experiment is stopped.
Parameters:
Usage:
`php
addaction(‘shahilandinexperimentstopped’, function($postid, $winner_id) {
if ($winner_id) {
// Archive losing variants
$variants = ExperimentService::getvariants($post_id);
foreach ($variants as $variant_id) {
if ($variantid !== $winnerid) {
wpupdatepost([
‘ID’ => $variant_id,
‘post_status’ => ‘shahilandin-archived’
]);
}
}
}
}, 10, 2);
`
Template Events
shahilandinbeforetemplate_load
Fires before loading the landing page template.
Parameters:
Usage:
`php
addaction(‘shahilandinbeforetemplateload’, function($post_id) {
// Enqueue custom scripts
wpenqueuescript(‘custom-landing-script’, getstylesheetdirectory_uri() . ‘/js/landing.js’);
}, 10, 1);
`
shahilandinaftertemplate_load
Fires after loading the landing page template.
Parameters:
Usage:
`php
addaction(‘shahilandinaftertemplateload’, function($post_id) {
// Add custom footer content
echo ‘‘;
}, 10, 1);
`
Import Events
shahilandinhtmlimported
Fires after HTML is successfully imported.
Parameters:
Usage:
`php
addaction(‘shahilandinhtmlimported’, function($postid, $import_data) {
// Tag imported landing pages
wpsetpostterms($postid, [‘imported-html’], ‘shahilandingtag’);
}, 10, 2);
`
shahilandinassetsmirrored
Fires after external assets are mirrored locally.
Parameters:
Usage:
`php
addaction(‘shahilandinassetsmirrored’, function($postid, $manifest) {
// Log mirrored assets
error_log(sprintf(
‘Mirrored %d assets for landing page %d’,
count($manifest),
$post_id
));
}, 10, 2);
`
Cache Events
shahilandinclearcache
Fires when caches should be cleared for a landing page.
Parameters:
Usage:
`php
addaction(‘shahilandinclearcache’, function($postid) {
// Clear WP Rocket cache
if (functionexists(‘rocketclean_post’)) {
rocketcleanpost($post_id);
}
// Clear custom caches
deletetransient(“landinghtml{$postid}”);
}, 10, 1);
`
Filters (apply_filters)
Filters allow you to modify data at specific points in the plugin’s execution.
Content Filters
shahilandinhtmloutput
Filters the HTML output before rendering.
Parameters:
Returns: (string) Modified HTML
Usage:
`php
addfilter(‘shahilandinhtmloutput’, function($html, $postid) {
// Add custom wrapper
return ‘
‘;
}, 10, 2);
`
shahilandincssoutput
Filters the CSS output before rendering.
Parameters:
Returns: (string) Modified CSS
Usage:
`php
addfilter(‘shahilandincssoutput’, function($css, $postid) {
// Add custom CSS
$custom_css = ‘.custom-class { color: red; }’;
return $css . “\n” . $custom_css;
}, 10, 2);
`
shahilandinheadassets
Filters the head assets before rendering.
Parameters:
Returns: (array) Modified assets array
Usage:
`php
addfilter(‘shahilandinheadassets’, function($assets, $postid) {
// Add custom meta tag
$assets[‘meta’][] = [
‘name’ => ‘custom-meta’,
‘content’ => ‘custom value’
];
return $assets;
}, 10, 2);
`
Sanitization Filters
shahilandinallowedhtml
Filters the allowed HTML tags during sanitization.
Parameters:
Returns: (array) Modified allowed tags
Usage:
`php
addfilter(‘shahilandinallowedhtml’, function($allowedtags) {
// Allow iframe embeds
$allowed_tags[‘iframe’] = [
‘src’ => true,
‘width’ => true,
‘height’ => true,
‘frameborder’ => true,
‘allowfullscreen’ => true
];
return $allowed_tags;
});
`
shahilandinsanitizehtml
Filters the HTML after sanitization.
Parameters:
Returns: (string) Final sanitized HTML
Usage:
`php
addfilter(‘shahilandinsanitizehtml’, function($sanitizedhtml, $original_html) {
// Custom post-sanitization processing
$sanitizedhtml = strreplace(‘OLDDOMAIN’, ‘NEWDOMAIN’, $sanitized_html);
return $sanitized_html;
}, 10, 2);
`
Analytics Filters
shahilandinanalyticscollect_ip
Filters whether IP addresses should be collected.
Parameters:
Returns: (bool) Modified value
Usage:
`php
addfilter(‘shahilandinanalyticscollectip’, ‘_returnfalse’);
`
shahilandinanalyticsanonymize_ip
Filters whether IP addresses should be anonymized.
Parameters:
Returns: (bool) Modified value
Usage:
`php
addfilter(‘shahilandinanalyticsanonymizeip’, ‘_returntrue’);
`
shahilandinviewcache_duration
Filters the view tracking cache duration (prevents duplicate counts).
Parameters:
Returns: (int) Modified duration
Usage:
`php
addfilter(‘shahilandinviewcacheduration’, function($duration) {
return 2 * HOURINSECONDS; // 2 hours instead of default 1 hour
});
`
shahilandinisbot
Filters whether a request is from a bot (for analytics filtering).
Parameters:
Returns: (bool) Modified value
Usage:
`php
addfilter(‘shahilandinisbot’, function($isbot, $user_agent) {
// Add custom bot detection
if (strpos($user_agent, ‘CustomBot’) !== false) {
return true;
}
return $is_bot;
}, 10, 2);
`
Experiment Filters
shahilandinexperimenttraffic_split
Filters the traffic split percentage for experiments.
Parameters:
Returns: (int) Modified split percentage
Usage:
`php
addfilter(‘shahilandinexperimenttrafficsplit’, function($split, $post_id) {
// Use 80/20 split for specific landing page
if ($post_id === 123) {
return 20; // 80% control, 20% variant
}
return $split;
}, 10, 2);
`
shahilandinexperimentduration
Filters the experiment duration.
Parameters:
Returns: (int) Modified duration
Usage:
`php
addfilter(‘shahilandinexperimentduration’, function($duration, $postid) {
// Run experiments for 30 days instead of default 14
return 30;
}, 10, 2);
`
shahilandinminexperiment_duration
Filters the minimum experiment duration.
Parameters:
Returns: (int) Modified minimum
Usage:
`php
addfilter(‘shahilandinminexperimentduration’, function($days) {
return 7; // Minimum 7 days
});
`
Import Filters
shahilandinmaximport_size
Filters the maximum file size for HTML imports.
Parameters:
Returns: (int) Modified size
Usage:
`php
addfilter(‘shahilandinmaximportsize’, function($size) {
return 1048576; // 1MB instead of default 512KB
});
`
shahilandinimportdefault_status
Filters the default post status for imported landing pages.
Parameters:
Returns: (string) Modified status
Usage:
`php
addfilter(‘shahilandinimportdefaultstatus’, function($status) {
return ‘pending’; // Require review before publishing
});
`
shahilandinassetmirror_enabled
Filters whether asset mirroring is enabled during import.
Parameters:
Returns: (bool) Modified value
Usage:
`php
addfilter(‘shahilandinassetmirrorenabled’, ‘_returnfalse’);
`
Performance Filters
shahilandinminifyhtml
Filters whether HTML should be minified.
Parameters:
Returns: (bool) Modified value
Usage:
`php
addfilter(‘shahilandinminifyhtml’, function($minify, $postid) {
// Disable minification for specific page
if ($post_id === 123) {
return false;
}
return $minify;
}, 10, 2);
`
shahilandinlazyload_enabled
Filters whether lazy loading is enabled.
Parameters:
Returns: (bool) Modified value
Usage:
`php
addfilter(‘shahilandinlazyloadenabled’, ‘_returntrue’);
`
shahilandinpreconnecturls
Filters the list of URLs for DNS preconnect hints.
Parameters:
Returns: (array) Modified URL array
Usage:
`php
addfilter(‘shahilandinpreconnect_urls’, function($urls) {
$urls[] = ‘https://cdn.example.com’;
$urls[] = ‘https://analytics.example.com’;
return $urls;
});
`
Rendering Filters
shahilandinrendermode
Filters the rendering mode for a landing page.
Parameters:
Returns: (string) Modified mode
Usage:
`php
addfilter(‘shahilandinrendermode’, function($mode, $postid) {
// Force canvas mode for specific page
if ($post_id === 123) {
return ‘canvas’;
}
return $mode;
}, 10, 2);
`
shahilandintemplatepath
Filters the template file path.
Parameters:
Returns: (string) Modified template path
Usage:
`php
addfilter(‘shahilandintemplatepath’, function($template, $postid) {
// Use custom template for specific page
if ($post_id === 123) {
return getstylesheetdirectory() . ‘/custom-landing-template.php’;
}
return $template;
}, 10, 2);
`
Permissions Filters
shahilandinusercan_create
Filters whether a user can create landing pages.
Parameters:
Returns: (bool) Modified value
Usage:
`php
addfilter(‘shahilandinusercancreate’, function($can, $user_id) {
// Allow specific users even if they don’t have the capability
$allowed_users = [5, 12, 23];
if (inarray($userid, $allowed_users)) {
return true;
}
return $can;
}, 10, 2);
`
shahilandinusercan_edit
Filters whether a user can edit a specific landing page.
Parameters:
Returns: (bool) Modified value
Usage:
`php
addfilter(‘shahilandinusercanedit’, function($can, $postid, $userid) {
// Allow page author even if capability was revoked
$post = getpost($postid);
if ($post && $post->postauthor == $userid) {
return true;
}
return $can;
}, 10, 3);
`
Notification Filters
shahilandinnotificationemail
Filters the email address for system notifications.
Parameters:
Returns: (string) Modified email
Usage:
`php
addfilter(‘shahilandinnotification_email’, function($email) {
return ‘landing-pages@example.com’;
});
`
shahilandinopsslack_webhook
Filters the Slack webhook URL for operational alerts.
Parameters:
Returns: (string) Modified webhook URL
Usage:
`php
addfilter(‘shahilandinopsslackwebhook’, function($webhook) {
return ‘https://hooks.slack.com/services/YOUR/CUSTOM/WEBHOOK’;
});
`
Data Retention Filters
shahilandinretaindata
Filters whether data should be retained during uninstall.
Parameters:
Returns: (bool) Modified value
Usage:
`php
addfilter(‘shahilandinretaindata’, ‘returntrue’);
`
shahilandindataretention_period
Filters the analytics data retention period in days.
Parameters:
Returns: (int) Modified period
Usage:
`php
addfilter(‘shahilandindataretentionperiod’, function($days) {
return 90; // Keep data for 90 days
});
`
Custom Hooks Examples
Integrate with Marketing Automation
`php
// Send conversion to marketing automation platform
addaction(‘shahilandinconversiontracked’, function($postid, $goal, $data) {
if ($goal === ‘newsletter_signup’ && isset($data[’email’])) {
$api = new MarketingAutomationAPI();
$api->add_contact([
’email’ => $data[’email’],
‘source’ => ‘landing_page’,
‘landingid’ => $postid
]);
}
}, 10, 3);
`
Custom Analytics Integration
`php
// Send events to custom analytics platform
addaction(‘shahilandinviewtracked’, function($postid, $data) {
wpremotepost(‘https://analytics.example.com/track’, [
‘body’ => json_encode([
‘event’ => ‘page_view’,
‘landingid’ => $postid,
‘url’ => getpermalink($postid),
‘referrer’ => $data[‘referrer’] ?? ”
])
]);
}, 10, 2);
`
Modify HTML Based on User Role
`php
addfilter(‘shahilandinhtmloutput’, function($html, $postid) {
if (isuserloggedin() && currentuser_can(‘administrator’)) {
// Add admin-only message
$html = ‘
‘ . $html;
}
return $html;
}, 10, 2);
`
Auto-Archive Old Landing Pages
`php
add_action(‘init’, function() {
if (! wpnextscheduled(‘shahilandinautoarchive’)) {
wpscheduleevent(time(), ‘daily’, ‘shahilandinautoarchive’);
}
});
addaction(‘shahilandinauto_archive’, function() {
$args = [
‘posttype’ => ‘shahilanding’,
‘post_status’ => ‘publish’,
‘date_query’ => [
[
‘before’ => ‘6 months ago’
]
],
‘fields’ => ‘ids’
];
$oldpages = getposts($args);
foreach ($oldpages as $postid) {
$stats = LandingService::getstatistics($post_id);
// Archive if no views in last 6 months
if ($stats[‘views’] === 0) {
wpupdatepost([
‘ID’ => $post_id,
‘post_status’ => ‘shahilandin-archived’
]);
}
}
});
`
—
For practical implementation examples, see the Developer Guide article.
Share this article
Still need help?
Our support team is ready to assist you with personalized guidance for your workspace.