= 5.3)
Author: VK (@chredd, @znoid, @victor_jonsson, @lefalque)
Version: 2.3
License: GPL2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
define('ARLIMA_PLUGIN_PATH', dirname(__FILE__));
define('ARLIMA_PLUGIN_URL', plugin_dir_url(__FILE__));
// Load arlima plugin class
require_once __DIR__.'/classes/Plugin.php';
// Register class loader for this plugin
spl_autoload_register('Arlima_Plugin::classLoader');
$arlima_plugin = new Arlima_Plugin();
if( is_admin() ) {
// Register install/uninstall procedures
register_activation_hook(__FILE__, 'Arlima_Plugin::install');
register_uninstall_hook(__FILE__, 'Arlima_Plugin::uninstall');
register_deactivation_hook(__FILE__, 'Arlima_Plugin::deactivate');
// Add actions and filters used in wp-admin
$arlima_plugin->initAdminActions();
$ajax_manager = new Arlima_AdminAjaxManager($arlima_plugin);
$ajax_manager->initActions();
}
else {
// Add actions and filters used in the theme
$arlima_plugin->initThemeActions();
}
/* * * * * * * * * * * ARLIMA PUBLIC API * * * * * * * * * * * * * * * * *
Plugin setup finished. The functions declared from here on is
meant to be used in the theme when writing template files
that uses Arlima.
*/
/**
* 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 '';
}
/**
* Replaces the entry-word span (tinymce plugin) with a link
* @param string $content
* @param string $url
* @return string
*/
function arlima_link_entrywords( $content, $url ) {
$pattern = '/((.*)(<\/span>)/isxmU';
return preg_replace($pattern, '$3' , $content);
}
/**
* Function that displays a link to wp-admin where
* given arlima list can be edited
* @param Arlima_List $list
* @param string $message
* @return void
*/
function arlima_edit_link($list, $message=null) {
if( !$list->preview && is_user_logged_in() && current_user_can('edit_posts') ) {
if($message === null) {
Arlima_Plugin::loadTextDomain();
$message = __('Edit article list', 'arlima').' "'.$list->title.'"';
}
?>
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 = get_comment_count($post_id);
$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 should use the latest preview
* versions of all arlima lists on page
* @return bool
*/
function arlima_is_requesting_preview() {
return isset( $_GET[Arlima_List::QUERY_ARG_PREVIEW] ) && !is_admin() && is_user_logged_in();
}
/**
* @see arlima_is_requesting_preview()
* @param string $url
* @param bool $entity_encode[optional=false]
* @return string
*/
function arlima_preview_url($url, $entity_encode = false) {
$new_url = $url . (strpos($url, '?') === false ? '?':'&') . Arlima_List::QUERY_ARG_PREVIEW . '=1';
return $entity_encode ? htmlentities($new_url) : $new_url;
}
/**
* 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_ListFactory::addFormat($format_class, $label, $templates);
}
/**
* Remove a registered format
* @param string $format_class
* @param array $templates
*/
function arlima_deregister_format($format_class, $templates=array()) {
Arlima_ListFactory::removeFormat($format_class, $templates);
}