post_type == 'metform-form') {
return \MetForm\Utils\Util::render_form_content($content, get_the_ID());
}
return $content;
}
public function add_author_support(){
add_post_type_support( 'metform-form', 'author' );
}
public function set_columns( $columns ) {
$date_column = $columns['date'];
$author_column = $columns['author'];
unset( $columns['date'] );
unset( $columns['author'] );
$columns['shortcode'] = esc_html__( 'Shortcode', 'metform' );
$columns['count'] = esc_html__( 'Entries', 'metform' );
$columns['views_conversion'] = esc_html__( 'Views/ Conversion', 'metform' );
$columns['author'] = esc_html( $author_column );
$columns['date'] = esc_html( $date_column );
return $columns;
}
public function render_column( $column, $post_id ) {
switch ( $column ) {
case 'shortcode':
echo '';
break;
case 'count':
$count = \MetForm\Core\Entries\Action::instance()->get_entry_count($post_id);
global $wp;
$current_url = admin_url();
$current_url .="edit.php?post_type=metform-entry&mf_form_id=".esc_attr($post_id);
$rest_url = get_rest_url();
$mf_ex_nonce = wp_create_nonce('wp_rest');
$url = $rest_url."metform/v1/entries/export/".$post_id;
$export_url = \MetForm\Utils\Util::add_param_url($url, "_wpnonce", $mf_ex_nonce);
echo "".esc_html($count)."";
echo "".esc_html__('Export CSV', 'metform')."";
break;
case 'views_conversion':
$views = \MetForm\Core\Forms\Action::instance()->get_count_views($post_id);
$views = (int)$views;
$count = \MetForm\Core\Entries\Action::instance()->get_entry_count($post_id);
$count = (int)$count;
if($views != 0){
$conversion = ($count*100)/$views;
$conversion = round($conversion, 2);
}else{
$conversion = 0;
}
echo esc_html($views."/ ".$conversion."%");
break;
}
}
}