php - How do I turn this commonly used javascript code into a plugin? -
overview i developing wordpress based website allows visitor upload images @ few different places on page. have (after lot of trial , error) got working code but, code differs between each 'upload' area, thought trying make re-usable in form of 'plugin'. my background i self-taught programmer prone lots of mistakes , doing things in illogical ways plus writing thousand lines of code when 1 line have sufficed. history of problem (please skip section see code below) i thought include bit of history don't fall foul of x-y problem . have 4 places on webpage visitors can upload site. 3 of these image uploads should allow visitor 'crop' image. i'm using jquery plugins plupload , jcrop in order provide functionality. initially attempted write code in way page included relevant code in dom @ execution time. in order have multiple plupload instances on same page created 1 "dynamic variable" , called code this... var dynamicpartofvar ...