'; $appendices = get_post_meta($post->ID, '_anno_appendices', true); if (!empty($appendices) && is_array($appendices)) { foreach ($appendices as $index => $content) { $html .= anno_appendix_box_content($index, $content); } } else { $html .= anno_appendix_box_content(0); } $html .= ' '; $html .= '
'; $html .= '

'._x('Add Another Appendix', 'Meta box repeater link', 'anno').'

'. '
'; echo $html; } else { echo '

'.sprintf(_x('The Annotum editor requires at least WordPress 3.3. It appears you are using WordPress %s. ', 'WordPress version error message', 'anno'), get_bloginfo('version')).'

'; } } /** * Output for Appendix edit input. */ function anno_appendix_box_content($index = null, $content = null) { $html = ''; if (empty($index) && $index !== 0) { $index = '###INDEX###'; $index_alpha = '###INDEX_ALPHA###'; } else { $index_alpha = anno_index_alpha($index); } if (empty($content)) { $content = '   '; } ob_start(); anno_load_editor(anno_process_editor_content($content), esc_attr('appendix-').$index, array('textarea_name' => esc_attr('anno_appendix['.$index.']'))); $editor_markup = ob_get_contents(); ob_end_clean(); $html .='

'._x('Appendix', 'meta box title', 'anno').' '.esc_html($index_alpha).' - '._x('delete', 'Meta box delete repeater link', 'anno').'

'.$editor_markup.'
'; return $html; } /** * Create an alpha representation of the appendix number. * * @param int $index Integer index to be converted to an equivalent base 26 (alphabet) sequence * @return string String of capital letters representing the index integer */ function anno_index_alpha($index) { for($return = ''; $index >= 0; $index = intval($index / 26) - 1) $return = chr(intval($index % 26) + 65) . $return; return $return; }