February 4, 201313 yr [hide]Thanks for the help in my previous thread. I am at the point now where I have a working script here http://www.fromefm.c...=homelyremedies which does what I need it to do. Now I somehow need to create wordpress so I can embed some shortcode syntax such as [fromefmplayer=homelyremedies] and it will output it into the blog or page I've added it to. This is a plugin designed to work on only one site so it doesn't matter if I have to hardcode urls into it (with the exception of the show name) but I want it as a plugin so i can change themes and update wordpress without having to remember the changes I made each time. The plugin will need to add a few extra css and js files to the header and then run the php code within the blog/page. I'm not asking someone to do it for me but some pointers on how to convert what is essentially a working js/html5/css script into a wordpress plugin.[/hide]Scroll down to see latest question. Tahttp://forum.tip.it/...n/#entry5364325 Mercifull <3 Suzi "We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12
February 5, 201313 yr Add js files: function add_js() { wp_register_script( 'scriptname', plugins_url( '/javascript.css', __FILE__ ) ); wp_enqueue_script( 'scriptname' ); } add_action('wp_enqueue_scripts', 'add_js'); Read more about the wp_register_script parameters here: http://codex.wordpress.org/Function_Reference/wp_register_script Add CSS: function add_styles() { wp_register_style( 'stylesheet', plugins_url( '/stylesheet.css', __FILE__ ) ); wp_enqueue_style( 'stylesheet' ); } add_action('wp_enqueue_scripts', 'add_styles'); Making a shortcode such as: [fromfmplayer title=homelyremedies] function your_function($atts) { //extracting the parameters and setting a default in case one isn't set by the user extract(shortcode_atts(array( 'title' => 'homelyremedies', ), $atts)); //now you have the variable $title to play with //normal function code here } function register_shortcodes() { add_shortcode('fromfmplayer', 'your_function'); } add_action('init', 'register_shortcodes'); Edited February 5, 201313 yr by tripsis - 99 fletching | 99 thieving | 99 construction | 99 herblore | 99 smithing | 99 woodcutting - - 99 runecrafting - 99 prayer - 125 combat - 95 farming - - Blog - DeviantART - Book Reviews & Blog
February 5, 201313 yr Author Thanks tripsis, I've done Wordpress plugins before but they have been very basic and I only made them to avoid editing functions.php directly. I'll have another got at this tomorrow, I've already spent about 5 hours on the player so far lol. Mercifull <3 Suzi "We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12
February 5, 201313 yr If you have php 5.3 you could do the following: add_action('wp_enqueue_scripts', function() { wp_register_script( 'scriptname', plugins_url( '/javascript.css', __FILE__ ) ); wp_enqueue_script( 'scriptname' ); }); "The more persistence a game tries to have; the longer it is set up to last; the greater number (and broader variety) of people it tries to attract; and in general the more immersive a game/world it set out to be--then the more breadth and depth of human experience it needs to support to be successful for more than say, 12-24 months. If you try to create a deeply immersive, broadly appealing, long-lasting world that does not adequately provide for human tendencies such as violence, acquisition, justice, family, community, exploration, etc (and I would contend we are nowhere close to doing this), you will see two results: first, individuals in the population will begin to display a wide range of fairly predictable socially pathological behaviors (including general malaise, complaining, excessive bullying and/or PKing, harassment, territoriality, inappropriate aggression, and open rebellion against those who run the game); and second, people will eventually vote with their feet--but only after having passionately cast 'a pox on both your houses.' In essence, if you set people up for an experience they deeply crave (and mostly cannot find in real life) and then don't deliver, they will become like spurned lovers--somebecome sullen and aggressive or neurotic, and eventually almost all leave."Mike Sellers' Hypothesis
February 5, 201313 yr Author I've successfully got my plugin including all the relevant js and css files it needs and also got it reading the shortcode in the following format:[ffmplayer show=homelyremedies showno=5] which currently just outputs some text using those variables. See: http://frome.me/ffm/?page_id=48 <?php /* Plugin Name: FromeFM Player Plugin Version: 0.1 */ // Ads JS files relating to plugin function add_js() { wp_register_script( 'fromefmplayer', plugins_url( '/includes/fromefmplayer.js', __FILE__ ) ); wp_enqueue_script( 'fromefmplayer' ); wp_register_script( 'audiojs', plugins_url( '/audiojs/audiojs.min.js', __FILE__ ) ); wp_enqueue_script( 'audiojs' ); } add_action('wp_enqueue_scripts', 'add_js'); //Add CSS files relating to plugin function add_styles() { wp_register_style( 'fromefmplayer', plugins_url( '/includes/fromefmplayer.css', __FILE__ ) ); wp_enqueue_style( 'fromefmplayer' ); } add_action('wp_enqueue_scripts', 'add_styles'); //Add shortcodes into wordpress function ffmplayer_func($atts) { //extracting the parameters and set defaults in case one isn't set by the user extract(shortcode_atts(array( 'show' => 'altfactor', 'showno' => '1000', ), $atts)); //now you have the variables $showname and $shownumbers to play with //normal function code here return "You entered as the showname {$show} and put {$showno} as the number. "; //normal function code ends } function register_shortcodes() { add_shortcode('ffmplayer', 'ffmplayer_func'); } add_action('init', 'register_shortcodes'); ?> I've got a separate php file called hello.php which contains only some text saying "working" and I'm struggling to find a way of including it. I tried the following above where it says "normal function code ends" but nothing happens. Also tried echo and return, still nothing. include (plugins_url( './hello.php' , __FILE__ )); Mercifull <3 Suzi "We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12
February 6, 201313 yr Try just: include('hello.php'); - 99 fletching | 99 thieving | 99 construction | 99 herblore | 99 smithing | 99 woodcutting - - 99 runecrafting - 99 prayer - 125 combat - 95 farming - - Blog - DeviantART - Book Reviews & Blog
February 6, 201313 yr Author Try just: include('hello.php');Tried that. Again nothing happens. No errors but nothing showing in source code. Edit: Took out the 'return' statement before it and it now works. Thanks Mercifull <3 Suzi "We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12
February 6, 201313 yr Author [hide]New question. My plugin is successfull including the javascript and css files for the player in the header of wordpress. My plugin is also successfully bringing accross my player.php script and generates the correct html as can be seeing by viewing the source of this page <audio src="http://www.fromefm.co.uk/archive/sponsors/fromefm-ident.mp3" preload="auto"></audio> However the audio.min.js doesn't convert that into the player as it should do. Any ideas?[/hide]Edit: Ignore. Forgot to add the following: <script> audiojs.events.ready(function() { var as = audiojs.createAll(); }); </script> Mercifull <3 Suzi "We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12
February 8, 201313 yr Author Right I've not managed to get the player working on a specific url but struggling with the rss reader part. I am using the built in Magpie RSS in Wordpress and have the following code include_once(ABSPATH . WPINC . '/rss.php'); $feedurl = 'http://services.runescape.com/m=news/latest_news.rss'; $feed = fetch_rss($feedurl); $items = array_slice ($feed->items, 0, 5); foreach ($items as $item ) { $title = $item[title]; $mp3link = $item[link]; $description = $item[description]; return "<li>$title - $description</li>"; } It only returns the latest one instead of the number I specified, 5. Any ideas? Mercifull <3 Suzi "We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12
February 8, 201313 yr Author Echo kinda works, but then it displays at the top of the post. I'm told you need to use the return function. But that only shows 1. I'm a bit stuck. Mercifull <3 Suzi "We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12
February 8, 201313 yr include_once(ABSPATH . WPINC . '/rss.php'); $feedurl = 'http://services.runescape.com/m=news/latest_news.rss'; $feed = fetch_rss($feedurl); $items = array_slice ($feed->items, 0, 5); $list = ""; foreach ($items as $item ) { $title = $item[title]; $mp3link = $item[link]; $description = $item[description]; $list .= "<li>$title - $description</li>"; } return $list; Does that work?
February 8, 201313 yr Author edit: actually it does. my apologies. } in the wrong place Mercifull <3 Suzi "We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12
February 8, 201313 yr Author Last question for tonight as its late. How do I put some specific html before and after it. So it does this Blah blah blah[every entry in the rss]blah blah Mercifull <3 Suzi "We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12
February 8, 201313 yr include_once(ABSPATH . WPINC . '/rss.php'); $feedurl = 'http://services.runescape.com/m=news/latest_news.rss'; $feed = fetch_rss($feedurl); $items = array_slice ($feed->items, 0, 5); $list = ""; foreach ($items as $item ) { $title = $item[title]; $mp3link = $item[link]; $description = $item[description]; $list .= "<a href=\"{$mp3link}\"><li>{$title} - {$description}</li></a>"; } return $list; Like that. Can you show me what it looks like with echo and with return?
February 8, 201313 yr Author Sorry im confused is that an answer to my last post or the one where I said it didnt work (as I typod a } symbol)? Mercifull <3 Suzi "We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12
February 8, 201313 yr Author I basically need this code: <audio preload></audio> <ol> <li><a href='#' data-src='$mp3link'>$title - $description</a></li> <li><a href='#' data-src='$mp3link'>$title - $description</a></li> <li><a href='#' data-src='$mp3link'>$title - $description</a></li> </ol> Mercifull <3 Suzi "We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12
February 8, 201313 yr That was a response to the 2nd post. The last sentence of my post is for your first post.
February 8, 201313 yr Author It's working but I'm struggling with some js issues now. Thanks for your help. Probably going to call it a night for tonight though. Current full code below. See it in action here - http://frome.me/ffm/?page_id=48 <?php /* Plugin Name: FromeFM Player Plugin Description: Enables shortcodes to generate audiojs players based on variables such as showname and number to pull from feed. Plugin relies on a special version of DirCaster placed in the /archive/ folder in order to work properly. Ensure jquery is also enabled in Wordpress (should be by default). Version: 0.1 License: GPL Author: Matt Sims Author URI: www.mattsims.com Contributors: Tripsis, JoWie, Hedgehog (forum.tip.it/topic/317233-need-help-again-wordpress-plugin-assistance-scroll-down) */ // Ads JS files relating to plugin function add_audiojs() { wp_register_script( 'audiojs', plugins_url( '/audiojs/audio.min.js', __FILE__ ) ); wp_enqueue_script( 'audiojs' ); } add_action('wp_enqueue_scripts', 'add_audiojs'); function add_ffmjs() { wp_register_script( 'fromefmplayer', plugins_url( '/includes/fromefmplayer.js', __FILE__ ) ); wp_enqueue_script( 'fromefmplayer' ); } add_action('wp_enqueue_scripts', 'add_ffmjs'); //Add CSS files relating to plugin function add_styles() { wp_register_style( 'fromefmplayer', plugins_url( '/includes/fromefmplayer.css', __FILE__ ) ); wp_enqueue_style( 'fromefmplayer' ); } add_action('wp_enqueue_scripts', 'add_styles'); //Add shortcodes into wordpress function ffmplayer_func($atts) { //extracting the parameters and set defaults in case one isn't set by the user extract(shortcode_atts(array( 'show' => 'altfactor', 'showno' => '1000', ), $atts)); //now you have the variables $showname and $showno to play with //normal function code here include_once(ABSPATH . WPINC . '/rss.php'); $num_items = $showno; $feedurl = 'http://fromefm.co.uk/archive/dircasterX.php?show='.$show; $feed = fetch_rss($feedurl); $items = array_slice ($feed->items, 0, $num_items); $list = ""; foreach ($items as $item ) { $title = $item[title]; $mp3link = $item[link]; $description = $item[description]; $list .= "<li><a href='#' data-src='$mp3link'>$title - $description</a></li>";} return "<script> audiojs.events.ready(function() { var as = audiojs.createAll(); }); </script> <audio preload></audio> <ol> <li><a href='#' data-src='http://www.fromefm.co.uk/archive/sponsors/fromefm-luke.mp3'>FromeFM - Ident</a></li> $list </ol>"; //normal function code ends } function register_shortcodes() { add_shortcode('ffmplayer', 'ffmplayer_func'); } add_action('init', 'register_shortcodes'); ?> Mercifull <3 Suzi "We don't want players to be able to buy their way to success in RuneScape. If we let players start doing this, it devalues RuneScape for others. We feel your status in real-life shouldn't affect your ability to be successful in RuneScape" Jagex 01/04/01 - 02/03/12
Create an account or sign in to comment