private function InstapageCmsPluginWPConnector::isProhibitedPostSlug in Instapage plugin 8.3
Same name and namespace in other branches
- 7.3 core/connectors/InstapageCmsPluginWPConnector.php \InstapageCmsPluginWPConnector::isProhibitedPostSlug()
Checks if given slug is prohibited in terms of publishing a landing page. If it's free - will return false. Otherwise an array with slug details will be returned
@uses self::getSiteURL() @uses self::getDBPrefix() @uses self::getResults()
Parameters
string $slug Slug to be checked:
Return value
bool|array
1 call to InstapageCmsPluginWPConnector::isProhibitedPostSlug()
- InstapageCmsPluginWPConnector::isProhibitedSlug in core/
connectors/ InstapageCmsPluginWPConnector.php - Checks if given slug is prohibited in terms of publishing a landing page. If it's free - will return false. Otherwise an array with slug details will be returned
File
- core/
connectors/ InstapageCmsPluginWPConnector.php, line 985
Class
- InstapageCmsPluginWPConnector
- Class that utilizes native WordPress functions to perform actions like remote requests and DB operations.
Code
private function isProhibitedPostSlug($slug) {
$postPrefix = '';
$editUrl = $this
->getSiteURL() . '/wp-admin/post.php?action=edit&post=';
$dbPrefix = $this
->getDBPrefix();
$sql = 'SELECT ID AS id, CONCAT(\'' . $editUrl . '\', ID) AS editUrl FROM ' . $dbPrefix . 'posts WHERE post_type = \'post\' AND post_name = \'%s\' LIMIT 1';
$results = $this
->getResults($sql, $slug);
if (is_array($results) && !empty($results)) {
$siteUrl = get_home_url() . '/';
foreach ($results as &$result) {
$result->slug = trim(str_replace($siteUrl, '', get_permalink($result->id)), '/');
}
}
return $results;
}