(.*)(<\/span>)/isxmU';
return preg_replace($pattern, '$3' , $content);
}
/**
* @param string $type - Deprecated
* @param bool|int $post_id - Optional
* @return array|bool
*/
function arlima_related_posts( $type = 'deprecated', $post_id = false) {
global $post;
$data = false;
if( Arlima_Plugin::isWPRelatedPostsInstalled() && ($post_id || is_object($post)) ) {
if(!$post_id)
$post_id = $post->ID;
$related_posts = MRP_get_related_posts($post_id, true);
if( !empty($related_posts) ) {
$data = array('single' => count($related_posts) == 1, 'posts'=>array());
foreach ( $related_posts as $related ) {
$related->url = get_permalink ( $related->ID );
$related->html_comment_stats = 0;
$stats = wp_count_comments($post_id);
if( is_object($stats) && property_exists($stats, 'approved') )
$related->html_comment_stats = $stats->approved;
$data['posts'][] = $related;
}
}
}
return $data;
}
/**
* Wrapper function for Arlima_PostSearchModifier::modifySearch. May be used by the theme to modify the post
* search in the article editor
* @param Closure $form_callback
* @param Closure $query_callback
* @param $deprecated
*/
function arlima_modify_post_search($form_callback, $query_callback, $deprecated=false) {
Arlima_PostSearchModifier::modifySearch($form_callback, $query_callback);
if( $deprecated !== false ) {
Arlima_Plugin::warnAboutUseOfDeprecatedFunction('arlima_modify_post_search', 2.22, 'Function arguments have changed');
}
}
/**
* Tells whether or not current request is requesting an arlima preview
* @return bool
*/
function is_arlima_preview() {
static $is_arlima_preview = null;
if( $is_arlima_preview === null ) {
$is_arlima_preview = isset( $_GET[Arlima_List::QUERY_ARG_PREVIEW] ) &&
// has_arlima_list() &&
// get_arlima_list()->id() == $_GET[Arlima_List::QUERY_ARG_PREVIEW] &&
is_user_logged_in();
}
return $is_arlima_preview;
}
/**
* This function makes it possible to add formats (class names) that will be possible
* to put on arlima articles in. The format class will be added to the div containing the
* article using the template variable ${container.class}
*
* @example
* arlima_register_format('my-custom-format', 'Cool looking article', array('giant', 'my-other-template'));
* arlima_register_format('my-boring-format', 'Serious looking article');
*
* @param string $format_class - The class that will be added to the article container
* @param string $label - The name of this format, displayed in wp-admin
* @param array $templates[optional=array()] - This argument tells arlima that this format
* should only be available for certain templates. The array should contain only the names of
* the templates where the format should be available, without path and extension. Omit this
* argument if you want your format to be available on all templates
*/
function arlima_register_format($format_class, $label, $templates=array()) {
Arlima_ArticleFormat::add($format_class, $label, $templates);
}
/**
* Remove a registered format
* @param string $format_class
* @param array $templates
*/
function arlima_deregister_format($format_class, $templates=array()) {
Arlima_ArticleFormat::remove($format_class, $templates);
}
/**
* Function that displays a link to wp-admin where
* given arlima list can be edited
* @param Arlima_List|bool $list
* @param string|bool $message
* @return void
*/
function arlima_edit_link($list=false, $message=false) {
if( !($list instanceof Arlima_List) ) {
$list = get_arlima_list();
if( false === $list ) {
trigger_error('Trying to get edit link for list that does not exist', E_USER_WARNING);
return;
}
}
if( is_user_logged_in() && current_user_can('edit_posts') ) {
if( !$message ) {
Arlima_Plugin::loadTextDomain();
$message = __('Edit article list', 'arlima').' "'.$list->getTitle().'"';
}
?>
getRelationData($post->ID);
if( $relation !== false ) {
$list_factory = new Arlima_ListFactory();
$relation = $connector->getRelationData($post->ID);
$is_requesting_preview = is_arlima_preview() && $_GET[Arlima_List::QUERY_ARG_PREVIEW] == $relation['id'];
$version = $is_requesting_preview ? 'preview' : '';
$list = $list_factory->loadList($relation['id'], $version, $is_requesting_preview);
if( $list->exists() ) {
$current_arlima_list = $list;
}
}
}
}
return $current_arlima_list;
}
/**
* Render an article list
* @see https://github.com/victorjonsson/Arlima/wiki/Programmatically-insert-lists
* @param Arlima_List|Arlima_AbstractListRenderingManager|int|string $list
* @param array $args
* @return string|void
*/
function arlima_render_list($list, $args=array()) {
$args = array_merge(array(
'width' => 560,
'offset' => 0,
'limit' => 0,
'echo' => true,
'filter_suffix' => ''
), $args);
$factory = new Arlima_ListFactory();
if( is_numeric($list) ) {
$renderer = new Arlima_ListTemplateRenderer( $factory->loadList($list) );
}
elseif( is_string($list) ) {
$renderer = new Arlima_ListTemplateRenderer( $factory->loadListBySlug($list) );
}
elseif( $list instanceof Arlima_AbstractListRenderingManager ) {
$renderer = $list;
}
else {
$renderer = new Arlima_ListTemplateRenderer($list);
}
if( !$renderer->getList()->exists() ) {
$msg = ''.__('This list does not exist', 'arlima').'
';
if( $args['echo'] )
echo $msg;
else
return $msg;
}
else {
$renderer->setOffset( $args['offset'] );
$renderer->setLimit( $args['limit'] );
if( $renderer->havePosts() ) {
// Add wordpress filters
if( !empty($args['filter_suffix']) )
Arlima_FilterApplier::setFilterSuffix($args['filter_suffix']);
Arlima_FilterApplier::setArticleWidth($args['width']);
Arlima_FilterApplier::applyFilters($renderer);
$content = $renderer->renderList($args['echo']);
Arlima_FilterApplier::setFilterSuffix('');
return $content;
}
}
return '';
}
/* * * * * * * * * * * * DEPRECATED FUNCTIONS * * * * * * * * * * * * * */
/**
* Returns a readable string of the version data
* @deprecated
* @see Arlima_List::getVersionInfo
* @param array $version
* @return string
*/
function arlima_get_version_info( $version ) {
Arlima_Plugin::warnAboutUseOfDeprecatedFunction('arlima_get_version_info()', 2.0, 'Arlima_List::getVersionInfo()');
if( isset($version[ 'id' ]))
return $version[ 'id' ];
else
return '';
}
/**
* Tells whether or not a preview of the list with given slug is requested
* @deprecated
* @param $list_id
* @return bool
*/
function arlima_requesting_preview($list_id) {
Arlima_Plugin::warnAboutUseOfDeprecatedFunction('arlima_requesting_preview()', 2.5, 'Function is removed');
return is_arlima_preview() && $_GET[Arlima_List::QUERY_ARG_PREVIEW] == $list_id;
}
/**
* @deprecated
*/
function arlima_is_requesting_preview() {
return !empty($_GET[Arlima_List::QUERY_ARG_PREVIEW]) && is_user_logged_in();
}
/**
* @deprecated
* @return string
*/
function arlima_preview_url() {
Arlima_Plugin::warnAboutUseOfDeprecatedFunction('arlima_preview_url()', 2.4, 'Function is removed');
}