public static function cred_delete_post_link($post_id = false, $text = '', $action = '', $class = '', $style = '', $message = '', $message_after = '', $message_show = 1, $redirect = '') { global $post, $current_user; static $idcount = 0; if (!current_user_can('delete_own_posts_with_cred') && $current_user->ID == $post->post_author) { //return '<strong>'.__('Do not have permission (delete own)','wp-cred').'</strong>'; return ''; } if (!current_user_can('delete_other_posts_with_cred') && $current_user->ID != $post->post_author) { //return '<strong>'.__('Do not have permission (delete other)','wp-cred').'</strong>'; return ''; } if ($post_id === false || empty($post_id) || !isset($post_id) || !is_numeric($post_id)) { if (!isset($post->ID)) { return '<strong>' . __('No post specified', 'wp-cred') . '</strong>'; } else { $post_id = $post->ID; } } // localise the ID $post_id = self::getLocalisedID(intval($post_id)); // provide WPML localization for hardcoded texts $text = str_replace(array('%TITLE%', '%ID%'), array(get_the_title($post_id), $post_id), cred_translate('Delete Link Text', $text, 'CRED Shortcodes')); $link_id = '_cred_cred_' . $post_id . '_' . ++$idcount . '_' . rand(1, 10); $_wpnonce = wp_create_nonce($link_id . '_' . $action); $link = CRED_CRED::routeAjax('cred-ajax-delete-post&cred_post_id=' . $post_id . '&cred_action=' . $action . '&redirect=' . $redirect . '&_wpnonce=' . $_wpnonce); $_atts = array(); if (!empty($class)) { $_atts[] = 'class="' . esc_attr(str_replace('"', "'", $class)) . '"'; } if (!empty($style)) { $_atts[] = 'style="' . esc_attr(str_replace('"', "'", $style)) . '"'; } $dps = ""; if ($idcount == 1) { //$dps = self::get_delete_post_link_js($message_after); global $message_after; add_action('wp_footer', array('CRED_Helper', 'get_delete_post_link_js'), 100); } return CRED_Loader::tpl('delete-post-link', array('link' => $link, 'text' => $text, 'link_id' => $link_id, 'link_atts' => !empty($_atts) ? implode(' ', $_atts) : false, 'message' => $message, 'message_after' => $message_after, 'message_show' => $message_show, 'js' => $dps)); }