plugin_url() . 'css/styles.css'); wp_enqueue_style('scnStyles'); } } function avia_preview_nonce() { if(!current_user_can('edit_files')) return; $nonce = wp_create_nonce ('avia_shortcode_preview'); echo "\n \n \n "; } function filter_mce_buttons( $buttons ) { array_push( $buttons, '|', 'scn_button'); return $buttons; } function filter_mce_external_plugins( $plugins ) { //if we are using tinymce 4 or higher change the javascript file global $tinymce_version; if(version_compare($tinymce_version[0], 4, ">=")) { $plugins['ShortcodeNinjaPlugin'] = $this->plugin_url() . 'tinymce/editor_plugin.js'; } else { $plugins['ShortcodeNinjaPlugin'] = $this->plugin_url() . 'tinymce/editor_plugin_3.js'; } return $plugins; } /** * Returns the full URL of this plugin including trailing slash. */ function plugin_url() { return AVIA_PHP_URL.'avia_shortcodes/'; } // AJAX ACTION /////////////// /** * Checks if a given url (via GET or POST) exists. * Returns JSON * * NOTE: for users that are not logged in this is not called. * The client receives -1 in that case. */ function ajax_action_check_url() { $hadError = true; $url = isset( $_REQUEST['url'] ) ? $_REQUEST['url'] : ''; if ( strlen( $url ) > 0 && function_exists( 'get_headers' ) ) { $file_headers = @get_headers( $url ); $exists = $file_headers && $file_headers[0] != 'HTTP/1.1 404 Not Found'; $hadError = false; } echo '{ "exists": '. ($exists ? '1' : '0') . ($hadError ? ', "error" : 1 ' : '') . ' }'; die(); } function extra_shortcodes() { $theme_support = get_theme_support( 'avia-shortcodes' ); if(is_array($theme_support) && !empty($theme_support[0])) { $supports = ""; foreach($theme_support[0] as $main_key => $supportitem) { $supports .= $main_key.":"; if(is_array($supportitem)) { $supports .= "{"; foreach($supportitem as $key => $subitem) { $supports .= $key.": '".$subitem."', "; } $supports = rtrim($supports,', '); $supports .= "}, "; } else { $supports .= "'"; $supports .= $supportitem; $supports .= "', "; } } $supports = rtrim($supports, ', '); echo "\n \n \n "; } } function extra_styles() { global $avia_config; if(isset($avia_config['backend_style'])) { //$string = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $avia_config['backend_style']); $string = preg_replace('/\r|\n|\t/', ' ', $avia_config['backend_style']); echo "\n \n \n "; } } } new avia_shortcodes(); ?>