';
/* translators: %s: "Custom Post Types" or "Custom Taxonomies" %s: "title" or "description" */
$html .= sprintf(__('Some %s have no meta %s set! We strongly encourage you to add one by filling in the fields below.', 'siteseo'), esc_html($notice_i18n), wp_kses_post($metadata));
$html .= '
';
$html .= $list;
$html .= '
';
$html .= '
';
return $html;
}
}
}
/**
* Generate Tooltip.
*
* @since 3.8.2
*
* @param string $tooltip_title, $tooltip_desc, $tooltip_code
* @param mixed $tooltip_desc
* @param mixed $tooltip_code
*
* @return string tooltip title, tooltip description, tooltip url
*
* author Softaculous
*/
function siteseo_tooltip($tooltip_title, $tooltip_desc, $tooltip_code) {
$html =
'';
if ( ! empty($impact)) {
echo '
' . wp_kses_post(reset($impact)) . '';
}
if ( ! empty($icon)) {
echo '
';
} else {
echo '
';
}
echo '
' . wp_kses_post($title) . '
';
if (false === $wrap) {
echo wp_kses_post($desc);
} else {
echo '
' . wp_kses_post($desc) . '
';
}
echo '
';
$href = '';
if (function_exists('siteseo_get_locale') && 'fr' == siteseo_get_locale() && isset($link['fr'])) {
$href = $link['fr'];
} elseif (isset($link['en'])) {
$href = $link['en'];
}
$target = '';
if (isset($link['external']) && true === $link['external']) {
$target = '_blank';
}
if ( ! empty($link) || true === $deleteable) {
echo '
';
if ( ! empty($link)) {
echo '' . esc_html($link['title']) . '';
}
if (true === $deleteable) {
echo '';
}
echo '
';
}
echo '
';
}
}
/**
* Filter the capability to allow other roles to use the plugin.
*
* @since 3.8.2
*
* @author Softaculous
*
* @return string
*
* @param mixed $cap
* @param mixed $context
*/
function siteseo_capability($cap, $context = '') {
$newcap = apply_filters('siteseo_capability', $cap, $context);
if ( ! current_user_can($newcap)) {
return $cap;
}
return $newcap;
}
/**
* Check if the page is one of ours.
*
* @since 3.8.2
*
* @author Softaculous
*
* @return bool
*/
function siteseo_is_valid_page() {
if ( ! is_admin() && ( ! isset($_REQUEST['page']) || ! isset($_REQUEST['post_type']))) {
return false;
}
if (isset($_REQUEST['page'])) {
return 0 === strpos(siteseo_opt_req('page'), 'siteseo');
} elseif (isset($_REQUEST['post_type'])) {
if (is_array(siteseo_opt_req('post_type')) && !empty($_REQUEST['post_type'])) {
return 0 === strpos(siteseo_opt_req('post_type')[0], 'siteseo');
} else {
return 0 === strpos(siteseo_opt_req('post_type'), 'siteseo');
}
}
}
/**
* Only add our notices on our pages.
*
* @since 3.8.2
*
* @author Softaculous
*
* @return bool
*/
function siteseo_remove_other_notices() {
if (siteseo_is_valid_page()) {
remove_all_actions('network_admin_notices');
remove_all_actions('admin_notices');
remove_all_actions('user_admin_notices');
remove_all_actions('all_admin_notices');
add_action('admin_notices', 'siteseo_admin_notices');
if (is_plugin_active('siteseo-pro/siteseo-pro.php')) {
//add_action('admin_notices', 'siteseo_pro_admin_notices');
}
}
}
add_action('in_admin_header', 'siteseo_remove_other_notices', 1000);//keep this value high to remove other notices
/**
* We replace the WP action by ours.
*
* @since 3.8.2
*
* @author Softaculous
*
* @return bool
*/
function siteseo_admin_notices() {
do_action('siteseo_admin_notices');
}
/**
* Return the 7 days in correct order.
*
* @since 3.8.2
*
* @author Softaculous
*
* @return bool
*/
function siteseo_get_days() {
$start_of_week = (int) get_option('start_of_week');
return array_map(
function () use ($start_of_week) {
//static $start_of_week;
return ucfirst(date_i18n('l', strtotime($start_of_week++ - date('w', 0) . ' day', 0)));
},
array_combine(
array_merge(
array_slice(range(0, 6), $start_of_week, 7),
array_slice(range(0, 6), 0, $start_of_week)
),
range(0, 6)
)
);
}
/**
* Check if a key exists in a multidimensional array.
*
* @since 3.8.2
*
* @author Softaculous
*
* @return bool
*
* @param mixed $key
*/
function siteseo_if_key_exists(array $arr, $key) {
// is in base array?
if (array_key_exists($key, $arr)) {
return true;
}
// check arrays contained in this array
foreach ($arr as $element) {
if (is_array($element)) {
if (siteseo_if_key_exists($element, $key)) {
return true;
}
}
}
return false;
}
/**
* Get Oxygen Content for version 4.0
*
* @since 5.9.0
*
* @author Softaculous
*
* @return null
*/
function siteseo_get_oygen_content_v4($data, $content = ""){
if(!is_array($data)){
return $content;
}
if(isset($data['children'])){
foreach($data['children'] as $child){
$content = siteseo_get_oygen_content_v4($child, $content);
}
}
if(isset($data['options']['ct_content'])){
$content .= $data['options']['ct_content'];
}
return $content . " ";
}
/**
* Get Oxygen Content.
*
* @since 3.8.5
*
* @author Softaculous
*
* @return null
*/
function siteseo_get_oxygen_content() {
if (is_plugin_active('oxygen/functions.php') && function_exists('ct_template_output')) {
if (!empty(get_post_meta(get_the_ID(), 'ct_builder_json', true))) {
$oxygen_content = get_post_meta(get_the_ID(), 'ct_builder_json', true);
$siteseo_get_the_content = siteseo_get_oygen_content_v4(json_decode($oxygen_content, true));
} else {
$siteseo_get_the_content = ct_template_output(true); //shortcodes?
}
//Get post content
if ( ! $siteseo_get_the_content) {
$siteseo_get_the_content = apply_filters('the_content', get_post_field('post_content', get_the_ID()));
$siteseo_get_the_content = normalize_whitespace(wp_strip_all_tags($siteseo_get_the_content));
}
if ($siteseo_get_the_content) {
//Get Target Keywords
if (get_post_meta(get_the_ID(), '_siteseo_analysis_target_kw', true)) {
$siteseo_analysis_target_kw = array_filter(explode(',', strtolower(esc_attr(get_post_meta(get_the_ID(), '_siteseo_analysis_target_kw', true)))));
$siteseo_analysis_target_kw = apply_filters( 'siteseo_content_analysis_target_keywords', $siteseo_analysis_target_kw, get_the_ID() );
//Keywords density
foreach ($siteseo_analysis_target_kw as $kw) {
if (preg_match_all('#\b(' . $kw . ')\b#iu', $siteseo_get_the_content, $m)) {
$data['kws_density']['matches'][$kw][] = $m[0];
}
}
}
//Words Counter
$data['words_counter'] = preg_match_all("/\p{L}[\p{L}\p{Mn}\p{Pd}'\x{2019}]*/u", $siteseo_get_the_content, $matches);
if ( ! empty($matches[0])) {
$words_counter_unique = count(array_unique($matches[0]));
} else {
$words_counter_unique = '0';
}
$data['words_counter_unique'] = $words_counter_unique;
//Update analysis
update_post_meta(get_the_ID(), '_siteseo_analysis_data_oxygen', $data);
}
}
}
/**
* Output submit button.
*
* @since 5.0
*
* @author Softaculous
*
* @param mixed $value
* @param mixed $classes
* @param mixed $type
*/
function siteseo_submit_button($value ='', $echo = true, $classes = 'btn btnPrimary', $type = 'submit') {
if ('' === $value) {
$value = __('Save changes', 'siteseo');
}
$html = '