= 5.3)
Author: VK (@chredd, @znoid, @victor_jonsson, @lefalque)
Version: 2.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;
}