ShahiLanding

Hooks & Filters Reference

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:

    1. $network_wide (bool) – Whether activation is network-wide
    2. 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:

    3. $post_id (int) – The ID of the created landing page
    4. $data (array) – The data used to create the landing page
    5. 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:

    6. $post_id (int) – The ID of the updated landing page
    7. $data (array) – The update data
    8. Usage:
      `php
      addaction(‘shahilandinlandingupdated’, function($postid, $data) {
      // Clear custom caches
      deletetransient(“landingcache{$postid}”);
      }, 10, 2);
      `

      shahilandinlandingdeleted

      Fires when a landing page is deleted.

      Parameters:

    9. $post_id (int) – The ID of the deleted landing page
    10. 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:

    11. $post_id (int) – The ID of the published landing page
    12. 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:

    13. $post_id (int) – The landing page ID
    14. $data (array) – View tracking data (IP, user agent, referrer, etc.)
    15. 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:

    16. $post_id (int) – The landing page ID
    17. $goal (string) – The conversion goal name
    18. $data (array) – Conversion data
    19. 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:

    20. $post_id (int) – The original landing page ID
    21. $variant_id (int) – The created variant ID
    22. 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:

    23. $post_id (int) – The original landing page ID
    24. $winner_id (int|null) – The winning variant ID (null if no winner declared)
    25. 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:

    26. $post_id (int) – The landing page ID
    27. 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:

    28. $post_id (int) – The landing page ID
    29. Usage:
      `php
      addaction(‘shahilandinaftertemplateload’, function($post_id) {
      // Add custom footer content
      echo ‘‘;
      }, 10, 1);
      `

      Import Events

      shahilandinhtmlimported

      Fires after HTML is successfully imported.

      Parameters:

    30. $post_id (int) – The created landing page ID
    31. $import_data (array) – Import metadata
    32. 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:

    33. $post_id (int) – The landing page ID
    34. $manifest (array) – Asset manifest with URLs
    35. 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:

    36. $post_id (int) – The landing page ID
    37. 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:

    38. $html (string) – The HTML content
    39. $post_id (int) – The landing page ID
    40. Returns: (string) Modified HTML

      Usage:
      `php
      addfilter(‘shahilandinhtmloutput’, function($html, $postid) {
      // Add custom wrapper
      return ‘

      ‘ . $html . ‘

      ‘;
      }, 10, 2);
      `

      shahilandincssoutput

      Filters the CSS output before rendering.

      Parameters:

    41. $css (string) – The CSS content
    42. $post_id (int) – The landing page ID
    43. 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:

    44. $assets (array) – Array of head assets (links, meta, scripts)
    45. $post_id (int) – The landing page ID
    46. 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:

    47. $allowed_tags (array) – Array of allowed HTML tags and attributes
    48. 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:

    49. $sanitized_html (string) – The sanitized HTML
    50. $original_html (string) – The original HTML before sanitization
    51. 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:

    52. $collect (bool) – Whether to collect IPs
    53. Returns: (bool) Modified value

      Usage:
      `php
      addfilter(‘shahilandinanalyticscollectip’, ‘_returnfalse’);
      `

      shahilandinanalyticsanonymize_ip

      Filters whether IP addresses should be anonymized.

      Parameters:

    54. $anonymize (bool) – Whether to anonymize IPs
    55. Returns: (bool) Modified value

      Usage:
      `php
      addfilter(‘shahilandinanalyticsanonymizeip’, ‘_returntrue’);
      `

      shahilandinviewcache_duration

      Filters the view tracking cache duration (prevents duplicate counts).

      Parameters:

    56. $duration (int) – Cache duration in seconds
    57. 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:

    58. $is_bot (bool) – Whether request is from a bot
    59. $user_agent (string) – The user agent string
    60. 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:

    61. $split (int) – Traffic split percentage (0-100)
    62. $post_id (int) – Original landing page ID
    63. 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:

    64. $duration (int) – Duration in days
    65. $post_id (int) – Original landing page ID
    66. 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:

    67. $days (int) – Minimum days
    68. 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:

    69. $size (int) – Maximum size in bytes
    70. 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:

    71. $status (string) – Default status
    72. 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:

    73. $enabled (bool) – Whether mirroring is enabled
    74. Returns: (bool) Modified value

      Usage:
      `php
      addfilter(‘shahilandinassetmirrorenabled’, ‘_returnfalse’);
      `

      Performance Filters

      shahilandinminifyhtml

      Filters whether HTML should be minified.

      Parameters:

    75. $minify (bool) – Whether to minify
    76. $post_id (int) – Landing page ID
    77. 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:

    78. $enabled (bool) – Whether lazy loading is enabled
    79. Returns: (bool) Modified value

      Usage:
      `php
      addfilter(‘shahilandinlazyloadenabled’, ‘_returntrue’);
      `

      shahilandinpreconnecturls

      Filters the list of URLs for DNS preconnect hints.

      Parameters:

    80. $urls (array) – Array of URLs
    81. 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:

    82. $mode (string) – Rendering mode (canvas, themescoped, themeshadow)
    83. $post_id (int) – Landing page ID
    84. 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:

    85. $template (string) – Template file path
    86. $post_id (int) – Landing page ID
    87. 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:

    88. $can (bool) – Whether user can create
    89. $user_id (int) – User ID
    90. 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:

    91. $can (bool) – Whether user can edit
    92. $post_id (int) – Landing page ID
    93. $user_id (int) – User ID
    94. 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:

    95. $email (string) – Email address
    96. 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:

    97. $webhook (string) – Webhook URL
    98. 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:

    99. $retain (bool) – Whether to retain data
    100. Returns: (bool) Modified value

      Usage:
      `php
      addfilter(‘shahilandinretaindata’, ‘returntrue’);
      `

      shahilandindataretention_period

      Filters the analytics data retention period in days.

      Parameters:

    101. $days (int) – Retention period in days

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 = ‘

Admin Preview Mode

‘ . $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

Was this article helpful?

Help us improve our documentation

Still need help?

Our support team is ready to assist you with personalized guidance for your workspace.

Submit a support ticket