addTemplateCSS(); } /** * If we get a lot of calls to this function we might as well always make a call * to load_plugin_textdomain on init, and not only in wp-admin * * @see Arlima_Plugin::loadTextDomain() * @static * @return bool */ public static function loadTextDomain() { if( !self::$has_loaded_textdomain ) { self::$has_loaded_textdomain = true; load_plugin_textdomain('arlima', false, 'arlima/lang/'); } } /** * Init hook taking place in both wp-admin and theme */ function commonInitHook() { add_action('wp_before_admin_bar_render', function() { /* @var WP_Admin_Bar $wp_admin_bar */ global $wp_admin_bar; if( is_admin_bar_showing() ) { Arlima_Plugin::loadTextDomain(); $wp_admin_bar->add_menu( array( 'id' => 'arlima', 'parent' => '', 'title' => __( 'Article lists', 'arlima'), 'href' => admin_url( 'admin.php?page=arlima' ) ) ); foreach(Arlima_ListFactory::loadListSlugs() as $list_data) { $wp_admin_bar->add_menu( array( 'id' => 'arlima-'.$list_data->id, 'parent' => 'arlima', 'title' => $list_data->title, 'href' => admin_url( 'admin.php?page=arlima&open_list='.$list_data->id ) ) ); } } }); $this->addExportFeeds(); self::$is_scissors_installed = function_exists('scissors_create_image'); self::$is_wp_related_post_installed = function_exists('MRP_get_related_posts'); // update publish date for arlima articles add_action('save_post', function($post_id) { if( !defined('DOING_AUTOSAVE') || !DOING_AUTOSAVE ) { Arlima_ListFactory::updateArlimaArticleData(get_post($post_id)); } }); } /** * Function called on init in wp-admin */ function adminInitHook() { self::update(); self::loadTextDomain(); } /** * Adds arlima export feed to Wordpress */ function addExportFeeds() { add_feed(self::EXPORT_FEED_NAME, array($this, 'loadExportFeed')); } /** * Install procedure for this plugin * - Adds database tables * - Adds version number in db * - Adds arlima export feed and flushed wp_rewrite * @static */ public static function install() { Arlima_ListFactory::install(); global $wp_rewrite; $plugin = new self(); $plugin->addExportFeeds(); $wp_rewrite->flush_rules(); $plugin = new self(); $settings = $plugin->loadSettings(); $settings['install_version'] = self::VERSION; $plugin->saveSettings($settings); } /** * Uninstall procedure for this plugin * - Removes plugin settings * - Removes database tables * @static */ public static function uninstall() { Arlima_ListFactory::uninstall(); delete_option('arlima_plugin_settings'); } /** * Deactivation procedure for this plugin * - Removes feed from wp_rewrite * @static */ public static function deactivate() { global $wp_rewrite; $feed_index = array_search('arlima', $wp_rewrite->feeds); if($feed_index) { array_splice($wp_rewrite->feeds, $feed_index, 1); $wp_rewrite->flush_rules(); } } /** * Update procedure for this plugin. Since wordpress is lacking this feature we * should call this function on a regular basis. */ public static function update() { $plugin = new self(); $settings = $plugin->loadSettings(); $current_version = isset($settings['install_version']) ? $settings['install_version'] : 0; // Time for update if($current_version != self::VERSION) { // Update to v 2.0 if($current_version < 2) { global $wp_rewrite; $plugin->addExportFeeds(); $wp_rewrite->flush_rules(); } // Update to version 2.2 if($current_version < self::VERSION) { Arlima_ListFactory::databaseUpdates($current_version); } $settings['install_version'] = self::VERSION; $plugin->saveSettings($settings); } } /** * Will try to export arlima list from currently visited page */ function loadExportFeed() { global $wp_query; $format = isset($_REQUEST['format']) ? $_REQUEST['format']:Arlima_ExportManager::DEFAULT_FORMAT; $page_slug = !empty($wp_query->query_vars['pagename']) ? $wp_query->query_vars['pagename'] : ''; $export_manager = new Arlima_ExportManager($this); $export_manager->export($page_slug, $format); die; } /** * Settings of any kind related to this plugin * @return array */ function loadSettings() { return get_option('arlima_plugin_settings', array()); } /** * @param array $setting */ function saveSettings(array $setting) { update_option('arlima_plugin_settings', $setting); } /** * Adds meta box to post edit/create page */ function addMetaBox() { add_meta_box( 'arlima-meta-box', 'Arlima', array($this, 'postMetaBox'), 'post', 'side', 'low' ); } /** * Content of meta box used to send a wordpress post immediately from post * edit page in wp-admin to an arlima list */ function postMetaBox() { global $post; wp_nonce_field( plugin_basename( __FILE__ ), 'vkuc_nonce' ); if ( $post->post_status == 'publish' ) { ?> '.__('Post needs to be published', 'arlima').''; } } /** * This function will output a warning message if the server has * a PHP version lower than 5.3 */ function warnAboutIncompatiblePHPVersion() { $version_parts = explode('.', phpversion()); $version = floatval($version_parts[0] .'.'. $version_parts[1]); if( $version < 5.3 ): ?>

WARNING

You need to deactivate the plugin "Arlima".
The reason for this is that your server does
not have a PHP installation of version 5.3 or higher.

addAdminPageScriptsAndStylesheets($arlima_mainpage, $arlima_editpage, $arlima_webservicepage); if( function_exists('poll_footer_admin' ) ) { add_action('admin_footer', 'poll_footer_admin'); } } /** * @param string $main_page_slug * @param string $edit_page_slug * @param string $service_page_slug */ function addAdminPageScriptsAndStylesheets($main_page_slug, $edit_page_slug, $service_page_slug) { add_action('admin_print_scripts-'.$main_page_slug, array($this, 'addAdminMainPageScripts')); add_action('admin_print_styles-'.$main_page_slug, array($this, 'addAdminStyleSheets')); add_action('admin_print_styles-'.$main_page_slug, array($this, 'addTemplateCSS')); add_action('admin_print_scripts-'.$main_page_slug, array($this, 'addTinyMCEFilters')); add_action('admin_footer-'.$main_page_slug, array($this, 'addTemplateLoadingJS')); add_action('admin_print_scripts-'.$edit_page_slug, array($this, 'addAdminEditPageScripts')); add_action('admin_print_styles-'.$edit_page_slug, array($this, 'addAdminStyleSheets')); add_action('admin_print_styles-'.$service_page_slug, array($this, 'addAdminStyleSheets')); add_action('admin_print_scripts-'.$service_page_slug, array($this, 'addAdminServicePageScripts')); // Javascript used in meta-box on wp-admin page where blog posts is created $php_file = basename($_SERVER['PHP_SELF']); if($php_file == 'post-new.php' || $php_file = 'post.php') { wp_enqueue_script('arlima_js_admin', ARLIMA_PLUGIN_URL.'/js/admin-post.js', array('jquery' ), self::STATIC_VERSION ); wp_localize_script('arlima_js_admin', 'ArlimaJSAdmin', array( 'ajaxurl' => admin_url('admin-ajax.php' ), 'arlimaNonce' => wp_create_nonce('arlima-nonce' ), 'imageurl' => ARLIMA_PLUGIN_URL . '/images/', 'lang' => array( 'notice' => __('Are you sure you want to insert this post in the top of selected article list?', 'arlima'), 'wasSentTo' => __('The post is inserted in article list', 'arlima') ) ) ); } } /** * Add javascripts used on list edit page in wp-admin */ function addAdminEditPageScripts() { wp_enqueue_script( 'arlima_js', ARLIMA_PLUGIN_URL . 'js/page-edit.js', array( 'jquery' ), self::STATIC_VERSION ); wp_enqueue_script( 'arlima_js_jquery', ARLIMA_PLUGIN_URL . 'js/arlima/arlima-jquery-plugins.js', array( 'jquery' ), self::STATIC_VERSION ); } /** * Add javascripts used on list edit page in wp-admin */ function addAdminServicePageScripts() { wp_enqueue_script( 'arlima_js', ARLIMA_PLUGIN_URL . 'js/page-service.js', array( 'jquery' ), self::STATIC_VERSION ); } /** * Adds all javascript files needed in the list editor in wp-admin */ function addAdminMainPageScripts() { // Enqueue scissors scripts if installed if( Arlima_Plugin::isScissorsInstalled() ) { $scissors_url = WP_PLUGIN_URL . '/scissors-continued'; wp_enqueue_script('scissors_crop', $scissors_url.'/js/jquery.Jcrop.js', array('jquery') ); wp_enqueue_script('scissors_js', $scissors_url.'/js/scissors.js' ); $scissors_js_obj = array('ajaxUrl' => admin_url('admin-ajax.php')); foreach( array('large', 'medium', 'thumbnail') as $size ) { $width = intval(get_option("{$size}_size_w")); $height = intval(get_option("{$size}_size_h")); $ratio = max(1, $width) / max(1, $height); if(!get_option("{$size}_crop")) $ratio = 0; $scissors_js_obj[$size.'AspectRatio'] = $ratio; } echo ''; } // Add our template css to tinyMCE if ( ! function_exists('tdav_css') ) { function tdav_css($wp) { $wp .= ',' . Arlima_Plugin::getTemplateCSS(); return $wp; } } add_filter( 'mce_css', 'tdav_css' ); wp_enqueue_script( 'jquery' ); wp_register_script( 'jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js', array( 'jquery' ) ); wp_enqueue_script( 'jquery-ui' ); wp_enqueue_script( 'media-upload' ); wp_enqueue_script( 'thickbox' ); wp_enqueue_script( 'qtip', ARLIMA_PLUGIN_URL . 'js/jquery/qtip/jquery.qtip.min.js', array( 'jquery' ) ); wp_enqueue_script( 'colourpicker', ARLIMA_PLUGIN_URL . 'js/jquery/colourpicker/jquery.colourpicker.js', array( 'jquery' ) ); wp_register_script( 'fancybox', ARLIMA_PLUGIN_URL . 'js/jquery/fancybox/jquery.fancybox-1.3.4.pack.js', 'jquery', null, true); wp_enqueue_script( 'fancybox' ); wp_enqueue_script( 'jquery-ui-nestedsortable', ARLIMA_PLUGIN_URL . 'js/jquery/jquery.ui.nestedSortable.js', array( 'jquery' ), '1.2' ); wp_enqueue_script( 'pluploadfull', ARLIMA_PLUGIN_URL . 'js/misc/plupload.full.js', array( 'jquery' )); wp_enqueue_script( 'jquery-tmpl', ARLIMA_PLUGIN_URL . 'js/jquery/jquery.tmpl.min.js', array( 'jquery' ) ); wp_enqueue_script( 'arlima-jquery-plugins', ARLIMA_PLUGIN_URL . 'js/arlima/arlima-jquery-plugins.js', array( 'jquery' ),self::STATIC_VERSION ); wp_enqueue_script( 'arlima-template-loader', ARLIMA_PLUGIN_URL . 'js/arlima/template-loader.js', array( 'jquery' ), self::STATIC_VERSION ); wp_enqueue_script( 'arlima-js', ARLIMA_PLUGIN_URL . 'js/arlima/arlima.js', array( 'jquery' ), self::STATIC_VERSION ); wp_enqueue_script( 'arlima-plupload-init', ARLIMA_PLUGIN_URL . 'js/arlima/plupload-init.js', array( 'jquery' ), self::STATIC_VERSION ); wp_enqueue_script( 'arlima-main-js', ARLIMA_PLUGIN_URL . 'js/page-main.js', array( 'jquery' ), self::STATIC_VERSION ); // Use the newest version of hotkeys (wordpress uses old beta) wp_deregister_script('jquery-hotkeys'); wp_register_script('jquery-hotkeys-new-version', ARLIMA_PLUGIN_URL . 'js/jquery/jquery.hotkeys.js', array(), self::STATIC_VERSION ); wp_enqueue_script('jquery-hotkeys-new-version'); wp_localize_script( 'arlima-js', 'ArlimaJS', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'arlimaNonce' => wp_create_nonce( 'arlima-nonce' ), 'imageurl' => ARLIMA_PLUGIN_URL . '/images/', 'baseurl' => get_bloginfo('url'), 'is_admin' => current_user_can('manage_options') ? 1:0, 'preview_query_arg' => Arlima_List::QUERY_ARG_PREVIEW, 'lang' => array( // todo: but these args in a separate .js.php file when this array gets to long 'unsaved' => __('You have one, or more, unsaved article lists', 'arlima'), 'laterVersion' => __('It exists an older version of this article list', 'arlima'), 'overWrite' => __('Do you still want to save this version of the list?', 'arlima'), 'severalExtras' => __('This article list has more than one extra-streamer', 'arlima'), 'changesBeforeRemove' => __('You have made changes to this list, do you want to remove it anyway?', 'arlima'), 'wantToRemove' => __('Do you want to remove "', 'arlima'), 'fromList' => __('" from this article list?', 'arlima'), 'chooseImage' => __('Choose image', 'arlima'), 'admin_lock' => __('This article is locked by admin', 'arlima'), 'admin_only' => __('Only administrators can manage article locks', 'arlima'), 'noList' => __('No list is active!', 'arlima'), 'noImages' => __('This article has no related image', 'arlima'), 'noConnection' => __('this article is not connected to any post', 'arlima'), 'listRemoved' => __('This list have been removed!', 'arlima'), 'savePreview' => __('to save article list', 'arlima'), 'isSaved' => __('This list has no unsaved changes', 'arlima'), 'missingPreviewPage' => __('This list is missing a preview page', 'arlima'), 'hasUnsavedChanges' => __('This list has unsaved changes', 'arlima'), 'dragAndDrop' => __('Drag images to this container', 'arlima'), 'sticky' => __('Sticky', 'arlima'), 'loggedOut' => __('Your login session seems to have expired, pls reload the page!', 'arlima') ) ) ); } /** * Will enqueue the css for the presentation of articles in an arlima list */ function addTemplateCSS() { wp_enqueue_style('arlima_template_css', self::getTemplateCSS(), array(), '1.0'); } /** * Get the path to the CSS file that controls the presentation of article in * an arlima list * @static * @return string */ public static function getTemplateCSS() { return apply_filters('arlima_template_css', ARLIMA_PLUGIN_URL . 'css/template.css'); } /** * Will output javascript that loads all jQuery templates from backend */ function addTemplateLoadingJS() { $tmpl_resolver = new Arlima_TemplatePathResolver(); $templates = array(); foreach($tmpl_resolver->getTemplateFiles() as $directory => $tmpl_files) { foreach($tmpl_files as $file) { $templates[] = $tmpl_resolver->fileToUrl($file); } } ?>

#'.$hex.''; } } // default colors else { $cs = array( '00', '33', '66', '99', 'CC', 'FF' ); for( $i=0; $i<6; $i++ ) { for( $j=0; $j<6; $j++ ) { for( $k=0; $k<6; $k++ ) { $c = $cs[ $i ] .$cs[ $j ] .$cs[ $k ]; echo '\n'; } } } } } /** * If current theme is missing an arlima page template this function will * output a div with information about the issue * @static */ public static function warnAboutMissingTemplate() { $arlima_template_path = get_stylesheet_directory().'/page-arlima.php'; if( !file_exists($arlima_template_path) ): ?>

Theme file "page-arlima.php" is missing. Please copy file to and reload this page.

If you just installed this plugin for the first time you also need to do the following:

  1. Go to "Pages" -> "All pages" in wp-admin and open the page named "Home"
  2. Change page template to "Article List Page"
  3. Add a custom field with name "arlima" and value "frontpage"