projects = $this->get_projects();
if ( !isset( $project_id ) ) {
if ( isset( $_GET['project_id'] ) ) {
$project_id = $_GET['project_id'];
} else {
$keys = array_keys( $this->projects, current( $this->projects ) );
$project_id = $keys[0];
}
}
$this->project_id = $project_id;
$export_step = ( isset( $_POST['export-step'] ) ) ? $_POST['export-step'] : '1';
if ( '1' === $export_step ) {
anthologize_delete_session();
}
if ( $export_step != '3' )
$this->display();
}
function display() {
wp_enqueue_style( 'anthologize-admin' );
$project_id = $this->project_id;
if ( isset( $_POST['export-step'] ) )
$this->save_session();
$options = get_post_meta( $project_id, 'anthologize_meta', true );
$cdate = !empty( $options['cdate'] ) ? $options['cdate'] : date('Y');
if ( isset( $options['cname'] ) )
$cname = $options['cname'];
else if ( isset( $options['author_name'] ) )
$cname = $options['author_name'];
else
$cname = '';
// Default is Creative Commons
$ctype = !empty( $options['ctype'] ) ? $options['ctype'] : 'cc';
$cctype = !empty( $options['cctype'] ) ? $options['cctype'] : 'by';
// No default for edition number
$edition = isset( $options['edition'] ) ? isset( $options['edition'] ) : false;
if ( isset( $options['authors'] ) ) {
$authors = $options['authors'];
} elseif ( isset( $options['author_name'] ) ) {
$authors = $options['authors'];
} else {
$author_names = anthologize_get_item_author_names( $project_id );
$authors = implode( ', ', $author_names );
}
$dedication = !empty( $options['dedication'] ) ? $options['dedication'] : '';
$acknowledgements = !empty( $options['acknowledgements'] ) ? $options['acknowledgements'] : '';
?>
$fdata ) {
$option_id = 'option-format-' . $name;
$disabled = '';
$message = '';
$is_available = call_user_func( $fdata['is_available_callback'] );
if ( ! $is_available ) {
// Non-admins should see nothing.
if ( ! current_user_can( 'install_plugins' ) ) {
continue;
}
// Admins see the option, but it's disabled.
$disabled = disabled( true, true, false );
$message = $fdata['unavailable_notice'];
}
?>
/>
$odata ) {
if ( $oname == 'label' || $oname == 'loader-path' )
continue;
if ( ! $odata || ! is_array( $odata ) ) {
continue;
}
$default = ( isset( $odata['default'] ) ) ? $odata['default'] : false;
$return .= '';
$return .= '| ';
$return .= sprintf( ' | ';
$return .= '';
switch( $odata['type'] ) {
case 'checkbox':
$return .= $this->build_checkbox( $oname, $odata['label'] );
break;
case 'checkboxes' :
$return .= $this->build_checkboxes( $oname, $odata['values'], $default );
break;
case 'dropdown':
$return .= $this->build_dropdown( $oname, $odata['label'], $odata['values'], $default );
break;
// Default is a textbox
default:
$return .= $this->build_textbox( $oname, $odata['label'] );
break;
}
$return .= ' | ';
$return .= '
';
}
} else {
$return = esc_html__( 'This appears to be an invalid export format. Please try again.', 'anthologize' );
}
echo $return;
}
function build_checkbox( $name, $label ) {
$html = '';
return apply_filters( 'anthologize_build_checkbox', $html, $name, $label );
}
/**
* Build 'checkboxes' selector markup.
*
* @since 0.8.0
*
* @param string $name Unique name of the format option.
* @param array $values Checkbox values. Array keys should be values, values should be labels.
* @param array $defaults Default selected values.
*/
public function build_checkboxes( $name, $values, $defaults ) {
$html = '';
return apply_filters( 'anthologize_build_checkboxes', $html, $name, $values, $defaults );
}
function build_dropdown( $name, $label, $options, $default ) {
// $name is the input name (no spaces, eg 'page-size')
// $label is the input label (for display, eg 'Page Size'. Should be internationalizable, eg __('Page Size', 'anthologize')
// $options is associative array where keys are option values and values are the text displayed in the option field.
// $default is the default option
$html = '';
return apply_filters( 'anthologize_build_dropdown', $html, $name, $label, $options );
}
function build_textbox( $name, $label ) {
$html = '';
return apply_filters( 'anthologize_build_textbox', $html, $name, $label );
}
function load_template() {
// The goggles! Zey do nossing!
// Check anthologize.php for the real handler method load_template, which happens before headers are sent.
}
function get_projects() {
$projects = array();
query_posts( 'post_type=anth_project&orderby=title&order=ASC&posts_per_page=-1' );
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
$projects[get_the_ID()] = get_the_title();
}
}
return $projects;
}
}
endif;